+ add method to retrieve an integer expression from the scanner

git-svn-id: trunk@47601 -
This commit is contained in:
svenbarth 2020-11-26 20:13:34 +00:00
parent 48271b880c
commit a8d316d187

View File

@ -227,6 +227,7 @@ interface
procedure skipoldtpcomment(read_first_char:boolean);
procedure readtoken(allowrecordtoken:boolean);
function readpreproc:ttoken;
function readpreprocint(var value:int64;const place:string):boolean;
function asmgetchar:char;
end;
@ -276,7 +277,6 @@ interface
Function SetCompileModeSwitch(s:string; changeInit: boolean):boolean;
procedure SetAppType(NewAppType:tapptype);
implementation
uses
@ -963,6 +963,7 @@ type
function evaluate(v:texprvalue;op:ttoken):texprvalue;
procedure error(expecteddef, place: string);
function isBoolean: Boolean;
function isInt: Boolean;
function asBool: Boolean;
function asInt: Integer;
function asInt64: Int64;
@ -1403,6 +1404,11 @@ type
end;
end;
function texprvalue.isInt: Boolean;
begin
result:=is_integer(def);
end;
function texprvalue.asBool: Boolean;
begin
result:=value.valueord<>0;
@ -5753,6 +5759,25 @@ exit_label:
end;
function tscannerfile.readpreprocint(var value:int64;const place:string):boolean;
var
hs : texprvalue;
begin
hs:=preproc_comp_expr;
if hs.isInt then
begin
value:=hs.asInt64;
result:=true;
end
else
begin
hs.error('Integer',place);
result:=false;
end;
hs.free;
end;
function tscannerfile.asmgetchar : char;
begin
readchar;