edited by
996 views

3 Answers

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
0 votes
0 votes
There will be 2 parser tree one by replacing left most variable with I'd and another by replacing rightmost variable by id
0 votes
0 votes

For the given input string id+id+id

There is only two possible parse tree

And for the string id*id+id 

​​​​​​There will be more than one

​​​

edited by

Related questions

1 votes
1 votes
1 answer
2
learner_geek asked Aug 2, 2017
537 views
If i am wrong please let me correct with giving proper explanation.
1 votes
1 votes
1 answer
3
im.raj asked Jun 16, 2016
14,424 views
A. AmbiguousB. UnambiguousC. ComplementationD. Concatenation Intersection
2 votes
2 votes
1 answer
4
Akriti sood asked Dec 10, 2016
4,181 views
can LR(1) parser parse any context-free grammar/language ??and hence every regular language can be parsed by LR(1) parsers.