Академический Документы
Профессиональный Документы
Культура Документы
Prof.R.Gururaj
BITS Pilani CS&IS Dept.
Hyderabad Campus
Syntax Directed Translator-2
(Ch.2 of T1)
Prof.R.Gururaj
BITS Pilani CS&IS Dept.
Hyderabad Campus
Introduction
Analysis phase:
breaks up the source program into pieces and produces an
internal representation called intermediate code.
Synthesis phase: translates the intermediate code into the target
program.
Grammar Definition:
1. Set of terminals (tokens)
2. Set of NTs (syntactic variables)
3. Set of productions
4. A starting NT
Root
Leaf
Interior node
Yield of the tree
Translate expr1;
Translate term’
Handle +;
Prof.R.Gururaj CSF363 Compiler Construction BITS Pilani, Hyderabad Campus
Attributes
expr expr-term
expr term
term 0|1|…|9
String : 9-5+2
Top-down parsing
Bottom-up parsing
<id, “count”>
id.lexeme= “count”
Symbol tables are the data structures that are used for holding
information about the source program constructs.
Syntactic checking:
Format x= y op z
Grammar
Parsing
Three-address code
Syntax tree
SDT – rules, action body
Lexical analyzer
Symbol table
Intermediate code