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.
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.
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.