Week1 (1.2) Flashcards
What are the two main parts of a compiler?
Analysis (front end) and synthesis (back end).
What does the analysis part of a compiler do?
Breaks the source program into pieces, imposes grammatical structure, and creates an intermediate representation.
What does the synthesis part of a compiler do?
Constructs the target program from the intermediate representation and symbol table.
What is the symbol table in a compiler?
A data structure that stores information about the source program, such as variable attributes.
What is the purpose of the machine-independent optimization phase?
To transform the intermediate representation to produce a better target program.
What is lexical analysis?
The phase that groups characters into lexemes and converts them into tokens for syntax analysis.
What is a token in lexical analysis?
A pair consisting of a token name and an attribute value, representing a meaningful sequence of characters.
What is syntax analysis?
The phase that uses tokens to create a tree-like intermediate representation of the program’s structure.
What is semantic analysis?
The phase that checks for semantic consistency and gathers type information for later stages.
What is type checking in semantic analysis?
Ensuring operators have matching operands and performing necessary type coercions.
What is intermediate code generation?
The phase where the source program is converted into an abstract machine-like intermediate representation.
What is three-address code?
A form of intermediate representation with assembly-like instructions and at most three operands per instruction.
What is code optimization?
The phase that improves intermediate code for better target code, such as faster or more efficient execution.
What is code generation?
The phase where intermediate representation is translated into target machine code.
What is the role of registers in code generation?
Registers are assigned to hold variables for efficient execution.
What is symbol-table management?
The process of recording variable names and attributes for use during compilation.
What is a compiler pass?
A grouping of phases that reads an input file and writes an output file, such as front-end or back-end passes.
What is the role of compiler-construction tools?
To assist in implementing compiler phases, such as parser generators, scanner generators, and code generators.
What does a parser generator do?
Automatically produces syntax analyzers from a grammatical description of a programming language.
What does a scanner generator do?
Creates lexical analyzers from regular-expression descriptions of tokens.