simplify macros

dev-srcloc
Matthew Butterick 8 years ago
parent 101a60f0f4
commit 71ace522c6

@ -79,23 +79,19 @@
;; change names of lexer abbreviations to be consistent with Racket srcloc conventions ;; change names of lexer abbreviations to be consistent with Racket srcloc conventions
(provide lexeme-start) (define-syntax-rule (dprt ID-IN ID-OUT)
(define-syntax lexeme-start (make-rename-transformer #'start-pos)) (begin
(provide ID-IN)
(define-syntax ID-IN (make-rename-transformer (syntax ID-OUT)))))
(provide lexeme-end) (dprt lexeme-start start-pos)
(define-syntax lexeme-end (make-rename-transformer #'end-pos)) (dprt lexeme-end end-pos)
(dprt line position-line)
(provide line) (dprt col position-col)
(define-syntax line (make-rename-transformer #'position-line)) (dprt pos position-offset)
(provide column)
(define-syntax column (make-rename-transformer #'position-col))
(provide position)
(define-syntax position (make-rename-transformer #'position-offset))
(provide span) (provide span)
(define (span lexeme-start lexeme-end) (define (span lexeme-start lexeme-end)
(abs ; thus same result in reverse order (abs ; thus same result in reverse order
(- (position lexeme-end) (- (pos lexeme-end)
(position lexeme-start)))) (pos lexeme-start))))
Loading…
Cancel
Save