]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/nsis.js
Initial commit.
[flow-web.git] / static / highlight / languages / nsis.js
1 /*! `nsis` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: NSIS
8 Description: Nullsoft Scriptable Install System
9 Author: Jan T. Sott <jan.sott@gmail.com>
10 Website: https://nsis.sourceforge.io/Main_Page
11 Category: scripting
12 */
13
14
15 function nsis(hljs) {
16 const regex = hljs.regex;
17 const LANGUAGE_CONSTANTS = [
18 "ADMINTOOLS",
19 "APPDATA",
20 "CDBURN_AREA",
21 "CMDLINE",
22 "COMMONFILES32",
23 "COMMONFILES64",
24 "COMMONFILES",
25 "COOKIES",
26 "DESKTOP",
27 "DOCUMENTS",
28 "EXEDIR",
29 "EXEFILE",
30 "EXEPATH",
31 "FAVORITES",
32 "FONTS",
33 "HISTORY",
34 "HWNDPARENT",
35 "INSTDIR",
36 "INTERNET_CACHE",
37 "LANGUAGE",
38 "LOCALAPPDATA",
39 "MUSIC",
40 "NETHOOD",
41 "OUTDIR",
42 "PICTURES",
43 "PLUGINSDIR",
44 "PRINTHOOD",
45 "PROFILE",
46 "PROGRAMFILES32",
47 "PROGRAMFILES64",
48 "PROGRAMFILES",
49 "QUICKLAUNCH",
50 "RECENT",
51 "RESOURCES_LOCALIZED",
52 "RESOURCES",
53 "SENDTO",
54 "SMPROGRAMS",
55 "SMSTARTUP",
56 "STARTMENU",
57 "SYSDIR",
58 "TEMP",
59 "TEMPLATES",
60 "VIDEOS",
61 "WINDIR"
62 ];
63
64 const PARAM_NAMES = [
65 "ARCHIVE",
66 "FILE_ATTRIBUTE_ARCHIVE",
67 "FILE_ATTRIBUTE_NORMAL",
68 "FILE_ATTRIBUTE_OFFLINE",
69 "FILE_ATTRIBUTE_READONLY",
70 "FILE_ATTRIBUTE_SYSTEM",
71 "FILE_ATTRIBUTE_TEMPORARY",
72 "HKCR",
73 "HKCU",
74 "HKDD",
75 "HKEY_CLASSES_ROOT",
76 "HKEY_CURRENT_CONFIG",
77 "HKEY_CURRENT_USER",
78 "HKEY_DYN_DATA",
79 "HKEY_LOCAL_MACHINE",
80 "HKEY_PERFORMANCE_DATA",
81 "HKEY_USERS",
82 "HKLM",
83 "HKPD",
84 "HKU",
85 "IDABORT",
86 "IDCANCEL",
87 "IDIGNORE",
88 "IDNO",
89 "IDOK",
90 "IDRETRY",
91 "IDYES",
92 "MB_ABORTRETRYIGNORE",
93 "MB_DEFBUTTON1",
94 "MB_DEFBUTTON2",
95 "MB_DEFBUTTON3",
96 "MB_DEFBUTTON4",
97 "MB_ICONEXCLAMATION",
98 "MB_ICONINFORMATION",
99 "MB_ICONQUESTION",
100 "MB_ICONSTOP",
101 "MB_OK",
102 "MB_OKCANCEL",
103 "MB_RETRYCANCEL",
104 "MB_RIGHT",
105 "MB_RTLREADING",
106 "MB_SETFOREGROUND",
107 "MB_TOPMOST",
108 "MB_USERICON",
109 "MB_YESNO",
110 "NORMAL",
111 "OFFLINE",
112 "READONLY",
113 "SHCTX",
114 "SHELL_CONTEXT",
115 "SYSTEM|TEMPORARY",
116 ];
117
118 const COMPILER_FLAGS = [
119 "addincludedir",
120 "addplugindir",
121 "appendfile",
122 "assert",
123 "cd",
124 "define",
125 "delfile",
126 "echo",
127 "else",
128 "endif",
129 "error",
130 "execute",
131 "finalize",
132 "getdllversion",
133 "gettlbversion",
134 "if",
135 "ifdef",
136 "ifmacrodef",
137 "ifmacrondef",
138 "ifndef",
139 "include",
140 "insertmacro",
141 "macro",
142 "macroend",
143 "makensis",
144 "packhdr",
145 "searchparse",
146 "searchreplace",
147 "system",
148 "tempfile",
149 "undef",
150 "uninstfinalize",
151 "verbose",
152 "warning",
153 ];
154
155 const CONSTANTS = {
156 className: 'variable.constant',
157 begin: regex.concat(/\$/, regex.either(...LANGUAGE_CONSTANTS))
158 };
159
160 const DEFINES = {
161 // ${defines}
162 className: 'variable',
163 begin: /\$+\{[\!\w.:-]+\}/
164 };
165
166 const VARIABLES = {
167 // $variables
168 className: 'variable',
169 begin: /\$+\w[\w\.]*/,
170 illegal: /\(\)\{\}/
171 };
172
173 const LANGUAGES = {
174 // $(language_strings)
175 className: 'variable',
176 begin: /\$+\([\w^.:!-]+\)/
177 };
178
179 const PARAMETERS = {
180 // command parameters
181 className: 'params',
182 begin: regex.either(...PARAM_NAMES)
183 };
184
185 const COMPILER = {
186 // !compiler_flags
187 className: 'keyword',
188 begin: regex.concat(
189 /!/,
190 regex.either(...COMPILER_FLAGS)
191 )
192 };
193
194 const ESCAPE_CHARS = {
195 // $\n, $\r, $\t, $$
196 className: 'char.escape',
197 begin: /\$(\\[nrt]|\$)/
198 };
199
200 const PLUGINS = {
201 // plug::ins
202 className: 'title.function',
203 begin: /\w+::\w+/
204 };
205
206 const STRING = {
207 className: 'string',
208 variants: [
209 {
210 begin: '"',
211 end: '"'
212 },
213 {
214 begin: '\'',
215 end: '\''
216 },
217 {
218 begin: '`',
219 end: '`'
220 }
221 ],
222 illegal: /\n/,
223 contains: [
224 ESCAPE_CHARS,
225 CONSTANTS,
226 DEFINES,
227 VARIABLES,
228 LANGUAGES
229 ]
230 };
231
232 const KEYWORDS = [
233 "Abort",
234 "AddBrandingImage",
235 "AddSize",
236 "AllowRootDirInstall",
237 "AllowSkipFiles",
238 "AutoCloseWindow",
239 "BGFont",
240 "BGGradient",
241 "BrandingText",
242 "BringToFront",
243 "Call",
244 "CallInstDLL",
245 "Caption",
246 "ChangeUI",
247 "CheckBitmap",
248 "ClearErrors",
249 "CompletedText",
250 "ComponentText",
251 "CopyFiles",
252 "CRCCheck",
253 "CreateDirectory",
254 "CreateFont",
255 "CreateShortCut",
256 "Delete",
257 "DeleteINISec",
258 "DeleteINIStr",
259 "DeleteRegKey",
260 "DeleteRegValue",
261 "DetailPrint",
262 "DetailsButtonText",
263 "DirText",
264 "DirVar",
265 "DirVerify",
266 "EnableWindow",
267 "EnumRegKey",
268 "EnumRegValue",
269 "Exch",
270 "Exec",
271 "ExecShell",
272 "ExecShellWait",
273 "ExecWait",
274 "ExpandEnvStrings",
275 "File",
276 "FileBufSize",
277 "FileClose",
278 "FileErrorText",
279 "FileOpen",
280 "FileRead",
281 "FileReadByte",
282 "FileReadUTF16LE",
283 "FileReadWord",
284 "FileWriteUTF16LE",
285 "FileSeek",
286 "FileWrite",
287 "FileWriteByte",
288 "FileWriteWord",
289 "FindClose",
290 "FindFirst",
291 "FindNext",
292 "FindWindow",
293 "FlushINI",
294 "GetCurInstType",
295 "GetCurrentAddress",
296 "GetDlgItem",
297 "GetDLLVersion",
298 "GetDLLVersionLocal",
299 "GetErrorLevel",
300 "GetFileTime",
301 "GetFileTimeLocal",
302 "GetFullPathName",
303 "GetFunctionAddress",
304 "GetInstDirError",
305 "GetKnownFolderPath",
306 "GetLabelAddress",
307 "GetTempFileName",
308 "GetWinVer",
309 "Goto",
310 "HideWindow",
311 "Icon",
312 "IfAbort",
313 "IfErrors",
314 "IfFileExists",
315 "IfRebootFlag",
316 "IfRtlLanguage",
317 "IfShellVarContextAll",
318 "IfSilent",
319 "InitPluginsDir",
320 "InstallButtonText",
321 "InstallColors",
322 "InstallDir",
323 "InstallDirRegKey",
324 "InstProgressFlags",
325 "InstType",
326 "InstTypeGetText",
327 "InstTypeSetText",
328 "Int64Cmp",
329 "Int64CmpU",
330 "Int64Fmt",
331 "IntCmp",
332 "IntCmpU",
333 "IntFmt",
334 "IntOp",
335 "IntPtrCmp",
336 "IntPtrCmpU",
337 "IntPtrOp",
338 "IsWindow",
339 "LangString",
340 "LicenseBkColor",
341 "LicenseData",
342 "LicenseForceSelection",
343 "LicenseLangString",
344 "LicenseText",
345 "LoadAndSetImage",
346 "LoadLanguageFile",
347 "LockWindow",
348 "LogSet",
349 "LogText",
350 "ManifestDPIAware",
351 "ManifestLongPathAware",
352 "ManifestMaxVersionTested",
353 "ManifestSupportedOS",
354 "MessageBox",
355 "MiscButtonText",
356 "Name|0",
357 "Nop",
358 "OutFile",
359 "Page",
360 "PageCallbacks",
361 "PEAddResource",
362 "PEDllCharacteristics",
363 "PERemoveResource",
364 "PESubsysVer",
365 "Pop",
366 "Push",
367 "Quit",
368 "ReadEnvStr",
369 "ReadINIStr",
370 "ReadRegDWORD",
371 "ReadRegStr",
372 "Reboot",
373 "RegDLL",
374 "Rename",
375 "RequestExecutionLevel",
376 "ReserveFile",
377 "Return",
378 "RMDir",
379 "SearchPath",
380 "SectionGetFlags",
381 "SectionGetInstTypes",
382 "SectionGetSize",
383 "SectionGetText",
384 "SectionIn",
385 "SectionSetFlags",
386 "SectionSetInstTypes",
387 "SectionSetSize",
388 "SectionSetText",
389 "SendMessage",
390 "SetAutoClose",
391 "SetBrandingImage",
392 "SetCompress",
393 "SetCompressor",
394 "SetCompressorDictSize",
395 "SetCtlColors",
396 "SetCurInstType",
397 "SetDatablockOptimize",
398 "SetDateSave",
399 "SetDetailsPrint",
400 "SetDetailsView",
401 "SetErrorLevel",
402 "SetErrors",
403 "SetFileAttributes",
404 "SetFont",
405 "SetOutPath",
406 "SetOverwrite",
407 "SetRebootFlag",
408 "SetRegView",
409 "SetShellVarContext",
410 "SetSilent",
411 "ShowInstDetails",
412 "ShowUninstDetails",
413 "ShowWindow",
414 "SilentInstall",
415 "SilentUnInstall",
416 "Sleep",
417 "SpaceTexts",
418 "StrCmp",
419 "StrCmpS",
420 "StrCpy",
421 "StrLen",
422 "SubCaption",
423 "Unicode",
424 "UninstallButtonText",
425 "UninstallCaption",
426 "UninstallIcon",
427 "UninstallSubCaption",
428 "UninstallText",
429 "UninstPage",
430 "UnRegDLL",
431 "Var",
432 "VIAddVersionKey",
433 "VIFileVersion",
434 "VIProductVersion",
435 "WindowIcon",
436 "WriteINIStr",
437 "WriteRegBin",
438 "WriteRegDWORD",
439 "WriteRegExpandStr",
440 "WriteRegMultiStr",
441 "WriteRegNone",
442 "WriteRegStr",
443 "WriteUninstaller",
444 "XPStyle"
445 ];
446
447 const LITERALS = [
448 "admin",
449 "all",
450 "auto",
451 "both",
452 "bottom",
453 "bzip2",
454 "colored",
455 "components",
456 "current",
457 "custom",
458 "directory",
459 "false",
460 "force",
461 "hide",
462 "highest",
463 "ifdiff",
464 "ifnewer",
465 "instfiles",
466 "lastused",
467 "leave",
468 "left",
469 "license",
470 "listonly",
471 "lzma",
472 "nevershow",
473 "none",
474 "normal",
475 "notset",
476 "off",
477 "on",
478 "open",
479 "print",
480 "right",
481 "show",
482 "silent",
483 "silentlog",
484 "smooth",
485 "textonly",
486 "top",
487 "true",
488 "try",
489 "un.components",
490 "un.custom",
491 "un.directory",
492 "un.instfiles",
493 "un.license",
494 "uninstConfirm",
495 "user",
496 "Win10",
497 "Win7",
498 "Win8",
499 "WinVista",
500 "zlib"
501 ];
502
503 const FUNCTION_DEFINITION = {
504 match: [
505 /Function/,
506 /\s+/,
507 regex.concat(/(\.)?/, hljs.IDENT_RE)
508 ],
509 scope: {
510 1: "keyword",
511 3: "title.function"
512 }
513 };
514
515 // Var Custom.Variable.Name.Item
516 // Var /GLOBAL Custom.Variable.Name.Item
517 const VARIABLE_NAME_RE = /[A-Za-z][\w.]*/;
518 const VARIABLE_DEFINITION = {
519 match: [
520 /Var/,
521 /\s+/,
522 /(?:\/GLOBAL\s+)?/,
523 VARIABLE_NAME_RE
524 ],
525 scope: {
526 1: "keyword",
527 3: "params",
528 4: "variable"
529 }
530 };
531
532 return {
533 name: 'NSIS',
534 case_insensitive: true,
535 keywords: {
536 keyword: KEYWORDS,
537 literal: LITERALS
538 },
539 contains: [
540 hljs.HASH_COMMENT_MODE,
541 hljs.C_BLOCK_COMMENT_MODE,
542 hljs.COMMENT(
543 ';',
544 '$',
545 { relevance: 0 }
546 ),
547 VARIABLE_DEFINITION,
548 FUNCTION_DEFINITION,
549 { beginKeywords: 'Function PageEx Section SectionGroup FunctionEnd SectionEnd', },
550 STRING,
551 COMPILER,
552 DEFINES,
553 VARIABLES,
554 LANGUAGES,
555 PARAMETERS,
556 PLUGINS,
557 hljs.NUMBER_MODE
558 ]
559 };
560 }
561
562 return nsis;
563
564 })();
565
566 hljs.registerLanguage('nsis', hljsGrammar);
567 })();