0

S -> () | (S) | SS

Is this grammar ambiguous? and How do i judge whether this grammar is ambiguous? I learned to draw a Parse tree. But I do not know how to draw it.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

You can do the following: write the grammar in the format for yacc (or any other parser generator you're familiar with). Like so

%%
s: '(' ')' | '(' s ')' | s s;

Run this through yacc, and look for error shift/reduce or reduce/reduce conflics.

Ingo
  • 36,037
  • 5
  • 53
  • 100