Racketize error reporting a little.
authorTony Garnock-Jones <tonygarnockjones@gmail.com>
Sun, 03 Jul 2011 18:42:34 -0400
changeset 34 ca269f5c30b3
parent 33 bec0f2436e38
child 35 5a234972f72a
Racketize error reporting a little.
ometa.scm
--- a/ometa.scm	Fri Dec 17 16:44:03 2010 -0500
+++ b/ometa.scm	Sun Jul 03 18:42:34 2011 -0400
@@ -54,7 +54,7 @@
    ((null? x) 3)
    ((pair? x) 4)
    ((eq? x #t) 5)
-   (else (error "Invalid parse-position" x))))
+   (else (error 'parse-position-type-index "Invalid parse-position ~v" x))))
 
 (define parse-position-type-predicates
   (vector (lambda (a b) #f)
@@ -159,7 +159,7 @@
 
 (define (->input-stream x)
   (or (->input-stream-or-false x)
-      (error "Could not construct input stream" x)))
+      (error '->input-stream "Could not construct input stream from ~v" x)))
 
 (define (input-stream-split-at-most input i k)
   (let loop ((acc '())
@@ -264,12 +264,12 @@
      ((symbol? exp)
       (cond
        ((assq exp env) => (lambda (entry) (k (cadr entry) (cddr entry))))
-       (else (error "Unbound variable" exp))))
+       (else (error 'interpret-ometa "Unbound variable ~v" exp))))
      ((pair? exp)
       (case (car exp)
 	((quote) (k #f (cadr exp)))
 	(else
-	 (error "Applications not supported in eval-host" exp))))
+	 (error 'interpret-ometa "Applications not supported in eval-host: ~v" exp))))
      (else (k #f exp))))
 
   (define (push-actuals args env tail)
@@ -482,7 +482,7 @@
 		    (lambda (sv) (ks sv env input #f))
 		    escape
 		    (nonshared-env-values env)))))
-      (else (error "Bad OMeta AST" exp))))
+      (else (error 'interpret-ometa "Bad OMeta AST: ~v" exp))))
 
   (e `(apply ,start) rules input
      ks
@@ -758,7 +758,7 @@
 				    (list "#" (if (memv #\' (string->list s))
 						  (q #\' s)
 						  s))))
-		    (else (error "Invalid literal in serialize-exp exactly" ev)))))
+		    (else (error 'serialize-ometa-ast "Invalid literal in (exactly): ~v" ev)))))
       ((sequence) (list "<{"(object->external-representation (cadr exp))"}>"))
       ((nest) (list "{"(serialize-exp (cadr exp))"}"))
       ((not) (list "~"(serialize-exp (cadr exp))))
@@ -771,7 +771,7 @@
       ((seq) (xi " " serialize-exp (cdr exp)))
       ((anything) "_")
       ((action) (list "->"(object->external-representation (cadr exp))))
-      (else (error "Bad AST in serialize" exp))))
+      (else (error 'serialize-ometa-ast "Bad AST in serialize: ~v" exp))))
   (define (serialize-production production)
     (list (car production)" =\n"
 	  (serialize-exp (cadr production))
@@ -828,7 +828,8 @@
 				 (grammar->env opt-ometa-unoptimised)
 				 (->input-stream opt-ometa-unoptimised)
 				 (lambda (sv new-env tail err) sv)
-				 (lambda (err) (error `(problem-optimising-optimiser ,err)))))))
+				 (lambda (err) (error 'opt-ometa
+						      "Problem optimising optimiser: ~v" err))))))
       cache)))
 (define (opt g)
   (interpret-ometa 'opt-grammar (grammar->env (opt-ometa)) (->input-stream g)