tweaks: fold some regexes together, and trim or improve some comments

Also, trim some whitespace and group one rule better.

Also, fix a stray closing parenthesis in the JSON syntax,
and add the missing slash to the possible escaped characters.
(Reference: https://www.json.org/json-en.html.)

Also, improve the ending of multiline strings in the Rust syntax.
master
Benno Schulenberg 2021-10-27 11:06:40 +02:00
parent 1cd92458e9
commit 0e1d45dc36
16 changed files with 34 additions and 31 deletions

View File

@ -11,8 +11,8 @@ color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single
color brightred "^[[:blank:]]*[.0-9A-Za-z_]*:" color brightred "^[[:blank:]]*[.0-9A-Za-z_]*:"
color brightcyan "^[[:blank:]]*#[[:blank:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)" color brightcyan "^[[:blank:]]*#[[:blank:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
# Strings. # Strings and names of included files.
color brightyellow "<[^= ]*>|"([^"\]|\\.)*"" color brightyellow ""([^"\]|\\.)*"|<[^= ]*>"
# Comments. # Comments.
color brightblue "//.*" color brightblue "//.*"

View File

@ -28,8 +28,7 @@ color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2})
# GCC builtins. # GCC builtins.
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
# Strings. (In general you will want your strings and comments to come last, # Strings and names of included files.
# because highlighting rules are applied in the order they are read in.)
color brightyellow ""([^"]|\\")*"" "#[[:blank:]]*include[[:blank:]]*<[^>]+>" color brightyellow ""([^"]|\\")*"" "#[[:blank:]]*include[[:blank:]]*<[^>]+>"
# Preprocessor directives. # Preprocessor directives.

View File

@ -13,13 +13,13 @@ color red "^(19|20)[0-9-]{8}"
color yellow "<[^>]*@[^>]*>" color yellow "<[^>]*@[^>]*>"
# Command-line options. # Command-line options.
color cyan "[[:blank:]]-[a-zA-Z\$]" "--[8a-z-]+" color cyan "[[:blank:]]-[a-zA-Z\$]|--[8a-z-]+"
# Bug and patch numbers. # Bug and patch numbers.
color cyan "(BZ|bug|patch)[ ]#[0-9]+" "PR [[:alnum:]]+/[0-9]+" color cyan "(BZ|bug|patch)[ ]#[0-9]+|PR [[:alnum:]]+/[0-9]+"
# Probable constants, for variety. # Probable constants, for variety.
color brightred "\<[A-Z_][0-9A-Z_]+\>" color brightred "\<[A-Z_][0-9A-Z_]+\>"
# Key sequences. # Key sequences.
color brightblue "\^[A-Z^\]" "\<M-." "\<F1?[0-9]" "(\^|M-)Space" color brightblue "\^[A-Z^\]|\<M-.|\<F1?[0-9]|(\^|M-)Space"
# Changed files. # Changed files.
color magenta start="^( | {8})\* " end="(:( |$)|^$)" color magenta start="^( | {8})\* " end="(:( |$)|^$)"

View File

@ -15,5 +15,8 @@ icolor brightred "^[[:blank:]]*((end)?(function|macro)|return)"
icolor cyan start="\$(ENV)?\{" end="\}" icolor cyan start="\$(ENV)?\{" end="\}"
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>" color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
# Comments.
color brightblue "(^|[[:blank:]])#.*" color brightblue "(^|[[:blank:]])#.*"
# Trailing whitespace.
color ,green "[[:space:]]+$" color ,green "[[:space:]]+$"

View File

@ -4,17 +4,17 @@ syntax css "\.css$"
comment "/*|*/" comment "/*|*/"
# First make everything red: # First make everything red:
color brightred "." color brightred "."
# Then everything between braces yellow: # Then everything between braces yellow:
color brightyellow start="\{" end="\}" color brightyellow start="\{" end="\}"
# Then everything after a colon white: # Then everything after a colon white:
color brightwhite start=":" end="([;^{]|$)" color brightwhite start=":" end="([;^{]|$)"
# Pseudo-classes: # Pseudo-classes:
color brightcyan ":(active|checked|focus|hover|link|visited|after|before)\>" color brightcyan ":(active|checked|focus|hover|link|visited|after|before)\>"
# Comments: # Comments:
color brightblue start="/\*" end="\*/" color brightblue start="/\*" end="\*/"
# Syntactic characters: # Syntactic characters:
color green ";|:|\{|\}" color green ";|:|\{|\}"

View File

@ -30,7 +30,7 @@ color cyan "'[[:alnum:]]+"
color green "\<[0-9][0-9A-Fa-f_#.+-]*" color green "\<[0-9][0-9A-Fa-f_#.+-]*"
# Characters / Strings # Characters / Strings
color red "'.'" ""[^"]*"" color red "'.'|"[^"]*""
# Comments # Comments
color brightblue "--.*" color brightblue "--.*"

View File

@ -26,6 +26,7 @@ color magenta "\<(break|continue|fallthrough|goto|return)\>"
color brightcyan "\<(package|import)\>" color brightcyan "\<(package|import)\>"
# Literals. # Literals.
color red "\<(true|false|nil|iota|_)\>"
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>" color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>"
color red "\<[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?i?\>" color red "\<[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?i?\>"
color red "\<[0-9]+[eE][+-]?[0-9]+i?\>" color red "\<[0-9]+[eE][+-]?[0-9]+i?\>"
@ -33,7 +34,6 @@ color red "\B\.[0-9]+([eE][+-]?[0-9]+)?i?\>"
color red "\<[0-9]+i\>" color red "\<[0-9]+i\>"
# Strings and characters; slightly fuzzy. # Strings and characters; slightly fuzzy.
color red "\<(true|false|nil|iota|_)\>"
color red ""([^"\]|\\.)*"|'([^'\]|\\.)+'" color red ""([^"\]|\\.)*"|'([^'\]|\\.)+'"
color red start=""([^"\]|\\.)*\\[[:blank:]]*$" end="^([^"\]|\\.)*"" color red start=""([^"\]|\\.)*\\[[:blank:]]*$" end="^([^"\]|\\.)*""

View File

@ -11,8 +11,7 @@ color brightcyan "\<define(-macro|-module|-public|-syntax)?\>"
# Quoted symbols # Quoted symbols
color brightyellow "'\<(\w|-)+\>" color brightyellow "'\<(\w|-)+\>"
# Chars # Chars
color brightmagenta "#\\." color brightmagenta "#\\(.|\w+)"
color brightmagenta "#\\\w+\>"
# Booleans # Booleans
color brightred "(#t|#f)\>" color brightred "(#t|#f)\>"
# Keywords # Keywords

View File

@ -14,7 +14,7 @@ color brightmagenta "".+""
# Hex numbers (used as value). # Hex numbers (used as value).
color green ":[[:blank:]]*"#[0-9abcdefABCDEF]+"" color green ":[[:blank:]]*"#[0-9abcdefABCDEF]+""
# Escapes. # Escapes.
color green "\\\\" "\\"" "\\[bfnrt]" "\\u[0-9abcdefABCDEF]{4})" color green "\\["\/bfnrt]" "\\u[0-9abcdefABCDEF]{4}"
# Special words. # Special words.
color green "\<(true|false|null)\>" color green "\<(true|false|null)\>"

View File

@ -25,8 +25,10 @@ color cyan "(^|[[:blank:]])#.*"
# Trailing whitespace # Trailing whitespace
color ,green "[[:space:]]+$" color ,green "[[:space:]]+$"
# Strings and others # Strings
color yellow ""([^"\]|\\.)*"|'([^'\]|\\.)*'" color yellow ""([^"\]|\\.)*"|'([^'\]|\\.)*'"
# Syntactic symbols
color green "[][{}():;|`$<>!=&\]" color green "[][{}():;|`$<>!=&\]"
# Basic variable names # Basic variable names

View File

@ -4,7 +4,7 @@ syntax m "\.m$"
magic "Objective-C source" magic "Objective-C source"
comment "//" comment "//"
# Stuffs, # Stuffs.
color brightwhite "\<[A-Z_][0-9A-Z_]+\>" color brightwhite "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(float|double|BOOL|bool|char|int|short|long|id|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\>" color green "\<(float|double|BOOL|bool|char|int|short|long|id|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<[[:alpha:]_][[:alnum:]_]*_t\>" color green "\<[[:alpha:]_][[:alnum:]_]*_t\>"
@ -24,7 +24,7 @@ color magenta "[[:alnum:]]*:"
color white "\[[^][:blank:]]*\]" color white "\[[^][:blank:]]*\]"
# Strings. # Strings.
color brightblack "'([^'\]|(\\["'abfnrtv\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'" color brightblack "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'"
color brightblack "<[^= ]*>|"([^"\]|\\.)*"" color brightblack "<[^= ]*>|"([^"\]|\\.)*""
color brightblue "@"([^"\]|\\.)*"" color brightblue "@"([^"\]|\\.)*""

View File

@ -26,5 +26,5 @@ color green "\<(include|inherit|initializer)\>"
color yellow "\<(new|ref|mutable|lazy|assert|raise)\>" color yellow "\<(new|ref|mutable|lazy|assert|raise)\>"
# Comments: # Comments:
color white start="\(\*" end="\*\)" color white start="\(\*" end="\*\)"
# Strings: (no multiline handling yet) # Strings:
color brightblack ""[^\"]*"" color brightblack ""[^"\]*""

View File

@ -29,8 +29,8 @@ color normal "'''|""""
# Comments. # Comments.
color brightred "(^|[[:blank:]])#.*" color brightred "(^|[[:blank:]])#.*"
# Triple-quoted strings. # Triple-quoted strings.
color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''" color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''"
color brightgreen start=""""([^"),]|$)" end="(^|[^(\])"""" color brightgreen start=""""([^"),]|$)" end="(^|[^(\])""""
# Reminders. # Reminders.
color brightwhite,yellow "\<(FIXME|TODO|XXX)\>" color brightwhite,yellow "\<(FIXME|TODO|XXX)\>"

View File

@ -23,8 +23,8 @@ color magenta "[A-Z][A-Za-z0-9]+"
# Strings # Strings
color green ""([^"]|\\")*"" color green ""([^"]|\\")*""
color green start=""([^"]|\\")*\\$" end=".*"" color green start=""([^"]|\\")*\\$" end="(^|.*[^\])""
## NOTE: This isn't accurate, but matching "#{0,} for the end of the string is too liberal. ## Inaccurate, but it's not possible to balance the number of hashes.
color green start="r#+"" end=""#+" color green start="r#+"" end=""#+"
# Comments # Comments

View File

@ -18,7 +18,7 @@ color green "[][{}():;|`$<>!=&\]"
color green "-(eq|ne|gt|lt|ge|le|ef|ot|nt)\>" color green "-(eq|ne|gt|lt|ge|le|ef|ot|nt)\>"
# Short and long options. # Short and long options.
color brightmagenta "[[:blank:]]-[A-Za-z]\>" "[[:blank:]]--[A-Za-z-]+\>" color brightmagenta "[[:blank:]](-[A-Za-z]|--\<[A-Za-z-]+)\>"
# Common commands. # Common commands.
color brightblue "\<(awk|cat|cd|ch(grp|mod|own)|cp|cut|echo|env|grep|head|install|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|sort|tail|tar|touch|umask|unset)\>" color brightblue "\<(awk|cat|cd|ch(grp|mod|own)|cp|cut|echo|env|grep|head|install|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|sort|tail|tar|touch|umask|unset)\>"

View File

@ -6,10 +6,10 @@ magic "(XML|SGML) (sub)?document"
comment "<!--|-->" comment "<!--|-->"
# The entire content of the tag: # The entire content of the tag:
color green start="<" end=">" color green start="<" end=">"
# The start and the end of the tag: # The start and the end of the tag:
color cyan "<[^> ]+" ">" color cyan "<[^> ]+" ">"
# The strings inside the tag: # The strings inside the tag:
color magenta ""[^"]*"" color magenta ""[^"]*""
@ -19,4 +19,4 @@ color yellow start="<!DOCTYPE" end="[/]?>"
color yellow start="<!--" end="-->" color yellow start="<!--" end="-->"
# Escapes: # Escapes:
color red "&[^;]*;" color red "&[^;]*;"