[antlr-interest] Newbie question: How to tell a parse failed or succeeded

Benjamin Niemann pink at odahoda.de
Fri Sep 14 00:35:52 PDT 2007


Hi,

smerzlia at optusnet.com.au wrote:

> I have built a grammar and I can get it to work using the various
> samples on the web (thanks to all!). The only problem i have is
> that the following code does not throw ANY exceptions on failed
> lexing or parsing (my grammar file is basic and identical to a lot
> of other samples) :
> 
> [snip]
>
> So how can I SIMPLY (using ANTLR API, not my own code) tell whether a
> lexical scan + parse succeeded  or failed ?

You have to override some methods in your lexer/parser. See section "Error
handling" in the V2->V3 migration guide at
<http://www.antlr.org/wiki/display/ANTLR3/
Migrating+from+ANTLR+2+to+ANTLR+3> (long URL splitted!)


HTH

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/



More information about the antlr-interest mailing list