Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/refzlund/antlr4-ts-template
https://github.com/refzlund/antlr4-ts-template
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/refzlund/antlr4-ts-template
- Owner: Refzlund
- Created: 2022-10-16T20:14:38.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T08:37:22.000Z (over 1 year ago)
- Last Synced: 2024-11-09T15:49:10.076Z (2 months ago)
- Language: TypeScript
- Size: 220 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Antlr4 Typescript Template
Since `antlr4ts` doesn't work (at least for me) — I'm taking advantage of inferring the types generated by `antlr4` instead.
## Get Started
- Install **java** and **antlr4** ([Windows](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md#windows))
- Only 1. and 2. are required as `package.json` references antlr4; `java org.antlr.v4.Tool`
- Clone the project
- Install project `pnpm i`
- Generate **antlr4** files `pnpm gen`
- Run the development command `pnpm dev`### `pnpm dev`
It looks for
- folders matching `src/*.g4/`
- a grammar file `src/*.g4/.*g4`
- test input file(s) `src/*.g4/*.test`
- If file begins with period (`.`) it is ignored
- an entry-point for running antlr4 `src/*.g4/ts/index.ts`Outputs generated **antlr** files to `src/*.g4/antlr`
When ***test-input*** changes, it will rerun the ***entry-point*** function.
When `.g4` changes, it wiil generate **antlr4** and restart nodemon.
When `.js` or `.ts` changes within `src/*.g4/`, nodemon will rerun the application.## References
To develop and understand with `antlr4` better.- [GitHub Antlr4 Documentation](https://github.com/antlr/antlr4/blob/master/doc/index.md)
- [A Course for Antl4](https://youtu.be/2o9ImGNI1uw)
- [Talk - Alena Khineika: Writing compilers in JavaScript using ANTLR](https://youtu.be/-Gtsh9VlycI)
- [Very simple JS Example](https://github.com/svzdvd/antlr4-javascript-example)
- [More JS examples](https://github.com/maiermic/antlr4-javascript-examples)
- [Language Server Extension Guide](https://code.visualstudio.com/api/language-extensions/language-server-extension-guide)
- [Semantic Tokens Sample](https://github.com/microsoft/vscode-extension-samples/tree/main/semantic-tokens-sample)
### My IDE setup
![My IDE setup](./my-setup.jpg)