mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 06:39:12 +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
|
The function Eval evaluates expressions and understands the operators
|
||||||
AND, OR, XOR, NOT, (, ), =, <, >, <=, >=, <>
|
AND, OR, XOR, NOT, (, ), =, <, >, <=, >=, <>
|
||||||
defined()
|
defined()
|
||||||
|
not defined V or undefined V
|
||||||
}
|
}
|
||||||
unit ExprEval;
|
unit ExprEval;
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ type
|
|||||||
function Equals(AnExpressionEvaluator: TExpressionEvaluator): boolean; reintroduce;
|
function Equals(AnExpressionEvaluator: TExpressionEvaluator): boolean; reintroduce;
|
||||||
procedure Assign(SourceExpressionEvaluator: TExpressionEvaluator);
|
procedure Assign(SourceExpressionEvaluator: TExpressionEvaluator);
|
||||||
procedure AssignTo(SL: TStringList);
|
procedure AssignTo(SL: TStringList);
|
||||||
|
function Eval2(const Expression: string):string;
|
||||||
function Eval(const Expression: string):string;
|
function Eval(const Expression: string):string;
|
||||||
property ErrorPosition:integer read ErrorPos;
|
property ErrorPosition:integer read ErrorPos;
|
||||||
property OnChange: TOnValuesChanged read FOnChange write FOnChange;
|
property OnChange: TOnValuesChanged read FOnChange write FOnChange;
|
||||||
@ -716,6 +718,54 @@ begin
|
|||||||
SL.Add(FNames[i]+'='+FValues[i]);
|
SL.Add(FNames[i]+'='+FValues[i]);
|
||||||
end;
|
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;
|
function TExpressionEvaluator.AsString: string;
|
||||||
var TxtLen, i, p: integer;
|
var TxtLen, i, p: integer;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user