Parsing questions — page 2 of 2

Q5

GATE CS 2017 CS-2ParsingMCQ1 mark−1/3 if wrong
Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it:

(P) Syntax tree
(Q) Character stream
(R) Intermediate representation
(S) Token stream

(i) Code generator
(ii) Syntax analyzer
(iii) Semantic analyzer
(iv) Lexical analyzer
Show answer without attempting

Answer: C

Q6

GATE CS 2017 CS-2ParsingMCQ1 mark−1/3 if wrong
Which of the following statements about parser is/are CORRECT?

I. Canonical LR is more powerful than SLR.
II. SLR is more powerful than LALR.
III. SLR is more powerful than Canonical LR.
Show answer without attempting

Answer: A

Q32

GATE CS 2017 CS-2ParsingMCQ2 marks−2/3 if wrong
Consider the following expression grammar G:

<br>E→E−T∣T<br>T→T+F∣F<br>F→(E)∣id<br>\begin{aligned}<br>E &\rightarrow E - T \mid T \\<br>T &\rightarrow T + F \mid F \\<br>F &\rightarrow (E) \mid id<br>\end{aligned}

Which of the following grammars is not left recursive, but is equivalent to G?
Show answer without attempting

Answer: C

Q45

GATE CS 2016 CS-2ParsingMCQ2 marks−2/3 if wrong
Which one of the following grammars is free from left recursion?
Show answer without attempting

Answer: B

Q15

GATE CS 2015 CS-3ParsingMCQ1 mark−1/3 if wrong
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?
Show answer without attempting

Answer: C

Q65

GATE CS 2015 CS-3ParsingMCQ2 marks−2/3 if wrong
Consider the following grammar GG

S→F∣HF→p∣cH→d∣c \begin{array}{rcl} S & \to & F \mid H \\ F & \to & p \mid c \\ H & \to & d \mid c \end{array}

where S,FS, F, and HH are non-terminal symbols, p,dp, d, and cc are terminal symbols. Which of the following statement(s) is/are correct?

S1. LL(1) can parse all strings that are generated using grammar GG
S2. LR(1) can parse all strings that are generated using grammar GG
Show answer without attempting

Answer: D

Q18

GATE CS 2015 CS-1ParsingMCQ1 mark−1/3 if wrong
Which one of the following is TRUE at any valid state in shift-reduce parsing?
Show answer without attempting

Answer: C

Q17

GATE CS 2014 CS-2ParsingMCQ1 mark−1/3 if wrong
Consider the grammar defined by the following production rules, with two operators ∗* and ++

S→T∗PS \rightarrow T * P
T→U∣T∗UT \rightarrow U \mid T * U
P→Q+P∣QP \rightarrow Q + P \mid Q
Q→IdQ \rightarrow Id
U→IdU \rightarrow Id

Which one of the following is TRUE?
Show answer without attempting

Answer: B

Q34

GATE CS 2014 CS-1ParsingMCQ2 marks−2/3 if wrong
A canonical set of items is given below

S→L⋅>RS \to L \cdot > R
Q→R⋅Q \to R \cdot

On input symbol << the set has
Show answer without attempting

Answer: D

Q9

GATE CS 2013 CSParsingMCQ1 mark−1/3 if wrong
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→ϵA \to \epsilon and A→aA \to a) to parse a string with nn tokens?
Show answer without attempting

Answer: B

Q40

GATE CS 2013 CSParsingMCQ2 marks−2/3 if wrong
Consider the following two sets of LR(1) items of an LR(1) grammar.

<br>X→c⋅X,c/dX→c⋅X,$<br>X→⋅cX,c/dX→⋅cX,$<br>X→⋅d,c/dX→⋅d,$<br>\begin{array}{ll}<br>X \to c\cdot X, c/d & X \to c\cdot X, \$ \\<br>X \to \cdot cX, c/d & X \to \cdot cX, \$ \\<br>X \to \cdot d, c/d & X \to \cdot d, \$<br>\end{array}

Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE?

1. Cannot be merged since look aheads are different.
2. Can be merged but will result in S-R conflict.
3. Can be merged but will result in R-R conflict.
4. Cannot be merged since goto on cc will lead to two different sets.
Show answer without attempting

Answer: D

Q52

GATE CS 2012 CSParsingMCQ2 marks−2/3 if wrong
The FIRST and FOLLOW sets for the non-terminals A and B are
Show answer without attempting

Answer: A

Q53

GATE CS 2012 CSParsingMCQ2 marks
The appropriate entries for E1, E2, and E3 are
Show answer without attempting

Answer: C

0/130 correct0 marks

Related topics in Compiler Design