1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
unit Parser;
interface
uses
System.Rtti,
System.Bindings.EvalProtocol,
System.Bindings.Evaluator,
System.Bindings.EvalSys,
System.SysUtils;
function CalcExpr(Expression : String) : Double; cdecl; export;
implementation
function CalcExpr(Expression : String) : Double;
Var
LScope : IScope;
LCompiledExpr : ICompiledBinding;
LResult : TValue;
begin
LScope:= BasicOperators;
LCompiledExpr:= Compile(Expression, LScope);
LResult:=LCompiledExpr.Evaluate(LScope, nil, nil).GetValue;
if not LResult.IsEmpty then Result:=LResult.AsExtended
else Result:=1;
end;
end. |
Partager