[antlr-interest] Re: While using preliminary C# code generator.

micheal_jor open.zone at virgin.net
Wed Apr 24 04:24:55 PDT 2002


--- In antlr-interest at y..., "dinurp" <dinurp at y...> wrote:
> Hi,
> I am trying to use the new C# code generator. I faced a peculiar 
> problem while using it for tree construction. 
> 
> condition :
>     boolean_term ( OR! boolean_term )*
>     {
>         if ( null != ##.getNextSibling() )
>             ## = #(#[OR],##);
>     }
>     ;
> 
> OR token is defined in another grammer and the grammer from which 
the 
> above piece is extracted imports that grammer.
> 
> The code generated by the CSharp generator doen't recognize OR in #
> [OR]. This is because the symbol OR is not known to the Parser 
class. 
> It is defined in TokenTypes class. Now I can go ahead and re-write 
it 
> as #[TokenTypes.OR]. But is that the correct way? All the samples I 
> have seen, they are for Java or C++, use #[OR] construct.

For C#, you have to prefix the Tokens with the xxxTokenTypes class 
name. C# interfaces cannot contain constants like in Java and there 
is no support for global identifiers like in C++.

> For the time being I copied all definitions from TokenTypes to the 
> Parser class.
> 
> What are your suggestions?
> Thanks,

It's better to get used to using the "TokenTypes.OR" style. This is 
how things will be done with C#. Study the CSharp examples for more 
info....

Micheal



 

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



More information about the antlr-interest mailing list