1 ## D syntax highlighting for GNU nano
3 ## Author: Andrei Vinokurov
4 ## Based on D lexer specification (http://dlang.org/lex)
6 syntax "d" "\.(d(i|d)?)$"
8 ## Operators and punctuation
9 color statement "(\*|/|%|\+|-|>>|<<|>>>|&|\^(\^)?|\||~)?="
10 color statement "\.\.(\.)?|!|\*|&|~|\(|\)|\[|\]|\\|/|\+|-|%|<|>|\?|:|;"
12 ## Octal integer literals are deprecated
13 color error "(0[0-7_]*)(L[uU]?|[uU]L?)?"
15 ## Decimal integer literals
16 color constant.number "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?"
18 ## Binary integer literals
19 color constant "(0[bB][01_]*)(L[uU]?|[uU]L?)?"
21 ## Decimal float literals
22 color constant.number "[0-9][0-9_]*\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
23 color constant.number "[0-9][0-9_]*([eE][+-]?([0-9][0-9_]*))[fFL]?i?"
24 color constant.number "[^.]\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
25 color constant.number "[0-9][0-9_]*([fFL]?i|[fF])"
27 ## Hexadecimal integer literals
28 color constant.number "(0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F]))(L[uU]?|[uU]L?)?"
30 ## Hexadecimal float literals
31 color constant.number "0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])(\.[0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])?[pP][+-]?([0-9][0-9_]*)[fFL]?i?"
32 color constant.number "0[xX]\.([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])[pP][+-]?([0-9][0-9_]*)[fFL]?i?"
36 color constant.string "'([^\']|\\(['"?\abfnrtv]|x[[:xdigit:]]{2}|[0-7]{1,3}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}|&.*;))'"
40 color statement "\b(abstract|alias|align|asm|assert|auto|body|break|case|cast|catch|class|const|continue|debug|default|delegate|do|else|enum|export|extern)\b"
42 color statement "\b(false|final|finally|for|foreach|foreach_reverse|function|goto|if|immutable|import|in|inout|interface|invariant|is|lazy)\b"
44 color statement "\b(macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|ref|return)\b"
46 color statement "\b(scope|shared|static|struct|super|switch|synchronized|template|this|throw|true|try|typeid|typeof|union|unittest|version|while|with)\b"
48 color statement "\b(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__|__gshared|__traits|__vector|__parameters)\b"
50 ## Deprecated keywords
51 color error "\b(delete|deprecated|typedef|volatile)\b"
54 color type "\b(bool|byte|cdouble|cent|cfloat|char|creal|dchar|double|float|idouble|ifloat|int|ireal|long|real|short|ubyte|ucent|uint|ulong|ushort|void|wchar)\b"
56 ## Globally defined symbols
57 color type "\b(string|wstring|dstring|size_t|ptrdiff_t)\b"
60 color constant "\b(__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\b"
63 ## TODO: multiline backtick and doublequote string. (Unlikely possible at all with nano.)
64 ### DoubleQuotedString
65 color constant.string ""(\\.|[^"])*""
68 color constant.string start="r"" end="""
69 color constant.string "`[^`]*`"
72 color constant.string "x"([[:space:]]*[[:xdigit:]][[:space:]]*[[:xdigit:]])*[[:space:]]*""
75 color constant.string "q"\(.*\)""
76 color constant.string "q"\{.*\}""
77 color constant.string "q"\[.*\]""
78 color constant.string "q"<.*>""
79 color constant.string start="q"[^({[<"][^"]*$" end="^[^"]+""
80 color constant.string "q"([^({[<"]).*""
83 ### True token strings require nesting, so, again, they can't be implemented accurately here.
84 ### At the same time, the intended purpose of token strings makes it questionable to highlight them as strings at all.
85 ## color ,magenta start="q\{" end="\}"
88 ## NB: true nested brightblacks are impossible to implement with plain regex
90 color comment start="/\*" end="\*/"
91 color comment start="/\+" end="\+/"