https://github.com/in-line/calculator
Simple mathematical expression evaluator (aka calculator) built using Nom, Pratt Parser, LLVM, Cranelift and Relm.
https://github.com/in-line/calculator
Last synced: 11 months ago
JSON representation
Simple mathematical expression evaluator (aka calculator) built using Nom, Pratt Parser, LLVM, Cranelift and Relm.
- Host: GitHub
- URL: https://github.com/in-line/calculator
- Owner: In-line
- Created: 2019-11-25T12:31:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-25T12:39:42.000Z (over 6 years ago)
- Last Synced: 2025-04-07T15:54:42.996Z (about 1 year ago)
- Language: Rust
- Size: 35.2 KB
- Stars: 53
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Calculator
Simple mathematical expression evaluator (aka calculator) built using Nom, Pratt Parser, LLVM, Cranelift and Relm.
Every mathematical expression is parsed to lexical tokens using Nom. After initial parsing is complete, Pratt Parser algorithm is used to create AST (Abstract Syntax Tree) with right operator precedence.
There is simple interpreter implementation, which visits every AST node and computes result.
Alongside interpreter there is JIT compiler implementation with Cranelift and LLVM backends.
For end-user every mathematical expression is evaluated simultaneously by the interpreter and JIT compiler. JIT and Interpretator are racing to compute value first.
| Crate name | Description |
| ----------------- | ----------------------------------------------------------------- |
| calculator_engine | Implementation of expression parser and execution modules |
| calculator_cli | Simple CLI interface that reads input from command line arguments  |
| calculator_repl | REPL with built-in basic syntax highlighting  |
| calculator_gtk | Simple cross-platform GTK GUI  |