AND ANSWERS 100% CORRECT
Compilation Process - ANSWER-Preprocessor -> Compiler -> Assembler -> Linker ->
Loader
Preprocessor Directive - ANSWER-lines begin with # (like #include or #define)
Preprocessing - ANSWER-before a program is compiled, definition of constants and
macros, conditional compilation of program code
#include - ANSWER-copy of a specified file included, used for programs with multiple
source files compiled together or libraries
#define - ANSWER-when program compiled, all occurrences of symbolic constant
replaced with replacement text
#undef - ANSWER-undefines a symbolic constant or macro (#define WIDTH
80 ........#undef WIDTH)
gcc - ANSWER-GNU Compiler Collection, standard Linux C compiler, translates C to
assembly
Assembler - ANSWER-assembles, but doesn't link, source code to generate relocatable
object code
Linker - ANSWER-combines compiled and assembled object code to make executable
file
Loader - ANSWER-ensures that object programs are placed in memory in executable
form
Only Compiling: - ANSWER-gcc -c hello.c
Only Linking: - ANSWER-gcc hello.o -o hello
Compiling and Linking: - ANSWER-gcc hello.c -o hello
To Run: - ANSWER-./hello
Compiler - ANSWER-system software that translates high level language to machine
language
, Intermediate Code - ANSWER-produces a program in a different language, between
source code and machine code levels
Semantic Analyzer - ANSWER-takes its input from the syntax analysis phase in the
form of a parse tree and a symbol table, determines if the input has a well-defined
meaning
Symbol Table - ANSWER-built and maintained by the semantic analyzer, contains
information about each identifier in a program, such as identifier type, scope of
identifier, etc
Lexical Error - ANSWER-a mistake in lexeme like misspelling or missing one of the
quotes in a string
Static Semantics - ANSWER-semantics rules that can be checked at compile time
Runtime Semantics - ANSWER-semantics rules that can be checked only at runtime
Compilation Stages - ANSWER-lexical analysis (scanner) -> syntax analysis (parser) ->
semantic analysis -> intermediate code generation -> machine independent
improvement (optional) -> target code generation -> machine specific improvement
(optional)
Lexical Analysis (Scanner) - ANSWER-recognizes tokens (keywords, operators,
identifiers, numbers) of a program, outputs sequence of tokens to syntax analyzer
Lexical Analysis Process - ANSWER-1. discard blanks, tabs
2. put characters together
3. repeat step 2 until end of token
4. classify and save token
5. repeat steps 1-4 until end of statement
6. repeat steps 1-5 until end of source code
x* - ANSWER-zero or more occurrence of x. i.e., it can generate { e, x, xx, xxx,
xxxx, ... }
x+ - ANSWER-one or more occurrence of x. i.e., it can generate { x, xx, xxx, xxxx ... } or
x.x*
x? - ANSWER-at most one occurrence of x i.e., it can generate either {x} or {e}.
Write all strings of 1s and 0s in regex - ANSWER-( 0 | 1 )*
Write all strings of 1s and 0s beginning with a 1 in regex - ANSWER-1 ( 0 | 1 )*