Skip to content

Commit

Permalink
Fix remaining bugs in regex engine
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jul 20, 2010
1 parent 1dc23fa commit 534e6b4
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion rxwork.pl
Expand Up @@ -6,6 +6,23 @@
method from() { $!from }
}

PRE-INIT {
Mu.HOW.add-method(Q:CgOp { (w (clr_string "flat")) },
anon method flat() { self, });
Parcel.HOW.add-method(Q:CgOp { (w (clr_string "flat")) },
anon method flat() {
my @x := self;
List.RAWCREATE("flat", 1, "items", LLArray.new(),
"rest", LLArray.new(@x));
});
List.HOW.add-method(Q:CgOp { (w (clr_string "flat")) },
anon method flat() {
my @x := self;
List.RAWCREATE("flat", 1, "items", LLArray.new(),
"rest", LLArray.new(@x));
});
}

sub _rxlazymap($cs, $sub) {
my class LazyIterator is Iterator {
method back() { $!back }
Expand All @@ -17,9 +34,11 @@ ($cs, $sub)
}
my $bv = $!back.value;
my $bn = $!back.next;
#say "In lazy map iterator";
if $bv.^isa(EMPTY) {
$!value = EMPTY;
} else {
#say "Going to pass " ~ $bv;
my $f = $!fun;
# XXX horrible. we're making the value act @-ish, maybe
Q:CgOp {
Expand All @@ -37,7 +56,7 @@ ($cs, $sub)
my $lit = LazyIterator.RAWCREATE("valid", 0, "value", Any,
"next", Any, "back", Any, "fun", $sub);
$lit.back = $cs.iterator;
$lit.back = $cs.flat.iterator;
my @l := List.RAWCREATE("flat", 1, "items", LLArray.new(), "rest",
LLArray.new($lit));
Expand All @@ -50,6 +69,7 @@ ($C, $sub)
}

sub _rxstr($C, $str) {
#say "_rxstr : " ~ ($C.str ~ (" @ " ~ ($C.from ~ (" ? " ~ $str))));
if $C.from + $str.chars <= $C.str.chars &&
$C.str.substr($C.from, $str.chars) eq $str {
Cursor.RAWCREATE("str", $C.str, "from", $C.from + $str.chars);
Expand All @@ -71,6 +91,7 @@ ($str)
if rxtest($C) {
$win = 1;
}
$i++;
}
say $str ~ (" ... " ~ $win);
}
Expand Down

0 comments on commit 534e6b4

Please sign in to comment.