syntax: sql: colorize only single-quoted things as strings

SQL does not know double-quoted strings.  Double quotes can be used
around identifiers, to prevent them being interpreted as keywords.

References:
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
  https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
master
Benno Schulenberg 2021-12-02 11:18:57 +01:00
parent 1c6f6ba212
commit 248ebf9117
1 changed files with 7 additions and 3 deletions

View File

@ -28,12 +28,16 @@ color brightyellow "\<(CASE|WHEN|IF|THEN|ELSE|ELSE?IF|LOOP|CONTINUE|EXIT)\>"
color brightyellow "\<(FOR|FOREACH|IN|WHILE|END (CASE|IF|LOOP))\>"
color magenta "\<(RAISE|EXCEPTION|NOTICE|RETURN)\>"
# Quoted identifiers. (First scare-color all, then uncolor what is valid.)
color ,red ""[^"]+""
color normal ""[[:alpha:]_][[:alnum:]_$]*""
# Strings.
color green "'([^']|\\')*'"
# Trailing whitespace.
color ,green "[[:space:]]+$"
# Strings, double-quoted and single-quoted.
color green ""([^"]|\\")*"|'([^']|\\')*'"
# Comments.
color red "--.*"
color brightblue "//.*"