[antlr-interest] Re: When does AST construction go through factory?

micheal_jor <open.zone at virgin.net> open.zone at virgin.net
Fri Jan 17 06:16:41 PST 2003


> 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?)

ANTLR 2.7.2rc2 contains a matching C# codegen.

> 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");

This would be a bug. ASTFactory.create(Token, string) doesn't exist
Can you post a simple repro-grammar please?

> 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.

Hmm...this isn't right. Please post a repro-grammar and I'll fix it 
before Ter's planned 2.7.2 release party  ;-)

> Would anyone (Micheal? :) care to comment?

Ahem..uh..well...

> 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?

Yes. Just remember that if the issues are reproducible here, they 
will be fixed asap and you won't need the workarounds.

Cheers,

Micheal



 

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



More information about the antlr-interest mailing list