[antlr-interest] Problem catching parser termination errors

Gerald B. Rosenberg gbr at newtechlaw.com
Sat Nov 17 17:49:31 PST 2007


In building an AntlrV3-based Eclipse editor for editing AntlrV3 
grammars, I have run across a bit of a problem supporting grammar 
error markers at the point of failure in the parsing a grammar file.

Specifically, if one of the elements of a rule is a subrule that does 
not itself exist as a defined rule, the *default* exception handling 
of the parser appears to just silently fail the parse -- I can find 
no RecognitionException or other exceptions being generated that 
would indicate the point of failure or reason for failure, both being 
desirable to visually identify the grammar error in the editor.  I 
have overridden BaseRecognizer#displayRecognitionError, but that only 
seems to yield missing Token and no viable alternative-type exceptions.

Have I missed an over-rideable routine that would yield this parser 
failure point information?

Currently, the editor's model is being built using an unmodified copy 
of the AntlrV3.g3 grammar (thanks, Ter!).  Aside from this one 
problem, I have been able to get everything I need to support the 
editor without touching the grammar and, for obvious maintenance 
reasons, would prefer to keep it that way.

(If anyone is interested, a page describing the editor is at 
www.certiv.net/products/antlrdt.html -- download is at 
www.certiv.net/download/certiv-antlrdt-0.10.33.zip - it is at an 
unreleased/alpha quality level, with syntax highlighting g3 editor, 
marginally smart indenter and accelerators, outline view, and 
builder.  The only guarantee is that there are bugs -- feedback welcome.)
----
Gerald B. Rosenberg
Certiv Analytics

www.certiv.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071117/838fa401/attachment.html 


More information about the antlr-interest mailing list