Add -E option to dump result of module reader before simplification.

This commit is contained in:
Jesse D. McDonald 2011-04-25 13:51:35 -05:00
parent be48535995
commit b14f75d946
1 changed files with 22 additions and 7 deletions

View File

@ -12,19 +12,30 @@
;(require profile)
;(profile (begin
(define simplify-code? (make-parameter #t))
(define reduce-code? (make-parameter #t))
(define map-bytecode? (make-parameter #t))
(define write-rla-bytecode? (make-parameter #t))
(define source-file
(command-line
#:once-each
[("-O") ol "Set the optimization level"
(optimize? (>= (string->number ol) 1))]
[("-E" "--read-only") "Stop before simplifying code"
(write-rla-bytecode? #f)
(map-bytecode? #f)
(reduce-code? #f)
(simplify-code? #f)]
[("-S" "--simplify-only") "Stop before reducing code to lowest terms"
(write-rla-bytecode? #f)
(map-bytecode? #f)
(reduce-code? #f)]
[("-R" "--reduce-only") "Stop before mapping forms to VM bytecode"
(write-rla-bytecode? #f)
(map-bytecode? #f)]
[("-M" "--map-only") "Stop before translating mapped forms to RLA syntax"
(write-rla-bytecode? #f)]
[("-v" "--verbose") "Output verbose intermediate (.rla) representation"
(verbose-rla? #t)]
#:args source-file
@ -42,13 +53,17 @@
(parameterize ([current-directory directory])
(read-module)))))))
(if (map-bytecode?)
(begin
(write-rla-value (compile-function source-module))
(write-char #\Newline))
(if (reduce-code?)
(pretty-print (reduce-function source-module))
(pretty-print (simplify-lambda source-module))))
(cond [(write-rla-bytecode?)
(write-rla-value (compile-function source-module))
(write-char #\Newline)]
[(map-bytecode?)
(pretty-print (compile-function source-module))]
[(reduce-code?)
(pretty-print (reduce-function source-module))]
[(simplify-code?)
(pretty-print (simplify-lambda source-module))]
[else
(pretty-print source-module)])
;) #:delay 0.002)
; vim:set sw=2 expandtab: