Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Lookahead, positive and negative.

  • Loading branch information...
commit 2d70bfa342b48ef2da83b44f6f24ca0c2d907947 1 parent 94286df
@jnthn jnthn authored
Showing with 31 additions and 0 deletions.
  1. +28 −0 src/QRegex/P5Regex/Actions.nqp
  2. +3 −0  src/QRegex/P5Regex/Grammar.nqp
View
28 src/QRegex/P5Regex/Actions.nqp
@@ -178,7 +178,35 @@ class QRegex::P5Regex::Actions is HLL::Actions {
QAST::SVal.new( :value(~$<number> - 1) ) ) );
}
}
+
+ method p5assertion:sym<=>($/) {
+ if $<nibbler> {
+ make QAST::Regex.new(
+ :rxtype<subrule>, :subtype<zerowidth>, :node($/),
+ QAST::Node.new(
+ QAST::SVal.new( :value('before') ),
+ qbuildsub($<nibbler>.ast, :anon(1), :addself(1))
+ ));
+ }
+ else {
+ make 0;
+ }
+ }
+ method p5assertion:sym<!>($/) {
+ if $<nibbler> {
+ make QAST::Regex.new(
+ :rxtype<subrule>, :subtype<zerowidth>, :negate(1), :node($/),
+ QAST::Node.new(
+ QAST::SVal.new( :value('before') ),
+ qbuildsub($<nibbler>.ast, :anon(1), :addself(1))
+ ));
+ }
+ else {
+ make 0;
+ }
+ }
+
method p5mods($/) {
for nqp::split('', ~$<on>) {
%*RX{$_} := 1;
View
3  src/QRegex/P5Regex/Grammar.nqp
@@ -88,6 +88,9 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {
proto token p5assertion { <...> }
+ token p5assertion:sym<=> { <sym> [ <?before ')'> | <nibbler> ] }
+ token p5assertion:sym<!> { <sym> [ <?before ')'> | <nibbler> ] }
+
token p5mod { <[imox]>* }
token p5mods { <on=p5mod> [ '-' <off=p5mod> ]? }
token p5assertion:sym<mod> {
Please sign in to comment.
Something went wrong with that request. Please try again.