in Compiler Design
2,547 views
17 votes
17 votes

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.

in Compiler Design
2.5k views

2 Answers

26 votes
26 votes
Best answer

$\mathbf{ab+cd+.}$

edited by

3 Comments

nice explanation jayendra
0
0
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?
0
0

@Doraemon

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

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

Related questions