How to force ANTLR to parse all input CharStream

后端 未结 1 1990
盖世英雄少女心
盖世英雄少女心 2021-01-21 14:48

I\'m using ANTLR4 to parse a syntax file. When I use BaseErrorListener to detect errors, I got a problem. When faced with an illegal input string, ANTLR automatically matches th

1条回答
  •  清酒与你
    2021-01-21 15:40

    Your main rule needs to end with the EOF token - an ANTLR-provided special token that matches end of input.

    If the token's not there, ANTLR will just parse whatever it can match and then stop. By putting the EOF at the end of your entry rule, you tell ANTLR that whatever it parses must end at the end of input.

    0 讨论(0)
提交回复
热议问题