[antlr-interest] Re: Problems with token class-type override feature (with C# codegen)
lgcraymer
lgc at mail1.jpl.nasa.gov
Mon Jul 29 11:24:15 PDT 2002
Micheal--
Manually constructed AST nodes use the default AST type--Ric says that
he's fixed that for C++ (although I don't remember if that is yet in
an available version). The ASTFactory needs to use a table of token
values and classes to make this work properly.
For automatic construction, ANTLR creates ASTs using the specified
classes, but doesn't do typecasting properly. The solution that I
found was to modify the code generation to specify all AST variables
declared by ANTLR as being of type "AST"--that effectively avoids the
typecasting problems since ANTLR only references the child and sibling
fields.
--Loring
--- In antlr-interest at y..., "micheal_jor" <open.zone at v...> wrote:
> Hi,
>
> While exploring the idea of custom AST classes, I noticed that the
> feature is supposed to that allow me to specify alternative AST
> classes on a per-token basis isn't working.
>
> I specified the following in my grammar but in the generated code
the
> default AST class type is still used for all nodes. There is no
> reference to the specified class type at all.
>
> tokens
> {
> LOCK_STMT<AST=LockStatement>;
> }
>
> I though it might be related to the fact that I use manual
> treebuilding commands such as:
>
> lockStatement
> : LOCK!
> ( ( LPAREN! stmtList )=> LPAREN! expression RPAREN! block
> { ## = #( [LOCK_STMT, "LOCK_STMT"], ##); }
> | block
> { ## = #( [LOCK_DIRECTIVE, "LOCK_DIRECTIVE"], ##); }
> )
> ;
>
> This is with C#. Does this feature work at all?. If it does, can
> anyone give me a quick pointer to what I should look out for in
> fixing the C# codegen pls (it needs an update soon anyways
methinks).
>
> Micheal
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list