Parsing
GATE CSE & IT · 51 questions across 23 years (1988-2026) · 57% recurrence rate
Recurrence sparkline
1988–2026Difficulty mix
Question types
All 51 questions on Parsing
Consider the canonical $L R(0)$ parsing of the grammar below using terminals $\{a, b, c\}$ and non-terminals $\{A, B, C, S\}$ with $S$ as the start symbol. $$ \begin{aligned} & S \rightarrow A C B \\ & A \rightarrow \alp...
Which of the following statements is/are true?
Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?
Given a Context-Free Grammar G as follows : $S \rightarrow A a|b a c| d c \mid b d a$ $A \rightarrow d$ Which ONE of the following statements is TRUE?
Consider two grammars $G_1$ and $G_2$ with the production rules given below: $G_1: S \rightarrow$ if $E$ then $S \mid$ if $E$ then $S$ else $S \mid a$ $$\mathrm{E} \rightarrow \mathrm{~b}$$ $G_2: S \rightarrow$ if $E$ th...
Which of the following is/are Bottom-Up Parser(s)?
Consider the following augmented grammar, which is to be parsed with a SLR parser. The set of terminals is $\{ a, b, c, d, \, \#, \, @ \}$ $S' \rightarrow S$ $S \rightarrow SS \;|\; Aa \;|\; bAc \;|\; Bc \;|\; bBa$ $A \r...
Consider the following context-free grammar where the start symbol is S and the set of terminals is {a,b,c,d}. $ S \rightarrow AaAb \mid BbBa $ $ A \rightarrow cS \mid \epsilon $ $ B \rightarrow dS \mid \epsilon $ The fo...
Consider the following grammar $G$, with $S$ as the start symbol. The grammar $G$ has three incomplete productions denoted by (1), (2), and (3). $$S \rightarrow d a T \mid \underline{\ (1)}$$ $$T \rightarrow a S \mid b T...
Consider the augmented grammar with {+, *, (, ), id} as the set of terminals. S' $$\to$$ S S $$\to$$ S + R | R R $$\to$$ R * P | P P $$\to$$ (S) | id If I 0 is the set of two LR(0) items {[S' $$\to$$ S.], [S $$\to$$ S. +...
Which one of the following statements is TRUE?
Consider the following augmented grammar with {#, @, <, >, a, b, c} as the set of terminals. S' → S S → S # cS S → SS S → S @ S → < S > S → a S → b S → c Let I 0 = CLOSURE({S' → ∙ S}). The number of items in the set GOTO...
Consider the following statements. S 1 : Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1). S 2 : For any context-free grammar, there is a parser that takes at most O(n 3...
Consider the following grammar. S $$ \to $$ aSB| d B $$ \to $$ b The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is _______.
Which one of the following kinds of derivation is used by LR parsers?
Consider the augmented grammar given below : S' → S S → 〈L〉 | id L → L,S | S Let I 0 = CLOSURE ({[S' → ●S]}). The number of items in the set GOTO (I 0 , 〈 ) is: _____.
The attributes of three arithmetic operators in some programming language are given below. Operator Precedence Associativity Arity + High Left Binary _ Medium Right Binary * Low Left Binary The value of the expression $$...
Which one of the following grammars is free from $$left$$ $$recursion$$?
A student wrote two context-free grammars G1 and G2 for generating a single $$C$$-like array declaration. The dimension of the array is at least one. For example, $$${\mathop{\rm int}} \,\,\,\,\,\,\,a[10]\,\,[3];$$$ The...
Which one of the following is TRUE at any valid state in shift-reduce parsing?
Among simple $$LR (SLR) ,$$ canonical $$LR,$$ and look-ahead $$LR$$ $$(LALR),$$ which of the following pairs identify the method that is very easy to implement and the method that is the most powerful , in that order?
Consider the following grammar $$G$$ $$\eqalign{ & \,\,\,\,\,\,\,S \to \,\,\,\,\,\,\,F|H \cr & \,\,\,\,\,\,F \to \,\,\,\,\,\,\,p|c \cr & \,\,\,\,\,\,H \to \,\,\,\,\,\,\,d|c \cr} $$ where $$S, F$$ and $$H$$ are non-termin...
Consider the grammar defined by the following production rules, with two operators * and + $$\eqalign{ & S \to T*P \cr & T \to U\,|\,T*U \cr & P \to Q + P\,|\,Q \cr & Q \to id \cr & U \to id \cr} $$ Which one of the foll...
A canonical set of items is given below $$\eqalign{ & S \to L. > R \cr & Q \to R. \cr} $$ On input symbol < the set has
Consider the following two sets of LR(1) items of an LR(1) grammar. $$\eqalign{ & X \to c.X,\,c/d\,\,\,\,\,\,\,\,X \to c.X,\$ \cr & X \to .cX,c/d\,\,\,\,\,\,\,\,X \to .cX,\$ \cr & X \to .d,c/d\,\,\,\,\,\,\,\,\,\,\,X \to...
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon and unit-production ( i.e., of type $$A \to \varepsilon $$ and $$A \to a$$ ) to parse a string with n token...
The grammar $$S \to aSa\,|\,\,bS\,|\,\,c$$ is
An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if
Which of the following describes a handle (as applicable to LR-parsing) appropriately?
Consider the following two statements: P: Every regular grammar is LL(1) Q: Every regular set has a LR(1) grammar Which of the following is TRUE?
Which one of the following is a top-down parser?
Consider the grammar with non-terminals N = { S, C, S 1 }, terminals T = { a, b, i, t, e }, with S as the start symbol, and the following set of rules: $$\eqalign{ & S \to iCtS{S_1}\,|\,\,a \cr & {S_1} \to eS\,|\,\,\vare...
Consider the following grammar: $$\eqalign{ & S \to FR \cr & R \to *S\,|\,\varepsilon \cr & F \to id \cr} $$ In the predictive parser table, M, of the grammar the entries $$M\left[ {S,id} \right]$$ and $$M\left[ {R,\$ }...
Consider the following grammar. $$\eqalign{ & S \to S*E \cr & S \to E \cr & E \to F + E \cr & E \to F \cr & F \to id \cr} $$ Consider the following LR(0) items corresponding to the grammar above. $$\eqalign{ & (i)\,S \to...
Consider line number 3 of the following C - program. int main ( ) { /* Line 1 */ int I, N; /* Line 2 */ fro (I = 0, I < N, I++); /* Line 3 */ } Identify the compiler's response about this line while creating the object-m...
Consider the grammar $$E \to E + n\,|\,E \times n\,|\,n$$ For a sentence n + n × n, the handles in the right-sentential form of the reduction are
The grammar $$A \to AA\,|\,\left( A \right)\,|\,\varepsilon $$ is not suitable for predictive-parsing because the grammar is
Consider the following expression grammar. The semantic rules for expression calculation are stated next to each grammar production. $$\eqalign{ & E \to number\,\,\,\,\,E.val = number.val \cr & \,\,\,\,\,\,\,\,\,\,\,|E\...
Consider the grammar $$S \to \left( S \right)\,|\,a$$ Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n 1 , n 2 and n 3 respectively. The following relationship holds good
Consider the following expression grammar. The semantic rules for expression calculation are stated next to each grammar production. $$\eqalign{ & E \to number\,\,\,\,\,E.val = number.val \cr & \,\,\,\,\,\,\,\,\,\,\,|E\...
What does the following C statement declare? int (*f)(int *);
Which of the following grammar rules violate the requirements of an operator grammar? P, Q, R are nonterminals, and r, s, t are terminals. $$\eqalign{ & 1.\,P \to QR \cr & 2.\,P \to QsR \cr & 3.\,P \to \varepsilon \cr &...
Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
Assume that the SLR parser for a grammar G has n 1 states and the LALR parser for G has n 2 states. The relationship between n 1 and n 2 is
Consider the grammar shown below. $$\eqalign{ & S \to CC \cr & C \to cC\,|\,d \cr} $$ This grammar is
Consider the grammar shown below $$\eqalign{ & S \to iEtSS'\,|\,\,a \cr & S' \to eS\,|\,\,\varepsilon \cr & E \to b \cr} $$ In the predictive parse table, $$M$$, of this grammar, the entries $$M\left[ {S',e} \right]$$ an...
Which of the following statements is false?
Which of the following statements is true?
In the following grammar: $$\eqalign{ & X:: = X \oplus {Y \over Y} \cr & Y:: = Z*{Y \over Z} \cr & Z:: = id \cr} $$ Which of the following is true?
Consider the SLR(1) and LALR (1) parsing tables for a context-free grammar. Which of the following statements is/are true?
Consider the following grammar: $$\eqalign{ & S \to S \cr & S \to SS\,|\,a\,|\,\varepsilon \cr} $$ (a) Construct the collection of sets of LR(0) items for this grammar and draw its go to graph. (b) Indicate the shift-red...