Wednesday, May 10, 2006

May 10th, 2006 -- Variables! Tests!

As I mentionedyesterday, Makefile.PL and a basic test file were added. But there were still something missing. I fixed the t/basic.t so that the test really passes. And the last two tests are corrected by updating the to the one I used which deal with backslashes correctly.

On the another hand, I originally planned to support statements more than a single "return." But I dropped the idea due to two reasons:

  1. I was not familiar enough to rules to write the grammar.

  2. Translating general statements to Haskell is not straight forward.

But I implemented an alternative: temporary variables.

Assignment is not provided so variables can be translated to a simple "let ... in ..." expression, pure lambda one. The old yada example can now be written as
rule yadaLiteral {
$<sym> := [ <'...'> | <'???'> | <'!!!'> ]
{ my $yada = doYada( $<sym> );
my $err = Val( VStr( $<sym> ~ " - not yet implemented") );
return App(
Var( $yada ),
[ $err ]
and translated into (the production rule part)
let yada = (doYada sym) in
let err = (Val (VStr (sym ++ " - not yet implemented"))) in
return $ (App (Var yada) Nothing [err])

Final notes:

  • Now it takes nearly three minutes for to translate the grammar to .pm file.

  • There are three kinds of variables now: named capture, numbered capture, and temporary. Some renaming (prefix or suffix adding) may be performed to prevent conflict.


Post a Comment

Links to this post:

Create a Link

<< Home