[antlr-interest] CSharp3 code generation suggestions

Ranco Marcus ranco.marcus at epirion.nl
Fri Aug 12 01:58:50 PDT 2011


Hi Sam,

I have a few rather small suggestions for the code generated by the CSharp3 target.

1. We used to have a namespace XXXX.Antlr in the same project as where our grammars are located. The compiler fails when it tries to resolve the generated grammar's base classes (Antlr.Runtime.___) and the included namespaces (using Antlr.___ ). Maybe you could make this explicit by prefixing those reference with global::.

2. The generated grammars are public by default. If the visibility modifier would be omitted from the partial class declaration, the grammar would be internal by default (something I usually prefer). In case somebody wants the grammar to be public, he/she only needs to add another partial class definition with a public modifier.

3. We are currently in the process of annotating our code with code contracts (see
http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx, separate assembly in .NET 3.5, included in the BCL in 4.0). The static checker (freely available for VS Premium or above) is able to check after compilation where contracts might be violated. Very cool stuff and maybe something to consider for the Antlr runtime.

These are only suggestions, as none of the above are show-stoppers.

Best regards,

Ranco



More information about the antlr-interest mailing list