Skip to content

Commit

Permalink
Implement /a || b/
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Aug 25, 2010
1 parent 6cc2651 commit 6c3c243
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/RxOp.pm
Expand Up @@ -195,6 +195,33 @@ use CgOp;
no Moose;
}

{
package RxOp::SeqAlt;
use Moose;
extends 'RxOp';

# zyg * N

sub op {
my ($self, $cn, $cont) = @_;

my $cni = Niecza::Actions->gensym;
my @terms;
for (@{ $self->zyg }) {
push @terms, Op::CallSub->new(
invocant => $self->_close_k($_->op($cn, $cont)),
positionals => [ Op::Lexical->new(name => $cni) ]);
}

$cni, Op::StatementList->new(children => \@terms);
}

sub lad { $_->zyg->[0]->lad }

__PACKAGE__->meta->make_immutable;
no Moose;
}

{
package RxOp::ConfineLang;
use Moose;
Expand Down
6 changes: 5 additions & 1 deletion test.pl
Expand Up @@ -2,7 +2,7 @@

use Test;

plan 386;
plan 392;

ok 1, "one is true";
ok 2, "two is also true";
Expand Down Expand Up @@ -905,3 +905,7 @@ ($rgx, $rgxname, @y, @n)
rxtest /<[ y ]>/, '<[ y ]>', ("y"), (" ", "x", "z");
rxtest /<[ i .. k ]>/, '<[ i .. k ]>', ("i", "j", "k"), ("h", "l");
rxtest /<[ \W a..z ]>/, '<[\W a..z]>', ("a", "z", "+"), ("\x4E00");
rxtest /a || b/, 'a || b', ("a", "b"), ("c", "");
rxtest /x [a || aa]: c/, 'x[a||b]:c', ("xac",), ("xaac",);

0 comments on commit 6c3c243

Please sign in to comment.