Mosh に psyntaxを移植しよう その1

The portable R6RS library and syntax-case system」を Mosh に移植しよう!。

スタート

pre-built な psyntax.pp を Mosh で実行し unbound variable を足していく。

./mosh tools/psyntax-r6rs/pre-built/psyntax-gosh.pp

void の定義を追加

void:  The procedure void is used in the output of the expander when
we don't care about a value (e.g. to provide the initial values for
the letrec*/internal-defines).  A call to void should not signal any
errors.  (define (void) (if #f #f)) suffices for this purpose.

という訳なので定義。

(define (void) (if #f #f))

eval-core の定義を追加

eval-core:  This procedure should take a core s-expression and
evaluate it in a "top-level" environment.  R5RS implementations can
define it as 
(define (eval-core x) (eval x (interaction-environment)))

ふむふむ。

(define (eval-core x) (eval x '()))

スタックオーバーフロー

うぎゃ。スタックオーバーフローに。
とりあえずスタックサイズを200万にした(ぉ。

実行

r6rs psyntax ready
provide a script name argument

と出たよ。

./mosh ./tools/psyntax-r6rs/pre-built/psyntax-mosh.pp ./tools/psyntax-r6rs/examples/hello-world.ss
    error : ("invalid syntax of top-level program")
      ./tools/psyntax-r6rs/pre-built/psyntax-mosh.pp:23: (<proc>) 

うむむ。
明日はここから調べる。
Gauche 用に簡単に pre-built できるようにしてデバッグしよう。