diff options
| author | mryouse | 2022-05-12 01:58:05 +0000 |
|---|---|---|
| committer | mryouse | 2022-05-12 01:58:05 +0000 |
| commit | d75ab6f5ef14cab3c2ad3841258656e217d36043 (patch) | |
| tree | fdc1a44b17f5611168c4c7a28ed47f92a4ddaad0 /lexer.py | |
| parent | bb09a338814e1ab6e77451a0cedf61341a4d75c8 (diff) | |
refactor types using inheritance
Diffstat (limited to 'lexer.py')
| -rw-r--r-- | lexer.py | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -31,7 +31,7 @@ def lex_string(inp): elif c == DOUBLE_QUOTE: #return token, inp[idx + 1:] - return NebLiteral(NebType.STRING, token), inp[idx + 1:] + return NebString(token), inp[idx + 1:] else: token += c @@ -52,7 +52,7 @@ def lex_bool(inp): raise Exception("invalid boolean") #return token, inp[len(str(token)):] - return NebLiteral(NebType.BOOL, token), inp[len(str(token)):] + return NebBool(token), inp[len(str(token)):] def lex_number(inp): @@ -61,10 +61,10 @@ def lex_number(inp): if c in (" ", CLOSE_PAREN): if "." in token: #return float(token), inp[idx:] - return NebLiteral(NebType.FLOAT, float(token)), inp[idx:] + return NebFloat(float(token)), inp[idx:] else: #return int(token), inp[idx:] - return NebLiteral(NebType.INT, int(token)), inp[idx:] + return NebInt(int(token)), inp[idx:] if c in list(DIGITS): # or c in ("-", "."): token += c @@ -88,10 +88,10 @@ def lex_number(inp): if "." in token: #return float(token), "" - return NebLiteral(NebType.FLOAT, float(token)), "" + return NebFloat(float(token)), "" else: #return int(token), "" - return NebLiteral(NebType.INT, int(token)), "" + return NebInt(int(token)), "" def lex_symbol(inp): token = "" |
