Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Detect repeat chars in character classes
  • Loading branch information
TimToady committed Jun 5, 2014
1 parent ec3d853 commit 77c9884
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions STD.pm6
Expand Up @@ -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<( )> {
Expand Down

0 comments on commit 77c9884

Please sign in to comment.