mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 06:49:27 +02:00
[PATCH 088/188] parsing integer with signs
From ed31376d1470b61911a44bc45f9f7d68e9c2b27e Mon Sep 17 00:00:00 2001 From: Dmitry Boyarintsev <skalogryz.lists@gmail.com> Date: Tue, 10 Mar 2020 08:45:05 -0400 git-svn-id: branches/wasm@46084 -
This commit is contained in:
parent
17942aa4ae
commit
11d77e330b
@ -17,6 +17,8 @@ const
|
||||
WhiteSpaceChars = SpaceChars;
|
||||
SpaceEolnChars = EoLnChars+SpaceChars;
|
||||
NumericChars = ['0'..'9'];
|
||||
SignChars = ['+','-'];
|
||||
SignNumericChars = NumericChars + SignChars;
|
||||
AlphabetChars = ['a'..'z','A'..'Z'];
|
||||
AlphaNumChars = AlphabetChars+NumericChars;
|
||||
|
||||
|
@ -201,6 +201,7 @@ var
|
||||
has2chars: Boolean;
|
||||
cmt : string;
|
||||
done: boolean;
|
||||
ch : char;
|
||||
begin
|
||||
Result := idx<=length(buf);
|
||||
if not Result then Exit;
|
||||
@ -240,9 +241,20 @@ begin
|
||||
end else if buf[idx] = IdStart then begin
|
||||
token:=weIdent;
|
||||
resText:=ScanWhile(buf, idx, IdBody);
|
||||
end else if buf[idx] in NumericChars then begin
|
||||
end else if buf[idx] in SignNumericChars then begin
|
||||
token:=weNumber;
|
||||
resText:=ScanWhile(buf, idx, NumericChars);
|
||||
if buf[idx] in SignChars then begin
|
||||
ch:=buf[idx];
|
||||
inc(idx);
|
||||
resText:=ScanWhile(buf, idx, NumericChars);
|
||||
if resText = '' then begin
|
||||
token:=weError;
|
||||
Exit;
|
||||
end;
|
||||
if (ch='-') then
|
||||
resText:=ch+resText;
|
||||
end else
|
||||
resText:=ScanWhile(buf, idx, Numericchars);
|
||||
end else if buf[idx] in AlphaNumChars then begin
|
||||
resText:=ScanWhile(buf, idx, GrammarChars);
|
||||
GetGrammar(resText, token, instrCode);
|
||||
|
Loading…
Reference in New Issue
Block a user