diff --git a/utils/wasmbin/parseutils.pas b/utils/wasmbin/parseutils.pas index 8e0860dc94..06494a292b 100644 --- a/utils/wasmbin/parseutils.pas +++ b/utils/wasmbin/parseutils.pas @@ -45,7 +45,11 @@ procedure ParseCSSValues(const s: String; css: TStrings); procedure GetCssAbsBoundsRect(Css: TStrings; var r: TRect); function CssValInt(const s: String; Def: integer): Integer; -function ScanNumberC(const buf: string; var idx: Integer; var numberText: string): Boolean; +type + TCNumberFormat = (nfError, nfInteger, nfHex, nfFloat); + +function ScanNumberC(const buf: string; var idx: Integer; + var numberText: string): TCNumberFormat; implementation @@ -233,11 +237,13 @@ begin Result:=Copy(s, i, index-i); end; -function ScanNumberC(const buf: string; var idx: Integer; var numberText: string): Boolean; +function ScanNumberC(const buf: string; var idx: Integer; var numberText: string): TCNumberFormat; var ch : char; + sec : string; begin - Result := false; + Result := nfError; + if buf[idx] in SignChars then begin ch:=buf[idx]; inc(idx); @@ -247,14 +253,23 @@ begin if (idx#0) then begin if (numberText = '') then Exit; numberText:=ch+numberText; end; - Result := true; end; end. diff --git a/utils/wasmbin/watscanner.pas b/utils/wasmbin/watscanner.pas index 6c04caeb95..32ad531bf0 100644 --- a/utils/wasmbin/watscanner.pas +++ b/utils/wasmbin/watscanner.pas @@ -24,6 +24,14 @@ type weElem, weData, weOffset ); + // used only for weNumber + TWatNumberFormat = ( + wnfNo, // other than number + wnfInteger, // 00 + wnfHex, // 0xABC + wnfFloat // 0.000 + ); + { TWatScanner } TWatScanner = class(TObject) @@ -37,6 +45,7 @@ type instrCode : byte; ofs : integer; token : TWatToken; + numformat : TWatNumberFormat; resText : string; asmCmd : string; @@ -200,7 +209,9 @@ function TWatScanner.Next: Boolean; var cmt : string; done: boolean; + fmt : TCNumberFormat; begin + numformat := wnfNo; Result := idx<=length(buf); if not Result then Exit; @@ -240,11 +251,19 @@ begin token:=weIdent; resText:=ScanWhile(buf, idx, IdBody); end else if buf[idx] in SignNumericChars then begin - if not ScanNumberC(buf, idx, resText) then begin + fmt := ScanNumberC(buf, idx, resText); + if fmt = nfError then begin token := weError; Exit; end else token:=weNumber; + case fmt of + nfFloat: numformat := wnfFloat; + nfHex: numformat := wnfHex; + else + numformat := wnfInteger; + end; + end else if buf[idx] in AlphaNumChars then begin resText:=ScanWhile(buf, idx, GrammarChars); GetGrammar(resText, token, instrCode);