Autometa & Compiler design (CY-603 (C)) - Important Questions
-
Unit 27 Marks High Priority
Define a context-free grammar (CFG). Explain the terms terminal, non-terminal, start symbol and production with suitable examples. Give two simple CFGs: one generating balanced parentheses and another generating arithmetic expressions with $+$ and $\times$ operators.
Core derivation from Unit 2: Definitions and fundamentals of context-free grammars (CFGs); appears frequently in theory questions.
-
Unit 27 Marks High Priority
For the grammar:
$S \rightarrow A\,b\mid C\,d$
$A \rightarrow a\mid \varepsilon$
$C \rightarrow c\,S\mid \varepsilon$
compute the $FIRST$ and $FOLLOW$ sets for all non-terminals. Show all steps.
Core computational skill for syntax analysis: computing $FIRST$ and $FOLLOW$ sets used in predictive parsing and parsing-table construction.
-
Unit 214 Marks High Priority
Given the grammar:
$E \rightarrow T\;E'$
$E' \rightarrow +\;T\;E'\mid \varepsilon$
$T \rightarrow F\;T'$
$T' \rightarrow \times\;F\;T'\mid \varepsilon$
$F \rightarrow (\;E\;)\mid id$
(a) Compute $FIRST$ and $FOLLOW$ sets for all non-terminals.
(b) Construct the LL(1) parsing table.
(c) Use the table to show the steps of parsing the input $id\;+\;id\;\times\;id$.
Standard RGPV-style question: construct LL(1) parsing table and parse a sample input using $FIRST$ and $FOLLOW$ results.
-
Unit 27 Marks High Priority
Explain the elimination of left recursion and left factoring with examples. Transform the grammar:
$A \rightarrow A\alpha \mid \beta \mid \gamma\;$
into an equivalent grammar suitable for predictive parsing by eliminating left recursion and applying left factoring where necessary.
Grammar transformation techniques required for top-down parsing: elimination of left recursion and left factoring are routinely tested.
-
Unit 214 Marks High Priority
For the grammar:
$S' \rightarrow S$
$S \rightarrow C\;C$
$C \rightarrow c\;C\mid d$
(a) Construct the canonical collection of LR(0) items (states).
(b) Build the SLR parsing table using $FOLLOW$ sets.
(c) Show the parsing actions for the input $c\;c\;d\;d$ and identify any shift-reduce or reduce-reduce conflicts (if present).
Canonical LR(0) items, SLR parsing table construction and conflict identification are core Unit 2 topics; high exam frequency.
-
Unit 27 Marks High Priority
Explain the differences between SLR, LALR and CLR (canonical LR(1)) parsers. Illustrate with an example grammar where SLR fails but LALR or CLR succeeds, and explain why.
Comparative understanding of LR parser variants (SLR, LALR, CLR) and where they differ is frequently asked as a conceptual question.
-
Unit 214 Marks High Priority
For the grammar:
$S' \rightarrow S$
$S \rightarrow L\;=\;R\mid R$
$L \rightarrow *\;R\mid id$
$R \rightarrow L$
(a) Construct the canonical collection of LR(1) items.
(b) Build the LR(1) parsing table.
(c) Use the table to parse the input $id\;=\;id$ and show stack configurations and actions.
Construction of LR(1) items and LR(1) parsing table is a high-value, often-tested skill in Unit 2 (bottom-up parsing).
-
Unit 27 Marks Medium Priority
Demonstrate shift-reduce parsing (using a shift-reduce parser) for the grammar:
$S \rightarrow a\;S\;b\mid a\;b$
on the input $a\;a\;b\;b$. Show the stack contents, the remaining input, and the action (shift or reduce) at each step. Draw the final parse tree.
Practical parsing trace: shift-reduce parsing steps and parse-tree construction from stack actions are commonly examined.
-
Unit 27 Marks Medium Priority
Define shift-reduce and reduce-reduce conflicts in bottom-up parsers. For the expression grammar:
$E \rightarrow E\;+\;E\mid E\;*\;E\mid (\;E\; )\mid id$
(a) Show how shift-reduce conflicts arise in an LR(0) or SLR table.
(b) Explain how operator precedence and associativity can be used to resolve these conflicts with an example.
Conflict resolution techniques (precedence and associativity) for ambiguous constructs are important for parser-generator questions.
-
Unit 27 Marks Medium Priority
What is an ambiguous grammar? Provide an example of an ambiguous grammar for arithmetic expressions and show two different parse trees for the same string. Then present an unambiguous grammar that generates the same language (respecting operator precedence and associativity).
Ambiguity in grammars and methods to remove ambiguity (or design unambiguous grammars) are common objective questions in Unit 2.
Quick Add to Notes
Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.
Create free accountHave an account? Log in
Notes Panel