forked from EnlighterJS/EnlighterJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisual-basic.js
executable file
·107 lines (84 loc) · 3.42 KB
/
visual-basic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// ----------------------------------------------------------------------
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// --
// Copyright 2016-2018 Andi Dittrich <https://andidittrich.de>
// ----------------------------------------------------------------------
// Generic Rules/Regex
import _language_common_rules from './rulesets/generic';
import {generic} from './generic';
// Visual Basic Language
// Author: [Andi Dittrich]
// --
export class visualbasic extends generic {
// language aliases
static alias(){
return ['vb'];
}
setupLanguage() {
this.rules = [
// strings
_language_common_rules.dqStrings,
// boolean
_language_common_rules.boolean,
// properties - render before keywords!
_language_common_rules.prop,
// directives
{
regex: /(#.*?)(?:'|$)/gim,
type: 'k4'
},
// control keywords
{
regex: /\b(Case|Catch|Continue|Each|Else|ElseIf|End|EndIf|Do|Finally|For|If|Loop|Next|OrElse|Then|Throw|Try|When|While)\b/g,
type: 'k1'
},
// namespace module imports
{
regex: /(Imports )(.*?)$/gm,
type: ['k0', 'k10']
},
// static types
{
regex: /\b(Boolean|Byte|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|CLng|CObj|CSByte|CShort|CSng|CStr|CType|CUInt|CULng|CUShort|Decimal|Double|Integer|Long|ParamArray|SByte|Short|Single|String|UInteger|ULong|UShort)\b/g,
type: 'k5'
},
// type initialization
{
regex: /\b(Dim|Enum|Let|ReDim)\b/g,
type: 'k2'
},
// qualifier/modifier
{
regex: /\b(Const|Shared|Static)\b/g,
type: 'k8'
},
// keywords
{
regex: /\b(AddHandler|AddressOf|Alias|As|ByRef|ByVal|Call|Class|Date|Declare|Default|Delegate|DirectCast|Erase|Error|Event|Exit|Friend|Function|Get|GetType|GetXMLNamespace|Global|GoSub|GoTo|Handles|Implements|In|Inherits|Interface|Lib|Like|Me|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|Narrowing|Nothing|NotInheritable|NotOverridable|Object|Of|On|Operator|Option|Optional|Out|Overloads|Overridable|Overrides|Partial|Private|Property|Protected|Public|RaiseEvent|ReadOnly|REM|RemoveHandler|Resume|Return|Select|Set|Shadows|Step|Stop|Structure|Sub|SyncLock|To|TryCast|Using|Variant|Wend|Widening|With|WithEvents|WriteOnly)\b/gi,
type: 'k0'
},
// operator
{
regex: /\b(And|AndAlso|Is|IsNot|Mod|New|Not|Or|TypeOf|Xor)\b/g,
type: 'k3'
},
// method calls
_language_common_rules.mCalls,
// global function calls
_language_common_rules.fCalls,
// single line comments
{
regex: /'.*$/gm,
type: 'c0'
},
// inetgers
_language_common_rules.int,
// floatss
_language_common_rules.floats,
// brackets
_language_common_rules.brackets
]
}
}