Consider the following Syntax Directed Translation Scheme , with non-terminals and terminals .
Using the above , the output printed by a bottom-up parser, for the input is:
View worked solution
Answer: C
A bottom-up parser performs reductions in the reverse order of a rightmost derivation.
First, let's find the rightmost derivation for the input string using the given grammar:
The sequence of reductions performed by the bottom-up parser is the exact reverse of this rightmost derivation:
-
First reduction: (reducing the second in to )
Associated action:{print 2} -
Second reduction: (reducing to )
Associated action:{print 3} -
Third reduction: (reducing the entire string to the start symbol )
Associated action:{print 1}
Thus, the output printed by the parser is: .
Free practice · Your answers on this page are not saved.
