MauryaHub PYQ Practice

cs4032_2026T2_Q2_NA.pdf

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.

Question 2 MSQ · 2.0 marks

Consider the regular language [[IMAGE:2d7550c87a5ff5e1_2_2]] over the alphabet [[IMAGE:2d7550c87a5ff5e1_2_3]] Which of the following strings belong to [[IMAGE:2d7550c87a5ff5e1_2_4]] ? (Select all that apply.)
Source diagram or notationSource diagram or notationSource diagram or notation
  1. [[IMAGE:2d7550c87a5ff5e1_2_5]]
    Source diagram or notation
  2. [[IMAGE:2d7550c87a5ff5e1_2_6]]
    Source diagram or notation
  3. [[IMAGE:2d7550c87a5ff5e1_2_7]]
    Source diagram or notation
  4. [[IMAGE:2d7550c87a5ff5e1_2_8]]
    Source diagram or notation
  5. [[IMAGE:2d7550c87a5ff5e1_2_9]]
    Source diagram or notation

A published solution is not available for this question yet.

Question 3 MCQ · 3.0 marks

A lexical analyzer uses the following rules. [[IMAGE:2d7550c87a5ff5e1_3_10]] The keyword rule has **higher priority** than the identifier rule. Input [[IMAGE:2d7550c87a5ff5e1_3_11]] Which of the following gives the correct number of **Keyword**, **Identifier**, and **Number** tokens?
Source diagram or notationSource diagram or notation
  1. (3,1,0)
  2. (2,2,0)
  3. (3,2,0)
  4. (2,1,1)

A published solution is not available for this question yet.

Question 4 MCQ · 3.0 marks

Convert the following infix expression to postfix notation: [[IMAGE:2d7550c87a5ff5e1_3_12]] Which one of the following is the correct postfix expression?
Source diagram or notation
  1. [[IMAGE:2d7550c87a5ff5e1_3_13]]
    Source diagram or notation
  2. [[IMAGE:2d7550c87a5ff5e1_3_14]]
    Source diagram or notation
  3. [[IMAGE:2d7550c87a5ff5e1_3_15]]
    Source diagram or notation
  4. [[IMAGE:2d7550c87a5ff5e1_4_16]]
    Source diagram or notation

A published solution is not available for this question yet.

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?
  1. LR(0)
  2. Canonical LR(1)
  3. LALR(1)
  4. SLR(1)

A published solution is not available for this question yet.

Question 6 MCQ · 3.0 marks

Consider the grammar [[IMAGE:2d7550c87a5ff5e1_4_17]] The initial state is [[IMAGE:2d7550c87a5ff5e1_4_18]] Which of the following is GOTO(I0, b) ?
Source diagram or notationSource diagram or notation
  1. [[IMAGE:2d7550c87a5ff5e1_4_19]]
    Source diagram or notation
  2. [[IMAGE:2d7550c87a5ff5e1_4_20]]
    Source diagram or notation
  3. [[IMAGE:2d7550c87a5ff5e1_4_21]]
    Source diagram or notation
  4. [[IMAGE:2d7550c87a5ff5e1_5_22]]
    Source diagram or notation

A published solution is not available for this question yet.

Question 7 MCQ · 3.0 marks

Consider the grammar: [[IMAGE:2d7550c87a5ff5e1_5_23]] A shift-reduce parser is parsing the input: [[IMAGE:2d7550c87a5ff5e1_5_24]] The parser has already performed the following actions: [[IMAGE:2d7550c87a5ff5e1_5_25]] What should be the **next action**?
Source diagram or notationSource diagram or notationSource diagram or notation
  1. Shift [[IMAGE:2d7550c87a5ff5e1_5_26]]
    Source diagram or notation
  2. Reduce [[IMAGE:2d7550c87a5ff5e1_5_27]]
    Source diagram or notation
  3. Reduce [[IMAGE:2d7550c87a5ff5e1_5_28]]
    Source diagram or notation
  4. Accept

A published solution is not available for this question yet.

Question 8 MCQ · 3.0 marks

Consider the production [[IMAGE:2d7550c87a5ff5e1_6_29]] The semantic rules are [[IMAGE:2d7550c87a5ff5e1_6_30]] Which of the following is the **minimum valid attribute evaluation sequence**?
Source diagram or notationSource diagram or notation
  1. [[IMAGE:2d7550c87a5ff5e1_6_31]]
    Source diagram or notation
  2. [[IMAGE:2d7550c87a5ff5e1_6_32]]
    Source diagram or notation
  3. [[IMAGE:2d7550c87a5ff5e1_6_33]]
    Source diagram or notation
  4. [[IMAGE:2d7550c87a5ff5e1_6_34]]
    Source diagram or notation

A published solution is not available for this question yet.

Question 9 MCQ · 3.0 marks

Consider the following overloaded functions. [[IMAGE:2d7550c87a5ff5e1_6_35]] The compiler evaluates the following function calls. [[IMAGE:2d7550c87a5ff5e1_6_36]] Which **one** of the following function calls requires **integer promotion** before overload resolution selects the best match?
Source diagram or notationSource diagram or notation
  1. [[IMAGE:2d7550c87a5ff5e1_7_37]]
    Source diagram or notation
  2. [[IMAGE:2d7550c87a5ff5e1_7_38]]
    Source diagram or notation
  3. [[IMAGE:2d7550c87a5ff5e1_7_39]]
    Source diagram or notation
  4. [[IMAGE:2d7550c87a5ff5e1_7_40]]
    Source diagram or notation

A published solution is not available for this question yet.

Question 10 MCQ · 3.0 marks

