## Syntax highlighting for SLUL source code # # Copyright © 2022-2024 Samuel Lidén Borell # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. syntax slul "\.slul$" header "\\slul " # TODO formatting and linting #formatter cslul --format #linter cslul --check-one-file comment "#" tabgives " " # Invalid indentation color normal,red "^[[:space:]]+((func|type|data)\>|\\[[:alnum:]_]*)" color normal,red "\<(func|type|data)\>" color normal,red "\\[[:alnum:]_]*" # Top-level keywords color brightmagenta "^(func|data|type)\>" # Type keywords color green "\<(aliased|arena|byte|bool|closed|enum|fileoffs|(w?u)?int|int8|wuint8|(w?u)?int(16|32|64)|own|ref|slot|funcref|[su]size|string|struct|threaded|var|writeonly)\>" # Types color cyan "\<[[:upper:]][[:alnum:]]*\>" # Flow control color brightyellow "\<(assert|if|else|for|in|while|do|switch|case|default|subcase|loopend|loopempty)\>" color magenta "\<(break|continue|goto|return)\>" color normal,red ":" color normal,normal ":( |$)" color brightmagenta,normal "\<[a-z_][a-zA-Z0-9_]*:" # Operators color normal,red "[!$%&'\\;@^`|~]" color brightyellow "\<(and|bitand|bitor|bitnot|bitxor|deref|not|or|ref_is|ref_is_not|refto|sh[lr])\>" color brightyellow "[-+*/=<>]" color magenta "->|[+-/*]?=" color brightyellow,normal "[!<>=]=" # Others, special values color yellow "\<(lifetime|since|noreturn)\>" color cyan "\<(false|none|true|undef)\>" color lightblack "\" # Numbers color yellow "\<([0-9][0-9_]*(\.[0-9]+)?([eE][+-]?[0-9_]+)?|0x[0-9a-fA-F_]+|0b[01_]+)\>" color yellow "\" # Strings color brightyellow ""(\\.|[^"])*"" # String escapes color normal,red "\\." color brightcyan,normal "\\([0bnrt\\"]|[ACGLOS]+;|x[0-9a-fA-F]{1,2}|u[0-9a-f]+)" # Module attributes color brightred,normal "^\\.*" color green,normal "^\\slul( +([0-9][0-9.]*( +impl( +([0-9][0-9.]*)?)?)?( +upto( +([0-9][0-9.]+)?)?)?)?)?" color green "^\\name( +([a-z][a-z0-9_]*)?)?" color green,normal "^\\type( +(internal|library|plugin|libraryspec|pluginspec|app)?)?" color green,normal "^\\version( +([0-9][0-9.]*)?)?( +unstable_api)?" color green "^\\(repo(\.mirror)?|website)( +([a-z][a-z0-9A-Z_]*://[^[:space:]]+)?)?" color green "^\\license(\.text|\.list)?( +.*)?" color green "^\\depends( +([a-z][a-z0-9_]*( +(([0-9][0-9a-z.~]*|bundled)( +([a-zA-Z0-9+/]{32})?)?( +(optional|nestedonly))*)?)?)?)?" color yellow "^\\depends +[a-z][[a-z0-9_]* +([0-9][0-9a-z.~]*|bundled) +unstable_api( +(optional|nestedonly))*" color green "^\\interface_depends( +([a-z][a-z0-9_]*( +(([0-9][0-9a-z.~]*)( +(optional|nestedonly))*( +(since +([0-9][0-9a-z.~]*( +([a-zA-Z0-9+/]{32})?)?)?)?)?)?)?)?)?" color yellow "^\\interface_depends +[a-z][a-z0-9_]* +unstable_api( +(optional|nestedonly))*" color green "^\\api_def( +([0-9][0-9a-z.~]*( +([a-zA-Z0-9+/]{32}|unstable_api)?)?)?)?" color green "^\\source( +([a-z0-9_]+(/[a-z0-9_]+)*\.slul)?)?" # Comments # Hack to avoid detection of comments inside strings color brightblue "#[^"]*("[^"]*"[^"]*)*$" color brightblue "^#.*" color brightblue start="^#\{\{" end="^#\}\}" # Reminders color brightwhite,yellow "\<(FIXME|TODO|XXX)\>" # Trailing whitespace. color ,green "[[:space:]]+$"