]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/vbnet.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / vbnet.js
1 /*! `vbnet` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Visual Basic .NET
7 Description: Visual Basic .NET (VB.NET) is a multi-paradigm, object-oriented programming language, implemented on the .NET Framework.
8 Authors: Poren Chiang <ren.chiang@gmail.com>, Jan Pilzer
9 Website: https://docs.microsoft.com/dotnet/visual-basic/getting-started
10 Category: common
11 */
12
13 /** @type LanguageFn */
14 function vbnet(hljs) {
15 const regex = hljs.regex;
16 /**
17 * Character Literal
18 * Either a single character ("a"C) or an escaped double quote (""""C).
19 */
20 const CHARACTER = {
21 className: 'string',
22 begin: /"(""|[^/n])"C\b/
23 };
24
25 const STRING = {
26 className: 'string',
27 begin: /"/,
28 end: /"/,
29 illegal: /\n/,
30 contains: [
31 {
32 // double quote escape
33 begin: /""/ }
34 ]
35 };
36
37 /** Date Literals consist of a date, a time, or both separated by whitespace, surrounded by # */
38 const MM_DD_YYYY = /\d{1,2}\/\d{1,2}\/\d{4}/;
39 const YYYY_MM_DD = /\d{4}-\d{1,2}-\d{1,2}/;
40 const TIME_12H = /(\d|1[012])(:\d+){0,2} *(AM|PM)/;
41 const TIME_24H = /\d{1,2}(:\d{1,2}){1,2}/;
42 const DATE = {
43 className: 'literal',
44 variants: [
45 {
46 // #YYYY-MM-DD# (ISO-Date) or #M/D/YYYY# (US-Date)
47 begin: regex.concat(/# */, regex.either(YYYY_MM_DD, MM_DD_YYYY), / *#/) },
48 {
49 // #H:mm[:ss]# (24h Time)
50 begin: regex.concat(/# */, TIME_24H, / *#/) },
51 {
52 // #h[:mm[:ss]] A# (12h Time)
53 begin: regex.concat(/# */, TIME_12H, / *#/) },
54 {
55 // date plus time
56 begin: regex.concat(
57 /# */,
58 regex.either(YYYY_MM_DD, MM_DD_YYYY),
59 / +/,
60 regex.either(TIME_12H, TIME_24H),
61 / *#/
62 ) }
63 ]
64 };
65
66 const NUMBER = {
67 className: 'number',
68 relevance: 0,
69 variants: [
70 {
71 // Float
72 begin: /\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/ },
73 {
74 // Integer (base 10)
75 begin: /\b\d[\d_]*((U?[SIL])|[%&])?/ },
76 {
77 // Integer (base 16)
78 begin: /&H[\dA-F_]+((U?[SIL])|[%&])?/ },
79 {
80 // Integer (base 8)
81 begin: /&O[0-7_]+((U?[SIL])|[%&])?/ },
82 {
83 // Integer (base 2)
84 begin: /&B[01_]+((U?[SIL])|[%&])?/ }
85 ]
86 };
87
88 const LABEL = {
89 className: 'label',
90 begin: /^\w+:/
91 };
92
93 const DOC_COMMENT = hljs.COMMENT(/'''/, /$/, { contains: [
94 {
95 className: 'doctag',
96 begin: /<\/?/,
97 end: />/
98 }
99 ] });
100
101 const COMMENT = hljs.COMMENT(null, /$/, { variants: [
102 { begin: /'/ },
103 {
104 // TODO: Use multi-class for leading spaces
105 begin: /([\t ]|^)REM(?=\s)/ }
106 ] });
107
108 const DIRECTIVES = {
109 className: 'meta',
110 // TODO: Use multi-class for indentation once available
111 begin: /[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,
112 end: /$/,
113 keywords: { keyword:
114 'const disable else elseif enable end externalsource if region then' },
115 contains: [ COMMENT ]
116 };
117
118 return {
119 name: 'Visual Basic .NET',
120 aliases: [ 'vb' ],
121 case_insensitive: true,
122 classNameAliases: { label: 'symbol' },
123 keywords: {
124 keyword:
125 'addhandler alias aggregate ansi as async assembly auto binary by byref byval ' /* a-b */
126 + 'call case catch class compare const continue custom declare default delegate dim distinct do ' /* c-d */
127 + 'each equals else elseif end enum erase error event exit explicit finally for friend from function ' /* e-f */
128 + 'get global goto group handles if implements imports in inherits interface into iterator ' /* g-i */
129 + 'join key let lib loop me mid module mustinherit mustoverride mybase myclass ' /* j-m */
130 + 'namespace narrowing new next notinheritable notoverridable ' /* n */
131 + 'of off on operator option optional order overloads overridable overrides ' /* o */
132 + 'paramarray partial preserve private property protected public ' /* p */
133 + 'raiseevent readonly redim removehandler resume return ' /* r */
134 + 'select set shadows shared skip static step stop structure strict sub synclock ' /* s */
135 + 'take text then throw to try unicode until using when where while widening with withevents writeonly yield' /* t-y */,
136 built_in:
137 // Operators https://docs.microsoft.com/dotnet/visual-basic/language-reference/operators
138 'addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor '
139 // Type Conversion Functions https://docs.microsoft.com/dotnet/visual-basic/language-reference/functions/type-conversion-functions
140 + 'cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort',
141 type:
142 // Data types https://docs.microsoft.com/dotnet/visual-basic/language-reference/data-types
143 'boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort',
144 literal: 'true false nothing'
145 },
146 illegal:
147 '//|\\{|\\}|endif|gosub|variant|wend|^\\$ ' /* reserved deprecated keywords */,
148 contains: [
149 CHARACTER,
150 STRING,
151 DATE,
152 NUMBER,
153 LABEL,
154 DOC_COMMENT,
155 COMMENT,
156 DIRECTIVES
157 ]
158 };
159 }
160
161 return vbnet;
162
163 })();
164 ;
165 export default hljsGrammar;