fix(parser): parse int literals as integers
avoid casting to float when the literal is an integer
This commit is contained in:
@@ -108,12 +108,15 @@ class MidasLexer(Lexer):
|
||||
while self.peek().isdigit():
|
||||
self.advance()
|
||||
|
||||
is_float: bool = False
|
||||
if self.peek() == "." and self.peek_next().isdigit():
|
||||
is_float = True
|
||||
self.advance()
|
||||
while self.peek().isdigit():
|
||||
self.advance()
|
||||
|
||||
value: float = float(self.source[self.start : self.idx])
|
||||
value_str: str = self.source[self.start : self.idx]
|
||||
value: int | float = float(value_str) if is_float else int(value_str)
|
||||
self.add_token(TokenType.NUMBER, value)
|
||||
|
||||
def scan_identifier(self):
|
||||
|
||||
Reference in New Issue
Block a user