From c52e7ccaa3d00fa590d34d3184f41a62dea201dd Mon Sep 17 00:00:00 2001 From: Lephe Date: Thu, 17 Oct 2019 10:33:30 +0200 Subject: [PATCH] lexer: record each constant's representation in the token --- fx92/lexer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fx92/lexer.py b/fx92/lexer.py index 409f7d6..2738749 100644 --- a/fx92/lexer.py +++ b/fx92/lexer.py @@ -85,7 +85,9 @@ class Token: except ValueError: base = "".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)