[antlr-interest] ANTLR3 with C# generates code that does not compile

Johannes Luber jaluber at gmx.de
Wed Nov 28 14:36:14 PST 2007


Arto Viitanen wrote:
> I use Antlr3.Tool.exe to generate C# code from .g files. I started to
> use StreamTemplates, and following code
> fragment:
> 
...
> 
> Problem is, line "using Hashtable = System.Collections.Hashtable;" is
> twice, and at least the new Visual Studio 2008
> Express Edition does not like it. I guess the problem is, both
> "language=CSharp;" and "output=template;" generate
> the Hashtable -line.

Can you check if the newest daily build still generates the error? If
yes, can you please send me a minimum working grammar which I can use to
debug this (add tokens file and some rules to make the grammar valid)?
Do you use per chance backtracking (the options in your sample say
otherwise but you may have edited the snippet)?

> How can I drop the second line (other than editing the .cs file by hand
> :-( )

Other than using a fixed template file no chance. I encountered once a
similar error, so maybe the previous maintainer has fixed that line already.

Johannes


More information about the antlr-interest mailing list