ANTLR 4.5 - Mismatched Input 'x' expecting 'x'

前端 未结 2 1335
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 01:10

I have been starting to use ANTLR and have noticed that it is pretty fickle with its lexer rules. An extremely frustrating example is the following:

grammar          


        
2条回答
  •  Happy的楠姐
    2020-12-01 01:30

    This was not directly OP's problem, but for those who have the same error message, here is something you could check.


    I had the same Mismatched Input 'x' expecting 'x' vague error message when I introduced a new keyword. The reason for me was that I had placed the new key word after my VARNAME lexer rule, which assigned it as a variable name instead of as the new keyword. I fixed it by putting the keywords before the VARNAME rule.

提交回复
热议问题