Hello, I've stumbled upon Perl6 a couple of weeks ago and I'm really looking forward to seeing the finished product. Currently, I'm trying to implement a perl-like rules module for Python, and I've got some questions which I think aren't covered in the Synopsis or anywhere else I looked, mostly concerning captures and aliases:
- Capture numbering: /(a) [ (b) (c) (d) | (e) & (f) ] (g)/ capture.t suggests something like $0 $1 $2 $3 $1 $2 $4, but I'm only guessing about the "&" bit. In the following, / (a) [ (b) (c) | $5 := (d) $0 := (e) ] (f) / does the first alias have any effect on where the f's will go (probably not)? - Which rules do apply to repeated captures with the same alias? For example, the second array aliasing example m:w/ Mr?s? @<names> := <ident> W\. @<names> := <ident> | Mr?s? @<names> := <ident> /; seems to suggests that by using $<names>, the lower branch would have resulted in a single Match object instead of an array (like the array we would have gotten if we hadn't used the aliases in the first place). Is this right? And could the same effect have been achieved by something like / $<names> := <indent>**{1} / ? - More array aliasing: is / mv @<files> := [...]* / just (slightly) shorter for / mv [$<files> := [...]]* / ? Likewise, could / @<pairs> := ( (\w+) \: (\N+) )+ / have also been written / [ $<pairs> := (\w+) \: $<pairs> := (\N+) ]+ / ? - Array and hash aliasing of quantified subpatterns or subrules: what happens to the named captures? / @<foo> := ( ... $bar := (...) ... )* / And if the subpattern or subrule ends with an alternation, can the number of array elements to be appended (or hashed) vary depending on whitch branch is taken? - Which of the following constructs could possibly be ok (I hope, none)? / $<foo> := ... & $<foo> := ... / / $<foo> := ... %<foo> := ... / / $<foo> := ... | %<foo> := ... / / $<foo> := $<foo> := ... / - Do aliases bind right-to-left, as do assignments? / $2 := $5 := ... / # next should be $3, not $6 - Which kind of escape sequences are allowed (or required) in enumerated character classes? Thanks in advance for any answers!