1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/vbnet.js

215 lines
5.9 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/**
* @param {string} value
* @returns {RegExp}
* */
/**
* @param {RegExp | string } re
* @returns {string}
*/
function source(re) {
if (!re) return null;
if (typeof re === "string") return re;
return re.source;
}
/**
* @param {...(RegExp | string) } args
* @returns {string}
*/
function concat(...args) {
const joined = args.map((x) => source(x)).join("");
return joined;
}
/**
* Any of the passed expresssions may match
*
* Creates a huge this | this | that | that match
* @param {(RegExp | string)[] } args
* @returns {string}
*/
function either(...args) {
const joined = '(' + args.map((x) => source(x)).join("|") + ")";
return joined;
}
/*
Language: Visual Basic .NET
Description: Visual Basic .NET (VB.NET) is a multi-paradigm, object-oriented programming language, implemented on the .NET Framework.
Authors: Poren Chiang <ren.chiang@gmail.com>, Jan Pilzer
Website: https://docs.microsoft.com/dotnet/visual-basic/getting-started
Category: common
*/
/** @type LanguageFn */
function vbnet(hljs) {
/**
* Character Literal
* Either a single character ("a"C) or an escaped double quote (""""C).
*/
const CHARACTER = {
className: 'string',
begin: /"(""|[^/n])"C\b/
};
const STRING = {
className: 'string',
begin: /"/,
end: /"/,
illegal: /\n/,
contains: [
{
// double quote escape
begin: /""/
}
]
};
/** Date Literals consist of a date, a time, or both separated by whitespace, surrounded by # */
const MM_DD_YYYY = /\d{1,2}\/\d{1,2}\/\d{4}/;
const YYYY_MM_DD = /\d{4}-\d{1,2}-\d{1,2}/;
const TIME_12H = /(\d|1[012])(:\d+){0,2} *(AM|PM)/;
const TIME_24H = /\d{1,2}(:\d{1,2}){1,2}/;
const DATE = {
className: 'literal',
variants: [
{
// #YYYY-MM-DD# (ISO-Date) or #M/D/YYYY# (US-Date)
begin: concat(/# */, either(YYYY_MM_DD, MM_DD_YYYY), / *#/)
},
{
// #H:mm[:ss]# (24h Time)
begin: concat(/# */, TIME_24H, / *#/)
},
{
// #h[:mm[:ss]] A# (12h Time)
begin: concat(/# */, TIME_12H, / *#/)
},
{
// date plus time
begin: concat(
/# */,
either(YYYY_MM_DD, MM_DD_YYYY),
/ +/,
either(TIME_12H, TIME_24H),
/ *#/
)
}
]
};
const NUMBER = {
className: 'number',
relevance: 0,
variants: [
{
// Float
begin: /\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/
},
{
// Integer (base 10)
begin: /\b\d[\d_]*((U?[SIL])|[%&])?/
},
{
// Integer (base 16)
begin: /&H[\dA-F_]+((U?[SIL])|[%&])?/
},
{
// Integer (base 8)
begin: /&O[0-7_]+((U?[SIL])|[%&])?/
},
{
// Integer (base 2)
begin: /&B[01_]+((U?[SIL])|[%&])?/
}
]
};
const LABEL = {
className: 'label',
begin: /^\w+:/
};
const DOC_COMMENT = hljs.COMMENT(/'''/, /$/, {
contains: [
{
className: 'doctag',
begin: /<\/?/,
end: />/
}
]
});
const COMMENT = hljs.COMMENT(null, /$/, {
variants: [
{
begin: /'/
},
{
// TODO: Use `beforeMatch:` for leading spaces
begin: /([\t ]|^)REM(?=\s)/
}
]
});
const DIRECTIVES = {
className: 'meta',
// TODO: Use `beforeMatch:` for indentation once available
begin: /[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,
end: /$/,
keywords: {
'meta-keyword':
'const disable else elseif enable end externalsource if region then'
},
contains: [ COMMENT ]
};
2023-12-18 13:12:25 +08:00
return {
2024-01-16 21:26:16 +08:00
name: 'Visual Basic .NET',
aliases: [ 'vb' ],
2023-12-18 13:12:25 +08:00
case_insensitive: true,
2024-01-16 21:26:16 +08:00
classNameAliases: {
label: 'symbol'
},
2023-12-18 13:12:25 +08:00
keywords: {
keyword:
2024-01-16 21:26:16 +08:00
'addhandler alias aggregate ansi as async assembly auto binary by byref byval ' + /* a-b */
2023-12-18 13:12:25 +08:00
'call case catch class compare const continue custom declare default delegate dim distinct do ' + /* c-d */
'each equals else elseif end enum erase error event exit explicit finally for friend from function ' + /* e-f */
2024-01-16 21:26:16 +08:00
'get global goto group handles if implements imports in inherits interface into iterator ' + /* g-i */
'join key let lib loop me mid module mustinherit mustoverride mybase myclass ' + /* j-m */
'namespace narrowing new next notinheritable notoverridable ' + /* n */
'of off on operator option optional order overloads overridable overrides ' + /* o */
2023-12-18 13:12:25 +08:00
'paramarray partial preserve private property protected public ' + /* p */
2024-01-16 21:26:16 +08:00
'raiseevent readonly redim removehandler resume return ' + /* r */
2023-12-18 13:12:25 +08:00
'select set shadows shared skip static step stop structure strict sub synclock ' + /* s */
2024-01-16 21:26:16 +08:00
'take text then throw to try unicode until using when where while widening with withevents writeonly yield' /* t-y */,
2023-12-18 13:12:25 +08:00
built_in:
2024-01-16 21:26:16 +08:00
// Operators https://docs.microsoft.com/dotnet/visual-basic/language-reference/operators
'addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor ' +
// Type Conversion Functions https://docs.microsoft.com/dotnet/visual-basic/language-reference/functions/type-conversion-functions
'cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort',
type:
// Data types https://docs.microsoft.com/dotnet/visual-basic/language-reference/data-types
'boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort',
literal: 'true false nothing'
2023-12-18 13:12:25 +08:00
},
2024-01-16 21:26:16 +08:00
illegal:
'//|\\{|\\}|endif|gosub|variant|wend|^\\$ ' /* reserved deprecated keywords */,
2023-12-18 13:12:25 +08:00
contains: [
2024-01-16 21:26:16 +08:00
CHARACTER,
STRING,
DATE,
NUMBER,
LABEL,
DOC_COMMENT,
COMMENT,
DIRECTIVES
2023-12-18 13:12:25 +08:00
]
};
2024-01-16 21:26:16 +08:00
}
module.exports = vbnet;