Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Micheal Jordan

Contents

...

  1. Firstly, the old target named {{CSharp)) can retain it's compatibility with the .NET v1.1 platform. As such, it can't take advantage of C# v2 features in the code generation templates. The runtime will require twice the number of files, effectively doubling the amount of maintenance.
  2. Secondly, a certain bug fix requires a C# v2 feature or, a change to the templates for each occurence of the bug - and this has to be done by the user. The details of doing so are found in #Known Issues below.
  3. Thirdly, because maintaining the backwards compatibility sucks majorly, creating the new CSharp2 target allows the existing CSharp target to be deprecated without forcing people by abandoning .NET v1.1 compatibility immediately.

Introducing the new target allows me to change even the code generation templates. As working on further enhancements will at least break binary compatibility, most of the changes will be done for ANTLR v3.2. During the life-time of ANTLR v3.1, the public API of the C# target(s) will be frozen. If you wish to future-proof your grammar, change them to use the new CSharp2 target. It is planned to remove the original CSharp target The original CSharp target that used only C# v1 language features and .NET v1.1 is deprecated and the current plan is to remove it for the ANTLR v3.3 release.

...

To specify that the ANTLR tool should generate C# code (rather than the default of generating Java code) for a grammar, set the grammar-level option named language to the value CSharp2 (or CSharp for ANTLR 3.1+version v3.0.x) as shown below:

Code Block
grammar MyGrammar;

options
{
    language=CSharp2;
}

// rest of grammar follows
....

...

Note
titleANTLR v3.0.x users

For ANTLR version v3.0.x, please use the CSharp target as the CSharp2 target is only supported for ANTLR v3.1.x and later.

Specifying the namespace for your recognizer

...