svn: r11058
This commit is contained in:
parent
2ee24a173e
commit
008414b3f5
|
@ -131,7 +131,8 @@
|
||||||
acc)))]))))))
|
acc)))]))))))
|
||||||
(reduction-relation-make-procs red))
|
(reduction-relation-make-procs red))
|
||||||
(reduction-relation-rule-names red)
|
(reduction-relation-rule-names red)
|
||||||
(reduction-relation-lws red))))
|
(reduction-relation-lws red)
|
||||||
|
`any)))
|
||||||
|
|
||||||
(define-syntax (--> stx) (raise-syntax-error '--> "used outside of reduction-relation"))
|
(define-syntax (--> stx) (raise-syntax-error '--> "used outside of reduction-relation"))
|
||||||
(define-syntax (fresh stx) (raise-syntax-error 'fresh "used outside of reduction-relation"))
|
(define-syntax (fresh stx) (raise-syntax-error 'fresh "used outside of reduction-relation"))
|
||||||
|
@ -187,20 +188,27 @@
|
||||||
(define-syntax-set (do-reduction-relation)
|
(define-syntax-set (do-reduction-relation)
|
||||||
(define (do-reduction-relation/proc stx)
|
(define (do-reduction-relation/proc stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ id orig-reduction-relation allow-zero-rules? lang args ...)
|
[(_ id orig-reduction-relation allow-zero-rules? lang w/domain-args ...)
|
||||||
(identifier? #'lang)
|
(identifier? #'lang)
|
||||||
(with-syntax ([(rules ...) (before-with (syntax (args ...)))]
|
(let-values ([(args domain-pattern)
|
||||||
[(shortcuts ...) (after-with (syntax (args ...)))])
|
(syntax-case #'(w/domain-args ...) ()
|
||||||
(with-syntax ([(lws ...) (map rule->lws (syntax->list #'(rules ...)))])
|
[(#:domain pat args ...)
|
||||||
(reduction-relation/helper
|
(values (syntax (args ...)) #'pat)]
|
||||||
stx
|
[else
|
||||||
(syntax-e #'id)
|
(values (syntax (w/domain-args ...)) #'any)])])
|
||||||
#'orig-reduction-relation
|
(with-syntax ([(rules ...) (before-with args)]
|
||||||
(syntax lang)
|
[(shortcuts ...) (after-with args)])
|
||||||
(syntax->list (syntax (rules ...)))
|
(with-syntax ([(lws ...) (map rule->lws (syntax->list #'(rules ...)))])
|
||||||
(syntax->list (syntax (shortcuts ...)))
|
(reduction-relation/helper
|
||||||
#'(list lws ...)
|
stx
|
||||||
(syntax-e #'allow-zero-rules?))))]
|
(syntax-e #'id)
|
||||||
|
#'orig-reduction-relation
|
||||||
|
(syntax lang)
|
||||||
|
(syntax->list (syntax (rules ...)))
|
||||||
|
(syntax->list (syntax (shortcuts ...)))
|
||||||
|
#'(list lws ...)
|
||||||
|
(syntax-e #'allow-zero-rules?)
|
||||||
|
domain-pattern))))]
|
||||||
[(_ id orig-reduction-relation lang args ...)
|
[(_ id orig-reduction-relation lang args ...)
|
||||||
(raise-syntax-error (syntax-e #'id)
|
(raise-syntax-error (syntax-e #'id)
|
||||||
"expected an identifier for the language name"
|
"expected an identifier for the language name"
|
||||||
|
@ -311,7 +319,7 @@
|
||||||
(to-lw where-expr))
|
(to-lw where-expr))
|
||||||
...))))]))
|
...))))]))
|
||||||
|
|
||||||
(define (reduction-relation/helper stx orig-name orig-red-expr lang-id rules shortcuts lws allow-zero-rules?)
|
(define (reduction-relation/helper stx orig-name orig-red-expr lang-id rules shortcuts lws allow-zero-rules? domain-pattern)
|
||||||
(let ([ht (make-module-identifier-mapping)]
|
(let ([ht (make-module-identifier-mapping)]
|
||||||
[all-top-levels '()]
|
[all-top-levels '()]
|
||||||
[withs (make-module-identifier-mapping)])
|
[withs (make-module-identifier-mapping)])
|
||||||
|
@ -370,17 +378,27 @@
|
||||||
(for-each loop nexts)))))
|
(for-each loop nexts)))))
|
||||||
all-top-levels)
|
all-top-levels)
|
||||||
|
|
||||||
(let ([name-ht (make-hasheq)])
|
(let ([name-ht (make-hasheq)]
|
||||||
|
[lang-nts (language-id-nts lang-id orig-name)])
|
||||||
(with-syntax ([lang-id lang-id]
|
(with-syntax ([lang-id lang-id]
|
||||||
[(top-level ...) (get-choices stx orig-name ht lang-id (syntax -->) name-ht lang-id allow-zero-rules?)]
|
[(top-level ...) (get-choices stx orig-name ht lang-id (syntax -->) name-ht lang-id allow-zero-rules?)]
|
||||||
[(rule-names ...) (hash-map name-ht (λ (k v) k))]
|
[(rule-names ...) (hash-map name-ht (λ (k v) k))]
|
||||||
[lws lws])
|
[lws lws]
|
||||||
|
|
||||||
|
[domain-pattern-side-conditions-rewritten
|
||||||
|
(rewrite-side-conditions/check-errs
|
||||||
|
lang-nts
|
||||||
|
orig-name
|
||||||
|
#t
|
||||||
|
domain-pattern)])
|
||||||
|
|
||||||
#`(build-reduction-relation
|
#`(build-reduction-relation
|
||||||
#,orig-red-expr
|
#,orig-red-expr
|
||||||
lang-id
|
lang-id
|
||||||
(list top-level ...)
|
(list top-level ...)
|
||||||
'(rule-names ...)
|
'(rule-names ...)
|
||||||
lws)))))
|
lws
|
||||||
|
`domain-pattern-side-conditions-rewritten)))))
|
||||||
|
|
||||||
#|
|
#|
|
||||||
;; relation-tree =
|
;; relation-tree =
|
||||||
|
@ -653,7 +671,8 @@
|
||||||
first-lang
|
first-lang
|
||||||
(reverse (apply append (map reduction-relation-make-procs lst)))
|
(reverse (apply append (map reduction-relation-make-procs lst)))
|
||||||
(hash-map name-ht (λ (k v) k))
|
(hash-map name-ht (λ (k v) k))
|
||||||
(apply append (map reduction-relation-lws lst)))))
|
(apply append (map reduction-relation-lws lst))
|
||||||
|
`any)))
|
||||||
|
|
||||||
(define (do-node-match lhs-frm-id lhs-to-id pat rhs-proc child-make-proc)
|
(define (do-node-match lhs-frm-id lhs-to-id pat rhs-proc child-make-proc)
|
||||||
;; need call to make-rewrite-proc
|
;; need call to make-rewrite-proc
|
||||||
|
|
|
@ -40,7 +40,9 @@
|
||||||
'()
|
'()
|
||||||
'()))
|
'()))
|
||||||
|
|
||||||
(define (build-reduction-relation orig-reduction-relation lang make-procs rule-names lws)
|
;; the domain pattern isn't actually used here.
|
||||||
|
;; I started to add it, but didn't finish. -robby
|
||||||
|
(define (build-reduction-relation orig-reduction-relation lang make-procs rule-names lws domain-pattern)
|
||||||
(cond
|
(cond
|
||||||
[orig-reduction-relation
|
[orig-reduction-relation
|
||||||
(let* ([new-names (map rewrite-proc-name make-procs)]
|
(let* ([new-names (map rewrite-proc-name make-procs)]
|
||||||
|
|
|
@ -406,7 +406,8 @@
|
||||||
(define-metafunction x-lang
|
(define-metafunction x-lang
|
||||||
f : x x -> x
|
f : x x -> x
|
||||||
[(f x_1 x_2) x_1])
|
[(f x_1 x_2) x_1])
|
||||||
(test (term (f p q)) (term p)))
|
(test (term (f p q)) (term p))
|
||||||
|
(test (in-domain? (f p q)) #t))
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
|
@ -486,8 +486,10 @@ is signaled. If no patterns match, an error is signaled.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defform/subs[#:literals (--> fresh side-condition where)
|
@defform/subs[#:literals (--> fresh side-condition where)
|
||||||
(reduction-relation language reduction-case ...)
|
(reduction-relation language domain reduction-case ...)
|
||||||
((reduction-case (--> pattern exp extras ...))
|
((domain (code:line)
|
||||||
|
(code:line #:domain pattern))
|
||||||
|
(reduction-case (--> pattern exp extras ...))
|
||||||
(extras name
|
(extras name
|
||||||
(fresh <fresh-clause> ...)
|
(fresh <fresh-clause> ...)
|
||||||
(side-condition <guard> ...)
|
(side-condition <guard> ...)
|
||||||
|
@ -727,24 +729,34 @@ legtimate inputs according to @scheme[metafunction-name]'s contract,
|
||||||
and @scheme[#f] otherwise.
|
and @scheme[#f] otherwise.
|
||||||
}
|
}
|
||||||
|
|
||||||
> (test-equal e1 e2) SYNTAX
|
@defidform[-->]{ Recognized specially within
|
||||||
|
@scheme[reduction-relation]. A @scheme[-->] form is an
|
||||||
|
error elsewhere. }
|
||||||
|
|
||||||
Tests to see if e1 is equal to e2.
|
@defidform[fresh]{ Recognized specially within
|
||||||
|
@scheme[reduction-relation]. A @scheme[-->] form is an
|
||||||
|
error elsewhere. }
|
||||||
|
|
||||||
> (test--> reduction-relation e1 e2 ...) SYNTAX
|
@defform[(test-equal e1 e2)]{
|
||||||
|
|
||||||
Tests to see if the value of e1 (which should be a term),
|
Tests to see if @scheme[e1] is equal to @scheme[e2].
|
||||||
reduces to the e2s.
|
}
|
||||||
|
|
||||||
> (test-predicate p? e) SYNTAX
|
@defform[(test--> reduction-relation e1 e2 ...)]{
|
||||||
|
|
||||||
Tests to see if the value of `e' matches the predicate p?.
|
Tests to see if the value of @scheme[e1] (which should be a term),
|
||||||
|
reduces to the @scheme[e2]s under @scheme[reduction-relation].
|
||||||
|
}
|
||||||
|
|
||||||
> test-results :: (-> void?)
|
@defform[(test-predicate p? e)]{
|
||||||
|
Tests to see if the value of @scheme[e] matches the predicate @scheme[p?].
|
||||||
|
}
|
||||||
|
|
||||||
|
@defproc[(test-results) void?]{
|
||||||
Prints out how many tests passed and failed, and resets the
|
Prints out how many tests passed and failed, and resets the
|
||||||
counters so that next time this function is called, it
|
counters so that next time this function is called, it
|
||||||
prints the test results for the next round of tests.
|
prints the test results for the next round of tests.
|
||||||
|
}
|
||||||
|
|
||||||
> plug :: (any? any? . -> . any)
|
> plug :: (any? any? . -> . any)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user