syntax: rust: do not colorize as string the text between two strings

Strings may not contain a double quote unless it is escaped.

Reference:
  https://doc.rust-lang.org/reference/tokens.html#string-literals

(This will still not colorize multi-line strings with an unescaped
newline, will still colorize "this\" as if it were a valid string,
and will still miscolor things when there is another string after
the closing quote of a two-line string.  But those things can't
be helped -- line-based regexes cannot emulate a full parser.)

This fixes https://savannah.gnu.org/bugs/?61361.
Reported-by: Elias Jonsson <e@ejon.eu>

Bug existed since version 2.6.1, since the Rust syntax was introduced.
master
Benno Schulenberg 2021-10-21 11:27:29 +02:00
parent 918ce1afa3
commit d57bfc057f
1 changed files with 2 additions and 2 deletions

View File

@ -22,8 +22,8 @@ color magenta "[A-Z][A-Z_0-9]+"
color magenta "[A-Z][A-Za-z0-9]+"
# Strings
color green "".*""
color green start="".*\\$" end=".*""
color green ""([^"]|\\")*""
color green start=""([^"]|\\")*\\$" end=".*""
## NOTE: This isn't accurate, but matching "#{0,} for the end of the string is too liberal.
color green start="r#+"" end=""#+"