如何在javaCC上解决“涉及两个扩展的hoice冲突”

时间:2019-04-24 15:44:03

标签: java parsing

我的解析器生成器(使用javaCC)有问题

我遇到此错误:

Warning: Choice conflict involving two expansions at
     line 119, column 3 and line 119, column 43 respectively.
     A common prefix is: <CONSTANT>
     Consider using a lookahead of 2 for earlier expansion.
Warning: Choice conflict involving two expansions at
         line 119, column 3 and line 119, column 43 respectively.
         A common prefix is: <CONSTANT>
         Consider using a lookahead of 2 for earlier expansion.

因为我的代码的这一部分:

TOKEN : /* OPERATORS */
{
  < POINT : "." >
| < VIRGULE : "," >
}

TOKEN :
{
  < CONSTANT : (< DIGIT >)+ >
| < STRING : ( ["A"-"Z","a"-"z"] )+ >
| < #DIGIT : [ "0"-"9" ] >
}

void number() :
{
}
{
  (< CONSTANT > < POINT > < CONSTANT >) | (< CONSTANT >)
}

也许是因为我在表达式“ |”的两边都有2个常数

我已经知道我可以使用LOOKAHEAD,但是请不要误解他的用途是什么

感谢您的帮助,因为我并不了解:(

0 个答案:

没有答案