A little maths expression engine, for the fun.
It's very simple to use.
Compiler compiler = new Compiler();
string code = "1 + 2(8/1.5)"
var result = compiler.Evaluate(code);
if(result.HasErrors){
//Some errors at Compile-time (Parser and Lexer) or Run-time
List<Error> errors = result.Errors;
}else{
//The result of the expression
double result = result.Value;
}
- This parser support a contextual execution. You can add and remove functions and properties, from other parsed maths-expression, from
C# assemblies
, or fromPython
code. Of course, you can create your own context system to supportJavaScript
code or whatever you want.
-
Basic operators :
+ - * / % ^
-
Unary operators :
+ -
-
Parentheses
-
Implicit
*
operator before(
-
Context evaluation :
-
Properties :
C# native
Expression-based
-
Functions :
C# native
Expression-based
Python
-
no more ideas for the moment...