Used:
Visual Studio - 2019
To install ANTLR I use - tunnelvisionlabs/antlr4cs // Github.com
I took the grammar here - antlr/grammars-v4 // Github.com
Grammar:
- CSharpLexer.g4;
- CSharpParser.g4;
- CSharpPreprocessorParser.g4;
I did:
1. Installed ANTLR;
2. Created a WinFrom application;
3. Added grammar;
Right-click the project or folder in Solution Explorer and selectAdd →Existing Element.
Question.
How to create Lexer/Parser?
The instructions say that additional classes should be created, but this does not happen.
Update 1.
I did:
1. I closed Visual Studio 2019;
2. I opened the project in Visual Studio 2017;
3. I deleted the files:
- CSharpLexer.g4;
- CSharpParser.g4;
- CSharpPreprocessorParser.g4;
4. I clicked "Add New Item";
5. I chose "ANTL 4 Lexer";
Note: there are no "ANTL" templates in "VS-2019".
6. I set the name to "CSharpLexer";
7. I clicked "Add";
8. Result:
- VS created a file - CSharpLexer.g4;
- VS created a file - CSharpLexer.g4.cs;
- VS for the file CSharpLexer.g4 set the property" Action at assembly "=" Antlr4 ".
Questions. Update-1.
1. Am I right?
2. Where can I get data to fill out the file CSharpLexer.g4?
Can I take data from the file CSharpLexer.g4, which is located at the link
https://github.com/antlr/grammars-v4/tree/master/csharp?
3. Do the files "CSharpParser.g4", "CSharpPreprocessorParser.g4" be created in the same way?
4. What template to use for the file - "CSharpPreprocessorParser.g4"?






CSharpLexer.g4,` CSharpParser.g4,CSharpPreprocessorParser.g4` from the link - [antlr / grammars-v4 // Github.com] (github.com/antlr/grammars-v4/tree/master/csharp) ** 2. ** Added to the projectRight-click the project or folder in Solution Explorer and select Add → Existing Element.** 3. ** PressedF6. Question. Am I doing the right thing? - eusataf