

MCQOPTIONS
Saved Bookmarks
This section includes 6 Mcqs, each offering curated multiple-choice questions to sharpen your Compilers knowledge and support exam preparation. Choose a topic below to get started.
1. |
Consider the grammar with non-terminals. The grammar is NOTLL(1) because ________ |
A. | It is left recursive |
B. | It is right recursive |
C. | It is ambiguous |
D. | It is not context-freeView Answer |
Answer» B. It is right recursive | |
2. |
Which one of the following is a top-down parser? |
A. | Recursive descent parser |
B. | Operator precedence parser |
C. | An LR(k) parser |
D. | An LALR(k) parser |
Answer» B. Operator precedence parser | |
3. |
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? |
A. | max (l, m) + 2 |
B. | l+m+2 |
C. | l + m + 3 |
D. | max (l, m) + 3 |
Answer» B. l+m+2 | |
4. |
Consider the following grammar: In the predictive parser table, M, of the grammar the entries M [S, id] and M [R, $] respectively. |
A. | {S ” FR} and {R ” ε} |
B. | {S ” FR} and {} |
C. | {S ” FR} and {R ” * S} |
D. | {F ” id} and {R ” ε}View Answer |
Answer» B. {S ” FR} and {} | |
5. |
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? |
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? a) Equal precedence and left associativity; expression is evaluated to 7 |
B. | Equal precedence and right associativity, expression is evaluated to 9 |
C. | Precedence of ‘x’ is higher than that of ‘+’, and both operators are left associative; expression is evaluated to 7 |
D. | Precedence of ‘ # ‘ is higher than that of ‘#’, and both operators are left associative; expression is evaluated to 9View Answer |
Answer» C. Precedence of ‘x’ is higher than that of ‘+’, and both operators are left associative; expression is evaluated to 7 | |
6. |
The below 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 actionView Answer |
Answer» D. It detects shift-reduce conflict and resolves the conflict in favor of a reduce over a shift actionView Answer | |