From 773fb58ca505c7ec80ab5ce4a16ebb26810b4cbf Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Sun, 5 Sep 2010 22:38:04 -0700 Subject: [PATCH] [nrx] Reimplement :sigspace --- src/RxOp.pm | 12 +++--------- test2.pl | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/RxOp.pm b/src/RxOp.pm index e3d674b1..f81cb6ea 100644 --- a/src/RxOp.pm +++ b/src/RxOp.pm @@ -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 { diff --git a/test2.pl b/test2.pl index ade15034..07d93856 100644 --- a/test2.pl +++ b/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"; @@ -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 { } -# regex moo { x } -# } -# -# ok G3.parse("x"), "capturing subrules work (positive)"; -# ok !G3.parse("y"), "capturing subrules work (negative)"; + my grammar G3 { + regex TOP { } + regex moo { x } + } + + ok G3.parse("x"), "capturing subrules work (positive)"; + ok !G3.parse("y"), "capturing subrules work (negative)"; } { @@ -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"; } # # {