syntax: sql: condense some regexes, and reduce their number

master
Benno Schulenberg 2020-04-26 17:21:32 +02:00
parent fd70c25d21
commit e62a6964f7
1 changed files with 12 additions and 14 deletions

View File

@ -1,4 +1,4 @@
## Syntax highlighting for Postgres SQL scripts. ## Syntax highlighting for (Postgres) SQL scripts.
syntax sql "\.sql[2345s~]?$" syntax sql "\.sql[2345s~]?$"
comment "-- " comment "-- "
@ -42,33 +42,31 @@ color ,green "[[:space:]]+$"
# Regular expressions. # Regular expressions.
color brightmagenta "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*" color brightmagenta "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*"
# Shell command expansion is in `backticks` or like %x{this}. These are # Shell command expansion, between `backticks` or like %x{this}.
# "double-quotish" (to use a perlism).
color brightblue "`[^`]*`" "%x\{[^}]*\}" color brightblue "`[^`]*`" "%x\{[^}]*\}"
# Strings, double-quoted. # Strings, double-quoted.
color green ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>" color green ""([^"]|(\\"))*"" "%[QW]?(![^!]*!|\$[^$]*\$|\^[^^]*\^)"
color green "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!" color green "%[QW]?(\([^)]*\)|<[^>]*>|\[[^]]*\]|\{[^}]*\})"
# Expression substitution. These go inside double-quoted strings, # Expression substitution for inside double-quoted strings, "like #{this}".
# "like #{this}".
color brightgreen "#\{[^}]*\}" color brightgreen "#\{[^}]*\}"
# Strings, single-quoted. # Strings, single-quoted.
color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" color green "'([^']|(\\'))*'" "%[qw](![^!]*!|\$[^$]*\$|\^[^^]*\^)"
color green "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!" color green "%[qw](\([^)]*\)|<[^>]*>|\[[^]]*\]|\{[^}]*\})"
# Comments. # Comments.
color red "##?[^{].*" "##?$" color red "##?([^{].*|$)"
color red "--[^{].*" "--$" color red "--([^{].*|$)"
color brightblue "//.*" color brightblue "//.*"
color brightblue start="/\*" end="\*/" color brightblue start="/\*" end="\*/"
# PostgreSQL markings. # PostgreSQL markings.
color red "(--)" color red "--"
# PostgreSQL default schemas. # PostgreSQL default schemas.
color brightred "(pg_catalog|public)" color brightred "\<(pg_catalog|public)\>"
# PostgreSQL PLs. # PostgreSQL PLs.
color brightblue "(pljava|plperlu?|plpgsql|plpy|plpythonu?|plr|plruby|plsh|pltcl|plscheme)" color brightblue "\<pl(java|perlu?|pgsql|py|pythonu?|r|ruby|scheme|sh|tcl)\>"