]> git.lizzy.rs Git - micro.git/blob - syntax_files/d.micro
Proper window resize handling
[micro.git] / syntax_files / d.micro
1 ## D syntax highlighting for GNU nano
2 ##
3 ## Author: Andrei Vinokurov
4 ## Based on D lexer specification (http://dlang.org/lex)
5
6 syntax "D" "\.(d(i|d)?)$"
7
8 ## Operators and punctuation
9 color statement "(\*|/|%|\+|-|>>|<<|>>>|&|\^(\^)?|\||~)?="
10 color statement "\.\.(\.)?|!|\*|&|~|\(|\)|\[|\]|\\|/|\+|-|%|<|>|\?|:|;"
11
12 ## Octal integer literals are deprecated
13 color error "(0[0-7_]*)(L[uU]?|[uU]L?)?"
14
15 ## Decimal integer literals
16 color constant "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?"
17
18 ## Binary integer literals
19 color constant "(0[bB][01_]*)(L[uU]?|[uU]L?)?"
20
21 ## Decimal float literals
22 color constant "[0-9][0-9_]*\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
23 color constant "[0-9][0-9_]*([eE][+-]?([0-9][0-9_]*))[fFL]?i?"
24 color constant "[^.]\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
25 color constant "[0-9][0-9_]*([fFL]?i|[fF])"
26
27 ## Hexadecimal integer literals
28 color constant "(0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F]))(L[uU]?|[uU]L?)?"
29
30 ## Hexadecimal float literals
31 color constant "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 "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?"
33
34
35 ## Character literals
36 color constant "'([^\']|\\(['"?\abfnrtv]|x[[:xdigit:]]{2}|[0-7]{1,3}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}|&.*;))'"
37
38 ## Keywords
39 ## a-e
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"
41 ## f-l
42 color statement "\b(false|final|finally|for|foreach|foreach_reverse|function|goto|if|immutable|import|in|inout|interface|invariant|is|lazy)\b"
43 ## m-r
44 color statement "\b(macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|ref|return)\b"
45 ## s-w
46 color statement "\b(scope|shared|static|struct|super|switch|synchronized|template|this|throw|true|try|typeid|typeof|union|unittest|version|while|with)\b"
47 ## __
48 color statement "\b(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__|__gshared|__traits|__vector|__parameters)\b"
49
50 ## Deprecated keywords
51 color error "\b(delete|deprecated|typedef|volatile)\b"
52
53 ## Primitive types
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"
55
56 ## Globally defined symbols
57 color type "\b(string|wstring|dstring|size_t|ptrdiff_t)\b"
58
59 ## Special tokens
60 color constant "\b(__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\b"
61
62 ## String literals
63 ## TODO: multiline backtick and doublequote string. (Unlikely possible at all with nano.)
64 ### DoubleQuotedString
65 color constant ""(\\.|[^"])*""
66  
67 ### WysiwygString
68 color constant (s) "r".*?""
69 color constant "`[^`]*`"
70
71 ### HexString
72 color ,constant "x"([[:space:]]*[[:xdigit:]][[:space:]]*[[:xdigit:]])*[[:space:]]*""
73
74 ### DelimitedString
75 color constant "q"\(.*\)""
76 color constant "q"\{.*\}""
77 color constant "q"\[.*\]""
78 color constant "q"<.*>""
79 color constant (s) "q"[^({[<"][^"]*$.*?^[^"]+""
80 color constant "q"([^({[<"]).*\1""
81
82 ### TokenString
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 (s) "q\{.*?\}"
86
87 ## Comments
88 ## NB: true nested brightblacks are impossible to implement with plain regex
89 color comment "//.*"
90 color comment (s) "/\*.*?\*/"
91 color comment (s) "/\+.*?\+/"