LATEST UPDATE (ALREADY GRADED A+)
when does a macro with arguments have its arguments substituted for replacement text?
when the macro is expanded
What is an assembler?
Assembles code (.s) to generate relocateable object code(.o)
What is a Linker?
Combines previous compiled and assembled object code along with standard library functions to make
executable file
What is the default executable?
a.out
What is a Loader?
The loader ensures that the object programs are placed in main memory in an executable form
What does lexical scanner output?
a sequence of tokens to the syntax analyzer
lexeme keywords:
if, while, ...
lexeme operators:
+, *, <=, ||
lexeme identifiers:
i, i1, j1, count, sum, ...
lexeme numbers:
12, 3.14, 7.2E-2, ...
DFA transition function:
maps every possible outcome in the DFA
DFA simulation:
Start in state s0 and follow transitions on each input character (state doesn't change if no input
character is read)
, syntax analyzer or parser
groups sequences of tokens from the lexical analysis phase into phrases, each with an associated phrase
type
Syntax analysis phases
-Obtain tokens from lexical analyzer (the output of the scanner is given to the parser)
-Check whether the expression is syntactically correct ( check the grammar of a program)
-Report syntax errors, if any-Determine the statement class
•An assignment statement, a condition (e.g.,if) statement, etc.
-Group tokens into statements
-Construct hierarchical structures called parse trees
•Parse trees represent the syntactic structure of the. program
Syntactic construction can be described as
context‐free grammar
to run a lexical file you do:
flex [filename], which creates a .yy.c file
semantic analyzers are usually concerned with:
type checking and type coercion
what does the symbol table contain information about?
each identifier in a program, such as identifier type (to check for type compatibility),scope of identifier
(to track the scope of identifiers), etc.
What is the symbol table built and maintained by?
the semantic analyzer
What gets input from the semantic analyzer?
the intermediate code generation
How do you optimize your code?
by making it smaller and faster
What are the two types of optimizing transformations?
local transformations and global transformations
local transformations:
Applied over small segments of a program
Provides limited benefits at a low cost
-Scope is a basic block which is a sequential set of instructions