]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/d.yaml
Add skip statements to all strings
[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         skip: "\\\\."
57         rules: 
58             - constant.specialChar: "\\\\."
59     # WysiwygString
60     - constant.string:
61         start: "r\""
62         end: "\""
63         rules:
64             - constant.specialChar: "\\\\."
65     - constant.string:
66         start: "`"
67         end: "`"
68         rules:
69             - constant.specialChar: "\\\\."
70     # HexString
71     - constant.string:
72         start: "x\""
73         end: "\""
74         rules:
75             - constant.specialChar: "\\\\."
76     # DelimitedString
77     - constant.string:
78         start: "q\"\\("
79         end: "\\)\""
80         rules:
81             - constant.specialChar: "\\\\."
82     - constant.string:
83         start: "q\"\\{"
84         end: "q\"\\}"
85         rules:
86             - constant.specialChar: "\\\\."
87     - constant.string:
88         start: "q\"\\["
89         end: "q\"\\]"
90         rules:
91             - constant.specialChar: "\\\\."
92     - constant.string:
93         start: "q\"<"
94         end: "q\">"
95         rules: 
96             - constant.specialChar: "\\\\."
97     - constant.string:
98         start: "q\"[^({[<\"][^\"]*$"
99         end: "^[^\"]+\""
100         rules:
101             - constant.specialChar: "\\\\."
102     - constant.string:
103         start: "q\"([^({[<\"])"
104         end: "\""
105         rules:
106             - constant.specialChar: "\\\\."
107     # Comments
108     - comment: 
109         start: "//"
110         end: "$"
111         rules: []
112     - comment:
113         start: "/\\*"
114         end: "\\*/"
115         rules: []
116     - comment:
117         start: "/\\+"
118         end: "\\+/"
119         rules: []
120