tree-sitter-c
tree-sitter-c copied to clipboard
Improve accuracy of escape sequences in string and character literals
There are a few cases where the current escape sequence parser is inaccurate, which causes misleading syntax highlighting.
hexadecimal-escape-sequencedoes not have a maximum length, so'\x00000000a'is the same as'\n'. Godbolt link: https://godbolt.org/z/fq18PbPc4octal-escape-sequencecan only contain octal digits[0-7], so"\749"is"<9"and the9should not be highlighted as part of the escape sequence. Godbolt link: https://godbolt.org/z/rEcM88had- Any other character except the valid escape sequence characters are not allowed in escape sequences, so they should not be highlighted as escape sequences. This PR introduces
invalid_escape_sequenceso that invalid escape sequences can be highlighted.