move to a new state after cosuming tokens in antlr4

自古美人都是妖i 提交于 2019-12-11 07:44:49

问题


i have following grammar

root
    : sql_statements EOF | EOF
   ;

sql_statements
    :( sql_statement )+
   ;

sql_statement
    : ddl_statement semicolon
   ;

ddl_statement
    : alter_statement
   ;

This is a initial snapshot of my grammar i have following test case

aleter table user;alter table group_user;

first statement has error hence i am getting error for both statements under sql_statements rule

Failed to parse at line 1:1 due to mismatched input 'aleter' expecting ALTER

Now i want to use Defaulterrorhandler functionality to skip first statement till semicolon. Then it should start from second statement starting with rule sql_statements.

Question :
How to tell which rule to start after consuming error tokens ?
Thanks in advance.

来源:https://stackoverflow.com/questions/46706766/move-to-a-new-state-after-cosuming-tokens-in-antlr4

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