Compiler Design: N I E T
Compiler Design: N I E T
COMPILER DESIGN
(Anna University, Regulation 2021)
TEXT BOOK:
Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman,
Compilers: Principles, Techniques and Toolsǁ, Second Edition,
Pearson Education, 2009.
Token Classes:
1. One token for each keyword
2. Tokens for the operators
3. One token representing all identifiers
4. One or more tokens representing constants
Mrs. S. Priya, AP- CSE, 7
5. Tokens for each punctuation
NIET symbol
Attributes for Tokens
• When more than one lexeme can match a pattern, the lexical
analyzer must provide the subsequent compiler phases additional
information about the particular lexeme that matched
• Examples: lexemes, token names and associated attribute values for
the following statements.
printf ( "Total = %d\n", score ) ;
E = M * C ** 2
Mrs. S. Priya, AP- CSE, 8
NIET
Language Processors
• A compiler is a program that can read a program in one language the source
language and translate it into an equivalent program in another language the target
language
• An important role of the compiler is to report any errors in the source program that
it detects during the translation process.
Syntax Analysis:
t1 = id3 * 60.0 (i.e., by literally defining the floating point value of 60 as 60.0.)
id1 = id2 + t1
Example: (8 * x) / 2
Load a, x
Mult a, 8
Div a, 2