gencomp 確認
普通の gauche が読めません。色々な意味で時間かかりそげ。
とりあえずトップダウンで見てみます。
;;================================================================
;; Entry
;;
(define (main args)
(let-args (cdr args)
((keep-private-macro "keep-private-macro=s" #f)
(ext-module "ext-module=s" #f)
(output-base "o|output=s" #f)
. args)
(when keep-private-macro
(private-macros-to-keep
(map string->symbol (string-split keep-private-macro #\,))))
(match args
((scmfile)
(when ext-module
(ext-module-file (ensure-ext-module-file ext-module)))
(do-it scmfile (or output-base
(sys-basename (path-sans-extension scmfile))))
(when ext-module (close-output-port (ext-module-file))))
(else (print "Usage: gosh gencomp [--keep-macro] <file.scm>")
(exit 0)))
0))まず、let-args から。こことか。同じカンジのナニを試してみる。
$ cat test.scm
(use gauche.parseopt)
(define (main args)
(let-args (cdr args)
((keep-private-macro "keep-private-macro=s" #f)
(ext-module "ext-module=s" #f)
(output-base "o|output=s" #f)
. args)
(print keep-private-macro)
(print ext-module)
(print output-base)
(print args)))
$実行してみました。
$ gosh ./test.scm test.scm #f #f #f (test.scm) $
ええともう少し色々試験。
$ gosh ./test.scm --keep-private-macro=abcde abcde #f #f () $ gosh ./test.scm --keep-private-macro=abcde test.scm abcde #f #f (test.scm) $
ケツの _. args_ が微妙。順番は大切な模様。もう少し試験。
$ gosh ./test.scm --output=xxx.c --keep-private-macro=abcde test.scm abcde #f xxx.c (test.scm) $ gosh ./test.scm -o xxx.c --keep-private-macro=abcde test.scm abcde #f xxx.c (test.scm) $
むむ。あ、あと scmfile ってのも微妙だったので以下をナニ。最初は util.match を use してなくてハマりました。以下なソレが
(use util.match)
(use gauche.parseopt)
(define (main args)
(let-args (cdr args)
((keep-private-macro "keep-private-macro=s" #f)
(ext-module "ext-module=s" #f)
(output-base "o|output=s" #f)
. args)
(print keep-private-macro)
(print ext-module)
(print output-base)
(match args
((scmfile)
(print scmfile)))))こんなカンジでナニ。
$ gosh ./test.scm test.scm #f #f #f test.scm $
when という構文も知らなかったんですが、凄いコアな命令使ってそうで怖い。ってか読んでく速度が微妙スギです。上記のメモ以外にも試行錯誤が盛り沢山ッス。
とりあえず do-it に渡される base って -o が略だったら、って試験してみれば良いのですね ...
gosh> (use file.util) #<undef> gosh> (sys-basename (path-sans-extension "xxx.scm")) gosh>
なんか進捗微妙ですが、台所仕事がある && 仕事なソレがあるみたいなんで一旦ヤメ。とりあえず次の do-it へのとっかかりにはなっているのか。