commit 248ebf9117ab0f95ce5bd3f5d30c2d6004d50f21
parent 1c6f6ba212c442fa3154e110abf6f1be7cc02b77
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 2 Dec 2021 11:18:57 +0100
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
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/syntax/sql.nanorc b/syntax/sql.nanorc
@@ -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 "//.*"