mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 17:27:33 +02:00
WIP, universal macro exception handler
This commit is contained in:
parent
c37e8dfad9
commit
1670670968
2 changed files with 19 additions and 17 deletions
|
@ -239,9 +239,8 @@
|
||||||
(let* ((found (assoc expr *source-loc-lis*))
|
(let* ((found (assoc expr *source-loc-lis*))
|
||||||
(loc-vec (if found
|
(loc-vec (if found
|
||||||
(cdr found) ;; Get value
|
(cdr found) ;; Get value
|
||||||
#f)))
|
#f))
|
||||||
(if loc-vec
|
(msg (if loc-vec
|
||||||
(error
|
|
||||||
(string-append
|
(string-append
|
||||||
"("
|
"("
|
||||||
(vector-ref loc-vec 0)
|
(vector-ref loc-vec 0)
|
||||||
|
@ -251,10 +250,10 @@
|
||||||
(number->string (vector-ref loc-vec 2))
|
(number->string (vector-ref loc-vec 2))
|
||||||
") "
|
") "
|
||||||
reason)
|
reason)
|
||||||
(if (pair? args) args expr))
|
reason)))
|
||||||
(error
|
(if (pair? args)
|
||||||
reason
|
(apply error (cons msg args))
|
||||||
(if (pair? args) args expr))))
|
(error msg expr))))
|
||||||
|
|
||||||
;; Features implemented by this Scheme
|
;; Features implemented by this Scheme
|
||||||
(define (features)
|
(define (features)
|
||||||
|
|
|
@ -829,6 +829,9 @@
|
||||||
|
|
||||||
;; Invoke ER macro
|
;; Invoke ER macro
|
||||||
(set! result
|
(set! result
|
||||||
|
(with-handler
|
||||||
|
(lambda (err)
|
||||||
|
(apply error/loc (append (list (car err) exp) (cdr err))) )
|
||||||
(cond
|
(cond
|
||||||
((not macro)
|
((not macro)
|
||||||
(error "macro not found" exp))
|
(error "macro not found" exp))
|
||||||
|
@ -844,7 +847,7 @@
|
||||||
(list 'quote exp)
|
(list 'quote exp)
|
||||||
(Cyc-er-rename use-env mac-env local-renamed)
|
(Cyc-er-rename use-env mac-env local-renamed)
|
||||||
(Cyc-er-compare? use-env rename-env))
|
(Cyc-er-compare? use-env rename-env))
|
||||||
mac-env))))
|
mac-env)))))
|
||||||
;(newline)
|
;(newline)
|
||||||
;(display "/* ")
|
;(display "/* ")
|
||||||
;(write (list 'macro:expand exp macro compiled-macro?))
|
;(write (list 'macro:expand exp macro compiled-macro?))
|
||||||
|
|
Loading…
Add table
Reference in a new issue