Skip to content
Related Articles
Open in App
Not now

Related Articles

GATE | GATE-CS-2016 (Set 1) | Question 56

Improve Article
Save Article
  • Difficulty Level : Expert
  • Last Updated : 07 Sep, 2021
Improve Article
Save Article

Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S, A} and terminals {a, b}}.

gt46

Using the above SDTS, the output printed by a bottom-up parser, for the input aab is
(A) 1 3 2
(B) 2 2 3
(C) 2 3 1
(D) Syntax Error


Answer: (C)

Explanation: Bottom up parser builds the parse tree from bottom to up, i.e from the given string to the starting symbol. The given string is aab and starting symbol is S.

so the process is to start from aab and reach S.

=>aab ( given string)
=>aSb (after reduction by S->a, and hence print 2)
=>aA (after reduction by A->Sb, and hence print 3)
=>S (after reduction by S->aA, and hence print 1)

As we reach the starting symbol from the string, the string belongs to the language of the grammar.

Another way to do the same thing is :- bottom up parser does the parsing by RMD in reverse.

RMD is as follows:

=>S
=> aA (hence, print 1)
=> aSb (hence, print 3)
=> aab (hence, print 2)

If we take in Reverse it will print : 231




Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!