[antlr-interest] Re: When does AST construction go through factory?
Daniel Gackle
gackle at shaw.ca
Thu Jan 16 23:51:05 PST 2003
Ter,
You beat me to the punch, I was just playing with antlr-2.7.2rc2 to see if
it changed the behavior. Indeed it does! But now I'm seeing two new
problems. Perhaps they have to do with a version mismatch between RC2 and
the C# codegen? (The latest C# version if I am not mistaken is 2.7.2a4?)
My previous example was something like this (where IDENT is a lexer token
and MYTOKEN is not):
tokens {
IDENT<AST=MyIdentifierNode>;
MYTOKEN<AST=MyASTNode>;
}
(Problem 1) For IDENT, the parser does:
astFactory.create(LT(1), "MyIdentifierNode");
which is wonderful in that it is a call to the factory, but it fails to
compile against the C# runtime with an error that says "cannot convert Token
to int".
(Problem 2) For MYTOKEN, I don't see any generated code that maps to
MyASTNode. The parser used to do this:
astFactory.registerFactory(MYTOKEN, "MyASTNode");
But that's gone, and I can't find anything in the generated code that
replaces it. As a result, when the AST for MYTOKEN gets created, its type
is not MyASTNode but simply the default AST type.
Would anyone (Micheal? :) care to comment? Based on a brief look at the
improved ASTFactory class, there appear to be methods I can call to set up
the mappings in my own code, and bypass the Tokens section altogether. Does
that sound like a valid workaround for now?
Thanks,
Daniel
--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at j...> wrote:
> Hi. ANTLR 2.7.2 should be out tomorrow or over the weekend. It fixes
> this so that all AST creation goes thru the factory. :)
>
> Ter
>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list