1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function vbnet(hljs) {
|
11 | const regex = hljs.regex;
|
12 | |
13 |
|
14 |
|
15 |
|
16 | const CHARACTER = {
|
17 | className: 'string',
|
18 | begin: /"(""|[^/n])"C\b/
|
19 | };
|
20 |
|
21 | const STRING = {
|
22 | className: 'string',
|
23 | begin: /"/,
|
24 | end: /"/,
|
25 | illegal: /\n/,
|
26 | contains: [
|
27 | {
|
28 |
|
29 | begin: /""/
|
30 | }
|
31 | ]
|
32 | };
|
33 |
|
34 |
|
35 | const MM_DD_YYYY = /\d{1,2}\/\d{1,2}\/\d{4}/;
|
36 | const YYYY_MM_DD = /\d{4}-\d{1,2}-\d{1,2}/;
|
37 | const TIME_12H = /(\d|1[012])(:\d+){0,2} *(AM|PM)/;
|
38 | const TIME_24H = /\d{1,2}(:\d{1,2}){1,2}/;
|
39 | const DATE = {
|
40 | className: 'literal',
|
41 | variants: [
|
42 | {
|
43 |
|
44 | begin: regex.concat(/# */, regex.either(YYYY_MM_DD, MM_DD_YYYY), / *#/)
|
45 | },
|
46 | {
|
47 |
|
48 | begin: regex.concat(/# */, TIME_24H, / *#/)
|
49 | },
|
50 | {
|
51 |
|
52 | begin: regex.concat(/# */, TIME_12H, / *#/)
|
53 | },
|
54 | {
|
55 |
|
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 |
|
67 | const NUMBER = {
|
68 | className: 'number',
|
69 | relevance: 0,
|
70 | variants: [
|
71 | {
|
72 |
|
73 | begin: /\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/
|
74 | },
|
75 | {
|
76 |
|
77 | begin: /\b\d[\d_]*((U?[SIL])|[%&])?/
|
78 | },
|
79 | {
|
80 |
|
81 | begin: /&H[\dA-F_]+((U?[SIL])|[%&])?/
|
82 | },
|
83 | {
|
84 |
|
85 | begin: /&O[0-7_]+((U?[SIL])|[%&])?/
|
86 | },
|
87 | {
|
88 |
|
89 | begin: /&B[01_]+((U?[SIL])|[%&])?/
|
90 | }
|
91 | ]
|
92 | };
|
93 |
|
94 | const LABEL = {
|
95 | className: 'label',
|
96 | begin: /^\w+:/
|
97 | };
|
98 |
|
99 | const DOC_COMMENT = hljs.COMMENT(/'''/, /$/, {
|
100 | contains: [
|
101 | {
|
102 | className: 'doctag',
|
103 | begin: /<\/?/,
|
104 | end: />/
|
105 | }
|
106 | ]
|
107 | });
|
108 |
|
109 | const COMMENT = hljs.COMMENT(null, /$/, {
|
110 | variants: [
|
111 | {
|
112 | begin: /'/
|
113 | },
|
114 | {
|
115 |
|
116 | begin: /([\t ]|^)REM(?=\s)/
|
117 | }
|
118 | ]
|
119 | });
|
120 |
|
121 | const DIRECTIVES = {
|
122 | className: 'meta',
|
123 |
|
124 | begin: /[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,
|
125 | end: /$/,
|
126 | keywords: {
|
127 | keyword:
|
128 | 'const disable else elseif enable end externalsource if region then'
|
129 | },
|
130 | contains: [ COMMENT ]
|
131 | };
|
132 |
|
133 | return {
|
134 | name: 'Visual Basic .NET',
|
135 | aliases: [ 'vb' ],
|
136 | case_insensitive: true,
|
137 | classNameAliases: {
|
138 | label: 'symbol'
|
139 | },
|
140 | keywords: {
|
141 | keyword:
|
142 | 'addhandler alias aggregate ansi as async assembly auto binary by byref byval ' +
|
143 | 'call case catch class compare const continue custom declare default delegate dim distinct do ' +
|
144 | 'each equals else elseif end enum erase error event exit explicit finally for friend from function ' +
|
145 | 'get global goto group handles if implements imports in inherits interface into iterator ' +
|
146 | 'join key let lib loop me mid module mustinherit mustoverride mybase myclass ' +
|
147 | 'namespace narrowing new next notinheritable notoverridable ' +
|
148 | 'of off on operator option optional order overloads overridable overrides ' +
|
149 | 'paramarray partial preserve private property protected public ' +
|
150 | 'raiseevent readonly redim removehandler resume return ' +
|
151 | 'select set shadows shared skip static step stop structure strict sub synclock ' +
|
152 | 'take text then throw to try unicode until using when where while widening with withevents writeonly yield' ,
|
153 | built_in:
|
154 |
|
155 | 'addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor ' +
|
156 |
|
157 | 'cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort',
|
158 | type:
|
159 |
|
160 | 'boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort',
|
161 | literal: 'true false nothing'
|
162 | },
|
163 | illegal:
|
164 | '//|\\{|\\}|endif|gosub|variant|wend|^\\$ ' ,
|
165 | contains: [
|
166 | CHARACTER,
|
167 | STRING,
|
168 | DATE,
|
169 | NUMBER,
|
170 | LABEL,
|
171 | DOC_COMMENT,
|
172 | COMMENT,
|
173 | DIRECTIVES
|
174 | ]
|
175 | };
|
176 | }
|
177 |
|
178 | export { vbnet as default };
|