adplus-dvertising

Welcome to the Compiler Design MCQs Page

Dive deep into the fascinating world of Compiler Design with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Compiler Design, a crucial aspect of GATE CSE Exam. In this section, you will encounter a diverse range of MCQs that cover various aspects of Compiler Design, 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 GATE CSE Exam.

frame-decoration

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

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

Compiler Design MCQs | Page 3 of 12

Q21.
Consider the grammar

S → (S) | a

Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3 respectively. The following relationship holds good
Discuss
Answer: (b).n1 = n3 < n2
Q22.
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?
Discuss
Answer: (c).It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
Q23.
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

Assume the conflicts in 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; ex­pression is evaluated to 9
Q24.
Which of the following grammar rules violate the requirements of an operator grammar ? P, Q, R are nonterminals, and r, s, t are terminals.

1. P → Q R
2. P → Q s R
3. P → ε
4. P → Q t R r
Discuss
Answer: (b).1 and 3 only
Q25.
Consider the grammar with the following translation rules and E as the start symbol.

E → E1 # T { E.value = E1.value * T.value }
| T{ E.value = T.value }
T → T1 & F { T.value = T1.value + F.value }
| F{ T.value = F.value }
F → num { F.value = num.value }

Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4.
Discuss
Answer: (c).160
Q26.
Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
Discuss
Answer: (d).None of these
Q27.
Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is:
Discuss
Answer: (b).n1 is necessarily equal to n2
Discuss
Answer: (b).be evaluated only if the definition is L-­attributed
Q29.
Consider the grammar shown below S → i E t S S' | a S' → e S | ε E → b In the predictive parse table. M, of this grammar, the entries M[S', e] and M[S', $] respectively are
Discuss
Answer: (d).{S' → e S, S'→ ε} and {S' → ε}
Q30.
Consider the grammar shown below.

S → C C
C → c C | d

The grammar is
Discuss
Answer: (a).LL(1)
Page 3 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!