Skip to content

Commit

Permalink
Improve error message when space with combiners is encountered
Browse files Browse the repository at this point in the history
New message:
q ̌̌(hi)
Whitespace character ‘SPACE’ (0x20) with 2 combining characters
is not allowed as a delimiter at line 2, near " ̌̌(hi)\n"
  • Loading branch information
samcv committed Oct 7, 2017
1 parent c20643c commit 0bed230
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/HLL/Grammar.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,17 @@ position C<pos>.
self.panic('Alphanumeric character is not allowed as a delimiter');
}
if nqp::iscclass(nqp::const::CCLASS_WHITESPACE, $start, 0) {
my $code := nqp::sprintf('%X', [nqp::ord($start)]);
self.panic('Whitespace character (0x' ~ $code ~ ') is not allowed as a delimiter');
my str $code := nqp::sprintf('%X', [nqp::ord($start)]);
# If it's a synthetic grapheme then we must have combiners.
# Notify the user to avoid confusion.
my int $combining-chars := nqp::codes($start) - 1;
my str $character_s := 1 < $combining-chars ?? 'characters' !! 'character';
my str $description := (nqp::chr(nqp::ordbaseat($start, 0)) ne $start)
?? "with $combining-chars combining $character_s"
!! '';
self.panic('Whitespace character ‘' ~
nqp::getuniname(nqp::ord($start)) ~
'’ (0x' ~ $code ~') ' ~ $description ~ ' is not allowed as a delimiter');
}
}

Expand Down

0 comments on commit 0bed230

Please sign in to comment.