Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adverbs for m//

Also update ChangeLog
  • Loading branch information...
commit fcf4f368cfc62cfd85dcfc499c52880dc966cb1d 1 parent 87c82c2
@moritz moritz authored
Showing with 14 additions and 3 deletions.
  1. +1 −1  docs/ChangeLog
  2. +8 −2 src/Perl6/Actions.pm
  3. +5 −0 src/Perl6/Grammar.pm
View
2  docs/ChangeLog
@@ -1,5 +1,5 @@
New in 2010.08 release
-+ syntactic adverbs on substitutions and rx quotes, e.g. '$x ~~ s:2nd/a/b/'
++ syntactic adverbs on substitutions, rx quotes and m//, e.g. '$x ~~ s:2nd/a/b/'
+ updated ROADMAP
+ speedups for integer operations
View
10 src/Perl6/Actions.pm
@@ -2663,17 +2663,22 @@ method typename($/) {
our %SUBST_ALLOWED_ADVERBS;
our %SHARED_ALLOWED_ADVERBS;
+our %MATCH_ALLOWED_ADVERBS;
INIT {
my $mods := 'i ignorecase s sigspace';
for pir::split__PSS(' ', $mods) {
%SHARED_ALLOWED_ADVERBS{$_} := 1;
- %SUBST_ALLOWED_ADVERBS{$_} := 1;
}
$mods := 'g global ii samecase x c continue p pos nth th st nd rd';
for pir::split__PSS(' ', $mods) {
%SUBST_ALLOWED_ADVERBS{$_} := 1;
}
+
+ $mods := 'g global x c continue p pos nth th st nd rd ov overlap';
+ for pir::split__PSS(' ', $mods) {
+ %MATCH_ALLOWED_ADVERBS{$_} := 1;
+ }
}
@@ -2760,6 +2765,7 @@ method quote:sym<m>($/) {
PAST::Var.new( :name('$_'), :scope('lexical') ),
$regex
);
+ self.handle_and_check_adverbs($/, %MATCH_ALLOWED_ADVERBS, 'm', $past);
$past := PAST::Op.new(
:node($/),
:pasttype('call'), :name('&infix:<=>'),
@@ -2772,7 +2778,7 @@ method quote:sym<m>($/) {
method handle_and_check_adverbs($/, %adverbs, $what, $past?) {
for $<quotepair> {
- unless %adverbs{$_.ast.named} {
+ unless %SHARED_ALLOWED_ADVERBS{$_.ast.named} || %adverbs{$_.ast.named} {
$/.CURSOR.panic("Adverb '" ~ $_.ast.named ~ "' not allowed on " ~ $what);
}
if $past {
View
5 src/Perl6/Grammar.pm
@@ -1428,10 +1428,15 @@ token quote:sym<rx> {
}
token quote:sym<m> {
<sym> >>
+ [ <quotepair> <.ws> ]*
+ :my @*REGEX_ADVERBS;
+ { @*REGEX_ADVERBS := $<quotepair>; }
+ <.setup_quotepairs>
[
| '/'<p6regex=.LANG('Regex','nibbler')>'/' <.old_rx_mods>?
| '{'<p6regex=.LANG('Regex','nibbler')>'}'
]
+ <.cleanup_modifiers>
}
token setup_quotepairs { '' }
Please sign in to comment.
Something went wrong with that request. Please try again.