diff --git a/: b/: new file mode 100644 index 0000000..0235826 --- /dev/null +++ b/: @@ -0,0 +1,20 @@ +""" Simple REPL for testing Ziffers notation """ +# pylint: disable=locally-disabled, redefined-builtin, broad-except + +from rich import print +from ziffers import parse_expression, zparse +import readline + +EXIT_CONDITION = ("exit", "quit", "") + +if __name__ == "__main__": + print("[purple]== ZIFFERS REPL ==[/purple]") + while True: + expr = input("> ") + if expr not in EXIT_CONDITION: + try: + print(parse_expression(expr)) + except Exception as e: + print(f"[red]Failed:[/red] {e}") + else: + exit() diff --git a/repl.py b/repl.py index b977f67..1d51a2d 100644 --- a/repl.py +++ b/repl.py @@ -3,6 +3,7 @@ from rich import print from ziffers import parse_expression +import readline EXIT_CONDITION = ("exit", "quit", "") @@ -12,8 +13,7 @@ if __name__ == "__main__": expr = input("> ") if expr not in EXIT_CONDITION: try: - result = parse_expression(expr) - print(result) + print(parse_expression(expr)) except Exception as e: print(f"[red]Failed:[/red] {e}") else: diff --git a/test.py b/test.py new file mode 100644 index 0000000..28f0a4f --- /dev/null +++ b/test.py @@ -0,0 +1,4 @@ +from ziffers import * +# a = z1("q e 1 ^ ^ 2 _ 3 4 <3> 3") +a = z1("1 2") +print(a.take(3))