(define (classify-id id senv hist)
(let ((item (classify-form id senv hist)))
(if (not (var-item? item))
- (serror id senv hist "Variable required in this context:" id))
+ (serror (serror-ctx id senv hist)
+ "Variable required in this context:" id))
(var-item-id item)))
\ No newline at end of file
;;; Internal checker for classifiers.
(define (scheck pattern form senv hist)
(if (not (syntax-match? (cdr pattern) (cdr form)))
- (serror form senv hist "Ill-formed special form:" form)))
+ (serror (serror-ctx form senv hist) "Ill-formed special form:" form)))
;;; External checker for macros.
(define (syntax-check pattern form)
(error "Rule failed to match entire form."))
(output 'get-only))
(lambda ()
- (serror form use-senv hist "Ill-formed syntax:" form))))
+ (serror (serror-ctx form use-senv hist) "Ill-formed syntax:" form))))
\f
;;;; Inputs and outputs
(lambda (input senv output success failure)
(declare (ignore success failure))
(apply serror
- (%input-form input)
- senv
- (%input-hist input)
+ (serror-ctx (%input-form input) senv (%input-hist input))
message
(%subst-args input senv output irritants))))
(cond ((identifier? form)
(let ((item (lookup-identifier form senv)))
(if (reserved-name-item? item)
- (serror form senv hist
+ (serror (serror-ctx form senv hist)
"Premature reference to reserved name:" form))
item))
((syntactic-closure? form)
((keyword-item-impl item) form senv hist)
(begin
(if (not (list? (cdr form)))
- (serror form senv hist
+ (serror (serror-ctx form senv hist)
"Combination must be a proper list:" form))
(combination-item item
(classify-forms (cdr form)
\f
;;;; Errors
+(define-record-type <serror-ctx>
+ (serror-ctx form senv hist)
+ serror-ctx?
+ (form serror-ctx-form)
+ (senv serror-ctx-senv)
+ (hist serror-ctx-hist))
+
(define-deferred condition-type:syntax-error
(make-condition-type 'syntax-error
condition-type:simple-error
- '(form senv hist message irritants)
+ '(context message irritants)
(lambda (condition port)
(format-error-message (access-condition condition 'message)
(access-condition condition 'irritants)
standard-error-handler))
;;; Internal signaller for classifiers.
-(define (serror form senv hist message . irritants)
- (error:syntax form senv hist message irritants))
+(define (serror ctx message . irritants)
+ (error:syntax ctx message irritants))
(define-deferred error-context
(make-unsettable-parameter unspecific))
(define (with-error-context form senv hist thunk)
- (parameterize* (list (cons error-context (vector form senv hist)))
+ (parameterize* (list (cons error-context (serror-ctx form senv hist)))
thunk))
;;; External signaller for macros.
(define (syntax-error message . irritants)
- (let ((context (error-context)))
- (error:syntax (vector-ref context 0)
- (vector-ref context 1)
- (vector-ref context 2)
- message
- irritants)))
+ (error:syntax (error-context) message irritants))
\f
;;;; Utilities