Skip to content

Commit 272d01c

Browse files
Update binop eval
1 parent 164b055 commit 272d01c

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

evalo/evalo.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,22 @@ def eval_stmto(stmt, env, value, previous_args=None):
6262

6363
def eval_expro(expr, env, value, previous_args=None):
6464
print('Evaluating expr {} to {} with env {}'.format(expr, value, env))
65-
current_args = (expr, env, value)
66-
#if not eval_to_stack(eval_expro, current_args):
67-
if previous_args == current_args:
68-
print('Failing on {}'.format(current_args))
69-
return fail
7065

7166
op = var('op')
7267
v1 = var('v1')
7368
v2 = var('v2')
7469
e1 = var('e1')
7570
e2 = var('e2')
76-
for y in current_args:
77-
if isinstance(y, ast.AST):
78-
print('Found AST value -> {}'.format(ast.dump(y)))
71+
if isinstance(expr, ast.AST):
72+
print('Found AST for expr -> {}'.format(ast.dump(expr)))
73+
if isinstance(value, ast.AST):
74+
print('Found AST for value -> {}'.format(ast.dump(value)))
7975
return conde(
8076
((eq, expr, ast.Num(n=value)),
8177
(membero, value, [0,1,2])),
8278
((eq, expr, ast.BinOp(left=e1, op=op, right=e2)), # Expressions
8379
(eq, op, ast.Add()),
84-
(eval_expro, e1, env, v1, current_args),
85-
(eval_expro, e2, env, v2, current_args),
86-
(typeo, v1, int),
87-
(typeo, v2, int),
80+
(eval_expro, e1, env, v1, None),
81+
(eval_expro, e2, env, v2, None),
8882
(add, v1, v2, value)),
8983
)

tests/test_expressions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def test_number_value_results_in_ast_number(self):
1919
ret = self.run_expr(var(), 1, eval_expr=True)
2020
self.assertIsInstance(ret[0], ast.Expr)
2121
self.assertIsInstance(vars(ret[0])['value'], ast.Num)
22+
self.assertEqual(len(ret), 2)
2223

2324
def test_ast_addition_results_in_var_integer(self):
2425
ret = self.run_expr(ast.Expr(value=ast.BinOp(left=ast.Num(n=1), op=ast.Add(), right=ast.Num(n=1))), var())

0 commit comments

Comments
 (0)