[antlr-interest] Overriding reportError

Ric Klaren klaren at cs.utwente.nl
Mon Mar 15 15:10:43 PST 2004


Hi,

On Fri, Mar 12, 2004 at 05:00:25PM -0000, kjerken wrote:
> I've sucessfully built a parser using ANTLR (in C++, thanks Ric!) and
> I was wondering what the appropriate method to isolate it from the std
> iostreams was.

I guess you should look at InputBufer and friends. I'm not sure if you can
circumvent all stream usage (might be a stringstream around somewhere) The
plain old string input buffer variant is the simplest to start from but
nothing stops you from hacking (deriving from) the stream one to something
different. Check the calc examples for details on how to set up
lexer/parser with a custom inputbuffer. (might have to grab examples from a
snapshot for the latest)

> I can inherit from my generated parser and override
> reportError, but I'd rather have an option to completely replace
> cout/cerr in the generated parser.  

You can directly override reportError etc. in the generated parser by
dumping them in the action part after 'x extends LLkParser' see the grammar
template in the docs for exact places (can't recall offhand if that was
extends Parser or something else ;))

If you got reportError and Inputbuffer covered then you should have most of
it.

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  "I don't have anything against Java - it's the best damn implementation
              of UCSD Pascal ever released..." --- Larry Smith



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list