-1

E->EE+/E(E)/id

Check if the given grammar is ambiguous. Also, it would be of a great help if you could tell me the process to remove the ambiguity.

I tried making the parse tree for it but could not figure out how to actually make it to find an ambiguous case

1 Answers1

1

Bison generates an LALR(1) parser for that grammar without any parser conflicts. An LALR(1) grammar without parsing conflicts cannot be ambiguous, so it seems unlikely that you will be able to find an ambiguity.

For reference, the bison input I used was:

%%
E: E E '+'
 | E '(' E ')'
 | 'i'

If you process that with the -v flag, bison will produce a report file which contains the complete state machine. (There are eight states plus the initial state.)

rici
  • 234,347
  • 28
  • 237
  • 341