2007-05-02 02:16:56 -04:00
|
|
|
|
|
|
|
|
2007-05-04 02:39:50 -04:00
|
|
|
;;; this is here to test that we can import things from other
|
|
|
|
;;; libraries within the compiler itself.
|
|
|
|
|
|
|
|
(library (ikarus greeting)
|
|
|
|
(export print-greeting)
|
2007-05-06 17:02:49 -04:00
|
|
|
(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"))))
|
2007-05-02 02:16:56 -04:00
|
|
|
|
|
|
|
|
2006-12-06 21:05:19 -05:00
|
|
|
;;; Finally, we're ready to evaluate the files and enter the cafe.
|
2007-05-02 02:16:56 -04:00
|
|
|
|
2007-05-09 23:42:32 -04:00
|
|
|
(library (ikarus main)
|
2007-05-04 03:00:16 -04:00
|
|
|
(export)
|
2007-05-09 07:35:31 -04:00
|
|
|
(import (ikarus)
|
|
|
|
(ikarus greeting)
|
|
|
|
(only (ikarus load) load-r6rs-top-level))
|
|
|
|
(let-values ([(files script script-type args)
|
2007-04-28 20:54:02 -04:00
|
|
|
(let f ([args (command-line-arguments)])
|
|
|
|
(cond
|
2007-05-09 07:35:31 -04:00
|
|
|
[(null? args) (values '() #f #f '())]
|
2007-04-28 20:54:02 -04:00
|
|
|
[(string=? (car args) "--")
|
2007-05-09 07:35:31 -04:00
|
|
|
(values '() #f #f (cdr args))]
|
2007-04-28 20:54:02 -04:00
|
|
|
[(string=? (car args) "--script")
|
|
|
|
(let ([d (cdr args)])
|
|
|
|
(cond
|
2007-05-09 07:35:31 -04:00
|
|
|
[(null? d)
|
2007-04-28 20:54:02 -04:00
|
|
|
(error #f "--script requires a script name")]
|
|
|
|
[else
|
2007-05-09 07:35:31 -04:00
|
|
|
(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))]))]
|
2007-04-28 20:54:02 -04:00
|
|
|
[else
|
2007-05-09 07:35:31 -04:00
|
|
|
(let-values ([(f* script script-type a*) (f (cdr args))])
|
|
|
|
(values (cons (car args) f*) script script-type a*))]))])
|
2007-04-28 20:54:02 -04:00
|
|
|
(cond
|
2007-05-09 07:35:31 -04:00
|
|
|
[(eq? script-type 'r6rs-script)
|
|
|
|
(command-line-arguments (cons script args))
|
|
|
|
;(for-each load files)
|
|
|
|
(load-r6rs-top-level script)
|
|
|
|
;(load script)
|
|
|
|
(exit 0)]
|
2007-04-28 20:54:02 -04:00
|
|
|
[script ; no greeting, no cafe
|
|
|
|
(command-line-arguments (cons script args))
|
|
|
|
(for-each load files)
|
|
|
|
(load script)
|
|
|
|
(exit 0)]
|
|
|
|
[else
|
2007-05-04 02:39:50 -04:00
|
|
|
(print-greeting)
|
2007-04-28 20:54:02 -04:00
|
|
|
(command-line-arguments args)
|
|
|
|
(for-each load files)
|
|
|
|
(new-cafe)
|
|
|
|
(exit 0)])))
|