update stackerizer

pull/2/head
Matthew Butterick 8 years ago
parent 6af77e0ce5
commit 2df0d0d870

@ -1,2 +1,2 @@
#lang s-exp br/demo/stackerizer #lang s-exp "stackerizer.rkt"
(+ 3 (* 6 (*) 2 (+ 145 56 3 6 (* 3 56436 9)) 15 22)) (* 3 (+ 8 4))

@ -1,28 +1,27 @@
#lang br/quicklang #lang br/quicklang
(provide + *) (provide + *)
(define-macro (stackerizer-module-begin EXPR ...) (define-macro (stackerizer-mb EXPR ...)
#'(#%module-begin #'(#%module-begin
(for-each displayln (reverse (flatten EXPR ...))))) (for-each displayln (reverse (flatten EXPR ...)))))
(provide (rename-out [stackerizer-module-begin #%module-begin])) (provide (rename-out [stackerizer-mb #%module-begin]))
#| (define-macro (define-ops OP ...)
(define-macro-cases * #'(begin
[(*) #'1] (define-macro-cases OP
[(* EXPR0) #'EXPR0] [(OP FIRST) #'FIRST]
[(* EXPR0 EXPR ...) #'(list '* EXPR0 (* EXPR ...))]) [(OP FIRST NEXT (... ...))
#'(list 'OP FIRST (OP NEXT (... ...)))])
...))
(define-macro-cases + (define-ops + *)
[(+) #'0]
[(+ EXPR0) #'EXPR0]
[(+ EXPR0 EXPR ...) #'(list '+ EXPR0 (+ EXPR ...))])
|#
(define-macro (define-op-macro OP-NAME IDENTITY-VAL) (module+ test
#'(define-macro-cases OP-NAME (require rackunit)
[(OP-NAME) #'IDENTITY-VAL] (check-equal? (with-output-to-string (λ () (dynamic-require "stackerizer-test.rkt" #f)))
[(OP-NAME EXPR0) #'EXPR0] "4
[(OP-NAME EXPR0 EXPR (... ...)) #'(list 'OP-NAME EXPR0 (OP-NAME EXPR (... ...)))])) 8
+
(define-op-macro * 1) 3
(define-op-macro + 0) *
"))
Loading…
Cancel
Save