antlr4ts-adt
v0.0.4
Published
A simple calculator:
Downloads
1
Readme
Generate ADT Typescript files for ANTLR4 grammars from antlr4ts files.
Example
A simple calculator:
- ANTL4 Grammar: Calculator.g4
- Autogenerated ADT Typescript types: CalculatorAdt.ts
- AST eval example: calculator.ts
Demo using the example/
from sources:
$ git clone https://github.com/tokland/antlr4ts-adt
$ cd example
$ yarn install
$ npx antlr4ts Calculator.g4 -o antlr4 -visitor
$ npx antlr4ts-adt antlr4/CalculatorParser.ts
$ npx ts-node calculator.ts "1 + product(5 - 2, 2) + sum(1, 2, 2 + 1)"
# 13