Type fixes
parent
b5d97cf5c6
commit
ee744b5245
12
runner.py
12
runner.py
|
@ -10,10 +10,6 @@ from runstatus import ReduceStatus
|
|||
from runstatus import CommandStatus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Runner:
|
||||
def __init__(self):
|
||||
self.macro_table = {}
|
||||
|
@ -43,7 +39,7 @@ class Runner:
|
|||
i = 0
|
||||
macro_expansions = 0
|
||||
|
||||
while i < self.reduction_limit:
|
||||
while (self.reduction_limit is None) or (i < self.reduction_limit):
|
||||
r = expr.reduce(self.macro_table)
|
||||
expr = r.output
|
||||
|
||||
|
@ -64,7 +60,7 @@ class Runner:
|
|||
return ReduceStatus(
|
||||
reduction_count = i - macro_expansions,
|
||||
stop_reason = StopReason.MAX_EXCEEDED,
|
||||
result = r.output
|
||||
result = r.output # type: ignore
|
||||
)
|
||||
|
||||
|
||||
|
@ -89,9 +85,11 @@ class Runner:
|
|||
return self.exec_command(e.name)
|
||||
|
||||
# If this line is a plain expression, reduce it.
|
||||
else:
|
||||
elif isinstance(e, tokens.LambdaToken):
|
||||
e.bind_variables()
|
||||
return self.reduce_expression(e)
|
||||
else:
|
||||
raise TypeError(f"I don't know what to do with a {type(e)}")
|
||||
|
||||
|
||||
def run_lines(self, lines: list[str]):
|
||||
|
|
12
tokens.py
12
tokens.py
|
@ -302,9 +302,9 @@ class lambda_func(LambdaToken):
|
|||
|
||||
|
||||
# Bind variables inside this function.
|
||||
if isinstance(self.output, macro):
|
||||
if isinstance(self.output, macro) and placeholder is not None:
|
||||
if self.output == placeholder:
|
||||
self.output = val
|
||||
self.output = val # type: ignore
|
||||
elif isinstance(self.output, lambda_func):
|
||||
self.output.bind_variables(placeholder, val)
|
||||
elif isinstance(self.output, lambda_apply):
|
||||
|
@ -345,7 +345,7 @@ class lambda_func(LambdaToken):
|
|||
calling_self = False
|
||||
if bound_var is None:
|
||||
calling_self = True
|
||||
bound_var = self.input
|
||||
bound_var = self.input # type: ignore
|
||||
new_out = self.output
|
||||
if isinstance(self.output, bound_variable):
|
||||
if self.output == bound_var:
|
||||
|
@ -353,7 +353,7 @@ class lambda_func(LambdaToken):
|
|||
elif isinstance(self.output, lambda_func):
|
||||
new_out = self.output.apply(val, bound_var = bound_var)
|
||||
elif isinstance(self.output, lambda_apply):
|
||||
new_out = self.output.sub_bound_var(val, bound_var = bound_var)
|
||||
new_out = self.output.sub_bound_var(val, bound_var = bound_var) # type: ignore
|
||||
|
||||
# If we're applying THIS function,
|
||||
# just give the output
|
||||
|
@ -430,7 +430,7 @@ class lambda_apply(LambdaToken):
|
|||
# everything below should still work as expected.
|
||||
if isinstance(self.fn, macro) and placeholder is not None:
|
||||
if self.fn == placeholder:
|
||||
self.fn = val
|
||||
self.fn = val # type: ignore
|
||||
elif isinstance(self.fn, lambda_func):
|
||||
self.fn.bind_variables(placeholder, val)
|
||||
elif isinstance(self.fn, lambda_apply):
|
||||
|
@ -438,7 +438,7 @@ class lambda_apply(LambdaToken):
|
|||
|
||||
if isinstance(self.arg, macro) and placeholder is not None:
|
||||
if self.arg == placeholder:
|
||||
self.arg = val
|
||||
self.arg = val # type: ignore
|
||||
elif isinstance(self.arg, lambda_func):
|
||||
self.arg.bind_variables(placeholder, val)
|
||||
elif isinstance(self.arg, lambda_apply):
|
||||
|
|
Reference in New Issue