kiyokaのブログアーカイブ

Archive of old blog posts

matchライブラリのデバッグ中

オレ処理系の[Nendo]についての開発メモ。 img let-syntaxの実装がだいぶ進んだ。 現在はchibi-scheme 0.3のmatchライブラリであるmacth.scmを変更無しで動かそうとしている。 あと、もうすこしで動きそうなんだけどなー。

chibi-scheme 0.3のテストスイートを動かしてみたら、半分以上は動いている。が、なにかが間違っている。 syntax-rulesのパターン部に

'symbol

のようなS式が来ると、正しくマッチしないようだ。 ほかにも、一部のsyntax-rulesの再起定義において、マクロ展開が無限に行われ、S式が際限なく成長してしまうという問題がある。 うーん。マクロのデバッグは本当に難しい…

テストスイートのソースコード

(match-test* "any" (match 'any (_ 'ok)) 'ok)
(match-test* "symbol" (match 'ok (x x)) 'ok)
(match-test* "number" (match 28 (28 'ok)) 'ok)
(match-test* "string" (match "good" ("bad" 'fail) ("good" 'ok)) 'ok)
  .
 (略)
  .
  .

実行結果 (問題のあるテストケースはpendingにして通している)

<match>------------------------------------------------------------------------
test any, expects ok ==> ok
test symbol, expects ok ==> ok
test number, expects ok ==> ok
test string, expects ok ==> ok
(pending) *literal symbol*
test null, expects ok ==> ok
test pair, expects ok ==> ok
test vector, expects ok ==> ok
test any doubled, expects ok ==> ok
test and empty, expects ok ==> ok
test and single, expects ok ==> ok
test and double, expects ok ==> ok
test or empty, expects ok ==> ok
test or single, expects ok ==> ok
(pending) *or double*
test not, expects ok ==> ok
test pred, expects ok ==> ok
test named pred, expects 29 ==> ok
test duplicate symbols pass, expects ok ==> ok
test duplicate symbols fail, expects ok ==> ok
(pending) *duplicate symbols samth*
test ellipses, expects ((a b c) (1 2 3)) ==> ok
test real ellipses, expects ((a b c) (1 2 3)) ==> ok
(pending) *vector ellipses*
(pending) *pred ellipses*
(pending) *failure continuation*
test let, expects (o k) ==> ok
test let*, expects (f o o f) ==> ok
test getter car, expects (1 2) ==> ok
test getter cdr, expects (1 2) ==> ok
test getter vector, expects (1 2 3) ==> ok
test setter car, expects (3 . 2) ==> ERROR: GOT (1 . 2)
test setter cdr, expects (1 . 3) ==> ERROR: GOT (1 . 2)
test setter vector, expects #(1 0 3) ==> ERROR: GOT #(1 2 3)
(pending) *single tail*
(pending) *single tail 2*
(pending) *multiple tail*
(pending) *Riastradh quasiquote*
test trivial tree search, expects (1 2 3) ==> ok
test simple tree search, expects (1 2 3) ==> ok
test deep tree search, expects (1 2 3) ==> ok
test non-tail tree search, expects (1 2 3) ==> ok
(pending) *restricted tree search*
test fail restricted tree search, expects #f ==> ok
(pending) *sxml tree search*
(pending) *failed sxml tree search*
(pending) *collect tree search*
failed.
discrepancies found.  Errors are:
test setter car: expects (3 . 2) => got (1 . 2)
test setter cdr: expects (1 . 3) => got (1 . 2)
test setter vector: expects #(1 0 3) => got #(1 2 3)
cat test.record
Total:    33 tests,    30 passed,     3 failed,     0 aborted.

処理系を実装するというのは、絶壁を登るような感じに似ている。 [Nendo]ではライブラリは自分で実装せず、chibi-schemeやGaucheのライブラリをなるべく変更無しで動かすという方針を取っている。 そのおかげで、自分のスキルが上がるよりも先に課題の難易度が上がってしまうのだ。

しかし、思えば高いところまで来たもんだ… でも、まだまだ頂上は見えず、この崖はどこまで続くのやら。