WIP, universal macro exception handler

This commit is contained in:
Justin Ethier 2020-07-23 12:10:24 -04:00
parent c37e8dfad9
commit 1670670968
2 changed files with 19 additions and 17 deletions

View file

@ -239,22 +239,21 @@
(let* ((found (assoc expr *source-loc-lis*))
(loc-vec (if found
(cdr found) ;; Get value
#f)))
(if loc-vec
(error
(string-append
"("
(vector-ref loc-vec 0)
" line "
(number->string (vector-ref loc-vec 1))
", column "
(number->string (vector-ref loc-vec 2))
") "
reason)
(if (pair? args) args expr))
(error
reason
(if (pair? args) args expr))))
#f))
(msg (if loc-vec
(string-append
"("
(vector-ref loc-vec 0)
" line "
(number->string (vector-ref loc-vec 1))
", column "
(number->string (vector-ref loc-vec 2))
") "
reason)
reason)))
(if (pair? args)
(apply error (cons msg args))
(error msg expr))))
;; Features implemented by this Scheme
(define (features)

View file

@ -829,6 +829,9 @@
;; Invoke ER macro
(set! result
(with-handler
(lambda (err)
(apply error/loc (append (list (car err) exp) (cdr err))) )
(cond
((not macro)
(error "macro not found" exp))
@ -844,7 +847,7 @@
(list 'quote exp)
(Cyc-er-rename use-env mac-env local-renamed)
(Cyc-er-compare? use-env rename-env))
mac-env))))
mac-env)))))
;(newline)
;(display "/* ")
;(write (list 'macro:expand exp macro compiled-macro?))