File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ def match(self, next):
53
53
string_re = StringParser ()
54
54
kw_re = re .compile (r'(?:true|false|null)' )
55
55
expr_kw_re = re .compile (r'(?:true|false|null|undefined)' )
56
- NUMBER_RE = r"(?:(?:(?:\d*\.\d+) |(?:\d+\.?)) (?:e[+-]?\d+)?|(?:0x)?[0-9]+ )"
56
+ NUMBER_RE = r"0x[0-9a-f]+ |(?:\d+([.]\d*)? (?:e[+-]?\d+)?|[.]\d+ (?:e[+-]?\d+)? )"
57
57
tr_re = re .compile (r"(?:qsTr|qsTranslate|tr|)\(" )
58
58
number_re = re .compile (NUMBER_RE , re .IGNORECASE )
59
59
percent_number_re = re .compile (NUMBER_RE + r'%' , re .IGNORECASE )
@@ -680,7 +680,12 @@ def __read_json_value(self):
680
680
return value
681
681
value = self .maybe (number_re )
682
682
if value is not None :
683
- return value
683
+ if value .startswith ("0x" ):
684
+ return int (value [2 :], 16 )
685
+ elif "." in value or "e" in value or "E" in value :
686
+ return float (value )
687
+ else :
688
+ return int (value )
684
689
if self .maybe (tr_re ):
685
690
value = self .read (string_re , "Expect tr argument be a string" )
686
691
self .read (')' , "Expect ) after string in tr" )
You can’t perform that action at this time.
0 commit comments