diff --git a/src/QRegex/P5Regex/Actions.nqp b/src/QRegex/P5Regex/Actions.nqp index 59a639237f..4f798c38af 100644 --- a/src/QRegex/P5Regex/Actions.nqp +++ b/src/QRegex/P5Regex/Actions.nqp @@ -190,6 +190,20 @@ class QRegex::P5Regex::Actions is HLL::Actions { QAST::SVal.new( :value(~$ - 1) ) ) ); } } + + method p5assertion:sym«<»($/) { + if $ { + make QAST::Regex.new( + :rxtype, :subtype, :negate($ eq '!'), :node($/), + QAST::Node.new( + QAST::SVal.new( :value('after') ), + qbuildsub(self.flip_ast($.ast), :anon(1), :addself(1)) + )); + } + else { + make 0; + } + } method p5assertion:sym<=>($/) { if $ { @@ -362,6 +376,22 @@ class QRegex::P5Regex::Actions is HLL::Actions { nqp::deletekey(%capnames, '$!to'); %capnames; } + + method flip_ast($qast) { + return $qast unless nqp::istype($qast, QAST::Regex); + if $qast.rxtype eq 'literal' { + $qast[0] := $qast[0].reverse(); + } + elsif $qast.rxtype eq 'concat' { + my @tmp; + while +@($qast) { @tmp.push(@($qast).shift) } + while @tmp { @($qast).push(self.flip_ast(@tmp.pop)) } + } + else { + for @($qast) { self.flip_ast($_) } + } + $qast + } # XXX Below here copied from p6regex; needs review @@ -549,20 +579,4 @@ class QRegex::P5Regex::Actions is HLL::Actions { else { $ast.name($name); } $ast.subtype('capture'); } - - method flip_ast($qast) { - return $qast unless nqp::istype($qast, QAST::Regex); - if $qast.rxtype eq 'literal' { - $qast[0] := $qast[0].reverse(); - } - elsif $qast.rxtype eq 'concat' { - my @tmp; - while +@($qast) { @tmp.push(@($qast).shift) } - while @tmp { @($qast).push(self.flip_ast(@tmp.pop)) } - } - else { - for @($qast) { self.flip_ast($_) } - } - $qast - } } diff --git a/src/QRegex/P5Regex/Grammar.nqp b/src/QRegex/P5Regex/Grammar.nqp index 8ae4401657..0c92a34059 100644 --- a/src/QRegex/P5Regex/Grammar.nqp +++ b/src/QRegex/P5Regex/Grammar.nqp @@ -88,6 +88,7 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar { proto token p5assertion { <...> } + token p5assertion:sym«<» { $=['='|'!'] [ | ] } token p5assertion:sym<=> { [ | ] } token p5assertion:sym { [ | ] }