Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
S -> () | (S) | 党卫军
这个语法有歧义吗?我如何判断这个语法是否有歧义?我学会了画 Parse 树。但是不知道怎么画。
您可以执行以下操作:以 yacc(或您熟悉的任何其他解析器生成器)的格式编写语法。像这样
%% s: '(' ')' | '(' s ')' | s s;
通过 yacc 运行此程序,并查找错误 shift/reduce 或 reduce/reduce 冲突。