improve error message
This commit is contained in:
parent
6e35db16ba
commit
a49b14c12c
5 changed files with 127 additions and 19 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue