All mock tests are FREE till 31 December — register to save your progress
Paper 2 CS · UNIT 08 · MOCK TEST

Mock 7 – Lexical & Syntax Analysis (Parsing)

Unit 8: Theory of Computation and Compilers · 26 questions · about 31 minutes. Press End Mock any time to see your score and the correct answers.

All 10 topic-wise mocks in this unit
0 / 26 answered 00:00

Consider the following Context Free Grammar (G):

S → A B
B → + A B | ε
A → C D
D → * C D | ε
C → [ S ] | x

Variable = { S, A, B, C, D }

Terminals = { +, *, [, ], x }

Q1. In the LL(1) Parsing table of the given CFG, how many valid non-blank entries will be there in the rows for variables 'B' and 'D'?
Q2. Arrange the following parsers in increasing order of their power of handling grammars, i.e. from the least powerful parser to the most powerful parser.
A. LR(0)
B. LR(1)
C. LALR(1)
D. LL(0)
E. SLR
Choose the correct answer from the options given below:
Q3. yacc is which of the following parsers?
Q4. Consider the grammar E → E + n | E × n | n. For the sentence n + n × n, the handles in the right-sentential forms of the reduction are:
Q5. Match List I with List II according to the input to the compiler phase that processes it:
List IList II
(a) Syntax tree(I) Code generator
(b) Intermediate representation(II) Semantic analyzer
(c) Token stream(III) Lexical analyzer
(d) Character stream(IV) Syntax analyzer
Q6. Which of the following parsers is the most powerful?
Q7. Shift-reduce conflicts are resolved by:
Q8. Match List I with List II
List IList II
A. A → aB | a (a ∈ T; A, B ∈ V)I. Recursive Descent Parser
B. A → BC | a (a ∈ T; A, B, C ∈ V)II. Turing Machine
C. LL(1) grammarIII. Chomsky Normal Form
D. Halting problemIV. Finite Automata
Q9. Which of the following is a function of the semantic analysis phase of compilation?
Q10. Match List I with List II
List IList II
A. Back TrackingI. Automata
B. Infinite languages with matching numbersII. Undecidable Problem
C. Canonical LR ParserIII. Predictive Parser
D. Post Correspondence ProblemIV. Large number of states
Q11. The number of tokens in the line ' for i in range (begin; end ; step) : ' is:
Q12. While processing a string, an LR parser reads the input
Q13. Match List I with List II (stack and input configurations)
List IList II
A. Initial configuration of stack and input in LL parsingI. $ | w$
B. Final configuration of stack and input in LL parsingII. $ | $
C. Initial configuration of stack and input in LR parsingIII. $S | w$
D. Final configuration of stack and input in LR parsingIV. $S | $
Q14. Consider the following statements:
Statement I: An LALR parser is more powerful than a canonical LR parser.
Statement II: An SLR parser is more powerful than LALR.
Which of the following is correct?
Q15.

Arrange the following parsers in increasing order of their power of handling grammars i.e. from the least powerful parser to the most powerful parser.

A. LR (0)

B. LR (1)

C. LALR(1)

D. LL (0)

E. SLR

Q16.

Match List I with List II. List I: A. A → aB | a (a ∈ T; A, B ∈ V), B. A → BC | a (a ∈ T; A, B, C ∈ V), C. LL(1) grammar, D. Halting problem. List II: I. Recursive descent parser, II. Turing machine, III. Chomsky Normal Form, IV. Finite automata.

Q17.

Match List-I with List-II :

Figure
Q18.

Match List - I with List - II according to input to the compiler phase that process it :

Figure
Q19.

Which of the following parser is most powerful parser?

Q20.

While processing a string by an LR parser, the reading of the given string by the parser is-

Q21.

Match the following based on the language accepted by using brute force method of parsing.

Figure

Directions (Q96–100): A Turing machine for L = {aⁿbᵐcⁿdᵐ | n ≥ 1, m ≥ 1} is designed as M = ({q0, …, q7, qf}, {a, b, c, d}, {a, b, c, d, X1, X2, Y1, Y2, B}, δ, q0, B, {qf}). X1 and X2 mark matched a's and c's; Y1 and Y2 mark matched b's and d's. Part of δ is given in the transition table (shown with each question); cells M1–M5 are to be filled.

Q22.

What is the Move in the cell with number 'M4' of the resultant Table?

Figure
Q23.

Statement I: The LALR parser is more powerful than the canonical LR parser. Statement II: The SLR parser is more powerful than LALR. Which is correct?

Q24.

Given below are two statements

Statement I: LL(1) and LR are examples of Bottom‐up parsers.

Statement II: Recursive descent parser and SLR are examples of Top‐down parsers In light of the above statements, choose the correct answer from the options given below

Q25.

Shift-reduce parser consists of

(a) input buffer

(b) stack

(c) parse table

Q26.

A bottom-up parser generates :