diff options
-rwxr-xr-x | src/mum | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -14,26 +14,30 @@ open my $tty, '+<:unix', '/dev/tty' or die "Could not open /dev/tty: $!"; # Define range syntax my @range; # range (one/two references) -our %ref; # current reference in range +our %ref; # current reference my $d = qr{ (?(DEFINE) - (?<range> (?{ @range = () }) + (?<range> (?{ @range = () }) ( (?&ref) | (?&ref),(?&ref) - | (?&pattern) + | (?&grep) ) - (?{ push @range, \%ref }) + (?{ push @range, \%ref }) ) - (?<ref> ( (\d+) (?{ local %ref = (line => $^N) }) - | (\.|\$) (?{ local %ref = (spec => $^N) }) - | ' ([a-z]) (?{ local %ref = (mark => $^N) }) - | /((\\/|[^/])*)/ (?{ local %ref = (next => $^N) }) - | \?((\\\?|[^?])*)\? (?{ local %ref = (prev => $^N) }) + (?<ref> ( (\d+) (?{ local %ref = (line => $^N) }) + | (\.|\$) (?{ local %ref = (spec => $^N) }) + | ' ([a-z]) (?{ local %ref = (mark => $^N) }) + | (?&next) (?{ local %ref = (next => $^R) }) + | (?&prev) (?{ local %ref = (prev => $^R) }) ) - ( ([+-] \d+) (?{ local %ref = (%ref, plus => $^N) }) + ( ([+-] \d+) (?{ local %ref = (%ref, plus => $^N) }) )? ) - (?<pattern> g/((\\/|[^/])*)/ (?{ local %ref = (patt => $^N) }) + (?<grep> g((?&next)) (?{ local %ref = (grep => $^R) }) + ) + (?<next> /(([^/\\]++ | \\.)*+)/ (?{ $^N }) + ) + (?<prev> \?(([^?\\]++ | \\.)*+)\? (?{ $^N }) ) ) }x; |