简体   繁体   中英

ANTLR handling mismatched Input Exception

I have a grammar which throws a mismatched input exception, as expected when passing a wrong input but the problem is it tries to recover causing Java.lang.outofmemoryexception and thus terminating the thread which I would not like to happen.

How do I handle that? Which function should I override so that it doesn't tries to recover, instead notifies and continues?

You could override either the parser's, or lexer's, reportError(...) method, and throw an exception instead of letting ANTLR (trying to) recover.

Also see: ANTLR 3.0 Error Reporting and Recovery .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM