ND-2020-CS 8602-Compiler Design
ND-2020-CS 8602-Compiler Design
2. With a neat block diagram specify the interactions between the lexical analyzer
and the parser.
3. State the various error recovery strategies used in a parser to correct the errors.
6. Construct the DAG and identify the value numbers for the subexpressions of the
following expressions, assuming + associates from the left.
i) a*b + (a*b)
ii) a*b*a*b
9. Brief about the methodology used to locally improve the target code.
11. a) What are Lexical errors ? What are the possible recovery mechanisms ? Divide
the following C++ program :
into appropriate lexemes. Which lexemes should get associated lexical values ?
What should those values be ? (13)
(OR)
b) What is a transition diagrams ? Explain briefly how the keywords and identifiers
are recognized using a running example. (13)
S →0|A
A → AB
B→1 (13)
(OR)
b) Consider the following grammar and construct SLR parser.
E → E + T/T, T → T * F|F, F → (E) |id. (13)
13. a) Describe how SDD can be evaluated at the nodes of a parse tree using
dependency graphs. (13)
(OR)
b) Explain type checking and type conversion. Explain with an example of
converting the operands the same type. (13)
15. a) What is code optimization ? State its advantages. Discuss various code
optimization schemes in detail. (13)
(OR)
b) Discuss about the following with example: (13)
i) Copy Propagation
ii) Dead-code Elimination and
iii) Code motion.
E→E or T|T
Write the semantic rules and explain the processes converting “not (true or
false)” to intermediate form using Parser tree method. (15)
(OR)
b) Consider the grammar S → ABD, A → a | Db | ε, B → gD |dA | ε , D → e | f
i) Construct FIRST and FOLLOW for each nonterminal of the above grammar.
iii) Show the parsing action on a valid string and on an invalid string
___________________