Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Draft the rest of the regex primitives needed here
  • Loading branch information
sorear committed Jul 20, 2010
1 parent 69370b6 commit 90ad541
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions rxwork.pl
Expand Up @@ -5,9 +5,6 @@
method from() { $!from }
}

sub _rxstar($¢, $sub) {
}

sub _rxlazymap($cs, $sub) {
my class LazyIterator is Iterator {
# $!valid $!value $!next $!fun $!back
Expand All @@ -23,20 +20,32 @@ ($cs, $sub)
Q:CgOp {
(prog
(setindex value (getfield slots (cast DynObject (@ (l self))))
(callsub (@ (l $f)) (l $bv)))
(subcall (@ (l $f)) (l $bv)))
(null Variable))
};
$!next = LazyIterator.RAWCREATE("valid", 0, "next", Any,
"value", Any, "back", $nb, "fun", $!fun);
}
}
List.RAWCREATE("flat", 1, "items", LLArray.new(), "rest",
my @l := List.RAWCREATE("flat", 1, "items", LLArray.new(), "rest",
LLArray.new(LazyIterator.new("valid", 0, "value", Any, "next", Any,
"back", $cs.iterator, "fun", $fun)));
@l.fill(1);
@l;
}

sub _rxstar($¢, $sub) {
_lazymap($sub($¢), sub ($¢) { _rxstar($¢, $sub) }), $¢
}

sub _rxstr($¢, $str) {
if.from + $str.chars <=.str.chars &&
.str.substr($¢.from, $str.chars) eq $str {
Cursor.RAWCREATE("str", $¢.str, "from", $¢.from + $str.chars);
} else {
Nil;
}
}

# regex { a b* c }
Expand Down

0 comments on commit 90ad541

Please sign in to comment.