1 /*! `d` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
7 Author: Aleksandar Ruzicic <aleksandar@ruzicic.info>
8 Description: D is a language with C-like syntax and static typing. It pragmatically combines efficiency, control, and modeling power, with safety and programmer productivity.
10 Website: https://dlang.org
18 * - invalid hex string literals will be recognized as a double quoted strings
19 * but 'x' at the beginning of string will not be matched
21 * - delimited string literals are not checked for matching end delimiter
22 * (not possible to do with js regexp)
24 * - content of token string is colored as a string (i.e. no keyword coloring inside a token string)
25 * also, content of token string is not validated to contain only valid D tokens
27 * - special token sequence rule is not strictly following D grammar (anything following #line
28 * up to the end of line is matched as special token sequence)
31 /** @type LanguageFn */
39 $pattern: hljs
.UNDERSCORE_IDENT_RE
,
41 'abstract alias align asm assert auto body break byte case cast catch class '
42 + 'const continue debug default delete deprecated do else enum export extern final '
43 + 'finally for foreach foreach_reverse|10 goto if immutable import in inout int '
44 + 'interface invariant is lazy macro mixin module new nothrow out override package '
45 + 'pragma private protected public pure ref return scope shared static struct '
46 + 'super switch synchronized template this throw try typedef typeid typeof union '
47 + 'unittest version void volatile while with __FILE__ __LINE__ __gshared|10 '
48 + '__thread __traits __DATE__ __EOF__ __TIME__ __TIMESTAMP__ __VENDOR__ __VERSION__',
50 'bool cdouble cent cfloat char creal dchar delegate double dstring float function '
51 + 'idouble ifloat ireal long real short string ubyte ucent uint ulong ushort wchar '
58 * Number literal regexps
62 const decimal_integer_re
= '(0|[1-9][\\d_]*)';
63 const decimal_integer_nosus_re
= '(0|[1-9][\\d_]*|\\d[\\d_]*|[\\d_]+?\\d)';
64 const binary_integer_re
= '0[bB][01_]+';
65 const hexadecimal_digits_re
= '([\\da-fA-F][\\da-fA-F_]*|_[\\da-fA-F][\\da-fA-F_]*)';
66 const hexadecimal_integer_re
= '0[xX]' + hexadecimal_digits_re
;
68 const decimal_exponent_re
= '([eE][+-]?' + decimal_integer_nosus_re
+ ')';
69 const decimal_float_re
= '(' + decimal_integer_nosus_re
+ '(\\.\\d*|' + decimal_exponent_re
+ ')|'
70 + '\\d+\\.' + decimal_integer_nosus_re
+ '|'
71 + '\\.' + decimal_integer_re
+ decimal_exponent_re
+ '?'
73 const hexadecimal_float_re
= '(0[xX]('
74 + hexadecimal_digits_re
+ '\\.' + hexadecimal_digits_re
+ '|'
75 + '\\.?' + hexadecimal_digits_re
76 + ')[pP][+-]?' + decimal_integer_nosus_re
+ ')';
78 const integer_re
= '('
79 + decimal_integer_re
+ '|'
80 + binary_integer_re
+ '|'
81 + hexadecimal_integer_re
85 + hexadecimal_float_re
+ '|'
90 * Escape sequence supported in D string and character literals
94 const escape_sequence_re
= '\\\\('
95 + '[\'"\\?\\\\abfnrtv]|' // common escapes
96 + 'u[\\dA-Fa-f]{4}|' // four hex digit unicode codepoint
97 + '[0-7]{1,3}|' // one to three octal digit ascii char code
98 + 'x[\\dA-Fa-f]{2}|' // two hex digit ascii char code
99 + 'U[\\dA-Fa-f]{8}' // eight hex digit unicode codepoint
101 + '&[a-zA-Z\\d]{2,};'; // named character entity
104 * D integer number literals
108 const D_INTEGER_MODE
= {
110 begin: '\\b' + integer_re
+ '(L|u|U|Lu|LU|uL|UL)?',
115 * [D_FLOAT_MODE description]
118 const D_FLOAT_MODE
= {
121 + float_re
+ '([fF]|L|i|[fF]i|Li)?|'
122 + integer_re
+ '(i|[fF]i|Li)'
128 * D character literal
132 const D_CHARACTER_MODE
= {
134 begin: '\'(' + escape_sequence_re
+ '|.)',
140 * D string escape sequence
144 const D_ESCAPE_SEQUENCE
= {
145 begin: escape_sequence_re
,
150 * D double quoted string literal
154 const D_STRING_MODE
= {
157 contains: [ D_ESCAPE_SEQUENCE
],
162 * D wysiwyg and delimited string literals
166 const D_WYSIWYG_DELIMITED_STRING_MODE
= {
174 * D alternate wysiwyg string literal
178 const D_ALTERNATE_WYSIWYG_STRING_MODE
= {
185 * D hexadecimal string literal
189 const D_HEX_STRING_MODE
= {
191 begin: 'x"[\\da-fA-F\\s\\n\\r]*"[cwd]?',
196 * D delimited string literal
200 const D_TOKEN_STRING_MODE
= {
211 const D_HASHBANG_MODE
= {
219 * D special token sequence
223 const D_SPECIAL_TOKEN_SEQUENCE_MODE
= {
235 const D_ATTRIBUTE_MODE
= {
236 className: 'keyword',
237 begin: '@[a-zA-Z_][a-zA-Z_\\d]*'
245 const D_NESTING_COMMENT_MODE
= hljs
.COMMENT(
249 contains: [ 'self' ],
256 keywords: D_KEYWORDS
,
258 hljs
.C_LINE_COMMENT_MODE
,
259 hljs
.C_BLOCK_COMMENT_MODE
,
260 D_NESTING_COMMENT_MODE
,
263 D_WYSIWYG_DELIMITED_STRING_MODE
,
264 D_ALTERNATE_WYSIWYG_STRING_MODE
,
270 D_SPECIAL_TOKEN_SEQUENCE_MODE
,
280 export default hljsGrammar
;