refactor for error handling

This commit is contained in:
Rutger van Beusekom 2016-09-20 13:04:31 +02:00
parent ad4098e4a4
commit 72397d937e
1 changed files with 5 additions and 4 deletions

View File

@ -83,11 +83,12 @@
ws < sp / nl
")
(let ((match (match-pattern script input)))
(let* ((match (match-pattern script input))
(tree (peg:tree match)))
(if (not (eq? (string-length input) (peg:end match)))
(let ((tree (peg:tree match)))
(pretty-print (peg:tree match))
(begin
(pretty-print tree)
(pretty-print "parse error" (current-error-port))
(pretty-print (peg:end match))
#f)
(peg:tree match))))
tree)))