adplus-dvertising

Welcome to the Syntax Directed Definition and Translations MCQs Page

Dive deep into the fascinating world of Syntax Directed Definition and Translations with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Syntax Directed Definition and Translations, a crucial aspect of Compiler Design. In this section, you will encounter a diverse range of MCQs that cover various aspects of Syntax Directed Definition and Translations, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Compiler Design.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Syntax Directed Definition and Translations. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Compiler Design.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Syntax Directed Definition and Translations. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Syntax Directed Definition and Translations MCQs | Page 4 of 12

Q31.
Consider the following translation scheme.
S > ER

R > * E{print{’ * ’);

R | f

E > F + E{print(’ + ’); | F F > (S) | id{print(id.value);}

Here id is a taken that represents an integer and id, value represents the corresponding integer value. For an input ‘2 * 3 + 4’, this translation scheme prints
Discuss
Answer: (b).2 * + 3 4
Discuss
Answer: (d).There is scope of dead code elimination in this code
Q33.
E -> number Eval number val
E E .val E .VAL E .val
E # E E .val E .VAL E .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?
Discuss
Answer: (c).It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
Q34.
E -> number Eval number val
E E .val E .VAL E .val
E # E E .val E .VAL E .val
;

Assume the conflicts part (a) of this question are resolved and an LALR (1) parser is generated for parsing arithmetic expressions as per the given grammar.
Consider an expression 3 # 2 + 1. What precedence and associativity properties does the generated parser realize?
Discuss
Answer: (b).Equal precedence and right associativity, expression is evaluated to 9
Q35.
Consider the following grammar.
S -> S * E

S -> E

E -> F + E

E -> F

F -> id

Consider the following LR (0) items corresponding to the grammar above.

(i) S -> S * .E

(ii) E -> F. + E

(iii) E “F + .E

Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar?
Discuss
Answer: (c).(iii)
Q36.
Consider the following grammar
S -> FR

R -> * S | ε

F -> id

In the predictive parser table, M, of the grammar the entries M [S, id] and M [R, $] respectively
Discuss
Answer: (a).{S ” FR} and {R ” ε}
Q37.
Consider the following translation scheme.
S -> ER

R -> * E{print{’ * ’);

R | f

E -> F + E{print(’ + ’); | F

F -> (S) | id{print(id.value);}

Here id is a taken that represents an integer and id. value represents the corresponding integer value. For an input ‘2 * 3 + 4’, this translation scheme prints
Discuss
Answer: (b).2 * + 3 4
Discuss
Answer: (d).There is scope of dead code elimination in this code
Discuss
Answer: (d).S -> AC | CB
C -> aCb |!
C -> aCb |!
A -> aA |!
A -> aA | a
B -> Bb |!
B -> bB | b
Q40.
In the correct grammar above, what is the length of the derivation (number of steps starting from S to generate the string a l b m with l ! m?
Discuss
Answer: (a).max (l, m) + 2
Page 4 of 12

Suggested Topics

Are you eager to expand your knowledge beyond Compiler Design? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!