Merge pull request #2542 from askingalot/csharp-target-syntax-highlighting

syntax highlighting for csharp language target doc
This commit is contained in:
Terence Parr 2019-05-03 09:09:47 -07:00 committed by GitHub
commit 7c334b114c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -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/03/13, base698, Justin Thomas, justin.thomas1@gmail.com
2019/03/18, carlodri, Carlo Dri, carlo.dri@gmail.com
2019/05/02, askingalot, Andy Collins, askingalot@gmail.com

View File

@ -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`:
```
```csharp
using Antlr4.Runtime;
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):
```
```csharp
interface IMyGrammarParserListener : IParseTreeListener {
void EnterKey (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:
```
```csharp
class KeyPrinter : MyGrammarBaseListener {
// override default listener behavior
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:
```
```csharp
...
IParseTree tree = parser.StartRule() - only repeated here for reference
KeyPrinter printer = new KeyPrinter();