better behaviour
This commit is contained in:
20
:
Normal file
20
:
Normal file
@ -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()
|
||||||
4
repl.py
4
repl.py
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from rich import print
|
from rich import print
|
||||||
from ziffers import parse_expression
|
from ziffers import parse_expression
|
||||||
|
import readline
|
||||||
|
|
||||||
EXIT_CONDITION = ("exit", "quit", "")
|
EXIT_CONDITION = ("exit", "quit", "")
|
||||||
|
|
||||||
@ -12,8 +13,7 @@ if __name__ == "__main__":
|
|||||||
expr = input("> ")
|
expr = input("> ")
|
||||||
if expr not in EXIT_CONDITION:
|
if expr not in EXIT_CONDITION:
|
||||||
try:
|
try:
|
||||||
result = parse_expression(expr)
|
print(parse_expression(expr))
|
||||||
print(result)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[red]Failed:[/red] {e}")
|
print(f"[red]Failed:[/red] {e}")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user