mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-10 09:28:21 +02:00
fixed expression evaluation
git-svn-id: trunk@4382 -
This commit is contained in:
parent
65d18dc437
commit
87f19981ac
@ -86,7 +86,8 @@ type
|
||||
implementation
|
||||
|
||||
var
|
||||
IsWordChar, IsNumberBeginChar, IsNumberChar:array[#0..#255] of boolean;
|
||||
IsWordChar, IsIdentifierChar, IsNumberBeginChar, IsNumberChar:
|
||||
array[#0..#255] of boolean;
|
||||
|
||||
procedure InternalInit;
|
||||
var c:char;
|
||||
@ -95,6 +96,7 @@ begin
|
||||
IsWordChar[c]:=(c in ['a'..'z','A'..'Z','_']);
|
||||
IsNumberBeginChar[c]:=(c in ['0'..'9','$','%']);
|
||||
IsNumberChar[c]:=(c in ['0'..'9','.','E','e']);
|
||||
IsIdentifierChar[c]:=(c in ['a'..'z','A'..'Z','_','0'..'9']);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -214,10 +216,13 @@ function TExpressionEvaluator.EvalAtPos: string;
|
||||
var r: string; // current result
|
||||
c,o1,o2: char;
|
||||
OldPos: integer;
|
||||
AtomCount: Integer;
|
||||
begin
|
||||
Result:='';
|
||||
AtomCount:=0;
|
||||
repeat
|
||||
if (not ReadNextAtom) then exit;
|
||||
inc(AtomCount);
|
||||
c:=Expr[AtomStart];
|
||||
if IsWordChar[c] then begin
|
||||
// identifier or keyword
|
||||
@ -236,7 +241,7 @@ begin
|
||||
Result:=EvalAtPos();
|
||||
if ErrorPos>=0 then exit;
|
||||
if (Result='') then ErrorPos:=CurPos;
|
||||
end else if (Result='') then ErrorPos:=CurPos;
|
||||
end else if (AtomCount<=1) then ErrorPos:=CurPos;
|
||||
exit;
|
||||
end else if (CompAtom('XOR')) then begin
|
||||
if (Result='') then begin
|
||||
@ -419,7 +424,7 @@ begin
|
||||
AtomStart:=CurPos;
|
||||
repeat
|
||||
inc(CurPos);
|
||||
until (CurPos>Max) or (IsWordChar[Expr[CurPos]]=false);
|
||||
until (CurPos>Max) or (not IsIdentifierChar[Expr[CurPos]]);
|
||||
AtomEnd:=CurPos;
|
||||
Result:=true;
|
||||
exit;
|
||||
|
@ -34,6 +34,9 @@ interface
|
||||
{$ASSERTIONS ON}
|
||||
{$endif}
|
||||
|
||||
{$IF VER1_0_8 or VER1_0_10}
|
||||
{$DEFINE UseFCLDataModule}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
Classes, Controls, LCLStrConsts, VCLGlobals, SysUtils, LCLType, LCLProc,
|
||||
@ -788,7 +791,7 @@ type
|
||||
function UniqueName(const BaseName: string): string; virtual; abstract;
|
||||
end;
|
||||
|
||||
{$IFNDEF VER1_0_8}
|
||||
{$IFNDEF UseFCLDataModule}
|
||||
type
|
||||
{ TDataModule }
|
||||
|
||||
@ -1141,7 +1144,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{$IFNDEF VER1_0_8}
|
||||
{$IFNDEF UseFCLDataModule}
|
||||
{ TDataModule }
|
||||
|
||||
constructor TDataModule.Create(TheOwner: TComponent);
|
||||
|
Loading…
Reference in New Issue
Block a user