[antlr-interest] More Error Handling and Recovery

madison_stjames madison_stjames at yahoo.com
Thu Apr 10 13:52:59 PDT 2003


Ok, I think I've almost got it:

Here's my start rule:
 startRule
    :  ( line )+ EOF
    ;
    exception // for rule
    catch [RecognitionException ex] {
    Console.Error.WriteLine("exception: "+ex);
    consume();
    consumeUntil(tokenSet_0_);
    }

What I want to do is resume the line production, upon encountering 
an unrecognized token. The error is written out, and parsing 
continues with the next line in the file.

The line production composed of sub-productions as follows:

line
    : ( date WS time WS cip WS csusername WS sip WS sport WS 
csmethod WS csuristem WS csuriquery WS scstatus WS csuseragent (WS)?
        { 
           Console.Out.WriteLine( SBLine.ToString() );
           SBLine = new StringBuilder();
        }
       )
    ; 

I want to continue to the next rule that the parser can recognize. I 
thought line should work, for example: consumeUntil(line) but that 
causes an error.

I looked at the parser file from a previous version, and noticed 
that error handling specified token sets. How do these map to the 
rules? And how do I determine which ones to use?

The exception handling routine above works, but I'm not sure exactly 
what I'm referencing with tokenSet_0_;

Thanks Again!


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list