Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hg0428 committed Apr 19, 2024
1 parent cbd9937 commit 6c09950
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
6 changes: 5 additions & 1 deletion Aardvark Compiler/Errors/ErrorFormatter.adk
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<main>", {
line: 2,
column: 16
Expand Down
13 changes: 9 additions & 4 deletions Aardvark Interpreter/Exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1043,9 +1046,11 @@ def notImplemented(errorhandler: "ErrorHandler", item, expr):


def findClosest(var: str, scope: Scope):
var = str(var)
lowest = 9999999999999999
ret = "<identifier>"
for item in list(scope.getAll().keys()):
item = str(item)
dist = edit_distance(var, item)
if dist < lowest:
ret = item
Expand Down
7 changes: 0 additions & 7 deletions Aardvark Interpreter/Parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions Aardvark Interpreter/Types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6c09950

Please sign in to comment.