MauryaHub PYQ Practice

Compiler Design · Quiz 2 · May 2026

Compiler Design · Quiz 2 · May 2026

← Course papers · Start practice / exam

Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.

0 / 17 published solutions

Question 2 MSQ · 2.0 marks

Consider the regular language
Source diagram or notation
over the alphabet
Source diagram or notation
Which of the following strings belong to
Source diagram or notation
? (Select all that apply.)
6406537123268.Source diagram or notation
6406537123269.Source diagram or notation
6406537123270.Source diagram or notation
6406537123271.Source diagram or notation
6406537123272.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q2

Question 3 MCQ · 3.0 marks

A lexical analyzer uses the following rules.
Source diagram or notation
The keyword rule has **higher priority** than the identifier rule. Input
Source diagram or notation
Which of the following gives the correct number of **Keyword**, **Identifier**, and **Number** tokens?
6406537123273.
(3,1,0)
6406537123274.
(2,2,0)
6406537123275.
(3,2,0)
6406537123276.
(2,1,1)

A published solution is not available for this question yet.

Report a correction for Q3

Question 4 MCQ · 3.0 marks

Convert the following infix expression to postfix notation:
Source diagram or notation
Which one of the following is the correct postfix expression?
6406537123287.Source diagram or notation
6406537123288.Source diagram or notation
6406537123289.Source diagram or notation
6406537123290.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q4

Question 5 MCQ · 3.0 marks

A parser generator performs the following steps: 1. Construct the canonical LR(1) collection of item sets. 2. Merge all states having the same LR(0) core. 3. Construct the ACTION and GOTO tables from the merged automaton. Which parsing technique is obtained after these steps?
6406537123295.
LR(0)
6406537123296.
Canonical LR(1)
6406537123297.
LALR(1)
6406537123298.
SLR(1)

A published solution is not available for this question yet.

Report a correction for Q5

Question 6 MCQ · 3.0 marks

Consider the grammar
Source diagram or notation
The initial state is
Source diagram or notation
Which of the following is GOTO(I0, b) ?
6406537123299.Source diagram or notation
6406537123300.Source diagram or notation
6406537123301.Source diagram or notation
6406537123302.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q6

Question 7 MCQ · 3.0 marks

Consider the grammar:
Source diagram or notation
A shift-reduce parser is parsing the input:
Source diagram or notation
The parser has already performed the following actions:
Source diagram or notation
What should be the **next action**?
6406537123303.
Shift
Source diagram or notation
6406537123304.
Reduce
Source diagram or notation
6406537123305.
Reduce
Source diagram or notation
6406537123306.
Accept

A published solution is not available for this question yet.

Report a correction for Q7

Question 8 MCQ · 3.0 marks

Consider the production
Source diagram or notation
The semantic rules are
Source diagram or notation
Which of the following is the **minimum valid attribute evaluation sequence**?
6406537123320.Source diagram or notation
6406537123321.Source diagram or notation
6406537123322.Source diagram or notation
6406537123323.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q8

Question 9 MCQ · 3.0 marks

Consider the following overloaded functions.
Source diagram or notation
The compiler evaluates the following function calls.
Source diagram or notation
Which **one** of the following function calls requires **integer promotion** before overload resolution selects the best match?
6406537123324.Source diagram or notation
6406537123325.Source diagram or notation
6406537123326.Source diagram or notation
6406537123327.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q9

Question 10 MCQ · 3.0 marks

An embedded SDT contains the production
Source diagram or notation
To convert it into an equivalent postfix SDT while preserving the execution point of the action
Source diagram or notation
, which of the following transformations is correct?
6406537123328.Source diagram or notation
6406537123329.Source diagram or notation
6406537123330.Source diagram or notation
6406537123331.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q10

Question 11 NAT · 3.0 marks

Consider the alphabet
Source diagram or notation
Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q11

Question 12 NAT · 3.0 marks

Consider the following operator grammar:
Source diagram or notation
An operator-precedence parser is used to parse the expression
Source diagram or notation
using the following precedence and associativity rules: •
Source diagram or notation
has higher precedence than
Source diagram or notation
. • Both operators are left associative . Ignoring the end marker
Source diagram or notation
, how many reduce operations are performed by the parser while parsing the expression?

A published solution is not available for this question yet.

Report a correction for Q12

Question 13 MSQ · 4.0 marks

Consider the grammar
Source diagram or notation
and the following recursive descent parser.
Source diagram or notation
Assume that: • Parsing starts by calling
Source diagram or notation
. •
Source diagram or notation
consumes the current input symbol only if it matches the expected symbol. • Any call that reports an error (i.e., executes
Source diagram or notation
) immediately causes the parse to fail, even if the final lookahead is
Source diagram or notation
. • After
Source diagram or notation
returns, the input is accepted only if no error has been reported and the current lookahead is
Source diagram or notation
. Which of the following input strings is/are accepted?
6406537123278.Source diagram or notation
6406537123279.Source diagram or notation
6406537123280.Source diagram or notation
6406537123281.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q13

Question 14 MCQ · 2.0 marks

A context-free grammar contains the productions
Source diagram or notation
Which language is generated?
6406537123282.Source diagram or notation
6406537123283.Source diagram or notation
6406537123284.
All strings over
Source diagram or notation
6406537123285.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q14

Question 15 MCQ · 2.0 marks

Consider the following statements about SLR(1), Canonical LR(1), and LALR(1) parsers. 1. Every SLR(1) grammar is also an LALR(1) grammar. 2. Every LALR(1) grammar is also an LR(1) grammar. 3. Every LR(1) grammar is also an LALR(1) grammar. Which of the following is correct?
6406537123307.
Only 1 and 2
6406537123308.
Only 2 and 3
6406537123309.
Only 1 and 3
6406537123310.
1, 2 and 3

A published solution is not available for this question yet.

Report a correction for Q15

Question 16 MCQ · 4.0 marks

Consider the grammar.
Source diagram or notation
Which of the following correctly gives **FIRST(S)** and **FOLLOW(X)**?
6406537123291.
FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s, $}
6406537123292.
FIRST(S) = {p, q, r, s, ε} FOLLOW(X) = {r, s}
6406537123293.
FIRST(S) = {p, q, s} FOLLOW(X) = {$}
6406537123294.
FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s}

A published solution is not available for this question yet.

Report a correction for Q16

Question 17 MSQ · 3.0 marks

A student wants the exponentiation operator (
Source diagram or notation
) to have higher precedence than multiplication. They write the following Bison declarations.
Source diagram or notation
For the expression
Source diagram or notation
which of the following statements are correct? (Select all that apply.)
6406537123311.
The expression is parsed as
Source diagram or notation
.
6406537123312.
The expression is parsed as
Source diagram or notation
.
6406537123313.
The
Source diagram or notation
declaration makes
Source diagram or notation
right-associative.
6406537123314.
The value of the expression is
Source diagram or notation
.

A published solution is not available for this question yet.

Report a correction for Q17

Question 18 MSQ · 3.0 marks

Consider the SDD.
Source diagram or notation
Which of the following statements are correct?
6406537123315.Source diagram or notation
is a synthesized attribute.
6406537123316.Source diagram or notation
is typically provided by the lexical analyzer.
6406537123317.
This SDD requires inherited attributes for expression evaluation.
6406537123318.Source diagram or notation
is inherited because it depends on
Source diagram or notation
.
6406537123319.
The attribute evaluation naturally proceeds from the leaves toward the root.

A published solution is not available for this question yet.

Report a correction for Q18