Skip to content

Commit 0c41eab

Browse files
committed
Add supports for:
Constants vbUseCompareOption vbBinaryCompare vbTextCompare vbDatabaseCompare String Manipulation Methods InStr InStrB InStrRev LCase LCase_S UCase UCase_S Len LenB Mid Mid_S MidB MidB_S Left Left_S LeftB LeftB_S Right Right_S RightB RightB_S RTrim RTrim_S LTrim LTrim_S Join Split Financial Methods DDB FV IPmt IRR MIRR NPer NPV Pmt PPmt PV Rate SLN SYD Array Methods Array LBound UBound
1 parent 90a3928 commit 0c41eab

File tree

17 files changed

+7048
-191
lines changed

17 files changed

+7048
-191
lines changed

Resources/samples/sample_12.txt

Lines changed: 4722 additions & 0 deletions
Large diffs are not rendered by default.

Resources/samples/sample_9.txt

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,5 @@
11

2+
arr = Array(1, 2, 3, "Hello", 5.5)
23

3-
Dim xx0101 As String: xx0101 = "A"
4-
Dim xx00101 As String: xx00101 = "a"
5-
Dim xx0104 As String: xx0104 = "d"
6-
Dim xx0105 As String: xx0105 = "e"
7-
Dim xx01007 As String: xx01007 = "u"
8-
Dim xx01008 As String: xx01008 = "v"
9-
Dim xx010a010x As String: xx010a010x = "ax"
10-
Dim xx0109 As String: xx0109 = "i"
11-
Dim xx01005 As String: xx01005 = "s"
12-
Dim xx01006 As String: xx01006 = "t"
13-
Dim xx010003 As String: xx010003 = "z"
14-
Dim xx010a007x As String: xx010a007x = "az"
15-
16-
Dim xx01001 As String: xx01001 = "o"
17-
Dim xx0106 As String: xx0106 = "f"
18-
Dim xx0107 As String: xx0107 = "g"
19-
Dim xx0108 As String: xx0108 = "h"
20-
Dim xx010002 As String: xx010002 = "y"
21-
Dim xx01004 As String: xx01004 = "r"
22-
23-
Dim xx01010 As String: xx01010 = "j"
24-
Dim xx01011 As String: xx01011 = "k"
25-
Dim xx010l2 As String: xx010l2 = "l"
26-
Dim xx01013 As String: xx01013 = "m"
27-
Dim xx0100x1 As String: xx0100x1 = "."
28-
Dim xx01009 As String: xx01009 = "w"
29-
Dim xx010001 As String: xx010001 = "x"
30-
31-
Dim xx01000 As String: xx01000 = "n"
32-
Dim xx0102 As String: xx0102 = "b"
33-
34-
Dim xx01002 As String: xx01002 = "p"
35-
Dim xx0103 As String: xx0103 = "c"
36-
Dim xx010q03 As String: xx010q03 = "q"
37-
Dim xx010l03 As String: xx010l03 = "\"
38-
39-
40-
Dim fpx As String: fpx = Environ(xx0101 & xx01002 & xx01002 & xx0104 & xx00101 & xx01006 & xx00101)
4+
lowerBound = LBound(arr,1)
5+

Resources/samples/sample_91.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+

2+
arr = Array(1, 2, 3, "Hello", 5.5)
3+
4+
lowerBound = LBound(arr,1)
5+

Resources/samples/sample_92.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+

2+
Dim TestSplit
3+
TestSplit = Split("v1;v2;v3", ";")
4+
TestSplit(1) = "yop"
5+
6+
Dim testjoin
7+
testjoin = Join(TestSplit)
8+
Debug.Print testjoin
9+
Debug.Print TestSplit(2)
10+

