fixed expression evaluation

git-svn-id: trunk@4382 -
This commit is contained in:
mattias 2003-07-07 20:02:08 +00:00
parent 65d18dc437
commit 87f19981ac
2 changed files with 13 additions and 5 deletions

View File

@ -86,7 +86,8 @@ type
implementation implementation
var var
IsWordChar, IsNumberBeginChar, IsNumberChar:array[#0..#255] of boolean; IsWordChar, IsIdentifierChar, IsNumberBeginChar, IsNumberChar:
array[#0..#255] of boolean;
procedure InternalInit; procedure InternalInit;
var c:char; var c:char;
@ -95,6 +96,7 @@ begin
IsWordChar[c]:=(c in ['a'..'z','A'..'Z','_']); IsWordChar[c]:=(c in ['a'..'z','A'..'Z','_']);
IsNumberBeginChar[c]:=(c in ['0'..'9','$','%']); IsNumberBeginChar[c]:=(c in ['0'..'9','$','%']);
IsNumberChar[c]:=(c in ['0'..'9','.','E','e']); IsNumberChar[c]:=(c in ['0'..'9','.','E','e']);
IsIdentifierChar[c]:=(c in ['a'..'z','A'..'Z','_','0'..'9']);
end; end;
end; end;
@ -214,10 +216,13 @@ function TExpressionEvaluator.EvalAtPos: string;
var r: string; // current result var r: string; // current result
c,o1,o2: char; c,o1,o2: char;
OldPos: integer; OldPos: integer;
AtomCount: Integer;
begin begin
Result:=''; Result:='';
AtomCount:=0;
repeat repeat
if (not ReadNextAtom) then exit; if (not ReadNextAtom) then exit;
inc(AtomCount);
c:=Expr[AtomStart]; c:=Expr[AtomStart];
if IsWordChar[c] then begin if IsWordChar[c] then begin
// identifier or keyword // identifier or keyword
@ -236,7 +241,7 @@ begin
Result:=EvalAtPos(); Result:=EvalAtPos();
if ErrorPos>=0 then exit; if ErrorPos>=0 then exit;
if (Result='') then ErrorPos:=CurPos; if (Result='') then ErrorPos:=CurPos;
end else if (Result='') then ErrorPos:=CurPos; end else if (AtomCount<=1) then ErrorPos:=CurPos;
exit; exit;
end else if (CompAtom('XOR')) then begin end else if (CompAtom('XOR')) then begin
if (Result='') then begin if (Result='') then begin
@ -419,7 +424,7 @@ begin
AtomStart:=CurPos; AtomStart:=CurPos;
repeat repeat
inc(CurPos); inc(CurPos);
until (CurPos>Max) or (IsWordChar[Expr[CurPos]]=false); until (CurPos>Max) or (not IsIdentifierChar[Expr[CurPos]]);
AtomEnd:=CurPos; AtomEnd:=CurPos;
Result:=true; Result:=true;
exit; exit;

View File

@ -34,6 +34,9 @@ interface
{$ASSERTIONS ON} {$ASSERTIONS ON}
{$endif} {$endif}
{$IF VER1_0_8 or VER1_0_10}
{$DEFINE UseFCLDataModule}
{$ENDIF}
uses uses
Classes, Controls, LCLStrConsts, VCLGlobals, SysUtils, LCLType, LCLProc, Classes, Controls, LCLStrConsts, VCLGlobals, SysUtils, LCLType, LCLProc,
@ -788,7 +791,7 @@ type
function UniqueName(const BaseName: string): string; virtual; abstract; function UniqueName(const BaseName: string): string; virtual; abstract;
end; end;
{$IFNDEF VER1_0_8} {$IFNDEF UseFCLDataModule}
type type
{ TDataModule } { TDataModule }
@ -1141,7 +1144,7 @@ begin
end; end;
{$IFNDEF VER1_0_8} {$IFNDEF UseFCLDataModule}
{ TDataModule } { TDataModule }
constructor TDataModule.Create(TheOwner: TComponent); constructor TDataModule.Create(TheOwner: TComponent);