[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error context info
Quoting Greg Pettyjohn:
> I tried doing a ... (syntax/loc stx (make-a ...))... but in this case, no
> line was highlighted.
`syntax/loc' only assigns a location to the top-most syntax object. In
this case, I think you really want to put more specific error handling
in `validate-b':
(define-syntax validate-b
(lambda (stx)
(syntax-case stx (b)
[(_ (b x ...)) (syntax (make-b (list (validate-c x) ...)))]
[(_ bad) (raise-syntax-error #f "not a b" (syntax bad))])))
Another possibility would be to give each `(validate-b x)' the location
of its `x'. The following `validate' does that:
(define-syntax validate
(lambda (stx)
(syntax-case stx (a)
[(_ (a x ...))
(with-syntax ([(valid-x ...)
(map
(lambda (var)
(with-syntax ([x var])
(syntax/loc var (validate-b x))))
(syntax->list (syntax (x ...))))])
(syntax/loc stx (make-a (list valid-x ...))))])))
Matthew