nano: add syntax highlighting for ucode scripts
[feed/packages.git] / utils / nano / files / ucode.nanorc
1 ## Syntax highlighting for OpenWrt ucode scripts.
2
3 syntax ucode "/ucode/|\.u[ct]$"
4 header "^#!.*\<ucode\>"
5 comment "//"
6
7 # Declarations
8 color green "\<(let|const|function|this)\>"
9
10 # Arrow functions
11 color green "(\<\w+\>|\([[:alnum:][:space:]_,.]*\))[[:space:]]*=>"
12
13 # Flow control and keywords
14 color brightyellow "\<(while|if|else|elif|switch|case|default|for|in|endif|endfor|endwhile|endfunction)\>"
15 color brightyellow "\<(export|import|try|catch|delete)\>"
16
17 # Exit points
18 color magenta "\<(break|continue|return)\>"
19
20 # Numeric literals
21 color cyan "\<([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\>"
22 color cyan "\<0[xX][[:xdigit:]]+(\.[[:xdigit:]]+)?\>"
23 color cyan "\<(0[oO][0-7]+|0[bB][01]+|[0-9]+)\>"
24
25 # Special values
26 color cyan "\<(true|false|null|NaN|Infinity)\>"
27
28 # Strings
29 color brightmagenta ""([^"\{%#}]|\\.|\{[^"\{%#]|[%#}][^"\}]|[{%#}]\\.)*[{%#}]?""
30 color brightmagenta "'([^'\{%#}]|\\.|\{[^'\{%#]|[%#}][^'\}]|[{%#}]\\.)*[{%#}]?'"
31 color brightmagenta "`([^`\{%#}]|\\.|\{[^`\{%#]|[%#}][^`\}]|[{%#}]\\.)*[{%#}]?`"
32
33 # Template string expressions
34 color normal start="\$\{" end="}"
35
36 # Comments
37 color brightblue "(^|[[:blank:]])//.*"
38 color brightblue start="(^|[[:space:]])/\*" end="\*/"
39 color brightblue start="\{#" end="#\}"
40
41 # Trailing whitespace.
42 color ,green "[[:space:]]+$"
43
44 # Text outside template directives
45 color slate start="[}%#]\}" end="\{[{%#]"
46 color slate start="^#!" end="\{[{%#]"
47 color slate "^([^{%#}]|\{[^{%#]|[%#}][^}])+\{[{%#]"
48
49 # Template tags
50 color white "\{[{%][+-]?|-?[%}]\}"
51 color brightblue "\{#[+-]?|-?#\}"