[antlr-interest] error recovery in top level repeated rules?

JesusFreke jesusfreke at jesusfreke.com
Fri Sep 7 18:58:17 PDT 2012


Is there any way to recover from an error (say, an extra unwanted token),
in a top level repeated rule?

For example, consider the following simple grammar

top : (('a' 'c') | ('b' 'c'))*;

For input acabc", it parses 'ac', produces an error on 'a', and then
contiues on with 'bc'. This is perfect.

But for input "accbc", it parses 'ac', and then fails at 'c' and stops
parsing. Is there any way to get it to produce an error for the extra 'c',
and then continue on parsing the remaining 'bc'?


More information about the antlr-interest mailing list