From 71ace522c668ab36d29078b1a87e1fe2136c0b36 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 8 Dec 2016 12:31:02 -0800 Subject: [PATCH] simplify macros --- brag/brag/support.rkt | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/brag/brag/support.rkt b/brag/brag/support.rkt index 1804a30..423d3a8 100755 --- a/brag/brag/support.rkt +++ b/brag/brag/support.rkt @@ -79,23 +79,19 @@ ;; change names of lexer abbreviations to be consistent with Racket srcloc conventions -(provide lexeme-start) -(define-syntax lexeme-start (make-rename-transformer #'start-pos)) +(define-syntax-rule (dprt ID-IN ID-OUT) + (begin + (provide ID-IN) + (define-syntax ID-IN (make-rename-transformer (syntax ID-OUT))))) -(provide lexeme-end) -(define-syntax lexeme-end (make-rename-transformer #'end-pos)) - -(provide line) -(define-syntax line (make-rename-transformer #'position-line)) - -(provide column) -(define-syntax column (make-rename-transformer #'position-col)) - -(provide position) -(define-syntax position (make-rename-transformer #'position-offset)) +(dprt lexeme-start start-pos) +(dprt lexeme-end end-pos) +(dprt line position-line) +(dprt col position-col) +(dprt pos position-offset) (provide span) (define (span lexeme-start lexeme-end) (abs ; thus same result in reverse order - (- (position lexeme-end) - (position lexeme-start)))) \ No newline at end of file + (- (pos lexeme-end) + (pos lexeme-start)))) \ No newline at end of file