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