]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/delphi.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / delphi.js
1 /*! `delphi` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Delphi
7 Website: https://www.embarcadero.com/products/delphi
8 Category: system
9 */
10
11 /** @type LanguageFn */
12 function delphi(hljs) {
13 const KEYWORDS = [
14 "exports",
15 "register",
16 "file",
17 "shl",
18 "array",
19 "record",
20 "property",
21 "for",
22 "mod",
23 "while",
24 "set",
25 "ally",
26 "label",
27 "uses",
28 "raise",
29 "not",
30 "stored",
31 "class",
32 "safecall",
33 "var",
34 "interface",
35 "or",
36 "private",
37 "static",
38 "exit",
39 "index",
40 "inherited",
41 "to",
42 "else",
43 "stdcall",
44 "override",
45 "shr",
46 "asm",
47 "far",
48 "resourcestring",
49 "finalization",
50 "packed",
51 "virtual",
52 "out",
53 "and",
54 "protected",
55 "library",
56 "do",
57 "xorwrite",
58 "goto",
59 "near",
60 "function",
61 "end",
62 "div",
63 "overload",
64 "object",
65 "unit",
66 "begin",
67 "string",
68 "on",
69 "inline",
70 "repeat",
71 "until",
72 "destructor",
73 "write",
74 "message",
75 "program",
76 "with",
77 "read",
78 "initialization",
79 "except",
80 "default",
81 "nil",
82 "if",
83 "case",
84 "cdecl",
85 "in",
86 "downto",
87 "threadvar",
88 "of",
89 "try",
90 "pascal",
91 "const",
92 "external",
93 "constructor",
94 "type",
95 "public",
96 "then",
97 "implementation",
98 "finally",
99 "published",
100 "procedure",
101 "absolute",
102 "reintroduce",
103 "operator",
104 "as",
105 "is",
106 "abstract",
107 "alias",
108 "assembler",
109 "bitpacked",
110 "break",
111 "continue",
112 "cppdecl",
113 "cvar",
114 "enumerator",
115 "experimental",
116 "platform",
117 "deprecated",
118 "unimplemented",
119 "dynamic",
120 "export",
121 "far16",
122 "forward",
123 "generic",
124 "helper",
125 "implements",
126 "interrupt",
127 "iochecks",
128 "local",
129 "name",
130 "nodefault",
131 "noreturn",
132 "nostackframe",
133 "oldfpccall",
134 "otherwise",
135 "saveregisters",
136 "softfloat",
137 "specialize",
138 "strict",
139 "unaligned",
140 "varargs"
141 ];
142 const COMMENT_MODES = [
143 hljs.C_LINE_COMMENT_MODE,
144 hljs.COMMENT(/\{/, /\}/, { relevance: 0 }),
145 hljs.COMMENT(/\(\*/, /\*\)/, { relevance: 10 })
146 ];
147 const DIRECTIVE = {
148 className: 'meta',
149 variants: [
150 {
151 begin: /\{\$/,
152 end: /\}/
153 },
154 {
155 begin: /\(\*\$/,
156 end: /\*\)/
157 }
158 ]
159 };
160 const STRING = {
161 className: 'string',
162 begin: /'/,
163 end: /'/,
164 contains: [ { begin: /''/ } ]
165 };
166 const NUMBER = {
167 className: 'number',
168 relevance: 0,
169 // Source: https://www.freepascal.org/docs-html/ref/refse6.html
170 variants: [
171 {
172 // Regular numbers, e.g., 123, 123.456.
173 match: /\b\d[\d_]*(\.\d[\d_]*)?/ },
174 {
175 // Hexadecimal notation, e.g., $7F.
176 match: /\$[\dA-Fa-f_]+/ },
177 {
178 // Hexadecimal literal with no digits
179 match: /\$/,
180 relevance: 0 },
181 {
182 // Octal notation, e.g., &42.
183 match: /&[0-7][0-7_]*/ },
184 {
185 // Binary notation, e.g., %1010.
186 match: /%[01_]+/ },
187 {
188 // Binary literal with no digits
189 match: /%/,
190 relevance: 0 }
191 ]
192 };
193 const CHAR_STRING = {
194 className: 'string',
195 variants: [
196 { match: /#\d[\d_]*/ },
197 { match: /#\$[\dA-Fa-f][\dA-Fa-f_]*/ },
198 { match: /#&[0-7][0-7_]*/ },
199 { match: /#%[01][01_]*/ }
200 ]
201 };
202 const CLASS = {
203 begin: hljs.IDENT_RE + '\\s*=\\s*class\\s*\\(',
204 returnBegin: true,
205 contains: [ hljs.TITLE_MODE ]
206 };
207 const FUNCTION = {
208 className: 'function',
209 beginKeywords: 'function constructor destructor procedure',
210 end: /[:;]/,
211 keywords: 'function constructor|10 destructor|10 procedure|10',
212 contains: [
213 hljs.TITLE_MODE,
214 {
215 className: 'params',
216 begin: /\(/,
217 end: /\)/,
218 keywords: KEYWORDS,
219 contains: [
220 STRING,
221 CHAR_STRING,
222 DIRECTIVE
223 ].concat(COMMENT_MODES)
224 },
225 DIRECTIVE
226 ].concat(COMMENT_MODES)
227 };
228 return {
229 name: 'Delphi',
230 aliases: [
231 'dpr',
232 'dfm',
233 'pas',
234 'pascal'
235 ],
236 case_insensitive: true,
237 keywords: KEYWORDS,
238 illegal: /"|\$[G-Zg-z]|\/\*|<\/|\|/,
239 contains: [
240 STRING,
241 CHAR_STRING,
242 NUMBER,
243 CLASS,
244 FUNCTION,
245 DIRECTIVE
246 ].concat(COMMENT_MODES)
247 };
248 }
249
250 return delphi;
251
252 })();
253 ;
254 export default hljsGrammar;