syntaxes: use one regex for coloring quoted strings, to avoid overlap

Quoted strings cannot start within another quoted string and end after
that other string has ended.  Therefore single-quoted and double-quoted
strings should (as much as possible) be colorized by a single rule, so
that overlapping colorations are avoided.

(This also fixes a double typo in the PHP syntax (\. --> \\.) that has
been there since the PHP syntax was added in 2008, commit 90ee8ee4.)

This fixes https://savannah.gnu.org/bugs/?61387.

Bug existed since each of these syntaxes was introduced,
the oldest ones around 2006, a few others around 2015.

The one that got it right was the Lua syntax from 2011.
This commit is contained in:
Benno Schulenberg
2021-10-26 12:27:15 +02:00
parent 375b30507e
commit 485eb18d83
9 changed files with 9 additions and 11 deletions

View File

@@ -24,8 +24,7 @@ color brightcyan "\<(exec|print)([[:blank:]]|$)"
color brightmagenta "\<(False|None|True)\>"
# Mono-quoted strings.
color brightgreen "'([^'\]|\\.)*'|'''"
color brightgreen ""([^"\]|\\.)*"|""""
color brightgreen "'([^'\]|\\.)*'|"([^"\]|\\.)*"|'''|""""
color normal "'''|""""
# Comments.
color brightred "(^|[[:blank:]])#.*"