diff --git a/compiler.scm b/compiler.scm index 268c320..d5acec3 100755 --- a/compiler.scm +++ b/compiler.scm @@ -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: