lexer: record each constant's representation in the token

This commit is contained in:
Lephe 2019-10-17 10:33:30 +02:00
parent 907c800696
commit c52e7ccaa3
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 5 additions and 3 deletions

View File

@ -85,7 +85,9 @@ class Token:
except ValueError:
base = "<Token:{}>".format(hex(self.type))
if self.args:
if self.type == T.CONST:
args = "({}) [typed as {}]".format(*self.args)
elif self.args:
args = "(" + ",".join(repr(arg) for arg in self.args) + ")"
else:
args = ""
@ -221,7 +223,7 @@ class BitcodeLexer(LexerBase):
self.pos += len(m[0]) - 1
f = str2float(integer, decimal, exp, percent)
return Token(T.CONST, f)
return Token(T.CONST, f, m[0])
# Variables
if code in range(0x42, 0x47+1):
@ -410,7 +412,7 @@ class TextLexer(LexerBase):
self.code = c[len(m[0]):]
self.pending_param = True
return Token(T.CONST, f)
return Token(T.CONST, f, m[0])
# Functions
m = re.match(self.RE_FUN, c)