Permalink
Browse files

Detect repeat chars in character classes

  • Loading branch information...
TimToady committed Jun 5, 2014
1 parent ec3d853 commit 77c988436a361ca842a63b5c521ad60b49c93e96
Showing with 15 additions and 0 deletions.
  1. +15 −0 STD.pm6
View
15 STD.pm6
@@ -5249,6 +5249,21 @@ grammar Regex is STD {
:dba('character class element')
"[" ~ "]" <nibble($¢.cursor_fresh( %*LANG<Q> ).tweak(:cc).unbalanced("]"))>
<.normspace>?
+ {
+ $_ = $<nibble>.Str;
+ 1 while s/\s+|\.\.|\\//;
+
+ # XXX emulate /(.) .*? $0/ which viv flubs
+ my %seen;
+ for unpack('C*', $_) {
+ %seen{$_}++;
+ }
+ for keys %seen {
+ next if %seen{$_} < 2;
+ my $c = chr($_);
+ $¢.worry("Repeated character ($c) unexpectedly found in character class");
+ }
+ }
}
token cclass_elem:sym<( )> {

0 comments on commit 77c9884

Please sign in to comment.