]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/d.yaml
Improve new syntax files and fix a region glitch
[micro.git] / runtime / syntax / d.yaml
1 filetype: d
2
3 detect:
4     filename: "\\.(d(i|d)?)$"
5
6 rules:
7     # Operators and punctuation
8     - statement: "(\\*|/|%|\\+|-|>>|<<|>>>|&|\\^(\\^)?|\\||~)?="
9     - statement: "\\.\\.(\\.)?|!|\\*|&|~|\\(|\\)|\\[|\\]|\\\\|/|\\+|-|%|<|>|\\?|:|;"
10     # Octal integer literals are deprecated
11     - error: "(0[0-7_]*)(L[uU]?|[uU]L?)?"
12     # Decimal integer literals
13     - constant.number: "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?"
14     # Binary integer literals
15     - constant: "(0[bB][01_]*)(L[uU]?|[uU]L?)?"
16     # Decimal float literals
17     - constant.number: "[0-9][0-9_]*\\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
18     - constant.number: "[0-9][0-9_]*([eE][+-]?([0-9][0-9_]*))[fFL]?i?"
19     - constant.number: "[^.]\\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
20     - constant.number: "[0-9][0-9_]*([fFL]?i|[fF])"
21     # Hexadecimal integer literals
22     - constant.number: "(0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F]))(L[uU]?|[uU]L?)?"
23     # Hexadecimal float literals
24     - 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?"
25     - 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?"
26     # Character literals
27     - constant.string:
28         start: "'"
29         end: "'"
30         rules:
31             - constant.specialChar: "\\\\."
32     # Keywords
33     # a-e
34     - 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"
35     # f-l
36     - statement: "\\b(false|final|finally|for|foreach|foreach_reverse|function|goto|if|immutable|import|in|inout|interface|invariant|is|lazy)\\b"
37     # m-r
38     - statement: "\\b(macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|ref|return)\\b"
39     # s-w
40     - statement: "\\b(scope|shared|static|struct|super|switch|synchronized|template|this|throw|true|try|typeid|typeof|union|unittest|version|while|with)\\b"
41     # __
42     - statement: "\\b(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__|__gshared|__traits|__vector|__parameters)\\b"
43     # Deprecated keywords
44     - error: "\\b(delete|deprecated|typedef|volatile)\\b"
45     # Primitive types
46     - 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"
47     # Globally defined symbols
48     - type: "\\b(string|wstring|dstring|size_t|ptrdiff_t)\\b"
49     # Special tokens
50     - constant: "\\b(__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\\b"
51     # String literals
52     # DoubleQuotedString
53     - constant.string: 
54         start: "\""
55         end: "\""
56         rules: 
57             - constant.specialChar: "\\\\."
58     # WysiwygString
59     - constant.string:
60         start: "r\""
61         end: "\""
62         rules:
63             - constant.specialChar: "\\\\."
64     - constant.string:
65         start: "`"
66         end: "`"
67         rules:
68             - constant.specialChar: "\\\\."
69     # HexString
70     - constant.string:
71         start: "x\""
72         end: "\""
73         rules:
74             - constant.specialChar: "\\\\."
75     # DelimitedString
76     - constant.string:
77         start: "q\"\\("
78         end: "\\)\""
79         rules:
80             - constant.specialChar: "\\\\."
81     - constant.string:
82         start: "q\"\\{"
83         end: "q\"\\}"
84         rules:
85             - constant.specialChar: "\\\\."
86     - constant.string:
87         start: "q\"\\["
88         end: "q\"\\]"
89         rules:
90             - constant.specialChar: "\\\\."
91     - constant.string:
92         start: "q\"<"
93         end: "q\">"
94         rules: 
95             - constant.specialChar: "\\\\."
96     - constant.string:
97         start: "q\"[^({[<\"][^\"]*$"
98         end: "^[^\"]+\""
99         rules:
100             - constant.specialChar: "\\\\."
101     - constant.string:
102         start: "q\"([^({[<\"])"
103         end: "\""
104         rules:
105             - constant.specialChar: "\\\\."
106     # Comments
107     - comment: 
108         start: "//"
109         end: "$"
110         rules: []
111     - comment:
112         start: "/\\*"
113         end: "\\*/"
114         rules: []
115     - comment:
116         start: "/\\+"
117         end: "\\+/"
118         rules: []