From adda7adb88642a113ee91512f745752361358958 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Wed, 10 Aug 2016 21:31:19 -0700 Subject: [PATCH] updates --- beautiful-racket-lib/br/define.rkt | 13 +++++++------ beautiful-racket-lib/br/main.rkt | 9 +-------- beautiful-racket/br/demo/bf/bf-expander.rkt | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/beautiful-racket-lib/br/define.rkt b/beautiful-racket-lib/br/define.rkt index 782a6e6..bfad0e7 100644 --- a/beautiful-racket-lib/br/define.rkt +++ b/beautiful-racket-lib/br/define.rkt @@ -9,7 +9,7 @@ syntax/define racket/string)) (provide (all-defined-out) - (for-syntax with-shared-id with-calling-site-id)) + (for-syntax with-shared-id)) (module+ test (require rackunit)) @@ -116,9 +116,10 @@ (begin-for-syntax (define-syntax-rule (with-shared-id (id ...) . body) - (with-syntax ([id (shared-syntax 'id)] ...) - . body)) - (define-syntax with-calling-site-id (make-rename-transformer #'with-shared-id))) + (with-syntax ([id (datum->syntax caller-stx (if (syntax? id) + (syntax-e id) + id))] ...) + . body))) ;; `syntax-parse` classes shared by `define-macro` and `define-macro-cases` @@ -172,8 +173,8 @@ (define result (syntax-parameterize ([caller-stx (make-rename-transformer #'stx)]) (syntax-case stx LITERALS - [pat . result-exprs] ... - else-clause))) + [pat . result-exprs] ... + else-clause))) (if (syntax? result) result (datum->syntax #'id result)))))] diff --git a/beautiful-racket-lib/br/main.rkt b/beautiful-racket-lib/br/main.rkt index b51a6cd..4343754 100644 --- a/beautiful-racket-lib/br/main.rkt +++ b/beautiful-racket-lib/br/main.rkt @@ -6,17 +6,10 @@ (all-from-out racket/list racket/string racket/format racket/match racket/port br/syntax br/datum br/debug br/cond racket/function br/define) (for-syntax (all-from-out racket/base racket/syntax br/syntax br/debug)) - (for-syntax caller-stx with-shared-id with-calling-site-id)) ; from br/define + (for-syntax caller-stx with-shared-id)) ; from br/define - ;; todo: activate at-exp reader by default -(define (remove-blank-lines strs) - (filter (λ(str) (regexp-match #px"\\S" str)) strs)) - -(provide remove-blank-lines) - - (module reader syntax/module-reader #:language 'br #:info br-get-info diff --git a/beautiful-racket/br/demo/bf/bf-expander.rkt b/beautiful-racket/br/demo/bf/bf-expander.rkt index 16ba161..2c16d60 100644 --- a/beautiful-racket/br/demo/bf/bf-expander.rkt +++ b/beautiful-racket/br/demo/bf/bf-expander.rkt @@ -6,7 +6,7 @@ #'(begin OP-OR-LOOP ...)) (provide bf-program) -(define-macro op +(define-macro-cases op [(op ">") #'(move-pointer 1)] [(op "<") #'(move-pointer -1)] [(op "+") #'(set-current-byte! (add1 (get-current-byte)))]