aboutsummaryrefslogtreecommitdiffhomepage
path: root/misc/syntax/slul.nanorc
blob: 1140be520a1cb84a4c74eb241b9bfceb813d07bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

## Syntax highlighting for SLUL source code
#
# Copyright © 2022-2024 Samuel Lidén Borell <samuel@kodafritt.se>
#
# 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 "\<this\>"
# Numbers
color yellow "\<([0-9][0-9_]*(\.[0-9]+)?([eE][+-]?[0-9_]+)?|0x[0-9a-fA-F_]+|0b[01_]+)\>"
color yellow "\<since [0-9][0-9a-zA-Z_]*([.~][0-9a-zA-Z_]+)*\>"

# 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:]]+$"