+3 votes
786 views

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

$S \to aA \quad \{\text{print }1\}$

$S \to a \quad \{\text{print }2\}$

$A \to Sb \quad \{\text{print }3\}$

Using the above $SDTS$ , the output printed by a bottom-up parser, for the input $aab$ is:

1.  $1 \ 3 \ 2$
2.  $2 \ 2 \ 3$
3.  $2 \ 3 \ 1$
4.  syntax error
asked
edited | 786 views

## 1 Answer

+23 votes
Best answer

aab could be derived as follows by the bottom up parser:

S->aA prints 1
A->aSb prints 3
A->aab  prints 2

Now since bottom up parser will work in reverse of right most derivation, so it will print in bottom up fashion i.e., 231 which is option C.

Note that this could also be visualized easily by drawing the derivation tree.

answered by Boss (7.7k points)
selected
Just a doubt... If the grammar given is not CLR(1) and the string is derivable will it be considered as parsable and sdt would be possible..??
Answer:

+7 votes
1 answer
1
+10 votes
9 answers
2
+13 votes
3 answers
3