Improve relevance of error reporting by avoiding supplying error reports for
authorTony Garnock-Jones <tonyg@kcbbs.gen.nz>
Sun, 18 Jan 2009 00:24:08 +0000
changeset 30 af04a16148de
parent 29 7b6adad58777
child 31 dd9850e5e4fc
Improve relevance of error reporting by avoiding supplying error reports for
"normal" kinds of failed parse. This way, user code has better control over
which errors are to be propagated out to the caller.
ometa.scm
--- a/ometa.scm	Sun Jan 18 00:22:47 2009 +0000
+++ b/ometa.scm	Sun Jan 18 00:24:08 2009 +0000
@@ -413,7 +413,7 @@
       ((not)
        (e (cadr exp) env input
 	  (lambda (sv new-env next err)
-	    (kf (make-parse-error (input-stream-position input) `(failed-no-follow ,(cadr exp)))))
+	    (kf (make-parse-error (input-stream-position input) `(unexpected ,(cadr exp)))))
 	  (lambda (err)
 	    (ks #t env input #f))))
       ((follow)
@@ -454,7 +454,7 @@
 		    (merge-failure prev-err kf))))))
       ((anything)
        (input (lambda (pos item tail) (ks item env tail #f))
-	      (lambda (pos) (kf (make-parse-error pos 'end-of-stream)))))
+	      (lambda (pos) (kf #f))))
       ((action)
        (let* ((names (nonshared-env-names env))
 	      (probe (cons (cadr exp) names))
@@ -470,7 +470,9 @@
 					 (set-escaped! error-report)))
 			  #f))))
 	 (if escaped
-	     (kf (make-parse-error (input-stream-position input) escaped))
+	     (kf (if (null? escaped)
+		     #f
+		     (make-parse-error (input-stream-position input) escaped)))
 	     (apply fn
 		    (lambda (sv) (ks sv env input #f))
 		    escape
@@ -540,7 +542,7 @@
 	       (seq (apply token "->") (bind r (apply host-language-expression))
 		    (action `(action ,r)))
 	       (seq (apply token "?") (bind r (apply host-language-expression))
-		    (action `(action (or ,r (error 'expected ',r)))))
+		    (action `(action (or ,r (error)))))
 	       (seq (bind x (apply literal))
 		    (action `(exactly ,x)))
 	       (seq (apply token "_") (action `(anything)))