Fix parsing decimals

A number literal is a float if it contains ".", not if it is divisible
by 1. For example, 1.0 should be considered a float literal.
This commit is contained in:
James Westman 2023-06-14 15:22:57 -05:00
parent c69a12096c
commit 883a136103
8 changed files with 24 additions and 6 deletions

View file

@ -70,8 +70,10 @@ class Token:
try:
if string.startswith("0x"):
return int(string, 16)
else:
elif "." in string:
return float(string)
else:
return int(string)
except:
raise CompileError(
f"{str(self)} is not a valid number literal", self.start, self.end