Syntax directed translation schema


#1

Consider the following syntax directed translation schema,with non terminals {S,A} and terminals {a,b}.
S->aA {print 1}
S->a {print 2}
A->Sb {print 3}

Using the above STDS ,the output printed by a bottom up parser for the input “aab” is:


#2

Bottom-up parser performs parsing by detecting proper number of handles present in a string.
It uses Right most derivation in reverse order to construct the parse tree.
If SDT is carried out using Bottom-up parser, for every reduce actions the semantic rules corresponding to given production rule is executed.
-> S
-> aA (1 is printed)
-> aSb (3 is printed)
-> aab (2 is printed)
Reduction takes place as per Right Most Derivation in Reverse Order.
So, Output will be : 231