[antlr-interest] Adding state to a TreeParser (C++)
Ric Klaren
klaren at cs.utwente.nl
Tue Aug 17 06:24:03 PDT 2004
On Tue, Aug 17, 2004 at 01:15:43PM -0000, jm_newton wrote:
> I'm using ANTLR 2.7.4 to generate c++ code. I've managed to generate
> an AST tree via Lexer/Parser and now I'm interested in adding some
> state information to my TreeParser which I'm using to 'run' the tree.
>
> Assuming I don't want to modify the files generated by ANTLR the
> cleanest way of doing this appears to be extending the TreeParser from
> my own base class which is derived from the ANTLR TreeParser. I can
> find examples of this in the documentation for Java
> (http://www.antlr.org/doc/metalang.html#_bb6) but none for C++.
>
> I've tried the following in my .g file:
>
> class MyTreeParser extends "MyTreeParserState";
Try: class MyTreeParser extends TreeParser("MyTreeParserState");
> Does anybody have any experience of trying to extend the C++
> TreeParser to add state in this way or are there better ways...
Did you notice the template grammar in doc/cpp-runtime.html it lists all
the spots where you can insert code into the generated file. E.g. how to
add attributes/methods to the generated class (or override methods).
Cheers,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755 ----
-----+++++*****************************************************+++++++++-------
Before they invented drawing boards, what did they go back to?
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