diff options
| author | mryouse | 2022-05-10 02:07:40 +0000 |
|---|---|---|
| committer | mryouse | 2022-05-10 02:07:40 +0000 |
| commit | 7bed8de9b493ca2a2b13d6293db6bd81b73325ce (patch) | |
| tree | 7efa56cddb8a0cec4b4c03495874474b510c6a09 /repl.py | |
initial commit
Diffstat (limited to 'repl.py')
| -rw-r--r-- | repl.py | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -0,0 +1,24 @@ +from lexer import lex +from parser import parse +from runner import evaluate + +def main(): + idx = 1 + while True: + inp = input(f"#{idx}> ") + if len(inp.strip()) == 0: + continue + try: + lexed = lex(inp, []) + print(f" - LEX: {lexed}") + parsed = parse(lexed, []) + print(f" - PARSE: {parsed}") + ev = evaluate(parsed, []) + print(f"=> {ev}") + idx += 1 + except Exception as e: + print(f"panic! {e}") + + +if __name__ == "__main__": + main() |
