Index: c/grt.c =================================================================== RCS file: /home/fn/src/cvs/goo/c/grt.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -u -r1.1.1.1 -r1.2 --- c/grt.c 27 Nov 2003 09:49:14 -0000 1.1.1.1 +++ c/grt.c 27 Nov 2003 09:51:25 -0000 1.2 @@ -786,9 +786,9 @@ } P YPapp_args () { - int i; + int i = Pargc - 1; P args = Ynil; - for (i = 1; i < Pargc; i++) + for (; i != 0; i--) args = YPpair(YPsb(Pargv[i]), args); return args; } Index: emacs/goo.el =================================================================== RCS file: /home/fn/src/cvs/goo/emacs/goo.el,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 goo.el --- emacs/goo.el 27 Nov 2003 09:49:14 -0000 1.1.1.1 +++ emacs/goo.el 27 Nov 2003 19:20:08 -0000 @@ -261,6 +261,7 @@ (put 'export 'goo-indent-function 0) (put 'need-implementation 'goo-indent-function 0) (put 'new 'goo-indent-function 1) +(put 'with-port 'goo-indent-function "define") ;;; deprecated (put 'isa 'goo-indent-function 1) (put 'select 'goo-indent-function 1) Index: src/eval/top.goo =================================================================== RCS file: /home/fn/src/cvs/goo/src/eval/top.goo,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 top.goo --- src/eval/top.goo 27 Nov 2003 09:49:14 -0000 1.1.1.1 +++ src/eval/top.goo 27 Nov 2003 19:14:12 -0000 @@ -87,6 +87,18 @@ (sexpr-sequence->begin (rev! forms)) (loop (pair x forms)))))) +(dm read-script (filename| modname| => ) + ; (mangle-argv-somehow) + (with-port (port (open filename)) + (gets port) ; skip first line + (def forms (rep loop ((forms '())) + (def x (read port)) + (if (eof-object? x) + (sexpr-sequence->begin (rev! forms)) + (loop (pair x forms))))) + (force-out out) + (auto-eval forms (runtime-environment modname)))) + (dm load-in (filename| ct-env) (if (compiled-file? filename) (so-load filename) @@ -276,6 +288,7 @@ load-file parse-in read-file + read-script top do-stack-frames backtrace bt frame frame-var Index: src/eval/main.goo =================================================================== RCS file: /home/fn/src/cvs/goo/src/eval/main.goo,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 main.goo --- src/eval/main.goo 27 Nov 2003 09:49:14 -0000 1.1.1.1 +++ src/eval/main.goo 27 Nov 2003 19:18:36 -0000 @@ -44,20 +44,34 @@ (dv *goo-version* "0.155") (dv *goo-date* "NOV 17, 2003") -(post ";;; GOO\n") -(post ";;; JONATHAN BACHRACH\n") -(post ";;; MIT CSAIL\n") -(post ";;; %s\n" *goo-date*) -(post ";;; \n") -(post ";;; VERSION = %s\n" *goo-version*) -(post ";;; ROOT = %s\n" *goo-root*) -;; (post ";;; Loading Runtime Bindings...\n") -(init-ast) -;; (post ";;; Loading System Patches...\n") -(let ((file (find-goo-file-at "init" *goo-root*))) - (and file (load-file file 'goo/user))) -;; (post ";;; Loading User Patches...\n") -(let ((file (find-goo-file-at "init" *goo-personal-root*))) - (and file (load-file file 'goo/user))) -;; (post ";;; \n") -(top 'goo/user) +;; If the first element of (app-args) is --, the second element is +;; the script to be executed. We need to munge argc/argv to skip +;; those two elements, open the script, skip the first line, execute +(let ((args (app-args))) + (if (and (>= (len args) 1) (= (elt args 0) "--")) + (seq + (init-ast) + (let ((file (find-goo-file-at "init" *goo-root*))) + (and file (load-file file 'goo/user))) + (let ((file (find-goo-file-at "init" *goo-personal-root*))) + (and file (load-file file 'goo/user))) + ;; (post ";;; Loading Script...\n") + (post "%=" (read-script (elt args 1) 'goo/user))) + (seq + (post ";;; GOO\n") + (post ";;; JONATHAN BACHRACH\n") + (post ";;; MIT CSAIL\n") + (post ";;; %s\n" *goo-date*) + (post ";;; \n") + (post ";;; VERSION = %s\n" *goo-version*) + (post ";;; ROOT = %s\n" *goo-root*) + ;; (post ";;; Loading Runtime Bindings...\n") + (init-ast) + ;; (post ";;; Loading System Patches...\n") + (let ((file (find-goo-file-at "init" *goo-root*))) + (and file (load-file file 'goo/user))) + ;; (post ";;; Loading User Patches...\n") + (let ((file (find-goo-file-at "init" *goo-personal-root*))) + (and file (load-file file 'goo/user))) + ;; (post ";;; \n") + (top 'goo/user))))