From 691a2e400d4ac37a5c874a70c9564b488bfab44e Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Wed, 8 Feb 2023 22:54:14 +0100 Subject: [PATCH 1/2] better behaviour --- : | 20 ++++++++++++++++++++ repl.py | 4 ++-- test.py | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 : create mode 100644 test.py 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)) From 0d9b1e54921396a2e8ba95ae870d49ab39781b8e Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Wed, 8 Feb 2023 22:55:18 +0100 Subject: [PATCH 2/2] fix --- : | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 : diff --git a/: b/: deleted file mode 100644 index 0235826..0000000 --- a/: +++ /dev/null @@ -1,20 +0,0 @@ -""" 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()