Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Add character class composition.
  • Loading branch information
pmichaud committed Oct 13, 2009
1 parent f00fd0d commit 8743056
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Regex/P6Regex/Actions.pm
Expand Up @@ -277,9 +277,29 @@ method assertion:sym<name>($/) {
}

method assertion:sym<[>($/) {
make $<cclass_elem>[0].ast;
my $clist := $<cclass_elem>;
my $past := $clist[0].ast;
if $past.negate {
$past := PAST::Regex.new(
$past,
PAST::Regex.new( :pasttype('charclass'), :subtype('.') )
);
}
my $i := 1;
my $n := +$clist;
while $i < $n {
my $ast := $clist[$i].ast;
if $ast.negate {
$past := PAST::Regex.new( $ast, $past, :pasttype('concat') );
}
else {
$past := PAST::Regex.new( $past, $ast, :pasttype('alt') );
}
$i := $i + 1;
}
make $past;
}

method cclass_elem($/) {
my $str := '';
my $past;
Expand Down

0 comments on commit 8743056

Please sign in to comment.