Regex: Only allow SyntaxCharacter and - to be escaped in a character class
Letting any character to be escaped is error prone as it looks like \l could mean [:lower:] (as it used to with boost) when it only means literal l. Fix the haskell.kak file as well. Fixes #1945
This commit is contained in:
parent
6fdb9db5d9
commit
b27d4afa8d
|
@ -39,7 +39,7 @@ add-highlighter shared/haskell/code regex (?<!')\b(case|do|else|if|in|let|mdo|of
|
||||||
|
|
||||||
# matches uppercase identifiers: Monad Control.Monad
|
# matches uppercase identifiers: Monad Control.Monad
|
||||||
# not non-space separated dot: Just.const
|
# not non-space separated dot: Just.const
|
||||||
add-highlighter shared/haskell/code regex \b([A-Z]['\w]*\.)*[A-Z]['\w]*(?!['\w])(?![.\l]) 0:variable
|
add-highlighter shared/haskell/code regex \b([A-Z]['\w]*\.)*[A-Z]['\w]*(?!['\w])(?![.a-z]) 0:variable
|
||||||
|
|
||||||
# matches infix identifier: `mod` `Apa._T'M`
|
# matches infix identifier: `mod` `Apa._T'M`
|
||||||
add-highlighter shared/haskell/code regex `\b([A-Z]['\w]*\.)*[\w]['\w]*` 0:operator
|
add-highlighter shared/haskell/code regex `\b([A-Z]['\w]*\.)*[\w]['\w]*` 0:operator
|
||||||
|
|
|
@ -429,24 +429,21 @@ private:
|
||||||
if (cp == '\\')
|
if (cp == '\\')
|
||||||
{
|
{
|
||||||
auto it = find_if(character_class_escapes,
|
auto it = find_if(character_class_escapes,
|
||||||
[cp = *m_pos](auto& t) { return t.cp == cp; });
|
[cp = *m_pos](auto&& t) { return t.cp == cp; });
|
||||||
if (it != std::end(character_class_escapes))
|
if (it != std::end(character_class_escapes))
|
||||||
{
|
{
|
||||||
character_class.ctypes |= it->ctype;
|
character_class.ctypes |= it->ctype;
|
||||||
++m_pos;
|
++m_pos;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else // its just an escaped character
|
else // its an escaped character
|
||||||
{
|
{
|
||||||
cp = *m_pos++;
|
cp = *m_pos++;
|
||||||
for (auto& control : control_escapes)
|
auto it = find_if(control_escapes, [cp](auto&& t) { return t.name == cp; });
|
||||||
{
|
if (it != std::end(control_escapes))
|
||||||
if (control.name == cp)
|
cp = it->value;
|
||||||
{
|
else if (not contains("^$\\.*+?()[]{}|-", cp)) // SyntaxCharacter and -
|
||||||
cp = control.value;
|
parse_error(format("unknown character class escape '{}'", cp));
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user