[antlr-interest] Lexer error handling,
Craig Main
craig at palantir.co.za
Thu Jul 17 13:15:20 PDT 2008
Hi,
I have made the necessary override and @rulecatch changes to ensure that my
parser throws the first error it encounters out to my catch block.
I followed the instructions in the book "Exiting the recogniser upon first
error".
I am struggling to achieve the same thing with the lexer. I am using the C#
target (3.0.1, though I have also tried 3.1).
I still get the four or five error messages printed, the lexer attempts to
recover and I cannot seem to override the default behaviour.
I have added the lexer members
@lexer::members{
protected override void Mismatch(IIntStream input, int ttype, BitSet
follow) {
throw new MismatchedTokenException(ttype, input);
}
public override object RecoverFromMismatchedSet(IIntStream input,
RecognitionException e, BitSet follow) {
throw e;
}
}
>From examining the source it would appear that @lexer::rulecatch is not
supported?
How do I get the lexer to bail on first error?
Regards
Craig.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080717/5fe6721b/attachment-0001.html
More information about the antlr-interest
mailing list