A powerful logic expression evaluator built with ANTLR4 and TypeScript, allowing you to parse and evaluate logical expressions with ease.
- Parse logical expressions using ANTLR4 grammar
- TypeScript-based implementation for type safety
- Extensible grammar system
- Visitor pattern implementation
- Easy-to-use API
- Node.js (Latest LTS version recommended)
- npm (Node Package Manager)
- Basic understanding of ANTLR4 grammar
- Clone the repository:
git clone https://github.com/exitdump/antlr-ts-logic-evaluator.git
- Navigate to the project directory:
cd antlr-ts-logic-evaluator
- Install dependencies:
npm install
-
Add your grammar:
- Navigate to the
/grammar
directory - Create or modify
Logic.g4
file with your ANTLR4 grammar rules
- Navigate to the
-
Generate parser and lexer:
npx antlr4ts -visitor -o src/parser grammar/Logic.g4
- Run the sample:
npx ts-node src/index.ts
After setting up the project, you can use it to evaluate logical expressions based on your grammar rules. The project uses ANTLR4's visitor pattern for traversing the parse tree.
antlr-ts-logic-evaluator/
├── grammar/
│ └── Logic.g4 # ANTLR4 grammar file
├── src/
│ ├── parser/ # Generated parser files
│ └── index.ts # Main entry point
├── package.json
└── README.md
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Jahid Hasan
- Github: @exitdump
- ANTLR4 team for the amazing parser generator
- TypeScript team for the excellent type system
- All contributors and users of this project
For any questions or suggestions, please open an issue in the GitHub repository.