A fix for my example hide hole based models

svn: r15715
This commit is contained in:
Jay McCarthy 2009-08-12 20:08:36 +00:00
parent 485785176a
commit 1dba4edcb9
5 changed files with 43 additions and 12 deletions

View File

@ -0,0 +1,17 @@
#lang scheme
(require redex)
(define-language tl-grammar
[v (cont (hide-hole E))]
[E hole
(v ... E)])
(define the-test
(reduction-relation
tl-grammar
[--> (in-hole E_1 (explode))
(in-hole E_1 1)]))
(test--> the-test
(term ((cont hole) (explode)))
(term ((cont hole) 1)))

View File

@ -72,8 +72,8 @@
(test-empty '(in-hole (name E_1 ((hide-hole hole) hole)) x) (test-empty '(in-hole (name E_1 ((hide-hole hole) hole)) x)
`(,the-hole x) `(,the-hole x)
(list (make-test-mtch (make-bindings (list (make-bind 'E_1 `(,the-hole ,the-hole)))) (list (make-test-mtch (make-bindings (list (make-bind 'E_1 `(,the-not-hole ,the-hole))))
`(x ,the-hole) `(,the-hole x)
none))) none)))

View File

@ -761,7 +761,7 @@ before the pattern compiler is invoked.
(lambda (exp hole-info) (lambda (exp hole-info)
(let ([matches (match-pat exp #f)]) (let ([matches (match-pat exp #f)])
(and matches (and matches
(map (λ (match) (make-mtch (mtch-bindings match) (mtch-context match) none)) (map (λ (match) (make-mtch (mtch-bindings match) (hole->not-hole (mtch-context match)) none))
matches)))) matches))))
#f))] #f))]
@ -1562,6 +1562,18 @@ before the pattern compiler is invoked.
(define-struct hole () #:inspector #f) (define-struct hole () #:inspector #f)
(define the-hole (make-hole)) (define the-hole (make-hole))
(values the-hole 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 hole->not-hole
(match-lambda
[(? hole?) the-not-hole]
[(list-rest f r)
(cons (hole->not-hole f) (hole->not-hole r))]
[x x]))
(define (build-flat-context exp) exp) (define (build-flat-context exp) exp)
(define (build-cons-context e1 e2) (cons e1 e2)) (define (build-cons-context e1 e2) (cons e1 e2))
@ -1579,13 +1591,14 @@ before the pattern compiler is invoked.
(cond (cond
[(pair? exp) [(pair? exp)
(cons (loop (car exp)) (cons (loop (car exp))
(if done? (loop (cdr exp)))]
(cdr exp) [(not-hole? exp)
(loop (cdr exp))))] the-hole]
[(hole? exp) [(hole? exp)
(set! done? #t) (if done?
hole-stuff] the-hole
(begin (set! done? #t)
hole-stuff))]
[else exp])))])) [else exp])))]))
;; ;;
@ -1641,7 +1654,7 @@ before the pattern compiler is invoked.
none? none none? none
make-repeat make-repeat
the-hole hole? the-not-hole the-hole hole?
rewrite-ellipses rewrite-ellipses
build-compatible-context-language build-compatible-context-language
caching-enabled?) caching-enabled?)

View File

@ -12,7 +12,8 @@
"keyword-macros-test.ss" "keyword-macros-test.ss"
"core-layout-test.ss" "core-layout-test.ss"
"bitmap-test.ss" "bitmap-test.ss"
"pict-test.ss")) "pict-test.ss"
"hole-test.ss"))
(define-runtime-path here ".") (define-runtime-path here ".")

View File

@ -8,7 +8,7 @@
(define syn-err-test-namespace (make-base-namespace)) (define syn-err-test-namespace (make-base-namespace))
(parameterize ([current-namespace syn-err-test-namespace]) (parameterize ([current-namespace syn-err-test-namespace])
(eval '(require "../reduction-semantics.ss"))) (eval '(require redex/reduction-semantics)))
(define-syntax (test stx) (define-syntax (test stx)
(syntax-case stx () (syntax-case stx ()