ikarus/src/ikarus.main.ss

63 lines
2.2 KiB
Scheme
Raw Normal View History

;;; this is here to test that we can import things from other
;;; libraries within the compiler itself.
(library (ikarus greeting)
(export print-greeting)
(import (ikarus))
2007-05-22 19:59:30 -04:00
(letrec-syntax ([compile-time-string (lambda (x) (date-string))])
(define (print-greeting)
(printf "Ikarus Scheme (Build ~a)\n" (compile-time-string))
(display "Copyright (c) 2006-2007 Abdulaziz Ghuloum\n\n"))))
2006-12-06 21:05:19 -05:00
;;; Finally, we're ready to evaluate the files and enter the cafe.
(library (ikarus main)
(export)
(import (ikarus)
(ikarus greeting)
(only (ikarus load) load-r6rs-top-level))
(let-values ([(files script script-type args)
(let f ([args (command-line-arguments)])
(cond
[(null? args) (values '() #f #f '())]
[(string=? (car args) "--")
(values '() #f #f (cdr args))]
[(string=? (car args) "--script")
(let ([d (cdr args)])
(cond
[(null? d)
(error #f "--script requires a script name")]
[else
(values '() (car d) 'script (cdr d))]))]
[(string=? (car args) "--r6rs-script")
(let ([d (cdr args)])
(cond
[(null? d)
(error #f "--r6rs-script requires a script name")]
[else
(values '() (car d) 'r6rs-script (cdr d))]))]
[else
(let-values ([(f* script script-type a*) (f (cdr args))])
(values (cons (car args) f*) script script-type a*))]))])
(cond
[(eq? script-type 'r6rs-script)
(command-line-arguments (cons script args))
;(for-each load files)
(load-r6rs-top-level script)
;(load script)
(exit 0)]
[script ; no greeting, no cafe
(command-line-arguments (cons script args))
(for-each load files)
(load script)
(exit 0)]
[else
(print-greeting)
(command-line-arguments args)
(for-each load files)
(new-cafe)
(exit 0)])))