Browse Source

[PATCH 093/188] update number parsing

From 3a04c920a0e521c9be7f61e5fc2d7f6725ade511 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Tue, 10 Mar 2020 09:07:24 -0400

git-svn-id: branches/wasm@46089 -
nickysn 5 years ago
parent
commit
5f20c9b269
1 changed files with 4 additions and 14 deletions
  1. 4 14
      utils/wasmbin/watscanner.pas

+ 4 - 14
utils/wasmbin/watscanner.pas

@@ -198,10 +198,8 @@ end;
 
 function TWatScanner.Next: Boolean;
 var
-  has2chars: Boolean;
   cmt : string;
   done: boolean;
-  ch  : char;
 begin
   Result := idx<=length(buf);
   if not Result then Exit;
@@ -242,19 +240,11 @@ begin
         token:=weIdent;
         resText:=ScanWhile(buf, idx, IdBody);
       end else if buf[idx] in SignNumericChars then begin
-        token:=weNumber;
-        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;
+        if not ScanNumberC(buf, idx, resText) then begin
+          token := weError;
+          Exit;
         end else
-          resText:=ScanWhile(buf, idx, Numericchars);
+          token:=weNumber;
       end else if buf[idx] in AlphaNumChars then begin
         resText:=ScanWhile(buf, idx, GrammarChars);
         GetGrammar(resText, token, instrCode);