Skip to content

Commit

Permalink
Add supports for:
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sbruyere committed Aug 30, 2024
1 parent 90a3928 commit 0c41eab
Show file tree
Hide file tree
Showing 17 changed files with 7,048 additions and 191 deletions.
4,722 changes: 4,722 additions & 0 deletions Resources/samples/sample_12.txt

Large diffs are not rendered by default.

41 changes: 3 additions & 38 deletions Resources/samples/sample_9.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@

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

Dim xx0101 As String: xx0101 = "A"
Dim xx00101 As String: xx00101 = "a"
Dim xx0104 As String: xx0104 = "d"
Dim xx0105 As String: xx0105 = "e"
Dim xx01007 As String: xx01007 = "u"
Dim xx01008 As String: xx01008 = "v"
Dim xx010a010x As String: xx010a010x = "ax"
Dim xx0109 As String: xx0109 = "i"
Dim xx01005 As String: xx01005 = "s"
Dim xx01006 As String: xx01006 = "t"
Dim xx010003 As String: xx010003 = "z"
Dim xx010a007x As String: xx010a007x = "az"

Dim xx01001 As String: xx01001 = "o"
Dim xx0106 As String: xx0106 = "f"
Dim xx0107 As String: xx0107 = "g"
Dim xx0108 As String: xx0108 = "h"
Dim xx010002 As String: xx010002 = "y"
Dim xx01004 As String: xx01004 = "r"

Dim xx01010 As String: xx01010 = "j"
Dim xx01011 As String: xx01011 = "k"
Dim xx010l2 As String: xx010l2 = "l"
Dim xx01013 As String: xx01013 = "m"
Dim xx0100x1 As String: xx0100x1 = "."
Dim xx01009 As String: xx01009 = "w"
Dim xx010001 As String: xx010001 = "x"

Dim xx01000 As String: xx01000 = "n"
Dim xx0102 As String: xx0102 = "b"

Dim xx01002 As String: xx01002 = "p"
Dim xx0103 As String: xx0103 = "c"
Dim xx010q03 As String: xx010q03 = "q"
Dim xx010l03 As String: xx010l03 = "\"


Dim fpx As String: fpx = Environ(xx0101 & xx01002 & xx01002 & xx0104 & xx00101 & xx01006 & xx00101)
lowerBound = LBound(arr,1)

5 changes: 5 additions & 0 deletions Resources/samples/sample_91.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

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

lowerBound = LBound(arr,1)

10 changes: 10 additions & 0 deletions Resources/samples/sample_92.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Dim TestSplit
TestSplit = Split("v1;v2;v3", ";")
TestSplit(1) = "yop"

Dim testjoin
testjoin = Join(TestSplit)
Debug.Print testjoin
Debug.Print TestSplit(2)

4 changes: 2 additions & 2 deletions Sources/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"type": "antlr-debug",
"request": "launch",
"name": "Debug Current Grammar",
"input": "<to_be_defined>",
"input": "D:\\Git\\Public\\vbSparkle\\Resources\\samples\\sample_92.txt",
"visualParseTree": true,
"startRule": "inlineBlock",
"startRule": "startRule",
"grammar": "${file}"
},
{
Expand Down
37 changes: 37 additions & 0 deletions Sources/Sources.generated.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vbSparkle", "vbSparkle\vbSparkle.csproj", "{CD1B4478-A56B-475A-8A05-C9A31414BD05}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vbSparkle.CLI", "vbSparkle.Console\vbSparkle.CLI.csproj", "{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vbSparkle.Web", "vbSparkle.Web\vbSparkle.Web.csproj", "{F2D6AE95-9E88-49D4-B48C-5B2D13553924}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD1B4478-A56B-475A-8A05-C9A31414BD05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD1B4478-A56B-475A-8A05-C9A31414BD05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD1B4478-A56B-475A-8A05-C9A31414BD05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD1B4478-A56B-475A-8A05-C9A31414BD05}.Release|Any CPU.Build.0 = Release|Any CPU
{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9B7FAC4-22B6-41D0-9A12-6868204C2C43}.Release|Any CPU.Build.0 = Release|Any CPU
{F2D6AE95-9E88-49D4-B48C-5B2D13553924}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2D6AE95-9E88-49D4-B48C-5B2D13553924}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2D6AE95-9E88-49D4-B48C-5B2D13553924}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2D6AE95-9E88-49D4-B48C-5B2D13553924}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0D824770-F814-4AE7-A4B3-031E98086E8C}
EndGlobalSection
EndGlobal
8 changes: 3 additions & 5 deletions Sources/vbSparkle.Console/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"profiles": {
"Help": {
"commandName": "Project",
"commandLineArgs": ""
"commandName": "Project"
},
"Sample_7": {
"commandName": "Project",
"commandLineArgs": "-p $(SolutionDir)\\Resources\\samples\\sample_11.txt"
"commandLineArgs": "-p D:\\Git\\Public\\vbSparkle\\Resources\\samples\\sample_92.txt"
},
"Sample_10": {
"commandName": "Project",
"commandLineArgs": "-p $(SolutionDir)\\Resources\\samples\\sample_10.txt --sym-rename-mode All"
},
"vbSparkle.Console": {
"commandName": "Project",
"commandLineArgs": ""
"commandName": "Project"
}
}
}
39 changes: 39 additions & 0 deletions Sources/vbSparkle/EvaluationObjects/DComplexStringExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,45 @@

namespace vbSparkle.EvaluationObjects
{
public class DArrayExpression : DExpression
{
public List<DExpression> Items { get; set; }

public DArrayExpression(int ubound)
{
Items = (new DExpression[ubound+1]).ToList();
}
public DArrayExpression(IEnumerable<DExpression> array)
{
Items = array.ToList();
}

public override bool IsValuable { get => true; set => throw new System.NotImplementedException(); }
public override bool HasSideEffet { get => false; set => throw new System.NotImplementedException(); }

public override string ToExpressionString()
{
string[] dExpressions = Items.Select(v=> v.ToExpressionString()).ToArray();
return "Array(" + string.Join(", ", dExpressions) + ")";
}

public override string ToValueString()
{
return ToExpressionString();
}

public DExpression this[int index]
{
get => Items[index];
set => Items[index] = value;
}

internal override SymbolicExpression GetSymExp()
{
return SymbolicExpression.Variable(ToExpressionString());
}
}

internal class DComplexStringExpression
: DExpression, IStringExpression
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using vbSparkle.EvaluationObjects;

namespace vbSparkle
{
Expand Down Expand Up @@ -79,6 +80,38 @@ public DExpression Evaluate()
{
if (CallArgs.Count() == 0)
return (identifiedObject as VbUserVariable).TryEvaluate();
else
{
try
{
var objArray = (identifiedObject as VbUserVariable);
DArrayExpression arrExp = objArray.CurrentValue as DArrayExpression;

if (arrExp != null)
{
if (CallArgs.Count == 1)
{
var argLevel1 = CallArgs[0];
if (argLevel1.Count() == 1)
{
DExpression idxExp = argLevel1[0].ValueStatement.Evaluate();
int idx;
if (vbSparkle.NativeMethods.Converter.TryGetInt32Value(idxExp, out idx))
{
if (idx < arrExp.Items.Count)
{
DExpression valueExp = arrExp.Items[idx];
return valueExp;
}
}
}
}
}
}
catch (Exception ex)
{
}
}
}

return GetAssignableExpression(true);
Expand Down
Loading

0 comments on commit 0c41eab

Please sign in to comment.