syntax: sql: remove alien stuff -- it was copied mostly from ruby syntax

Regular expressions in SQL are not written between // or %r{},
strings are not written between <> or %Q{} or anything similar,
and comments do not start with # -- and officially not with //
either, but some dialects seem to allow it.

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

Bug existed since version 2.4.2, since the SQL syntax was included.
master
Benno Schulenberg 2021-10-25 17:40:24 +02:00
parent 7c6d3942c4
commit f2c9aed16c
1 changed files with 4 additions and 28 deletions

View File

@ -1,11 +1,8 @@
## Syntax highlighting for (Postgres) SQL scripts. ## Syntax highlighting for (Postgres) SQL scripts.
syntax sql "\.sql[2345s~]?$" syntax sql "\.sql$"
comment "-- " comment "-- "
# Functions.
color white "\<[a-z_]*\("
# Types. # Types.
color green "\<(int2|smallint|int4|int|integer|int8|bigint|decimal|numeric|real|double precision|(small|big)?serial)\>" color green "\<(int2|smallint|int4|int|integer|int8|bigint|decimal|numeric|real|double precision|(small|big)?serial)\>"
color green "\<(bit( varying)?|boolean|bytea|enum|money|tsvector|uuid)\>" color green "\<(bit( varying)?|boolean|bytea|enum|money|tsvector|uuid)\>"
@ -33,38 +30,17 @@ color blue "\<(PARSER|PREPARED?|PRIVILEGES|REASSIGN|REFRESH|RELEASE|RESET|REVOKE
color blue "\<(SAVEPOINT|SCHEMA|SEARCH|SECURITY|SELECT|SEQUENCE|SERVER|SESSION|SET|SHOW|SPACE|START|SYSTEM)\>" color blue "\<(SAVEPOINT|SCHEMA|SEARCH|SECURITY|SELECT|SEQUENCE|SERVER|SESSION|SET|SHOW|SPACE|START|SYSTEM)\>"
color blue "\<(TABLE|TEXT|TO|TRANSACTION|TYPE|UPDATE|USER|VACUUM|VALUES|VIEW|WHERE|WITH|WRAPPER)\>" color blue "\<(TABLE|TEXT|TO|TRANSACTION|TYPE|UPDATE|USER|VACUUM|VALUES|VIEW|WHERE|WITH|WRAPPER)\>"
# Strings.
color brightyellow "<[^= ]*>" ""(\.|[^"])*""
# Trailing whitespace. # Trailing whitespace.
color ,green "[[:space:]]+$" color ,green "[[:space:]]+$"
# Regular expressions. # Strings, double-quoted and single-quoted.
color brightmagenta "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*" color green ""([^"]|\\")*"|'([^']|\\')*'"
# Shell command expansion, between `backticks` or like %x{this}.
color brightblue "`[^`]*`" "%x\{[^}]*\}"
# Strings, double-quoted.
color green ""([^"]|(\\"))*"" "%[QW]?(![^!]*!|\$[^$]*\$|\^[^^]*\^)"
color green "%[QW]?(\([^)]*\)|<[^>]*>|\[[^]]*\]|\{[^}]*\})"
# Expression substitution for inside double-quoted strings, "like #{this}".
color brightgreen "#\{[^}]*\}"
# Strings, single-quoted.
color green "'([^']|(\\'))*'" "%[qw](![^!]*!|\$[^$]*\$|\^[^^]*\^)"
color green "%[qw](\([^)]*\)|<[^>]*>|\[[^]]*\]|\{[^}]*\})"
# Comments. # Comments.
color red "##?([^{].*|$)" color red "--.*"
color red "--([^{].*|$)"
color brightblue "//.*" color brightblue "//.*"
color brightblue start="/\*" end="\*/" color brightblue start="/\*" end="\*/"
# PostgreSQL markings.
color red "--"
# PostgreSQL default schemas. # PostgreSQL default schemas.
color brightred "\<(pg_catalog|public)\>" color brightred "\<(pg_catalog|public)\>"