pugs-comm...@feather.perl6.nl wrote:
> Author: lwall
> Date: 2009-03-19 01:43:53 +0100 (Thu, 19 Mar 2009)
> New Revision: 25902
> 
> Modified:
>    docs/Perl6/Spec/S05-regex.pod
> Log:
> [S05] define .caps and .chunks methods on match objects
> 
> 
> Modified: docs/Perl6/Spec/S05-regex.pod
> ===================================================================
[...]
> @@ -2547,6 +2547,9 @@
>      $/.chars # $/.to - $/.from
>      $/.orig  # the original match string
>      $/.Str   # substr($/.orig, $/.from, $/.chars)
> +    $/.ast      # the abstract result associated with this node
> +    $/.caps     # sequential captures
> +    $/.chunks   # sequential tokenization
>  
>  Within the regex the current match state C<$ยข> also provides
>  
> @@ -2558,6 +2561,18 @@
>  
>  =item *
>  
> +As described above, a C<Match> in list context returns its positional
> +captures.  However, sometimes you'd rather get a flat list of tokens in
> +the order they occur in the text.  The C<.caps> method returns a list
> +of every captured item, regardless of how it was otherwise bound into
> +named or numbered captures.  The C<.chunks> method returns the captures
> +as well as all the interleaved "noise" between the captures. [Conjecture:
> +we could also have C<.deepcaps> and C<.deepchunks> that recursively expand
> +any capture containing submatches.  Presumably each returned chunk would
> +come equipped with some method to discover its "pedigree" in the parse tree.]

Could you elaborate on the "items" you are talking about? simple strings
for non-captures and Match objects for captures? Or pairs of the form
$name => $capture or $number => $capture for captures?

(Either way is fine by me, I just want to know how to write the tests ;-)

Cheers,
Moritz

Reply via email to