Hi Steve. When using a grammar in grammars-v4, please first check the instructions for testing:
https://github.com/antlr/grammars-v4/wiki#how-do-i-test-the-grammars. And, check the desc.xml (
https://github.com/antlr/grammars-v4/blob/master/javascript/typescript/desc.xml). The "<targets>" element indicates whether a port exists for the grammar. Fortunately, there is one for CSharp. Sometimes people save incomplete work, or the port does work, but it is impractical because it is too slow to test. For CSharp, ideally, you use the Antlr4BuildTasks package (
https://www.nuget.org/packages/Antlr4BuildTasks ;
https://github.com/kaby76/Antlr4BuildTasks?tab=readme-ov-file#new-approach ). That removes you from installing the prerequisites, e.g., downloading the Antrl Tool JAR, downloading and installing Java (you may have multiple installations), or manually working out the build dependencies. "About:
Grammars written for ANTLR v4; expectation that the grammars are free of actions." Grammars in the repo are free of semantics, except when the grammar is not context-free, i.e., ambiguous. In those cases, the grammar uses semantics strictly to disambiguate the CFG, implemented via Antlr4 actions written in a given target language, such as CSharp. These are implemented as "semantic predicates" and state-altering "actions" in the .g4. The Typescript grammar is one of those. That is why the base classes are required for the application.
If you have questions, you can ask on
https://github.com/antlr/grammars-v4/issues. --Ken