...
Code Block |
---|
tree grammar MyGrammar; options { language=CSharp2; } @namespace { My.Custom.NameSpace.For.TreeParser } // rest of grammar follows .... |
{{@embers} Alternative
Instead using @members
in the grammar, the CSharp2
target also supports partial classes. This has the additional advantage of being able to use the favored editor for C#, as ANTLRworks doesn't support syntax highlighting for target languages.
Syntactic differences compared to grammars and the Java target
...
ANTLR | C# Syntax | Notes |
---|---|---|
text | Text |
|
start | Start | |
stop | Stop | |
tree | Tree | |
st | ST |
|
type | Type | |
line | Line | |
pos | CharPositionInLine | |
channel | Channel | |
$x.size() | $x.Count | size() is no grammar attribute, but still regularly used |
Known Issues
Another A problem, you may encounter while using the CSharp
target, is that value types are initialized with null (happens e.g. while using labels). The cause lies in the following definition of CSharp.stg:
...