From 6c099502790e999bf4e39bd106a885b3a3367997 Mon Sep 17 00:00:00 2001 From: Hudson Gouge Date: Thu, 18 Apr 2024 20:24:11 -0400 Subject: [PATCH] Bug fix --- Aardvark Compiler/Errors/ErrorFormatter.adk | 6 +++++- Aardvark Interpreter/Exec.py | 13 +++++++++---- Aardvark Interpreter/Parser.py | 7 ------- Aardvark Interpreter/Types.py | 10 +++++----- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Aardvark Compiler/Errors/ErrorFormatter.adk b/Aardvark Compiler/Errors/ErrorFormatter.adk index 6c79421..d1c6410 100644 --- a/Aardvark Compiler/Errors/ErrorFormatter.adk +++ b/Aardvark Compiler/Errors/ErrorFormatter.adk @@ -94,7 +94,11 @@ function format(source_lines, message, error_type, filename, location, markers) } if is_main { include Highlight from SyntaxHighlighter - let code = Highlight("\n\n\n\n\n\n\n\n\n\nlet my_number = 1234\nlet my_string = 'string'\nstdout.write(my_number + my_string, '\\n')", {linenums: false}) + from Lexer include Lexer + let code = "\n\n\n\n\n\n\n\n\n\nlet my_number = 1234\nlet my_string = 'string'\nstdout.write(my_number + my_string, '\\n')" + let lexer = Lexer(false, true, null) + let tokens = lexer.tokenize(code) + let code = Highlight(code, tokens, {linenums: false}) stderr.write(format(code.split("\n"), "'+' is undefined for types 'Number' and 'String'", "TypeError", "
", { line: 2, column: 16 diff --git a/Aardvark Interpreter/Exec.py b/Aardvark Interpreter/Exec.py index 2662c5f..bc33cd3 100644 --- a/Aardvark Interpreter/Exec.py +++ b/Aardvark Interpreter/Exec.py @@ -349,10 +349,13 @@ def x(*args, **kwargs): # if param["value_type"] != None: # notImplemented(self.errorhandler, "Type Checking", param) functscope.vars[param["name"]] = arg - if self.is_strict or param.get("is_static", False): - functscope.vars[param["name"]].is_static = True - else: - functscope.vars[param["name"]].is_static = False + try: + if self.is_strict or param.get("is_static", False): + functscope.vars[param["name"]].is_static = True + else: + functscope.vars[param["name"]].is_static = False + except: + pass ret = self.Exec(code, functscope) if is_macro: return ret @@ -1043,9 +1046,11 @@ def notImplemented(errorhandler: "ErrorHandler", item, expr): def findClosest(var: str, scope: Scope): + var = str(var) lowest = 9999999999999999 ret = "" for item in list(scope.getAll().keys()): + item = str(item) dist = edit_distance(var, item) if dist < lowest: ret = item diff --git a/Aardvark Interpreter/Parser.py b/Aardvark Interpreter/Parser.py index 91fe406..e7fb0b7 100644 --- a/Aardvark Interpreter/Parser.py +++ b/Aardvark Interpreter/Parser.py @@ -1151,13 +1151,6 @@ def pIfStatement(self, inline=False): condition = self.pExpression(require=True) body = None lasti = condition["positions"]["end"] - print( - "HERE", - condition["type"], - self.peek(), - self.compare("Delimiter", "{"), - inline, - ) if self.compare("Delimiter", "{") and not inline: body, lasti = self.eatBlockScope() elif not inline: diff --git a/Aardvark Interpreter/Types.py b/Aardvark Interpreter/Types.py index 7c9ce64..7df2c31 100644 --- a/Aardvark Interpreter/Types.py +++ b/Aardvark Interpreter/Types.py @@ -387,11 +387,11 @@ def __init__( self.value = value float.__init__(self) self.vars = { - # "digits": ( - # [int(x) if x in "0123456789" else x for x in str(value)] - # if len(str(value)) > 1 - # else [value] - # ), + "digits": ( + [int(x) if x in "0123456789" else x for x in str(value)] + if len(str(value)) > 1 + else [value] + ), # methods and attributes here } # try: