The Structure of a Compiler (8) Scanner [Lexical Analyzer] Parser [Syntax Analyzer] Semantic Process [Semantic analyzer] Code Generator [Intermediate Code Generator] Code Optimizer Parse tree Abstract Syntax Tree w/ Attributes Non-optimized Intermediate Code Optimized Intermediate Code Code Genrator Target machine code Compiler Design 40106 Tokens
The input program as you see it. main () { int i,sum; sum = 0; for (i=1; i<=10; i++); sum = sum + i; printf("%d",sum); } Compiler Design 40106
Attributes for Tokens Tokens influence parsing decision; the attributes influence the translation of tokens. Example: E = M * C ** 2 <id, pointer to symbol-table entry for E> <assign_op, > <id, pointer to symbol-table entry for M> <mult_op, > <id, pointer to symbol-table entry for C> <exp_op, > <num, integer value 2> Compiler Design 40106
Role of the Lexical Analyzer Compiler Design 40106