-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmodSourceCode.bas
96 lines (77 loc) · 3.29 KB
/
modSourceCode.bas
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
Attribute VB_Name = "modSourceCode"
Option Explicit
Public Const AllowedCharsInVariables As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-[]'"
Public Const AllowedCharsInNumerals As String = "1234567890,."
Public Const sourcecode_definition_quotedouble As String = """"
Public Const sourcecode_definition_quotesingle As String = "'"
Public Const sourcecode_lexer_directory As String = "\lexer\"
Public sourcecode_definitions() As String
Public metacode_definitions() As String
Public Sub InitializeCodeDefinitions(ByRef sLexerFileName As String, ByRef sPublicArray() As String)
Dim i As Integer
Dim sInput As String
Dim sLines() As String
Dim sEntry() As String
Dim iLinesArrayUpper As Integer
If LenB(Dir$(sLexerFileName)) Then
Open sLexerFileName For Input As #1
sInput = Input(LOF(1), #1)
Close
sLines = Split(sInput, vbCrLf, , vbBinaryCompare)
iLinesArrayUpper = UBound(sLines)
ReDim sPublicArray(0 To iLinesArrayUpper, 0 To 1)
For i = 0 To iLinesArrayUpper
sEntry = Split(sLines(i), ";", , vbBinaryCompare)
sPublicArray(i, 0) = sEntry(0)
sPublicArray(i, 1) = sEntry(1)
Next i
Call frmLog.AddLogEntry("Loading lexer module " & sLexerFileName & " ...")
End If
End Sub
Public Function Source2Meta(ByRef sSource As String) As String
Dim i As Integer
Dim j As Integer
Dim iSourceCodeDefinitionArrayUpper As Integer
Dim iMetaCodeDefinitionArrayUpper As Integer
iSourceCodeDefinitionArrayUpper = UBound(sourcecode_definitions)
iMetaCodeDefinitionArrayUpper = UBound(metacode_definitions)
For i = 0 To iSourceCodeDefinitionArrayUpper
If sourcecode_definitions(i, 1) = sSource Then
For j = 0 To iMetaCodeDefinitionArrayUpper
If sourcecode_definitions(i, 0) = metacode_definitions(j, 0) Then
Source2Meta = metacode_definitions(j, 1)
Exit Function
End If
Next j
End If
Next i
End Function
Public Function Meta2Source(ByRef sMeta As String) As String
Dim i As Integer
Dim j As Integer
Dim iSourceCodeDefinitionArrayUpper As Integer
Dim iMetaCodeDefinitionArrayUpper As Integer
iSourceCodeDefinitionArrayUpper = UBound(sourcecode_definitions)
iMetaCodeDefinitionArrayUpper = UBound(metacode_definitions)
For i = 0 To iMetaCodeDefinitionArrayUpper
If metacode_definitions(i, 1) = sMeta Then
For j = 0 To iSourceCodeDefinitionArrayUpper
If sourcecode_definitions(i, 0) = metacode_definitions(j, 0) Then
Meta2Source = sourcecode_definitions(j, 1)
Exit Function
End If
Next j
End If
Next i
End Function
Public Function SourceDefinition(ByRef sStatement As String) As String
Dim i As Integer
Dim iSourceCodeDefinitionArrayUpper As Integer
iSourceCodeDefinitionArrayUpper = UBound(sourcecode_definitions)
For i = 0 To iSourceCodeDefinitionArrayUpper
If sourcecode_definitions(i, 0) = sStatement Then
SourceDefinition = sourcecode_definitions(i, 1)
Exit For
End If
Next i
End Function