Skip to content

Commit

Permalink
[nrx] Reimplement :sigspace
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Sep 6, 2010
1 parent 6d0d084 commit 773fb58
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
12 changes: 3 additions & 9 deletions src/RxOp.pm
Expand Up @@ -318,15 +318,9 @@ use CgOp;
use Moose;
extends 'RxOp';

sub op {
my ($self, $cn, $cont) = @_;
my $icn = Niecza::Actions->gensym;
$icn, Op::CallSub->new(
invocant => Op::Lexical->new(name => '&_rxcall'),
positionals => [
Op::CallMethod->new(name => 'ws',
receiver => Op::Lexical->new(name => $icn)),
$self->_close_k($cn, $cont)]);
sub code {
my ($self, $body) = @_;
RxOp::Subrule->new(name => 'ws')->code($body);
}

sub lad {
Expand Down
34 changes: 17 additions & 17 deletions test2.pl
@@ -1,7 +1,7 @@
# vim: ft=perl6
use Test;

#ok '{}' ~~ / \{ <.ws> \} /, 'ws matches between \W';
ok '{}' ~~ / \{ <.ws> \} /, 'ws matches between \W';

{
ok ("a" ~~ /a/), "letter matches itself";
Expand Down Expand Up @@ -48,13 +48,13 @@
ok G2.parse("yxxy"), "subrule position tracking works";
ok !G2.parse("yxy"), "subrule position tracking works (2)";

# my grammar G3 {
# regex TOP { <moo> }
# regex moo { x }
# }
#
# ok G3.parse("x"), "capturing subrules work (positive)";
# ok !G3.parse("y"), "capturing subrules work (negative)";
my grammar G3 {
regex TOP { <moo> }
regex moo { x }
}

ok G3.parse("x"), "capturing subrules work (positive)";
ok !G3.parse("y"), "capturing subrules work (negative)";
}

{
Expand All @@ -65,15 +65,15 @@
ok !("aab" ~~ /:r a*: ab/), "ratcheting a*: ab does not";
ok ("aab" ~~ /:r a*! ab/), "ratcheting a*! ab does";
ok !("aab" ~~ token { a* ab }), "a* ab in a token does not";
#
# ok ("ab ab" ~~ / ab <.ws> ab /), "ws matches a space";
# ok (q:to/end/ ~~ / ab <.ws> ab /), "ws matches a newline";
# ab
# ab
# end
# ok ("ab ab" ~~ / ab <.ws> ab /), "ws matches several spaces";
# ok !("abab" ~~ / ab <.ws> ab /), "ws does not match nothing";
# ok ("ab ab" ~~ rule { ab ab }), "rule gives space";

ok ("ab ab" ~~ / ab <.ws> ab /), "ws matches a space";
ok (q:to/end/ ~~ / ab <.ws> ab /), "ws matches a newline";
ab
ab
end
ok ("ab ab" ~~ / ab <.ws> ab /), "ws matches several spaces";
ok !("abab" ~~ / ab <.ws> ab /), "ws does not match nothing";
ok ("ab ab" ~~ rule { ab ab }), "rule gives space";
}
#
# {
Expand Down

0 comments on commit 773fb58

Please sign in to comment.