improve error message

This commit is contained in:
JOLIMAITRE Matthieu 2024-05-23 02:27:56 +02:00
parent 6e35db16ba
commit a49b14c12c
5 changed files with 127 additions and 19 deletions

View file

@ -7,6 +7,7 @@ import sys
sys.path.append(f"{dirname(__file__)}/../src")
from pyalibert import regex, Parser, just, Declare
from pyalibert.result import ParseError
# ast modeling
@ -79,9 +80,12 @@ def repl():
print("> ", end="")
sys.stdout.flush()
for line in sys.stdin:
result = parser.parse(line.strip())
print(result)
print(f"= {result.eval()}")
try:
result = parser.parse(line.strip())
print(result)
print(f"= {result.eval()}")
except ParseError as err:
print(err)
print("> ", end="")
sys.stdout.flush()