我想写一个C语法与Antlwork,并为此我使用这一个http://stuff.mit.edu/afs/athena/software/antlr_v3.2/examples-v3/java/C/C.g我试图通过删除很多块我不使用和回溯。这里是我有:http://www.archive-host.com/files/1956778/24fe084677d7655eb57ba66e1864081450017dd9/CNew.txt许多多种替代错误与我的C语法
后来,当我做CTRL + d,我得到这样的很多错误和警告的:
[21:20:54] warning(200): C:\CNew.g:188:2: Decision can match input such as "'{' '}'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
[21:20:54] warning(200): C:\CNew.g:210:2: Decision can match input such as "'for' '('" using multiple alternatives: 2, 3
As a result, alternative(s) 3 were disabled for that input
[21:20:54] error(201): C:\CNew.g:210:2: The following alternatives can never be matched: 3
[21:20:54] error(208): C:\CNew.g:250:1: The following token definitions can never be matched because prior tokens match the same input: CHAR
我真的不明白,为什么我有这些警示,不应该有冲突。
那就不要删除'backtrack'(和'memoize')选项。 – 2013-03-06 20:46:44
感谢您的回复,但有朋友告诉我,使用回溯会让我后来遇到很多困难,当我尝试执行AST时。 – Exia0890 2013-03-06 20:50:41
这里有两个选项:'1)'要么重写语法,以便模糊不再存在(这可能相当困难,看到您开始使用启用了回溯的语法),或者2)重新启用回溯。询问你的朋友究竟是什么意思*“当我尝试做AST时会遇到很多困难”*,因为这听起来像是无意义的。从启用回溯的语法分析器语法创建AST没有任何问题。 – 2013-03-06 20:58:32