Sources/.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"type": "antlr-debug",
99
"request": "launch",
1010
"name": "Debug Current Grammar",
11-
"input": "<to_be_defined>",
11+
"input": "D:\\Git\\Public\\vbSparkle\\Resources\\samples\\sample_92.txt",
1212
"visualParseTree": true,
13-
"startRule": "inlineBlock",
13+
"startRule": "startRule",
1414
"grammar": "${file}"
1515
},
1616
{

Sources/Sources.generated.sln

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vbSparkle", "vbSparkle\vbSparkle.csproj", "{CD1B4478-A56B-475A-8A05-C9A31414BD05}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vbSparkle.CLI", "vbSparkle.Console\vbSparkle.CLI.csproj", "{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vbSparkle.Web", "vbSparkle.Web\vbSparkle.Web.csproj", "{F2D6AE95-9E88-49D4-B48C-5B2D13553924}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{CD1B4478-A56B-475A-8A05-C9A31414BD05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{CD1B4478-A56B-475A-8A05-C9A31414BD05}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{CD1B4478-A56B-475A-8A05-C9A31414BD05}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{CD1B4478-A56B-475A-8A05-C9A31414BD05}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{F2D6AE95-9E88-49D4-B48C-5B2D13553924}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{F2D6AE95-9E88-49D4-B48C-5B2D13553924}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{F2D6AE95-9E88-49D4-B48C-5B2D13553924}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{F2D6AE95-9E88-49D4-B48C-5B2D13553924}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {0D824770-F814-4AE7-A4B3-031E98086E8C}
36+
EndGlobalSection
37+
EndGlobal
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
{
22
"profiles": {
33
"Help": {
4-
"commandName": "Project",
5-
"commandLineArgs": ""
4+
"commandName": "Project"
65
},
76
"Sample_7": {
87
"commandName": "Project",
9-
"commandLineArgs": "-p $(SolutionDir)\\Resources\\samples\\sample_11.txt"
8+
"commandLineArgs": "-p D:\\Git\\Public\\vbSparkle\\Resources\\samples\\sample_92.txt"
109
},
1110
"Sample_10": {
1211
"commandName": "Project",
1312
"commandLineArgs": "-p $(SolutionDir)\\Resources\\samples\\sample_10.txt --sym-rename-mode All"
1413
},
1514
"vbSparkle.Console": {
16-
"commandName": "Project",
17-
"commandLineArgs": ""
15+
"commandName": "Project"
1816
}
1917
}
2018
}

Sources/vbSparkle/EvaluationObjects/DComplexStringExpression.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,45 @@
77

88
namespace vbSparkle.EvaluationObjects
99
{
10+
public class DArrayExpression : DExpression
11+
{
12+
public List<DExpression> Items { get; set; }
13+
14+
public DArrayExpression(int ubound)
15+
{
16+
Items = (new DExpression[ubound+1]).ToList();
17+
}
18+
public DArrayExpression(IEnumerable<DExpression> array)
19+
{
20+
Items = array.ToList();
21+
}
22+
23+
public override bool IsValuable { get => true; set => throw new System.NotImplementedException(); }
24+
public override bool HasSideEffet { get => false; set => throw new System.NotImplementedException(); }
25+
26+
public override string ToExpressionString()
27+
{
28+
string[] dExpressions = Items.Select(v=> v.ToExpressionString()).ToArray();
29+
return "Array(" + string.Join(", ", dExpressions) + ")";
30+
}
31+
32+
public override string ToValueString()
33+
{
34+
return ToExpressionString();
35+
}
36+
37+
public DExpression this[int index]
38+
{
39+
get => Items[index];
40+
set => Items[index] = value;
41+
}
42+
43+
internal override SymbolicExpression GetSymExp()
44+
{
45+
return SymbolicExpression.Variable(ToExpressionString());
46+
}
47+
}
48+
1049
internal class DComplexStringExpression
1150
: DExpression, IStringExpression
1251
{

Sources/vbSparkle/LanguageStatements/CallStatements/VB_ICS_S_ProcedureOrArrayCallStatement.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using vbSparkle.EvaluationObjects;
45

56
namespace vbSparkle
67
{
@@ -79,6 +80,38 @@ public DExpression Evaluate()
7980
{
8081
if (CallArgs.Count() == 0)
8182
return (identifiedObject as VbUserVariable).TryEvaluate();
83+
else
84+
{
85+
try
86+
{
87+
var objArray = (identifiedObject as VbUserVariable);
88+
DArrayExpression arrExp = objArray.CurrentValue as DArrayExpression;
89+
90+
if (arrExp != null)
91+
{
92+
if (CallArgs.Count == 1)
93+
{
94+
var argLevel1 = CallArgs[0];
95+
if (argLevel1.Count() == 1)
96+
{
97+
DExpression idxExp = argLevel1[0].ValueStatement.Evaluate();
98+
int idx;
99+
if (vbSparkle.NativeMethods.Converter.TryGetInt32Value(idxExp, out idx))
100+
{
101+
if (idx < arrExp.Items.Count)
102+
{
103+
DExpression valueExp = arrExp.Items[idx];
104+
return valueExp;
105+
}
106+
}
107+
}
108+
}
109+
}
110+
}
111+
catch (Exception ex)
112+
{
113+
}
114+
}
82115
}
83116

84117
return GetAssignableExpression(true);

0 commit comments

Comments
 (0)