UNIT III
UNIT III
1. Define parser.
Hierarchical analysis is one in which the tokens are grouped hierarchically into nested
collections with collective meaning.
Also termed as Parsing.
2. Mention the basic issues in parsing.
There are two important issues in parsing.
Specification of syntax
FOLLOW
1. Place $ in FOLLOW(S),where S is the start symbol and $ is the input right endmarker.
2. If there is a production A → αBβ, then everything in FIRST(β) except for ε is placed
in FOLLOW(B).
3. If there is a production A → αB, or a production A→ αBβ where FIRST(β) contains ε
, then everything in FOLLOW(A) is in FOLLOW(B).
12. List the advantages and disadvantages of operator precedence
parsing. Advantages
This typeof parsing is simple to implement.
Disadvantages
1. The operator like minus has two different precedence(unary and binary).Hence it
is hard to handle tokens like minus sign.
2. This kind of parsing is applicable to only small class of grammars.
13. What is dangling else problem?
Ambiguity can be eliminated by means of dangling-else grammar which is show below:
stmt → if expr then stmt
| if expr then stmt else stmt
| other
14. Write short notes on YACC.
YACC is an automatic tool for generating the parser program.
YACC stands for Yet Another Compiler Compiler which is basically the utility
available from UNIX.
Basically YACC is LALR parser generator.
It can report conflict or ambiguities in the form of error messages.
15. What is meant by handle pruning?
A rightmost derivation in reverse can be obtained by handle pruning.
If w is a sentence of the grammar at hand, then w = γn, where γn is the nth right-
sentential form of some as yet unknown rightmost derivation
S = γ0 => γ1…=> γn-1 => γn = w
PART B