From 829c8416b65df4ed75ebebaa8fa8142823397813 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Wed, 12 Aug 2009 20:43:10 +0000 Subject: [PATCH] Fix a bug suggested by Robby and add a test case svn: r15718 --- collects/redex/private/hole-test.ss | 21 ++++++++++++++++++--- collects/redex/private/matcher.ss | 16 ++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/collects/redex/private/hole-test.ss b/collects/redex/private/hole-test.ss index b983d4e582..b539da0f3f 100644 --- a/collects/redex/private/hole-test.ss +++ b/collects/redex/private/hole-test.ss @@ -6,12 +6,27 @@ [E hole (v ... E)]) -(define the-test +(define test1 (reduction-relation tl-grammar [--> (in-hole E_1 (explode)) (in-hole E_1 1)])) -(test--> the-test +(test--> test1 (term ((cont hole) (explode))) - (term ((cont hole) 1))) \ No newline at end of file + (term ((cont hole) 1))) + +(define test2 + (reduction-relation + tl-grammar + [--> (in-hole E_1 (explode)) + (asplode E_1)])) + +(define-metafunction tl-grammar + asplode : E -> any + [(asplode ((cont hole) hole)) + okay]) + +(test--> test2 + (term ((cont hole) (explode))) + (term okay)) \ No newline at end of file diff --git a/collects/redex/private/matcher.ss b/collects/redex/private/matcher.ss index 5bc715f8f6..f29f7c92e8 100644 --- a/collects/redex/private/matcher.ss +++ b/collects/redex/private/matcher.ss @@ -1557,16 +1557,12 @@ before the pattern compiler is invoked. |# (define (context? x) #t) -(define-values (the-hole hole?) +(define-values (the-hole the-not-hole hole?) (let () (define-struct hole () #:inspector #f) (define the-hole (make-hole)) - (values the-hole hole?))) -(define-values (the-not-hole not-hole?) - (let () - (define-struct not-hole () #:inspector #f) - (define the-not-hole (make-not-hole)) - (values the-not-hole not-hole?))) + (define the-not-hole (make-hole)) + (values the-hole the-not-hole hole?))) (define hole->not-hole (match-lambda @@ -1592,11 +1588,11 @@ before the pattern compiler is invoked. [(pair? exp) (cons (loop (car exp)) (loop (cdr exp)))] - [(not-hole? exp) + [(eq? the-not-hole exp) the-hole] - [(hole? exp) + [(eq? the-hole exp) (if done? - the-hole + exp (begin (set! done? #t) hole-stuff))] [else exp])))]))