|
|
@ -1,22 +1,46 @@
|
|
|
|
#lang typed/racket/base
|
|
|
|
#lang typed/racket/base
|
|
|
|
(require (for-syntax racket/base racket/syntax))
|
|
|
|
(require (for-syntax racket/base racket/syntax))
|
|
|
|
|
|
|
|
|
|
|
|
(provide (all-defined-out))
|
|
|
|
(provide (all-defined-out))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report stx)
|
|
|
|
(define-syntax (report stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
[(_ expr) #'(report expr expr)]
|
|
|
|
[(_ expr) #'(report expr expr)]
|
|
|
|
[(_ expr #:line) #'(report expr expr #:line)]
|
|
|
|
|
|
|
|
[(_ expr name)
|
|
|
|
[(_ expr name)
|
|
|
|
#'(let ([x expr])
|
|
|
|
#'(let ([expr-result expr])
|
|
|
|
(eprintf "~a = ~v\n" 'name x)
|
|
|
|
(eprintf "~a = ~v\n" 'name expr-result)
|
|
|
|
x)]
|
|
|
|
expr-result)]))
|
|
|
|
[(_ expr name #:line)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report/line stx)
|
|
|
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
|
|
|
[(_ expr) #'(report/line expr expr)]
|
|
|
|
|
|
|
|
[(_ expr name)
|
|
|
|
(with-syntax ([line (syntax-line #'expr)])
|
|
|
|
(with-syntax ([line (syntax-line #'expr)])
|
|
|
|
#'(let ([x expr])
|
|
|
|
#'(let ([expr-result expr])
|
|
|
|
(eprintf "~a = ~v on line ~v\n" 'name x line)
|
|
|
|
(eprintf "~a = ~v on line ~v\n" 'name expr-result line)
|
|
|
|
x))]
|
|
|
|
expr-result))]))
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report/file stx)
|
|
|
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
|
|
|
[(_ expr) #'(report/file expr expr)]
|
|
|
|
|
|
|
|
[(_ expr name)
|
|
|
|
|
|
|
|
(with-syntax ([file (syntax-source #'expr)]
|
|
|
|
|
|
|
|
[line (syntax-line #'expr)])
|
|
|
|
|
|
|
|
#'(let ([expr-result expr])
|
|
|
|
|
|
|
|
(eprintf "~a = ~v on line ~v in \"~a\"\n" 'name expr-result line file)
|
|
|
|
|
|
|
|
expr-result))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (define-multi-version multi-name name)
|
|
|
|
|
|
|
|
(define-syntax-rule (multi-name x (... ...))
|
|
|
|
|
|
|
|
(begin (name x) (... ...))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-multi-version report* report)
|
|
|
|
|
|
|
|
(define-multi-version report*/line report/line)
|
|
|
|
|
|
|
|
(define-multi-version report*/file report/file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax report-apply
|
|
|
|
(define-syntax report-apply
|
|
|
|
(syntax-rules ()
|
|
|
|
(syntax-rules ()
|
|
|
@ -27,8 +51,7 @@
|
|
|
|
[(report-apply proc expr #:line)
|
|
|
|
[(report-apply proc expr #:line)
|
|
|
|
(let ([lst expr])
|
|
|
|
(let ([lst expr])
|
|
|
|
(report (apply proc lst) (apply proc expr) #:line)
|
|
|
|
(report (apply proc lst) (apply proc expr) #:line)
|
|
|
|
lst)]
|
|
|
|
lst)]))
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#|
|
|
|
|
#|
|
|
|
|
(define-syntax (verbalize stx)
|
|
|
|
(define-syntax (verbalize stx)
|
|
|
@ -40,9 +63,7 @@
|
|
|
|
(report (proc args ...))))]))
|
|
|
|
(report (proc args ...))))]))
|
|
|
|
|#
|
|
|
|
|#
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report* stx)
|
|
|
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
|
|
|
[(_ expr ...) #'(begin (report expr) ...)]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (repeat num expr ...)
|
|
|
|
(define-syntax-rule (repeat num expr ...)
|
|
|
|