[antlr-interest] Re: C# generator, tree & bug report

micheal_jor open.zone at virgin.net
Tue Sep 3 17:31:46 PDT 2002


--- In antlr-interest at y..., "Lloyd Dupont" <lloyd at g...> wrote:
> Hi folks !
> 
> I was using ANTLR to write a little code generator.
> C# is the natural language of my programs.

I presume you mean that C# is the implementation language right?. 

As opposed to the source language for your lexer/parser or indeed the 
target language you will be generating from your project.

> So I though a C# Parser would be more powerfullto do some of my app 
specific
> stuff.
> I also use customized AST tree construction in my parser.
> something like :
> args
>  :(
>      ! LPAR RPAR { #args = #[VOID]; }
>      |! (LPAR VOID RPAR)=> LPAR VOID RPAR { #args = #[VOID]; }
>      | LPAR! argList RPAR!
>     )
>  { #args = #([PARAMS, "args"], #args); }
>     ;
> but I have some trouble with this contruction semantic:
> "#args = #[VOID];"
> 
> as it generate:
> args_AST = (AST)astFactory.create(VOID);
> whereas it should generate (in C#, as it is correct in Java)
> args_AST = (AST)astFactory.create(MyTokenTypes.VOID);
> 
> mmhh..
> that's very curious.

I can't remember if it always adds the prefix for you. It can in some 
situation but in general you should do that yourself.

[Actually, from the next upgrade that - adding the prefix - wouldn't 
be _neccesary_ anymore.]

> I use this syntax more than once, but it write this uncorrect 
output only
> once.
> my grammar file is relatively short, I could send it to whoever is
> interested, if needed....

Please post it to the list and I will have a look. Please include as 
much detail as you have.

Incidentally, I can only help with the C# codegen from www.antlr.org 
OK?. Pls include the timestamp of the .zip file or when roughly you 
downloaded the C# code generator you are using?. 

Cheers!,

Micheal



 

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



More information about the antlr-interest mailing list