Antlr3: Could not match token in parser rules which is used in lexer rule

老子叫甜甜 提交于 2019-12-02 13:44:43

In ANTLR lexer, the lexer rule that can match the longest sub-sequence of input is used. So your input

abc-abc

will be tokenized as

CHARS("abc")
TOKEN("-abc")

and therefore will not match the expected CHARS HYPHEN CHARS.

You should consider making TOKEN a parser rule instead of lexer rule.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!