Skip to content

Commit

Permalink
Implement :!s-like modifiers and fix null subregexes
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jul 25, 2010
1 parent efc2334 commit 78b17bb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
32 changes: 28 additions & 4 deletions Niecza/Actions.pm
Expand Up @@ -29,6 +29,7 @@ sub AUTOLOAD {
}

sub ws { }
sub normspace { }
sub vws { }
sub unv { }
sub begid { }
Expand Down Expand Up @@ -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});
}
}

Expand Down Expand Up @@ -328,16 +330,38 @@ 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) = @_;
if (! $M->{quote}{_ast}->isa('Op::StringLiteral')) {
$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')) {
Expand Down
6 changes: 4 additions & 2 deletions RxOp.pm
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 78b17bb

Please sign in to comment.