[antlr-interest] Re: Adding state to a TreeParser (C++)
jm_newton
jm_newton at yahoo.co.uk
Tue Aug 17 06:30:16 PDT 2004
Hmm,
Obviously having a bad day.
declaring some suitable memebers in a {} block after the class
definition in the .g file is good enough for me...
--- In antlr-interest at yahoogroups.com, "jm_newton" <jm_newton at y...> wrote:
> Hi,
> 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";
>
> where MyTreeParserState is defined as:
>
> class MyTreeParserState : public antlr::TreeParser
> {
> ...
>
> but this results in the following errors:
>
> BlobManagement.g:129:39: rule classDef trapped:
> BlobManagement.g:129:39: expecting "Parser", found '"BlobManagement"'
> error: aborting grammar 'BlobManagementLexer' due to errors
> Exiting due to errors.
>
> Does anybody have any experience of trying to extend the C++
> TreeParser to add state in this way or are there better ways...
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