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