• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Parsing and Syntax directed translation

Question 71

A bottom-up parser generates:
  • Left-most derivation in reverse
  • Right-most derivation in reverse
  • Left-most derivation
  • Right-most derivation

Question 72

Consider the following statements.
  • I. Symbol table is accessed only during lexical analysis and syntax analysis.
  • II. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment.
  • III. Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis.
Which of the above statements is/are TRUE ?
  • I only
  • I and III only
  • Ⅱ only
  • None of Ⅰ, Ⅱ and Ⅲ

Question 73

Consider the following grammar.
S → aSB ∣ d
B → b 
The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is ________ . Note - This question was Numerical Type.
  • 6
  • 7
  • 8
  • 4

Question 74

Consider the productions A → PQ and A → XY. Each of the five non-terminals A,P,Q,X, and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules.
Rule 1: P.i=A.i+2, Q.i=P.i+A.i, and A.s=P.s+Q.s
Rule 2: X.i=A.i+Y.s and Y.i=X.s+A.i 
Which one of the following is TRUE ?
  • Both Rule 1 and Rule 2 are L-attributed
  • Only Rule 1 is L-attributed
  • Only Rule 2 is L-attributed
  • Neither Rule 1 nor Rule 2 is L-attributed

Question 75

Consider the following statements.
  • S1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).
  • S2: For any context-free grammar, there is a parser that takes at most O(n3) time to parse a string of length n.
Which one of the following options is correct?
  • S1 is true and S2 is false
  • S1 is false and S2 is true
  • S1 is true and S2 is true
  • S1 is false and S2 is false

Question 76

Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code With respect to the above grammar, which one of the following choices is correct?
  • The actions can be used to correctly type-check any syntactically correct program
  • The actions can be used to type-check syntactically correct integer variable declarations and integer expressions
  • The actions can be used to type-check syntactically correct boolean variable declarations and boolean expressions.
  • The actions will lead to an infinite loop

Question 77

Consider the following context-free grammar where the set of terminals is {a,b,c,d,f}. The following is a partially-filled LL(1) parsing table. Which one of the following choices represents the correct combination for the numbered cells in the parsing table (“blank” denotes that the corresponding cell is empty)?
  • A
  • B
  • C
  • D

Question 78

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 I0=CLOSURE({S′→∙S}). The number of items in the set GOTO(GOTO(I0 <), <) is ___________ .
  • 8
  • 7
  • 5
  • 9

Question 79

Shift-reduce parser consists of (a) input buffer (b) stack (c) parse table choose the correct option from those given below:
  • (a) and (b) only
  • (a) and (c) only
  • (c) only
  • (a), (b) and (c)

Question 80

A CFG G is given with the following productions where S is the start symbol, A is a non-terminal and a and b are terminals.
S→aS∣A
A→aAb∣bAa∣ϵ
For the correct answer in Q75, how many steps are required to derive the string and how many parse trees are there?
  • 6 and 1
  • 6 and 2
  • 7 and 2
  • 4 and 2

There are 85 questions to complete.

Last Updated :
Take a part in the ongoing discussion