Sunday, April 30, 2006

April 30th, 2006 -- Small improvement

There is a course project deadline on midnight today (several minutes before). It took I and my partner about 50+ hours each. However, we've done it in time.

Since the rule ProductionRule consist of Statements and Return goes into infinite loop (I'm not sure, but I don't want to wait any more), I currently restrict it to have only a return statement. And I played with capture aliasing and quantified subpattern captures in Pugs::Compiler::Rule. It basically works but seems to have some problem on deeper matching?

I have a (self recursive) rule
rule AdditiveExpr {
<FunctionAppExpr> <ws>?
[ $<op> := (\+ | \- | ~) <ws>?
$<rhs> := (<AdditiveExpr>) <ws>? ]?
{ use v5;
return "(" . $<FunctionAppExpr>() . " " . $<op>[0] . " " . $<rhs>[0] . ")";
return $<FunctionAppExpr>();
This works for matching "$<a> + t" there both terms can be matched by FunctionAppExpr, but when I feed "$<a> + t + 3", the "+ 3" part disappeared.

But some good news. r10165 can translate "return $<a> + t" to "return $ (a + t)", which valid Haskell and is what I want.


Post a Comment

Links to this post:

Create a Link

<< Home