Question 1 |
Syntax directed translation scheme is desirable because:
It is based on the syntax | |
It is easy to modify | |
Its description is independent of any implementation | |
All of these |
Question 1 Explanation:
Syntax Directed Definition
- An SDD is a CFG with attributes and rules.
– Attributes are associated with grammar symbols.
– Rules are associated with productions. - An SDD specifies the semantics of productions.
– It does not enforce a specific way of achieving the semantics
- An SDT is done by attaching rules or program fragments to productions.
- The order induced by the syntax analysis produces a translation of the input program
- To associate actions with productions
- To associate attributes with non-terminals
- To create implicit or explicit syntax tree
- To perform semantic analysis
Question 2 |
Synthesized attribute can easily be simulated by an
LL grammar | |
Ambiguous grammar | |
LR grammar | |
None of the above |
Question 2 Explanation:
Synthesized attributes follows bottom up parsing evaluation.
Example :
X -> Y | Z i attribute is there in X,Y and Z
X.i = f( Y.i , Z.i ) means parent is taking attribute from there children
Bottom Up Parsers
LR( 0 ) , SLR( 1 ) , LR( 1 ) , LALR( 1 ) and Operator Precedence
Top Down Parsers
Non Recursive descent ( LL( 1 ) ) and Recursive descent
LR Parsers which are generated from LR grammar are also coming under bottom up parsing fashion Therefore option(C) is correct.
Example :
X -> Y | Z i attribute is there in X,Y and Z
X.i = f( Y.i , Z.i ) means parent is taking attribute from there children
Bottom Up Parsers
LR( 0 ) , SLR( 1 ) , LR( 1 ) , LALR( 1 ) and Operator Precedence
Top Down Parsers
Non Recursive descent ( LL( 1 ) ) and Recursive descent
LR Parsers which are generated from LR grammar are also coming under bottom up parsing fashion Therefore option(C) is correct.
There are 2 questions to complete.
bala chua