123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- /*
- Language: VBScript
- Description: VBScript ("Microsoft Visual Basic Scripting Edition") is an Active Scripting language developed by Microsoft that is modeled on Visual Basic.
- Author: Nikita Ledyaev <lenikita@yandex.ru>
- Contributors: Michal Gabrukiewicz <mgabru@gmail.com>
- Website: https://en.wikipedia.org/wiki/VBScript
- Category: scripting
- */
- /** @type LanguageFn */
- function vbscript(hljs) {
- const regex = hljs.regex;
- const BUILT_IN_FUNCTIONS = [
- "lcase",
- "month",
- "vartype",
- "instrrev",
- "ubound",
- "setlocale",
- "getobject",
- "rgb",
- "getref",
- "string",
- "weekdayname",
- "rnd",
- "dateadd",
- "monthname",
- "now",
- "day",
- "minute",
- "isarray",
- "cbool",
- "round",
- "formatcurrency",
- "conversions",
- "csng",
- "timevalue",
- "second",
- "year",
- "space",
- "abs",
- "clng",
- "timeserial",
- "fixs",
- "len",
- "asc",
- "isempty",
- "maths",
- "dateserial",
- "atn",
- "timer",
- "isobject",
- "filter",
- "weekday",
- "datevalue",
- "ccur",
- "isdate",
- "instr",
- "datediff",
- "formatdatetime",
- "replace",
- "isnull",
- "right",
- "sgn",
- "array",
- "snumeric",
- "log",
- "cdbl",
- "hex",
- "chr",
- "lbound",
- "msgbox",
- "ucase",
- "getlocale",
- "cos",
- "cdate",
- "cbyte",
- "rtrim",
- "join",
- "hour",
- "oct",
- "typename",
- "trim",
- "strcomp",
- "int",
- "createobject",
- "loadpicture",
- "tan",
- "formatnumber",
- "mid",
- "split",
- "cint",
- "sin",
- "datepart",
- "ltrim",
- "sqr",
- "time",
- "derived",
- "eval",
- "date",
- "formatpercent",
- "exp",
- "inputbox",
- "left",
- "ascw",
- "chrw",
- "regexp",
- "cstr",
- "err"
- ];
- const BUILT_IN_OBJECTS = [
- "server",
- "response",
- "request",
- // take no arguments so can be called without ()
- "scriptengine",
- "scriptenginebuildversion",
- "scriptengineminorversion",
- "scriptenginemajorversion"
- ];
- const BUILT_IN_CALL = {
- begin: regex.concat(regex.either(...BUILT_IN_FUNCTIONS), "\\s*\\("),
- // relevance 0 because this is acting as a beginKeywords really
- relevance: 0,
- keywords: { built_in: BUILT_IN_FUNCTIONS }
- };
- const LITERALS = [
- "true",
- "false",
- "null",
- "nothing",
- "empty"
- ];
- const KEYWORDS = [
- "call",
- "class",
- "const",
- "dim",
- "do",
- "loop",
- "erase",
- "execute",
- "executeglobal",
- "exit",
- "for",
- "each",
- "next",
- "function",
- "if",
- "then",
- "else",
- "on",
- "error",
- "option",
- "explicit",
- "new",
- "private",
- "property",
- "let",
- "get",
- "public",
- "randomize",
- "redim",
- "rem",
- "select",
- "case",
- "set",
- "stop",
- "sub",
- "while",
- "wend",
- "with",
- "end",
- "to",
- "elseif",
- "is",
- "or",
- "xor",
- "and",
- "not",
- "class_initialize",
- "class_terminate",
- "default",
- "preserve",
- "in",
- "me",
- "byval",
- "byref",
- "step",
- "resume",
- "goto"
- ];
- return {
- name: 'VBScript',
- aliases: [ 'vbs' ],
- case_insensitive: true,
- keywords: {
- keyword: KEYWORDS,
- built_in: BUILT_IN_OBJECTS,
- literal: LITERALS
- },
- illegal: '//',
- contains: [
- BUILT_IN_CALL,
- hljs.inherit(hljs.QUOTE_STRING_MODE, { contains: [ { begin: '""' } ] }),
- hljs.COMMENT(
- /'/,
- /$/,
- { relevance: 0 }
- ),
- hljs.C_NUMBER_MODE
- ]
- };
- }
- export { vbscript as default };
|