Compiler Construction MCQ :Syntax Directed Definition-S-attributed and L-attributed definition : Link2

Compiler Construction MCQ :Syntax Directed Definition-S-attributed and L-attributed definition : Link2

Compiler Construction MCQ & Answers

       Are you worried about the answers to Compiler Construction questions :Syntax Directed Definition-S-attributed and L-attributed definition? We have arranged the Show Answer button under the each question. Candidates can click on it to know the right option among the given alternatives. Furthermore, the applicants can check our web portal @ www.totalmcq.com to take part in more MCQ on various subject. Wish, the given information about the Compiler Construction MCQ will helpful to the advance and can learn the various types of questions and answers.


Q.1. Consider the productions A → PQ and A → XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: s is a synthesized attribute and i is an inherited attribute. Consider the following rules.
Rule 1 : P.i = A.i + 2, Q.i = P.i + A.i, and A.s = P.s + Q.s
Rule 2 : X.i = A.i + Y.s and Y.i = X.s + A.i
Which one of the following is TRUE?

A. Only Rule 2 is L-attributed.
B. Neither Rule 1 nor Rule 2 is L-attributed.
C. Both Rule 1 and Rule 2 are L-attributed.
D. Only Rule 1 is L-attributed

Q.2. Consider the following expression grammar. The seman¬tic rules for expression calculation are stated next to each grammar production.
E→number       E.val=number.val
|E+E      E(1).val=E(2).val+E(3).val
|E×E      E(1).val=E(2).val×E(3).val
The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?

A. It detects recursion and eliminates recursion
B. It detects reduce-reduce conflict, and resolves
C. It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
D. It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action

Q.3. Which one of the following restricts the class of syntax directed definitions that can be implemented----------

A. Parse tree methods                                    B. Rule-based methods
C. Oblivious method                                      D. None of the above.

Q.4. Which one of the following is not method for evaluating semantic rules?

A. Parse tree methods
B. Oblivious method
C. syntax -based methods
D. Rule-based methods

Q.5. Syntax directed translation can be based on---------

A. syntax tree
B. parse tree.
C. syntax tree as well as parse tree.
D. None of the above.

Q.6.-----------are useful tool for determining an evaluation order for the attribute instances in given parse tree.

A. DAG                                                              B. Dependency graph
C. Graph coloring graph                               D. None of the above.

Q.7. Notations for associating semantic rules with productions are--------

A. Syntax directed definition                         B. Translation scheme
C. Both A and B                                               D. None of the above.

Q.8. The interdependencies among inherited and synthesized attributes at nodes in parse tree can be depicted by---------

A. DAG                                                               B. Dependency graph
C. Interdependency graph                             D. Wait for graph

Q.9. Inherited attribute can easily be simulated by an ----------

A. LL grammar                                                B. Ambiguous
C. LR grammar                                                D. None of the above.

Q.10. From the following production with semantic rule E.val is-------.
E → E1 + T { E.val = E1.val + T.val}

A. Synthesized attribute
B. Inherited attribute
C. Syntax attribute
D. None of the above.

Q.11. In a bottom-up evaluation of a syntax directed definition, inherited attributes can---------

A. always be evaluated
B. be evaluated only if the definition is L-attributed
C. be evaluated only if the definition has synthesized attributes
D. never be evaluated

Q.12. Which one of the following is not type of intermediate code representations?

A. Syntax tree                                                  B. Postfix
C. Preorder                                                      D. Three address code