Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New test for proto tokens

git-svn-id: http://svn.pugscode.org/pugs@29908 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit ad9a7700a0280cb8ded67bfa8745bc5d667dcc2d 1 parent 63d92ff
bkeeler authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 S05-grammar/protos.t
View
31 S05-grammar/protos.t
@@ -0,0 +1,31 @@
+use v6;
+
+use Test;
+
+plan 4;
+
+# L<S05/Variable (non-)interpolation/Alternatively, if you predeclare a proto regex>
+
+grammar Grammar::With::Protos {
+ token TOP {
+ <fred>+
+ }
+
+ proto token fred { <...> }
+
+ token fred:sym<foo> {
+ <sym> \d+
+ }
+ token fred:sym<bar> {
+ <sym> :s 'boz'+
+ }
+}
+
+my $m = Grammar::With::Protos.parse("foo23bar bozboz foo42");
+
+ok($m, 'parse succeeded');
+is(~$m<fred>[0], "foo23", "Submatch 1 correct");
+is(~$m<fred>[1], "bar bozboz ", "Submatch 2 correct");
+is(~$m<fred>[2], "foo42", "Submatch 3 correct");
+
+# vim: ft=perl6
Please sign in to comment.
Something went wrong with that request. Please try again.