Permalink
Browse files

subrule capturing, RT #107254

  • Loading branch information...
1 parent 8fb35f5 commit 18e1f8066c7ec7becefeba21289d1a28b22fb311 @moritz moritz committed May 17, 2012
Showing with 20 additions and 1 deletion.
  1. +20 −1 S05-capture/subrule.t
View
21 S05-capture/subrule.t
@@ -12,7 +12,7 @@ be valid perl6.
=end pod
-plan 38;
+plan 44;
# L<S05/Match objects/When used as a hash>
@@ -88,4 +88,23 @@ is(~$/<caprep>[0], "abcabcabcabc", 'Caprep abc one captured');
'can use $/ and subrule capture in embeeded code block';
}
+# RT #107254
+{
+ grammar G {
+ rule TOP { ^ <w1> <w2>? <w3>? $ }
+ token w1 { \w+ }
+ token w2 { \w+ }
+ token w3 { \w+ }
+ }
+ ok G.parse('one two three'), 'basic grammar sanity';
+ is $/, 'one two three', 'matched the whole string';
+ is $<w1 w2 w3>.map({ "[$_]" }).join(' '), '[one] [two] [three]',
+ 'right sub captures';
+
+ ok G.parse('one two'), 'basic grammar sanity part two';
+ is $<w1>, 'one', 'got the right sub caputre for ordinary subrule';
+ is $<w2>, 'two', 'got the right sub capture for quantified subrule';
+
+}
+
# vim: ft=perl6

0 comments on commit 18e1f80

Please sign in to comment.