An embedded SDT contains the production [[IMAGE:2d7550c87a5ff5e1_7_41]] To convert it into an equivalent postfix SDT while preserving the execution point of the action [[IMAGE:2d7550c87a5ff5e1_7_42]] , which of the following transformations is correct?
Source diagram or notationSource diagram or notation
  1. [[IMAGE:2d7550c87a5ff5e1_7_43]]
    Source diagram or notation
  2. [[IMAGE:2d7550c87a5ff5e1_7_44]]
    Source diagram or notation
  3. [[IMAGE:2d7550c87a5ff5e1_7_45]]
    Source diagram or notation
  4. [[IMAGE:2d7550c87a5ff5e1_8_46]]
    Source diagram or notation

A published solution is not available for this question yet.

Question 11 NAT · 3.0 marks

Consider the alphabet [[IMAGE:2d7550c87a5ff5e1_8_47]] [[IMAGE:2d7550c87a5ff5e1_8_48]]
Source diagram or notationSource diagram or notation

    A published solution is not available for this question yet.

    Question 12 NAT · 3.0 marks

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

      A published solution is not available for this question yet.

      Question 13 MSQ · 4.0 marks

      Consider the grammar [[IMAGE:2d7550c87a5ff5e1_9_54]] and the following recursive descent parser. [[IMAGE:2d7550c87a5ff5e1_10_55]] Assume that: • Parsing starts by calling [[IMAGE:2d7550c87a5ff5e1_10_56]] . • [[IMAGE:2d7550c87a5ff5e1_10_57]] consumes the current input symbol only if it matches the expected symbol. • Any call that reports an error (i.e., executes [[IMAGE:2d7550c87a5ff5e1_10_58]] ) immediately causes the parse to fail, even if the final lookahead is [[IMAGE:2d7550c87a5ff5e1_10_59]] . • After [[IMAGE:2d7550c87a5ff5e1_10_60]] returns, the input is accepted only if no error has been reported and the current lookahead is [[IMAGE:2d7550c87a5ff5e1_10_61]] . Which of the following input strings is/are accepted?
      Source diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notationSource diagram or notation
      1. [[IMAGE:2d7550c87a5ff5e1_10_62]]
        Source diagram or notation
      2. [[IMAGE:2d7550c87a5ff5e1_11_63]]
        Source diagram or notation
      3. [[IMAGE:2d7550c87a5ff5e1_11_64]]
        Source diagram or notation
      4. [[IMAGE:2d7550c87a5ff5e1_11_65]]
        Source diagram or notation

      A published solution is not available for this question yet.

      Question 14 MCQ · 2.0 marks

      A context-free grammar contains the productions [[IMAGE:2d7550c87a5ff5e1_11_66]] Which language is generated?
      Source diagram or notation
      1. [[IMAGE:2d7550c87a5ff5e1_11_67]]
        Source diagram or notation
      2. [[IMAGE:2d7550c87a5ff5e1_11_68]]
        Source diagram or notation
      3. All strings over [[IMAGE:2d7550c87a5ff5e1_11_69]]
        Source diagram or notation
      4. [[IMAGE:2d7550c87a5ff5e1_11_70]]
        Source diagram or notation

      A published solution is not available for this question yet.

      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?
      1. Only 1 and 2
      2. Only 2 and 3
      3. Only 1 and 3
      4. 1, 2 and 3

      A published solution is not available for this question yet.

      Question 16 MCQ · 4.0 marks

      Consider the grammar. [[IMAGE:2d7550c87a5ff5e1_12_71]] Which of the following correctly gives **FIRST(S)** and **FOLLOW(X)**?
      Source diagram or notation
      1. FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s, $}
      2. FIRST(S) = {p, q, r, s, ε} FOLLOW(X) = {r, s}
      3. FIRST(S) = {p, q, s} FOLLOW(X) = {$}
      4. FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s}

      A published solution is not available for this question yet.

      Question 17 MSQ · 3.0 marks

      A student wants the exponentiation operator ( [[IMAGE:2d7550c87a5ff5e1_12_72]] ) to have higher precedence than multiplication. They write the following Bison declarations. [[IMAGE:2d7550c87a5ff5e1_13_73]] For the expression [[IMAGE:2d7550c87a5ff5e1_13_74]] which of the following statements are correct? (Select all that apply.)
      Source diagram or notationSource diagram or notationSource diagram or notation
      1. The expression is parsed as [[IMAGE:2d7550c87a5ff5e1_13_75]] .
        Source diagram or notation
      2. The expression is parsed as [[IMAGE:2d7550c87a5ff5e1_13_76]] .
        Source diagram or notation
      3. The [[IMAGE:2d7550c87a5ff5e1_13_77]] declaration makes [[IMAGE:2d7550c87a5ff5e1_13_78]] right-associative.
        Source diagram or notationSource diagram or notation
      4. The value of the expression is [[IMAGE:2d7550c87a5ff5e1_13_79]] .
        Source diagram or notation

      A published solution is not available for this question yet.

      Question 18 MSQ · 3.0 marks

      Consider the SDD. [[IMAGE:2d7550c87a5ff5e1_13_80]] Which of the following statements are correct?
      Source diagram or notation
      1. [[IMAGE:2d7550c87a5ff5e1_14_81]] is a synthesized attribute.
        Source diagram or notation
      2. [[IMAGE:2d7550c87a5ff5e1_14_82]] is typically provided by the lexical analyzer.
        Source diagram or notation
      3. This SDD requires inherited attributes for expression evaluation.
      4. [[IMAGE:2d7550c87a5ff5e1_14_83]] is inherited because it depends on [[IMAGE:2d7550c87a5ff5e1_14_84]] .
        Source diagram or notationSource diagram or notation
      5. The attribute evaluation naturally proceeds from the leaves toward the root.

      A published solution is not available for this question yet.