[antlr-interest] How does one suppress 'no viable alternative at character' warning messages

Jim Idle jimi at temporal-wave.com
Wed Sep 17 13:37:09 PDT 2008


On Wed, 2008-09-17 at 16:27 -0400, Tim Halloran wrote:
> On Wed, Sep 17, 2008 at 3:27 PM, Terence Parr <parrt at cs.usfca.edu>
> wrote:
> 
>         Just throw an Error, which will not require a change to the
>         signature and will blast all way out.
> 
> 
> This is undesirable because it breaks the client side and loses
> reporting information.  My client side looks like:


Basically though, if your lexer is throwing NVA's, it means it isn't
complete or has bugs. By rights, the lexer should make something out of
anything, even if it is a throw away element:

ANY : . { skip(); }

Or more likely, a more controlled error message:
ANY : . { myErrorLog.error("The character " + $text + " is not
supported."); $channel = HIDDEN; }




> 



> }
> }
> 
> A better approach (like an option to turn off lexer error recovery)
> seems a good enhancement to a future version of ANTLR.  

Given all the things that can happen, the approach now seems best. It is
not difficult to override a method.


> That said, this approach is nice because it works in the way most
> folks client code would expect.


Lexer recovery is just that it eats the character it did not want. There
is not much else you can do. If you turn it off, then what should it do?

Jim


> 
> Regards,
> Tim
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 
> 

> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080917/7d901555/attachment.html 


More information about the antlr-interest mailing list