https://github.com/drkwitht/expreval
Parse and evaluate arithmetic expressions.
https://github.com/drkwitht/expreval
cpp math-expression-evaluator recursive-descent-parser
Last synced: about 1 year ago
JSON representation
Parse and evaluate arithmetic expressions.
- Host: GitHub
- URL: https://github.com/drkwitht/expreval
- Owner: DrkWithT
- Created: 2024-02-25T06:43:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-09T19:47:28.000Z (over 2 years ago)
- Last Synced: 2025-02-09T23:30:02.595Z (over 1 year ago)
- Topics: cpp, math-expression-evaluator, recursive-descent-parser
- Language: C++
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# README: Math Expr Evaluator
### Brief:
An arithmetic expression evaluator written in C++. It uses a recursive descent parser & AST approach for basic syntax checking and later support for additional syntax if needed.
### Grammar:
```bnf
; Some tokens!
whitespace ::= (SP | TAB | CR | LF)+
number ::= (DIGIT | ".")+
operators ::= "+" | "-" | "*" | "/"
; Note: Start parsing from lower precedence and descend to tighter binding precedence rule if needed!
expr ::= term
term ::= factor (("+" | "-") factor)*
factor ::= power (("*" | "/") power)*
power ::= unary ("^" unary)*
unary ::= ?("-") number | "(" expr ")"
```
### Some extras:
- ~~I must add parenthesis support soon.~~ **DONE**
- ~~Add a REPL for expressions?~~ **DONE**
- Make error messages more detailed?