Provides support for evaluating arbitrary C-like artithmetic/string expressions like govaluate.
- Support basic math expression, example
"1 + 1 == 2". - Support variable in expression, example
"a + 1 == 2". - Support Accessors, example
"a.b == 1". - Support Functions in expression, example
"foo(a, b)".
-
Parse expression and get tokens.
- Parse expression.
- Check tokens syntax and check balance.
- Test parse tokens.
-
Build expression tree by tokens.
- Support baisc numeric add expression
1 + 49. - Design expression tree like evaluationStage.
- Test expression tree.
- Support baisc numeric add expression
-
Support basic math expression.
- Support
+-*/. - Support compare operator.
- If two operator have same prority, like
"1 + 101 % 2 * 5". Because2 * 5is in the right stage of operator%, so it will calculate2 * 5first. In this case, we will get wrong answer2rather than6. This issue can be fixed by reorderStages. - Support bit shift.
- Support
-
Support variable and accessors.
- Support
Eval(params),paramsis amaplikename: objectingvaluate. -
Basic data type ofUse json as base data type.paramsisint ,float, string. - Support simple field accessor using json.
- Object data of
paramsshould reloadoperator[]andoperatorforaccessand compare. Maybe we can accomplish it by define a base object or use template to support accessors.
- Support
-
Add benchmark for Cvaluate.
-
Performance enhancement.
-
Download this repository
git clone https://github.com/casbin-cpp/Cvaluate. -
Make a directory to complie
mkdir build && cd build. -
Prepare build file
cmake -DCMAKE_BUILD_TYPE=Release ... -
Build and install
make install.
void test_cvaluate() {
using namespace std;
string s = "1 + 2 > 1.3";
auto expression = Cvaluate::EvaluableExpression(s);
cout << expression.Evaluate({}) << endl; // output true
}