|
|
@ -1,44 +1,45 @@
|
|
|
|
#lang racket/base
|
|
|
|
#lang racket/base
|
|
|
|
(require (for-syntax racket/base racket/syntax) "define.rkt")
|
|
|
|
(require (for-syntax racket/base) "define.rkt")
|
|
|
|
|
|
|
|
|
|
|
|
(provide+safe report report/line report/file
|
|
|
|
(provide+safe report report/line report/file
|
|
|
|
report* report*/line report*/file
|
|
|
|
report* report*/line report*/file
|
|
|
|
report-apply repeat time-repeat time-repeat* compare)
|
|
|
|
report-apply repeat time-repeat time-repeat* compare)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report stx)
|
|
|
|
(define-syntax (report stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
[(_ expr) #'(report expr expr)]
|
|
|
|
[(MACRO EXPR) #'(MACRO EXPR EXPR)]
|
|
|
|
[(_ expr name)
|
|
|
|
[(_ EXPR NAME)
|
|
|
|
#'(let ([expr-result expr])
|
|
|
|
#'(let ([expr-result EXPR])
|
|
|
|
(eprintf "~a = ~v\n" 'name expr-result)
|
|
|
|
(eprintf "~a = ~v\n" 'NAME expr-result)
|
|
|
|
expr-result)]))
|
|
|
|
expr-result)]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report/line stx)
|
|
|
|
(define-syntax (report/line stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
[(_ expr) #'(report/line expr expr)]
|
|
|
|
[(MACRO EXPR) #'(MACRO EXPR EXPR)]
|
|
|
|
[(_ expr name)
|
|
|
|
[(_ EXPR NAME)
|
|
|
|
(with-syntax ([line (syntax-line #'expr)])
|
|
|
|
#`(let ([expr-result EXPR])
|
|
|
|
#'(let ([expr-result expr])
|
|
|
|
(eprintf "~a = ~v on line ~v\n" 'NAME expr-result #,(syntax-line #'EXPR))
|
|
|
|
(eprintf "~a = ~v on line ~v\n" 'name expr-result line)
|
|
|
|
expr-result)]))
|
|
|
|
expr-result))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (report/file stx)
|
|
|
|
(define-syntax (report/file stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
[(_ expr) #'(report/file expr expr)]
|
|
|
|
[(MACRO EXPR) #'(MACRO EXPR EXPR)]
|
|
|
|
[(_ expr name)
|
|
|
|
[(_ EXPR NAME)
|
|
|
|
(with-syntax ([file (syntax-source #'expr)]
|
|
|
|
#`(let ([expr-result EXPR])
|
|
|
|
[line (syntax-line #'expr)])
|
|
|
|
(eprintf "~a = ~v on line ~v in \"~a\"\n" 'NAME expr-result
|
|
|
|
#'(let ([expr-result expr])
|
|
|
|
#,(syntax-line #'EXPR)
|
|
|
|
(eprintf "~a = ~v on line ~v in \"~a\"\n" 'name expr-result line 'file)
|
|
|
|
'#,(syntax-source #'EXPR))
|
|
|
|
expr-result))]))
|
|
|
|
expr-result)]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (define-multi-version multi-name name)
|
|
|
|
(define-syntax-rule (define-multi-version multi-name name)
|
|
|
|
(define-syntax-rule (multi-name x (... ...))
|
|
|
|
(define-syntax-rule (multi-name x (... ...))
|
|
|
|
(begin (name x) (... ...))))
|
|
|
|
(begin (name x) (... ...))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-multi-version report* report)
|
|
|
|
(define-multi-version report* report)
|
|
|
|
(define-multi-version report*/line report/line)
|
|
|
|
(define-multi-version report*/line report/line)
|
|
|
|
(define-multi-version report*/file report/file)
|
|
|
|
(define-multi-version report*/file report/file)
|
|
|
@ -55,39 +56,27 @@
|
|
|
|
(report (apply proc lst) (apply proc expr) #:line)
|
|
|
|
(report (apply proc lst) (apply proc expr) #:line)
|
|
|
|
lst)]))
|
|
|
|
lst)]))
|
|
|
|
|
|
|
|
|
|
|
|
#|
|
|
|
|
|
|
|
|
(define-syntax (verbalize stx)
|
|
|
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
|
|
|
[(_ proc args ...)
|
|
|
|
|
|
|
|
(with-syntax ([proc-input (format-id stx "args to ~a" #'proc)])
|
|
|
|
|
|
|
|
#'(begin
|
|
|
|
|
|
|
|
(let () (report (list args ...) proc-input) (void))
|
|
|
|
|
|
|
|
(report (proc args ...))))]))
|
|
|
|
|
|
|
|
|#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (repeat num expr ...)
|
|
|
|
(define-syntax-rule (repeat NUM EXPR ...)
|
|
|
|
(for/last ([i (in-range num)])
|
|
|
|
(for/last ([i (in-range NUM)])
|
|
|
|
expr ...))
|
|
|
|
EXPR ...))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax-rule (time-repeat num expr ...)
|
|
|
|
(define-syntax-rule (time-repeat NUM EXPR ...)
|
|
|
|
(time (repeat num expr ...)))
|
|
|
|
(time (repeat NUM EXPR ...)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (time-repeat* stx)
|
|
|
|
(define-syntax (time-repeat* stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
[(_ num expr ...)
|
|
|
|
[(_ NUM EXPR ...)
|
|
|
|
#'(let ([n num])
|
|
|
|
#'(let ([n NUM])
|
|
|
|
(values (time-repeat n expr) ...))]))
|
|
|
|
(values (time-repeat n EXPR) ...))]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (compare stx)
|
|
|
|
(define-syntax (compare stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
[(_ expr id id-alt ...)
|
|
|
|
[(_ EXPR ID ID-ALT ...)
|
|
|
|
#'(values expr (let ([id id-alt]) expr) ...)]))
|
|
|
|
#'(values EXPR (let ([ID ID-ALT]) EXPR) ...)]))
|
|
|
|
|
|
|
|
|
|
|
|
(module reader racket/base
|
|
|
|
(module reader racket/base
|
|
|
|
(require syntax/module-reader racket/syntax version/utils)
|
|
|
|
(require syntax/module-reader racket/syntax version/utils)
|
|
|
|