[antlr-interest] How to get ANTLR 3.2 to exit upon first error?

Andrew Haritonkin thikone at gmail.com
Mon Mar 15 13:32:13 PDT 2010


For Java and C# target add this in the beginning of the grammar but
after grammar statement:

grammar grammar1;

@members {
protected override object RecoverFromMismatchedToken(IIntStream input,
int ttype, BitSet follow)
{
	throw new MismatchedTokenException(ttype, input);
}
public override object RecoverFromMismatchedSet(IIntStream input,
RecognitionException e, BitSet follow)
{
	throw e;
}
}

@rulecatch {
catch (RecognitionException e)
{
    throw e;
}
}

Hope it helps,
Andrew


More information about the antlr-interest mailing list