[antlr-interest] Missing error when tokens are left to parse

Gavin Lambert antlr at mirality.co.nz
Fri Jan 15 03:10:05 PST 2010


At 22:43 15/01/2010, Arne Schröder wrote:
 >file    : section1 section2?
 >        ;
[...]
 >If I now try to parse "Section1 bla()) 
Section2" something similar
 >happens:
 >It parses up to the second ")" and then decides 
to skip the rest.
 >And I definitely do not want the second ")" to 
be there i.e. want
 >it to throw a recognition-error and recover itself.

Try adding EOF to the end of your top-level 
rule.  Without that, ANTLR assumes that it is not 
required to parse all the input, so if it 
successfully parses a section1 it will just 
decide that the section2 has been omitted (since it's optional).



More information about the antlr-interest mailing list