source: node_modules/highlight.js/lib/languages/vbscript.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.1 KB
Line 
1/**
2 * @param {string} value
3 * @returns {RegExp}
4 * */
5
6/**
7 * @param {RegExp | string } re
8 * @returns {string}
9 */
10function source(re) {
11 if (!re) return null;
12 if (typeof re === "string") return re;
13
14 return re.source;
15}
16
17/**
18 * @param {...(RegExp | string) } args
19 * @returns {string}
20 */
21function concat(...args) {
22 const joined = args.map((x) => source(x)).join("");
23 return joined;
24}
25
26/**
27 * Any of the passed expresssions may match
28 *
29 * Creates a huge this | this | that | that match
30 * @param {(RegExp | string)[] } args
31 * @returns {string}
32 */
33function either(...args) {
34 const joined = '(' + args.map((x) => source(x)).join("|") + ")";
35 return joined;
36}
37
38/*
39Language: VBScript
40Description: VBScript ("Microsoft Visual Basic Scripting Edition") is an Active Scripting language developed by Microsoft that is modeled on Visual Basic.
41Author: Nikita Ledyaev <lenikita@yandex.ru>
42Contributors: Michal Gabrukiewicz <mgabru@gmail.com>
43Website: https://en.wikipedia.org/wiki/VBScript
44Category: scripting
45*/
46
47/** @type LanguageFn */
48function vbscript(hljs) {
49 const BUILT_IN_FUNCTIONS = ('lcase month vartype instrrev ubound setlocale getobject rgb getref string ' +
50 'weekdayname rnd dateadd monthname now day minute isarray cbool round formatcurrency ' +
51 'conversions csng timevalue second year space abs clng timeserial fixs len asc ' +
52 'isempty maths dateserial atn timer isobject filter weekday datevalue ccur isdate ' +
53 'instr datediff formatdatetime replace isnull right sgn array snumeric log cdbl hex ' +
54 'chr lbound msgbox ucase getlocale cos cdate cbyte rtrim join hour oct typename trim ' +
55 'strcomp int createobject loadpicture tan formatnumber mid ' +
56 'split cint sin datepart ltrim sqr ' +
57 'time derived eval date formatpercent exp inputbox left ascw ' +
58 'chrw regexp cstr err').split(" ");
59 const BUILT_IN_OBJECTS = [
60 "server",
61 "response",
62 "request",
63 // take no arguments so can be called without ()
64 "scriptengine",
65 "scriptenginebuildversion",
66 "scriptengineminorversion",
67 "scriptenginemajorversion"
68 ];
69
70 const BUILT_IN_CALL = {
71 begin: concat(either(...BUILT_IN_FUNCTIONS), "\\s*\\("),
72 // relevance 0 because this is acting as a beginKeywords really
73 relevance:0,
74 keywords: {
75 built_in: BUILT_IN_FUNCTIONS
76 }
77 };
78
79 return {
80 name: 'VBScript',
81 aliases: ['vbs'],
82 case_insensitive: true,
83 keywords: {
84 keyword:
85 'call class const dim do loop erase execute executeglobal exit for each next function ' +
86 'if then else on error option explicit new private property let get public randomize ' +
87 'redim rem select case set stop sub while wend with end to elseif is or xor and not ' +
88 'class_initialize class_terminate default preserve in me byval byref step resume goto',
89 built_in: BUILT_IN_OBJECTS,
90 literal:
91 'true false null nothing empty'
92 },
93 illegal: '//',
94 contains: [
95 BUILT_IN_CALL,
96 hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [{begin: '""'}]}),
97 hljs.COMMENT(
98 /'/,
99 /$/,
100 {
101 relevance: 0
102 }
103 ),
104 hljs.C_NUMBER_MODE
105 ]
106 };
107}
108
109module.exports = vbscript;
Note: See TracBrowser for help on using the repository browser.