dfintha / exprparser

Very basic expression parser written in C++.
0 stars 0 forks source link

exprparser

This is a study project about parsing mathematical expressions. The implementation consists of a state-machine-based tokenizer, a recursive descent parser, a simple peephole optimizer, and a recursive evaluator.

The demo application can be built with barge. It consists of parsing an expression entered by the user, and printing the token stream, the parsed expression tree, the optimized expression tree, and the result of the expression's evaluation to the standard output.

The software uses features of the C++17 standard, so when building in with another build system, such standard such be given.

exprparser supports the following "language features": numeric literals, boolean literals, variable identifiers, function calls, unary numeric operators (+, -), binary numeric operators (+, -, *, /, ^), and sub-expressions (( ... )). Boolean literals are parsed as numeric 1 or 0 expressions.