2007-10-25 16:27:34 -04:00
|
|
|
;;; Ikarus Scheme -- A compiler for R6RS Scheme.
|
|
|
|
;;; Copyright (C) 2006,2007 Abdulaziz Ghuloum
|
|
|
|
;;;
|
|
|
|
;;; This program is free software: you can redistribute it and/or modify
|
|
|
|
;;; it under the terms of the GNU General Public License version 3 as
|
|
|
|
;;; published by the Free Software Foundation.
|
|
|
|
;;;
|
|
|
|
;;; This program is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
;;; General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
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-08-26 21:24:22 -04:00
|
|
|
[(eq? script-type 'script) ; no greeting, no cafe
|
2007-04-28 20:54:02 -04:00
|
|
|
(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)])))
|