From 248ebf9117ab0f95ce5bd3f5d30c2d6004d50f21 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 2 Dec 2021 11:18:57 +0100 Subject: [PATCH] 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 --- syntax/sql.nanorc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/syntax/sql.nanorc b/syntax/sql.nanorc index d57c5ba4..6f6b0133 100644 --- 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 "//.*"