; /* vim: set filetype=scheme : */ -*- scheme -*- (require (lib "cmdline.ss")) (require (lib "defmacro.ss")) (define (seta! list key value) (set-cdr! (assq key list) value)) (define (pusha! list key value) (let* ((val (cdr (assq key list))) (val (cons value val))) (print val) (set-cdr! (assq key list) val))) (define *options* '((verbose . #f) (profiling-on . #f) (optimize-level . 0) (file ) (link-flags ) )) (halt) (define (t2) (pusha! *options* 'link-flags 'aa) *options*) (define t1 (let ((temp ())) (set! temp (command-line "compile" (current-command-line-arguments) (once-each [("-v" "--verbose") "Compile with verbose messages" (seta! *options* 'verbose-mode #t)] [("-p" "--profile") "Compile with profiling" (seta! *options* 'profiling-on #t)]) (once-any [("-o" "--optimize-1") "Compile with optimization level 1" (seta! *options* 'optimize-level 1)] ["--optimize-2" "" ; show help on separate lines "Compile with optimization level 2," "which implies all optimizations of level 1" (seta! *otpions* 'optimize-level 2)]) (multi [("-l" "--link-flags") lf ; flag takes one argument "Add a flag for the linker" (pusha! *options* 'link-flags lf) ]) ;(args (filename) ; expects one command-line argument: a filename ; filename))) )) (seta! *options* 'file temp) )); return a single filename to compile (print *options*) (define (nb trainf testf) (let ((wm ())) (file-do trainf train) (file-do testf test))) (define (two x y) (printf "~a: ~a [~a]~n" x y (symbol? (car y)))) ;define (line row cells0) ; (let loop ((col 1) ; (cells cells)) ; (if cells ; (let ((token (symbolize (car cells))) ; (wm)))))) (define (file-do file proc) (define (worker) (let loop ((n 1) (x (read))) (cond ((not (eof-object? x)) (proc n x) (loop (+ 1 n) (read)))))) (if (file-exists? file) (with-input-from-file file worker) (error "file " file " missing"))) ;(file-do "/Users/timm/wisp/trunk/sandbox/timm/scm1/eg/0.in" two)