diff options
| author | mryouse | 2022-05-11 03:22:13 +0000 |
|---|---|---|
| committer | mryouse | 2022-05-11 03:22:13 +0000 |
| commit | 9a9f38aa564e0e15726d5b5dadb4098dde7cb0bb (patch) | |
| tree | 2b3c7ad9fb4b0190dc1de4161b232e30d307e308 /runner.py | |
| parent | 93d9ed5115cd32d14d7b0f4ccc672eaf6060ab05 (diff) | |
basic flow control!
Diffstat (limited to 'runner.py')
| -rw-r--r-- | runner.py | 21 |
1 files changed, 1 insertions, 20 deletions
@@ -1,5 +1,5 @@ from tokens import * -from std import STD +from std import STD, evaluate_expression def peek(inp): @@ -7,25 +7,6 @@ def peek(inp): return None return inp[0] -def evaluate_expression(expr): - if not expr.symbol.name in STD: - raise Exception(f"no such symbol: {expr.symbol.name}") - this_func = STD[expr.symbol.name] - - # try to match the signature - in_sig = expr.in_sig() - if in_sig in this_func: - ret = this_func[expr.in_sig()].impl(*(expr.args)) - return ret - - # evaluate inner expressions, if possible/necessary - for idx, arg in enumerate(expr.args): - if arg.type_ == NebType.EXPR: - expr.args[idx] = evaluate_expression(arg) - return evaluate_expression(expr) - - raise Exception(f"'{expr.symbol.name}' called with unknown signature: '{expr.in_sig()}'") - def evaluate(items, pop): nxt = peek(items) if nxt is None: |
