You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
653 B
Racket
23 lines
653 B
Racket
#lang br
|
|
(require "struct.rkt")
|
|
(provide b-line raise-line-error)
|
|
|
|
(define-macro (b-line NUM STATEMENT ...)
|
|
(with-pattern ([LINE-NUM (prefix-id "line-" #'NUM
|
|
#:source #'NUM)])
|
|
(syntax/loc caller-stx
|
|
(define (LINE-NUM #:error [msg #f])
|
|
(with-handlers
|
|
([line-error?
|
|
(λ (le) (handle-line-error NUM le))])
|
|
(when msg (raise-line-error msg))
|
|
STATEMENT ...)))))
|
|
|
|
(define (raise-line-error error-msg)
|
|
(raise (line-error error-msg)))
|
|
|
|
(define (handle-line-error num le)
|
|
(error (format "error in line ~a: ~a"
|
|
num (line-error-msg le))))
|
|
|