source: node_modules/refractor/lang/d.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 3.6 KB
Line 
1'use strict'
2
3module.exports = d
4d.displayName = 'd'
5d.aliases = []
6function d(Prism) {
7 Prism.languages.d = Prism.languages.extend('clike', {
8 comment: [
9 {
10 // Shebang
11 pattern: /^\s*#!.+/,
12 greedy: true
13 },
14 {
15 pattern: RegExp(
16 /(^|[^\\])/.source +
17 '(?:' +
18 [
19 // /+ comment +/
20 // Allow one level of nesting
21 /\/\+(?:\/\+(?:[^+]|\+(?!\/))*\+\/|(?!\/\+)[\s\S])*?\+\//.source, // // comment
22 /\/\/.*/.source, // /* comment */
23 /\/\*[\s\S]*?\*\//.source
24 ].join('|') +
25 ')'
26 ),
27 lookbehind: true,
28 greedy: true
29 }
30 ],
31 string: [
32 {
33 pattern: RegExp(
34 [
35 // r"", x""
36 /\b[rx]"(?:\\[\s\S]|[^\\"])*"[cwd]?/.source, // q"[]", q"()", q"<>", q"{}"
37 /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/.source, // q"IDENT
38 // ...
39 // IDENT"
40 /\bq"((?!\d)\w+)$[\s\S]*?^\1"/.source, // q"//", q"||", etc.
41 // eslint-disable-next-line regexp/strict
42 /\bq"(.)[\s\S]*?\2"/.source, // eslint-disable-next-line regexp/strict
43 /(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source
44 ].join('|'),
45 'm'
46 ),
47 greedy: true
48 },
49 {
50 pattern: /\bq\{(?:\{[^{}]*\}|[^{}])*\}/,
51 greedy: true,
52 alias: 'token-string'
53 }
54 ],
55 // In order: $, keywords and special tokens, globally defined symbols
56 keyword:
57 /\$|\b(?:__(?:(?:DATE|EOF|FILE|FUNCTION|LINE|MODULE|PRETTY_FUNCTION|TIMESTAMP|TIME|VENDOR|VERSION)__|gshared|parameters|traits|vector)|abstract|alias|align|asm|assert|auto|body|bool|break|byte|case|cast|catch|cdouble|cent|cfloat|char|class|const|continue|creal|dchar|debug|default|delegate|delete|deprecated|do|double|dstring|else|enum|export|extern|false|final|finally|float|for|foreach|foreach_reverse|function|goto|idouble|if|ifloat|immutable|import|inout|int|interface|invariant|ireal|lazy|long|macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|ptrdiff_t|public|pure|real|ref|return|scope|shared|short|size_t|static|string|struct|super|switch|synchronized|template|this|throw|true|try|typedef|typeid|typeof|ubyte|ucent|uint|ulong|union|unittest|ushort|version|void|volatile|wchar|while|with|wstring)\b/,
58 number: [
59 // The lookbehind and the negative look-ahead try to prevent bad highlighting of the .. operator
60 // Hexadecimal numbers must be handled separately to avoid problems with exponent "e"
61 /\b0x\.?[a-f\d_]+(?:(?!\.\.)\.[a-f\d_]*)?(?:p[+-]?[a-f\d_]+)?[ulfi]{0,4}/i,
62 {
63 pattern:
64 /((?:\.\.)?)(?:\b0b\.?|\b|\.)\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:e[+-]?\d[\d_]*)?[ulfi]{0,4}/i,
65 lookbehind: true
66 }
67 ],
68 operator:
69 /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
70 })
71 Prism.languages.insertBefore('d', 'string', {
72 // Characters
73 // 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot'
74 char: /'(?:\\(?:\W|\w+)|[^\\])'/
75 })
76 Prism.languages.insertBefore('d', 'keyword', {
77 property: /\B@\w*/
78 })
79 Prism.languages.insertBefore('d', 'function', {
80 register: {
81 // Iasm registers
82 pattern:
83 /\b(?:[ABCD][LHX]|E?(?:BP|DI|SI|SP)|[BS]PL|[ECSDGF]S|CR[0234]|[DS]IL|DR[012367]|E[ABCD]X|X?MM[0-7]|R(?:1[0-5]|[89])[BWD]?|R[ABCD]X|R[BS]P|R[DS]I|TR[3-7]|XMM(?:1[0-5]|[89])|YMM(?:1[0-5]|\d))\b|\bST(?:\([0-7]\)|\b)/,
84 alias: 'variable'
85 }
86 })
87}
Note: See TracBrowser for help on using the repository browser.