Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drkwitht/expreval
Parse and evaluate arithmetic expressions.
https://github.com/drkwitht/expreval
cpp math-expression-evaluator recursive-descent-parser
Last synced: 5 days 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 (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-09T19:47:28.000Z (10 months ago)
- Last Synced: 2024-03-10T18:47:44.897Z (10 months 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?