mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 07:39:25 +02:00
+ add method to retrieve an integer expression from the scanner
git-svn-id: trunk@47601 -
This commit is contained in:
parent
48271b880c
commit
a8d316d187
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user