> Now, could you just do
>
> rule leftop ($leftop, $op) {
> <$leftop> [$op <$leftop>]*
> }
>
> rule leftop ($leftop, $op, $rightop) {
> <$leftop> [$op <$rightop>]*
> }
I should hope that rules can take multiple arguments. Here's something
that made me wonder, though: the <$leftop> there is meant to call a rule.
But, that syntax -- <$whatever> -- is how you embed a regex in another
regex. So how do we know that $leftop is not a regex wanting to match
"atom"? How do we force it to be a rule call? Is it like <$leftop:>?
But back to this: If <$leftop:> is a rule call, I'd want to see it like
this:
rule leftop ($leftop, $op) { <$leftop:> [<$op> <$leftop:>]* }
Because I want to give a regex as an op, rather than a string.
What about capturing? What does $leftop contain after a call to
<leftop ...>? If it's not a list, how do you make it contain a list? So
many questions....... or am I just suffering from A5 forgetfulness?
I know you heavyweights are working out how to specify the return value
from a rule or a capture. Can you do this?
rule leftop ($leftop, $op) {
@rands := [ (<$leftop:>) [ <$op> (<$leftop:>) ] ] {
return \@rands;
}
}
That could work well for rules. Could you do the same for captures?
/ ( @foo := [ (<atom> and) ] { return \@foo } ) {
$1[1] # Second atom
} /
I still thing P6 regexen are gorgeous :)
Luke