lexer: record each constant's representation in the token
This commit is contained in:
parent
907c800696
commit
c52e7ccaa3
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue