From 07350988e7875f7cf5f8ddda40d5afef007e0929 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 6 May 2016 13:32:36 -0700 Subject: [PATCH] make hider/splicer tests --- brag/brag/codegen/codegen.rkt | 3 ++- brag/brag/codegen/runtime.rkt | 6 +++--- brag/brag/elider/json-elider-toy.rkt | 4 ---- brag/brag/elider/test-json-elider-toy.rkt | 9 --------- .../json-elider.rkt => examples/baby-json-hider.rkt} | 5 ++--- .../test-baby-json-hider.rkt} | 4 ++-- 6 files changed, 9 insertions(+), 22 deletions(-) delete mode 100644 brag/brag/elider/json-elider-toy.rkt delete mode 100644 brag/brag/elider/test-json-elider-toy.rkt rename brag/brag/{elider/json-elider.rkt => examples/baby-json-hider.rkt} (78%) rename brag/brag/{elider/test-json-elider.rkt => test/test-baby-json-hider.rkt} (90%) diff --git a/brag/brag/codegen/codegen.rkt b/brag/brag/codegen/codegen.rkt index b58f8df..75837c9 100755 --- a/brag/brag/codegen/codegen.rkt +++ b/brag/brag/codegen/codegen.rkt @@ -247,7 +247,8 @@ (with-syntax ([$1-start-pos (datum->syntax (first translated-patterns) '$1-start-pos)] [$n-end-pos (format-id (last translated-patterns) "$~a-end-pos" (length translated-patterns))]) #`(positions->srcloc $1-start-pos $n-end-pos)))) - + + ;; move 'splice property into function because name is datum-ized (with-syntax ([(translated-pattern ...) translated-patterns] [(translated-action ...) translated-actions]) #`[(translated-pattern ...) diff --git a/brag/brag/codegen/runtime.rkt b/brag/brag/codegen/runtime.rkt index ebb8902..12212ca 100755 --- a/brag/brag/codegen/runtime.rkt +++ b/brag/brag/codegen/runtime.rkt @@ -163,15 +163,15 @@ This would be the place to check a syntax property for hiding. ;; Creates an stx out of the rule name and its components. ;; The location information of the rule spans that of its components. (define (rule-components->syntax rule-name/false #:srcloc [srcloc #f] #:splice? [splice #f] . componentss) - (let ([componentss (append-map (λ(cs) + (let ([spliced-componentss (append-map (λ(cs) (if (and (pair? cs) (syntax-property (car cs) 'splice)) - (list (cdr (syntax->list (car cs)))) + (list (cdr (syntax->list (car cs)))) ; pop off the rule name and splice its components into this rule (list cs))) componentss)]) (syntax-property (datum->syntax #f (cons (datum->syntax #f rule-name/false srcloc stx-with-original?-property) - (apply append componentss)) + (apply append spliced-componentss)) srcloc stx-with-original?-property) 'splice splice))) \ No newline at end of file diff --git a/brag/brag/elider/json-elider-toy.rkt b/brag/brag/elider/json-elider-toy.rkt deleted file mode 100644 index 8eed9e8..0000000 --- a/brag/brag/elider/json-elider-toy.rkt +++ /dev/null @@ -1,4 +0,0 @@ -#lang brag - -thing : foo -foo : <"bar"> diff --git a/brag/brag/elider/test-json-elider-toy.rkt b/brag/brag/elider/test-json-elider-toy.rkt deleted file mode 100644 index c3072c3..0000000 --- a/brag/brag/elider/test-json-elider-toy.rkt +++ /dev/null @@ -1,9 +0,0 @@ -#lang br -(require "json-elider-toy.rkt" - brag/support - rackunit) - -(check-equal? - (syntax->datum - (parse (list "bar"))) - '(thing)) diff --git a/brag/brag/elider/json-elider.rkt b/brag/brag/examples/baby-json-hider.rkt similarity index 78% rename from brag/brag/elider/json-elider.rkt rename to brag/brag/examples/baby-json-hider.rkt index 677a02d..eb2097f 100755 --- a/brag/brag/elider/json-elider.rkt +++ b/brag/brag/examples/baby-json-hider.rkt @@ -1,8 +1,7 @@ #lang brag ;; Simple baby example of JSON structure -json: number - | string +json: number | string | array | object @@ -14,4 +13,4 @@ array: "[" [json ("," json)*] "]" object: <"{"> [kvpair ("," kvpair)*] <"}"> - : ":" +: ":" diff --git a/brag/brag/elider/test-json-elider.rkt b/brag/brag/test/test-baby-json-hider.rkt similarity index 90% rename from brag/brag/elider/test-json-elider.rkt rename to brag/brag/test/test-baby-json-hider.rkt index c7e48d0..81af1a1 100755 --- a/brag/brag/elider/test-json-elider.rkt +++ b/brag/brag/test/test-baby-json-hider.rkt @@ -1,5 +1,5 @@ -#lang br -(require "json-elider.rkt" +#lang racket/base +(require brag/examples/baby-json-hider brag/support rackunit)