On Sun, Jun 09, 2002 at 03:34:16PM +1000, Damian Conway wrote:
> Trey Harris wrote:
> > rule val {
> >     [   # quoted
> >        $b := <['"]>
> >        ( [ \\. | . ]*? )
> >        $b
> >     ] | # or not
> >        (\H+)
> > }
> 
> Not quite. Assigning to $b is a capture. 

I'm confused. The examples in A5 all show $var := (pattern). So are you
saying that parens or no, binding with := affects a capture into
$1,$2,etc.? Or that it affects a capture that alters the return value
of the rule, just not $1,$2,etc.?

A5 says:

        Subrules called via <rule> also capture their result in
        hypothetical variables. It's possible to name the results of any
        <...>, but grammar rules already have a name by default, so you
        don't have to give them names unless you call the same rule more
        than once. So, presuming you have grammar rules defining "key"
        and "value", you can say:

                / <key> \: <value> { let %hash{$key} = $value } /

So ... should this work?

        rule quote      { <["']> }
        rule quotedword { <quote> (<alpha>+) $quote }
        $justtheword = /<quotedword>/;

And if the above works, why can't "$var:=atom" be a short hand for a
lexical "rule var { atom }" that only applies for the current ... um ...
rule/<insert more appropriate word>? And thus the capture would be out
of band WRT $1, $2, etc. or the rule's return value.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to