2,547 views

Consider the syntax-directed translation schema (SDTS) shown below:

• $E\rightarrow E + E$ {print “+”}
• $E\rightarrow E * E$ {print “.”}
• $E\rightarrow id$ {print id.name}
• $E\rightarrow (E)$

An LR-parser executes the actions associated with the productions immediately after a reduction by the corresponding production. Draw the parse tree and write the translation for the sentence.

$(a+b)*(c+d)$, using SDTS given above.

$\mathbf{ab+cd+.}$

by

nice explanation jayendra
my question is that this grammar is ambigious and LR-parsers can parse only unambigious grammars.
Here do we assume that we have removed the ambiguity from the grammar and only then passed it to the parser?

@Doraemon

$just\ a\ thought\ that\ maybe\ we\ can\ make\ use\ of\ operator\ precedence\ parser !!$

ab+cd+.      its a basic SDT, used to find the postfix expression.

1
2
3