[antlr-interest] Disabling recovery during parsing
foolishewe at hotmail.com
Mon Nov 5 07:33:09 PST 2007
Hopefully this attempt to transmit will get through, I'm sorry if you see this twice but I tried on October 30 but I didn't see my message in the list.
Our experiences with ANTLR has been generally good, but we could use a bit of help here. We have a fairly simple language which we read in one command at a time. A command is passed in as a buffer with an ascii NULL ('\0') terminator character, which we treat as a "sentinel" token to try to better detect when an invalid suffix might be in the look ahead. Since we have an interactive scripting tool, and all commands are terminated by newlines, we have a "wrapper" which invokes the parser and catches exceptions due to syntax errors. However, for some suffix errors, the parser appears to capture the exception internally, and generates a warning message, rather than passing the exception out. So although the diagnostic messages which might look something like (the null terminator is not displayed):
XXXX YYYYYY ZZZZ index-10;ge
BR.recoverFromMismatchedToken line 1:25 mismatched input ';ge expecting ENDOFCOMMAND
where XXXX, YYYYYY and ZZZZ are all valid keywords in the language, and the lexer has a production:
// Lexer Rules
ENDOFCOMMAND : '\000'; // A terminal NULL Character
The ;ge suffix should not be there, and is correctly flagged as invalid, but the error recovery is more "forgiving" than we want in our application, we would prefer the parser to throw a RecognitionException which we handle in the wrapper for consistency reasons.
Help yourself to FREE treats served up daily at the Messenger Café. Stop by today.
More information about the antlr-interest