From 78b17bb81e1199fab9f3c61ddadb5c4fce2cd5a2 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Sun, 25 Jul 2010 01:03:53 -0700 Subject: [PATCH] Implement :!s-like modifiers and fix null subregexes --- Niecza/Actions.pm | 32 ++++++++++++++++++++++++++++---- RxOp.pm | 6 ++++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Niecza/Actions.pm b/Niecza/Actions.pm index 0f2d2dbb..aa5971b5 100644 --- a/Niecza/Actions.pm +++ b/Niecza/Actions.pm @@ -29,6 +29,7 @@ sub AUTOLOAD { } sub ws { } +sub normspace { } sub vws { } sub unv { } sub begid { } @@ -189,7 +190,8 @@ sub atom { my ($cl, $M) = @_; if ($M->{metachar}) { $M->{_ast} = $M->{metachar}{_ast}; } else { - $M->{_ast} = RxOp::String->new(text => $M->Str); + $M->{_ast} = RxOp::String->new(text => $M->Str, + igcase => $::RX{i}, igmark => $::RX{a}); } } @@ -328,7 +330,8 @@ sub metachar__S_Single_Single { my ($cl, $M) = @_; $M->sorry("Interpolating strings in regexes NYI"); return; } - $M->{_ast} = RxOp::String->new(text => $M->{quote}{_ast}->text); + $M->{_ast} = RxOp::String->new(text => $M->{quote}{_ast}->text, + igcase => $::RX{i}, igmark => $::RX{a}); } sub metachar__S_Double_Double { my ($cl, $M) = @_; @@ -336,8 +339,29 @@ sub metachar__S_Double_Double { my ($cl, $M) = @_; $M->sorry("Interpolating strings in regexes NYI"); return; } - $M->{_ast} = RxOp::String->new(text => $M->{quote}{_ast}->text); -} + $M->{_ast} = RxOp::String->new(text => $M->{quote}{_ast}->text, + igcase => $::RX{i}, igmark => $::RX{a}); +} + +# These have effects only in the parser, so undef ast is correct. +sub mod_value {} +sub mod_internal {} +sub mod_internal__S_Coloni {} +sub mod_internal__S_ColonBangi {} +sub mod_internal__S_ColoniParen_Thesis {} +sub mod_internal__S_Colon0i {} +sub mod_internal__S_Colons {} +sub mod_internal__S_ColonBangs {} +sub mod_internal__S_ColonsParen_Thesis {} +sub mod_internal__S_Colon0s {} +sub mod_internal__S_Colonr {} +sub mod_internal__S_ColonBangr {} +sub mod_internal__S_ColonrParen_Thesis {} +sub mod_internal__S_Colon0r {} +sub mod_internal__S_Colona {} +sub mod_internal__S_ColonBanga {} +sub mod_internal__S_ColonaParen_Thesis {} +sub mod_internal__S_Colon0a {} sub nibbler { my ($cl, $M) = @_; if ($M->isa('STD::Regex')) { diff --git a/RxOp.pm b/RxOp.pm index 7c5d5546..7fbf7511 100644 --- a/RxOp.pm +++ b/RxOp.pm @@ -8,7 +8,7 @@ use CgOp; package RxOp; use Moose; - has zyg => (isa => 'ArrayRef[RxOp]', is => 'ro'); + has zyg => (isa => 'ArrayRef[RxOp]', is => 'ro', default => sub { [] }); my $i = 0; sub _closurize { @@ -110,7 +110,9 @@ use CgOp; positionals => [ $l, $self->_closurize($r) ]); } - $zyg[0] || Op::Lexical->new(name => '$¢'); + $zyg[0] || Op::CallSub->new( + invocant => Op::Lexical->new(name => '&_rxone'), + positionals => [ Op::Lexical->new(name => '$¢') ]); } __PACKAGE__->meta->make_immutable;