[antlr-interest] Please Help : How do i change the default AST node type for a grammar ?

Ric Klaren klaren at cs.utwente.nl
Wed Feb 19 07:44:06 PST 2003


Hi,

On Wed, Feb 19, 2003 at 04:09:48PM +0100, Anthony Brenelière wrote:
> 1/
> The parser ::setASTNodeType method, as specified in the documentation,
> does not exist in the Cpp distrib.

C++ differs from java mode on several details. Check the C++ section of the
documentation and/or header files in case of trouble. Also doxygen
generated docs of the support lib are availabe at:

http://wwwhome.cs.utwente.nl/~klaren/antlr/support-docs/

One of these days these need to be integrated in the normal docs.

> 2/
> I also specified the option :
> options {
> 	..
> 	ASTLabelType = "ANTLR_USE_NAMESPACE(antlr)RefTextNode";
>          ..
> }
> .. but there is no effect, commonAST is still used.

I use it daily and it works. Maybe you have your ASTFactory setup
incorrectly?

> 3/
> In..
>
> ASTFactory::ASTFactory( const char* factory_node_name, factory_type fact
> )
>
> ..what does the second arguement mean ? there is no comment about the
> second arguement.

It specifies a default factory to use of type factory type. As noted in the
comment in the ASTFactory.hpp.

> I also tried to declare the factory in that way:
> ASTFactory ast_factory( "RefTextNode", 0 )
> ..but there is no effect when i run the program.
>
> So/
> My question is :
>
> How do i set the default AST node type ?

http://www.antlr.org/doc/cpp-runtime.html#_changingasttype

Also the heteroAST example contains some setup code that is will work in
the simple custom AST type case.

If it still fails post relevant bits of how you setup your
lexer/parser/treewalker and the rest of the options section.

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
 Why don't we just invite them to dinner and massacre them all when they're
  drunk? You heard the man. There's seven hundred thousand of them. Ah? ..
           So it'd have to be something simple with pasta, then.
                 From: Interesting Times by Terry Pratchet


 

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



More information about the antlr-interest mailing list