Skip to content

Commit 5680b10

Browse files
committed
Fix NFA construction for the empty literal, so / '' / now gets its NFA built properly. Gets 45-smartmatch.t building and passing again.
1 parent a915744 commit 5680b10

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/QRegex/NFA.nqp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ class QRegex::NFA {
105105
my $litconst := $node[0];
106106
my $litlen := nqp::chars($litconst) - 1;
107107
my $i := 0;
108-
while $i < $litlen {
109-
$from := self.addedge($from, -1, $EDGE_CODEPOINT, nqp::ord($litconst, $i));
110-
$i := $i + 1;
108+
if $litlen >= 0 {
109+
while $i < $litlen {
110+
$from := self.addedge($from, -1, $EDGE_CODEPOINT, nqp::ord($litconst, $i));
111+
$i := $i + 1;
112+
}
113+
self.addedge($from, $to, $EDGE_CODEPOINT, nqp::ord($litconst, $i));
114+
}
115+
else {
116+
self.addedge($from, $to, $EDGE_EPSILON, 0);
111117
}
112-
self.addedge($from, $to, $EDGE_CODEPOINT, nqp::ord($litconst, $i));
113118
}
114119

115120
method subrule($node, $from, $to) {

0 commit comments

Comments
 (0)