123456789101112131415161718192021222324252627282930 |
- ;(define-module (trs trs)
- ; #:use-module (trs utilities)
- ; #:use-module (ice-9 match)
- ; #:export (define-trs))
- (library (trs)
- (export define-trs)
- (import (chezscheme) (utilities) (match))
- (define-syntax define-trs
- (lambda (x)
- (syntax-case x (==>)
- ((define-trs <name>
- (==> <pattern> <result>) ...)
- (let ((patterns (map qqify (syntax->list #'(<pattern> ...))))
- (results (map qqify (syntax->list #'(<result> ...)))))
- #`(begin
- (define (step s)
- (match s
- #,@(map (lambda (p r)
- #`(#,p (values #t #,r)))
- patterns results)
- (else (if (atomic? s)
- (values #f s)
- (step-body step s)))))
- (define (<name> s)
- (iterate step s))))))))
- )
|