in Compiler Design edited by
167 views
0 votes
0 votes

E--> E+E

E--> E*E

E--> id

Input string: id + id + id

in Compiler Design edited by
167 views

1 Answer

0 votes
0 votes

For the string “ id + id + id” is generated by this grammar then there will be 2 parse tree

e.g. 1: 

For the string "3 * 2 + 5",

For the string "3 * 2 + 5", the above grammar can generate two parse trees

Ambiguity in Grammar

Since there are two parse trees for a single string "3 * 2 + 5", the grammar G is ambiguous.

Total 2  parse trees for a single string "3 * 2 + 5”

 

e.g. 2: For the string " id * id + id * id", there will be more than two parse tree

So, by grammar, we can only conclude whether it is ambiguous.

and there should be a string given for the number of parse trees generated.

edited by