1 |
#Region "Microsoft.VisualBasic::e52326c9f906543d245f7cac8deccee0, Microsoft.VisualBasic.Core\Scripting\VBLanguage.vb"
|
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 |
#End Region
|
49 |
|
50 |
Imports System.Runtime.CompilerServices
|
51 |
|
52 |
Namespace Scripting.SymbolBuilder.VBLanguage
|
53 |
|
54 |
Public NotInheritable Class Patterns
|
55 |
|
56 |
Private Sub New()
|
57 |
End Sub
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
Public Const Identifer$ = "\[?[_a-z][_a-z0-9]*\]?"
|
63 |
|
64 |
Public Const Access$ = "((Partial )|(Public )|(Private )|(Friend )|(Protected )|(Shadows )|(Shared )|(Overrides )|(Overloads )|(Overridable )|(MustOverrides )|(NotInheritable )|(MustInherit ))*"
|
65 |
Public Const Type$ = "^\s*" & Access & "((Class)|(Module)|(Structure)|(Enum)|(Delegate)|(Interface))\s+" & VBLanguage.Patterns.Identifer
|
66 |
Public Const Property$ = "^\s+" & Access & "\s*((ReadOnly )|(WriteOnly )|(Default ))*\s*Property\s+" & VBLanguage.Patterns.Identifer
|
67 |
Public Const Method$ = "^\s+" & Access & "\s*((Sub )|(Function )|(Iterator )|(Operator ))+\s*" & VBLanguage.Patterns.Identifer
|
68 |
Public Const Operator$ = "^\s+" & Access & "\s*Operator\s+(([<]|[>]|\=|\+|\-|\*|/|\^|\\)+|(" & VBLanguage.Patterns.Identifer & "))"
|
69 |
Public Const Close$ = "^\s+End\s((Sub)|(Function)|(Class)|(Structure)|(Enum)|(Interface)|(Operator)|(Module))"
|
70 |
Public Const CloseType$ = "^\s*End\s((Class)|(Structure)|(Enum)|(Interface)|(Module))"
|
71 |
Public Const Indents$ = "^\s+"
|
72 |
Public Const Attribute$ = "<.+?>\s*"
|
73 |
|
74 |
End Class
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
Public NotInheritable Class KeywordProcessor
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
Public Const VBKeywords$ =
|
85 |
"|AddHandler|AddressOf|Alias|And|AndAlso|As|" &
|
86 |
"|Boolean|ByRef|Byte|" &
|
87 |
"|Call|Case|Catch|CBool|CByte|CChar|CDate|CDec|CDbl|Char|CInt|Class|CLng|CObj|Const|Continue|CSByte|CShort|CSng|CStr|CType|CUInt|CULng|CUShort|" &
|
88 |
"|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|" &
|
89 |
"|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|" &
|
90 |
"|False|Finally|For|Friend|Function|" &
|
91 |
"|Get|GetType|GetXMLNamespace|Global|GoSub|GoTo|" &
|
92 |
"|Handles|" &
|
93 |
"|If|Implements|Imports|In|Inherits|Integer|Interface|Is|IsNot|" &
|
94 |
"|Let|Lib|Like|Long|Loop|" &
|
95 |
"|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|" &
|
96 |
"|Namespace|Narrowing|New|Next|Not|Nothing|NotInheritable|NotOverridable|NameOf|" &
|
97 |
"|Object|Of|On|Operator|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|" &
|
98 |
"|ParamArray|Partial|Private|Property|Protected|Public|" &
|
99 |
"|RaiseEvent|ReadOnly|ReDim|REM|RemoveHandler|Resume|Return|" &
|
100 |
"|SByte|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|" &
|
101 |
"|Then|Throw|To|True|Try|TryCast|TypeOf|" &
|
102 |
"|Variant|" &
|
103 |
"|Wend|" &
|
104 |
"|UInteger|ULong|UShort|Using|" &
|
105 |
"|When|While|Widening|With|WithEvents|WriteOnly|" &
|
106 |
"|Xor|" &
|
107 |
"|Yield|"
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
Public ReadOnly Property Words As String()
|
114 |
<MethodImpl(MethodImplOptions.AggressiveInlining)>
|
115 |
Get
|
116 |
Return VBKeywords _
|
117 |
.Split("|"c) _
|
118 |
.Where(Function(s) Not s.StringEmpty) _
|
119 |
.ToArray
|
120 |
End Get
|
121 |
End Property
|
122 |
|
123 |
Private Sub New()
|
124 |
End Sub
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
Public Shared Function AutoEscapeVBKeyword(name$) As String
|
135 |
If InStr(VBKeywords, $"|{name}|", CompareMethod.Text) > 0 Then
|
136 |
Return $"[{name}]"
|
137 |
Else
|
138 |
Return name
|
139 |
End If
|
140 |
End Function
|
141 |
End Class
|
142 |
End Namespace
|