| 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?)?\\b" |
| 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 |
skip: "\\\\." |
| 31 |
rules: |
| 32 |
- constant.specialChar: "\\\\." |
| 33 |
# Keywords |
| 34 |
# a-e |
| 35 |
- 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" |
| 36 |
# f-l |
| 37 |
- statement: "\\b(false|final|finally|for|foreach|foreach_reverse|function|goto|if|immutable|import|in|inout|interface|invariant|is|lazy)\\b" |
| 38 |
# m-r |
| 39 |
- statement: "\\b(macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|ref|return)\\b" |
| 40 |
# s-w |
| 41 |
- statement: "\\b(scope|shared|static|struct|super|switch|synchronized|template|this|throw|true|try|typeid|typeof|union|unittest|version|while|with)\\b" |
| 42 |
# __ |
| 43 |
- statement: "\\b(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__|__gshared|__traits|__vector|__parameters)\\b" |
| 44 |
# Deprecated keywords |
| 45 |
- error: "\\b(delete|deprecated|typedef|volatile)\\b" |
| 46 |
# Primitive types |
| 47 |
- 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" |
| 48 |
# Globally defined symbols |
| 49 |
- type: "\\b(string|wstring|dstring|size_t|ptrdiff_t)\\b" |
| 50 |
# Special tokens |
| 51 |
- constant: "\\b(__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\\b" |
| 52 |
# String literals |
| 53 |
# DoubleQuotedString |
| 54 |
- constant.string: |
| 55 |
start: "\"" |
| 56 |
end: "\"" |
| 57 |
skip: "\\\\." |
| 58 |
rules: |
| 59 |
- constant.specialChar: "\\\\." |
| 60 |
# WysiwygString |
| 61 |
- constant.string: |
| 62 |
start: "r\"" |
| 63 |
end: "\"" |
| 64 |
rules: |
| 65 |
- constant.specialChar: "\\\\." |
| 66 |
- constant.string: |
| 67 |
start: "`" |
| 68 |
end: "`" |
| 69 |
rules: |
| 70 |
- constant.specialChar: "\\\\." |
| 71 |
# HexString |
| 72 |
- constant.string: |
| 73 |
start: "x\"" |
| 74 |
end: "\"" |
| 75 |
rules: |
| 76 |
- constant.specialChar: "\\\\." |
| 77 |
# DelimitedString |
| 78 |
- constant.string: |
| 79 |
start: "q\"\\(" |
| 80 |
end: "\\)\"" |
| 81 |
rules: |
| 82 |
- constant.specialChar: "\\\\." |
| 83 |
- constant.string: |
| 84 |
start: "q\"\\{" |
| 85 |
end: "q\"\\}" |
| 86 |
rules: |
| 87 |
- constant.specialChar: "\\\\." |
| 88 |
- constant.string: |
| 89 |
start: "q\"\\[" |
| 90 |
end: "q\"\\]" |
| 91 |
rules: |
| 92 |
- constant.specialChar: "\\\\." |
| 93 |
- constant.string: |
| 94 |
start: "q\"<" |
| 95 |
end: "q\">" |
| 96 |
rules: |
| 97 |
- constant.specialChar: "\\\\." |
| 98 |
- constant.string: |
| 99 |
start: "q\"[^({[<\"][^\"]*$" |
| 100 |
end: "^[^\"]+\"" |
| 101 |
rules: |
| 102 |
- constant.specialChar: "\\\\." |
| 103 |
- constant.string: |
| 104 |
start: "q\"([^({[<\"])" |
| 105 |
end: "\"" |
| 106 |
rules: |
| 107 |
- constant.specialChar: "\\\\." |
| 108 |
# Comments |
| 109 |
- comment: |
| 110 |
start: "//" |
| 111 |
end: "$" |
| 112 |
rules: [] |
| 113 |
- comment: |
| 114 |
start: "/\\*" |
| 115 |
end: "\\*/" |
| 116 |
rules: [] |
| 117 |
- comment: |
| 118 |
start: "/\\+" |
| 119 |
end: "\\+/" |
| 120 |
rules: [] |
| 121 |
|