syntax highlighting for csharp language target doc
This commit is contained in:
parent
837aa60e2c
commit
be993de7d9
|
@ -215,3 +215,4 @@ YYYY/MM/DD, github id, Full name, email
|
||||||
2019/02/06, ralucado, Cristina Raluca Vijulie, ralucris.v[at]gmail[dot]com
|
2019/02/06, ralucado, Cristina Raluca Vijulie, ralucris.v[at]gmail[dot]com
|
||||||
2019/03/13, base698, Justin Thomas, justin.thomas1@gmail.com
|
2019/03/13, base698, Justin Thomas, justin.thomas1@gmail.com
|
||||||
2019/03/18, carlodri, Carlo Dri, carlo.dri@gmail.com
|
2019/03/18, carlodri, Carlo Dri, carlo.dri@gmail.com
|
||||||
|
2019/05/02, askingalot, Andy Collins, askingalot@gmail.com
|
||||||
|
|
|
@ -30,7 +30,7 @@ Let's suppose that your grammar is named `MyGrammar`. The tool will generate for
|
||||||
|
|
||||||
Now a fully functioning code might look like the following for start rule `StartRule`:
|
Now a fully functioning code might look like the following for start rule `StartRule`:
|
||||||
|
|
||||||
```
|
```csharp
|
||||||
using Antlr4.Runtime;
|
using Antlr4.Runtime;
|
||||||
using Antlr4.Runtime.Tree;
|
using Antlr4.Runtime.Tree;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ Let's suppose your MyGrammar grammar comprises 2 rules: "key" and "value".
|
||||||
|
|
||||||
The antlr4 tool will have generated the following listener (only partial code shown here):
|
The antlr4 tool will have generated the following listener (only partial code shown here):
|
||||||
|
|
||||||
```
|
```csharp
|
||||||
interface IMyGrammarParserListener : IParseTreeListener {
|
interface IMyGrammarParserListener : IParseTreeListener {
|
||||||
void EnterKey (MyGrammarParser.KeyContext context);
|
void EnterKey (MyGrammarParser.KeyContext context);
|
||||||
void ExitKey (MyGrammarParser.KeyContext context);
|
void ExitKey (MyGrammarParser.KeyContext context);
|
||||||
|
@ -70,7 +70,7 @@ interface IMyGrammarParserListener : IParseTreeListener {
|
||||||
|
|
||||||
In order to provide custom behavior, you might want to create the following class:
|
In order to provide custom behavior, you might want to create the following class:
|
||||||
|
|
||||||
```
|
```csharp
|
||||||
class KeyPrinter : MyGrammarBaseListener {
|
class KeyPrinter : MyGrammarBaseListener {
|
||||||
// override default listener behavior
|
// override default listener behavior
|
||||||
void ExitKey (MyGrammarParser.KeyContext context) {
|
void ExitKey (MyGrammarParser.KeyContext context) {
|
||||||
|
@ -82,7 +82,7 @@ class KeyPrinter : MyGrammarBaseListener {
|
||||||
In order to execute this listener, you would simply add the following lines to the above code:
|
In order to execute this listener, you would simply add the following lines to the above code:
|
||||||
|
|
||||||
|
|
||||||
```
|
```csharp
|
||||||
...
|
...
|
||||||
IParseTree tree = parser.StartRule() - only repeated here for reference
|
IParseTree tree = parser.StartRule() - only repeated here for reference
|
||||||
KeyPrinter printer = new KeyPrinter();
|
KeyPrinter printer = new KeyPrinter();
|
||||||
|
|
Loading…
Reference in New Issue