mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 02:38:13 +02:00
codetools: started new expreval
git-svn-id: trunk@22745 -
This commit is contained in:
parent
2f775eda3a
commit
aa565ed7b4
@ -20,6 +20,7 @@
|
||||
The function Eval evaluates expressions and understands the operators
|
||||
AND, OR, XOR, NOT, (, ), =, <, >, <=, >=, <>
|
||||
defined()
|
||||
not defined V or undefined V
|
||||
}
|
||||
unit ExprEval;
|
||||
|
||||
@ -73,6 +74,7 @@ type
|
||||
function Equals(AnExpressionEvaluator: TExpressionEvaluator): boolean; reintroduce;
|
||||
procedure Assign(SourceExpressionEvaluator: TExpressionEvaluator);
|
||||
procedure AssignTo(SL: TStringList);
|
||||
function Eval2(const Expression: string):string;
|
||||
function Eval(const Expression: string):string;
|
||||
property ErrorPosition:integer read ErrorPos;
|
||||
property OnChange: TOnValuesChanged read FOnChange write FOnChange;
|
||||
@ -716,6 +718,54 @@ begin
|
||||
SL.Add(FNames[i]+'='+FValues[i]);
|
||||
end;
|
||||
|
||||
function TExpressionEvaluator.Eval2(const Expression: string): string;
|
||||
{ 1 = true
|
||||
0 = syntax error
|
||||
-1 = false
|
||||
|
||||
brackets ()
|
||||
unary operators: not, defined, undefined
|
||||
binary operators: < <= = <> => > and or xor shl shr
|
||||
functions: defined(), undefined(), declared()
|
||||
}
|
||||
{type
|
||||
TOperator = (
|
||||
opNone,
|
||||
opNot,
|
||||
opDefined,
|
||||
opUndefined,
|
||||
opDeclared,
|
||||
opLowerThan,
|
||||
opLowerOrEqual,
|
||||
opEqual,
|
||||
opNotEqual,
|
||||
opGreaterOrEqual,
|
||||
opGreaterThan,
|
||||
opAnd,
|
||||
opOr,
|
||||
opXor,
|
||||
opShl
|
||||
);
|
||||
TOperandAndOperator = record
|
||||
Operand: string;
|
||||
theOperator: PChar;
|
||||
OperatorLvl: integer;
|
||||
end;
|
||||
TExprStack = array[0..4] of TOperandAndOperator;
|
||||
|
||||
function EvalExpression(p: PChar): string;
|
||||
begin
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
var
|
||||
ExprStack: TExprStack;
|
||||
StackPtr: integer;}
|
||||
begin
|
||||
//if Expression='' then exit('0');
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function TExpressionEvaluator.AsString: string;
|
||||
var TxtLen, i, p: integer;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user