diff --git a/pom.xml b/pom.xml index c3f12fa..c0cf2fe 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ optic_fusion1 Kitsune - 1.7.1 + 1.8 diff --git a/src/main/java/optic_fusion1/kitsune/parser/vbs/StatementFactory.java b/src/main/java/optic_fusion1/kitsune/parser/vbs/StatementFactory.java index 8e8b05b..ed892d3 100644 --- a/src/main/java/optic_fusion1/kitsune/parser/vbs/StatementFactory.java +++ b/src/main/java/optic_fusion1/kitsune/parser/vbs/StatementFactory.java @@ -25,6 +25,8 @@ Sub SubName( param1, param2 ) || Sub SubName(param1,param2) // Or other variants */ // TODO: Implement support for storing the values that variables get set to // TODO: Implement support for parsing operators (=, +, -, /, *, %) +// TODO: Implement support for parsing things like Array(1,2) Array () +// TODO: Implement support for parsing function calls like reader.ReadFromFile WScript.Arguments(0) or WScript.Echo "Found barcode with type '" & reader.GetFoundBarcodeType(i) & "' and value '" & reader.GetFoundBarcodeValue(i) & "'" public class StatementFactory { /* @@ -72,9 +74,18 @@ public static VariableInit buildVariableInitStatements(int index, String lineTri VariableInit vinit = new VariableInit(); vinit.setText(lineTrimmed); vinit.setLineNumber(index); - // TODO: Make private static final Pattern for this Pattern pattern; - Matcher matcher = null; + Matcher matcher; + if (lineTrimmed.contains(":") && lineTrimmed.contains("=")) { + // TODO: Check to see if this REGEX Pattern can be improved + pattern = Pattern.compile("Dim (.*) : (.*) = (.*)", Pattern.CASE_INSENSITIVE); + matcher = pattern.matcher(lineTrimmed); + matcher.find(); + vinit.setName(matcher.group(1)); + vinit.getVariables().add(matcher.group(3)); + return vinit; + } + // TODO: Make private static final Pattern for this if (lineTrimmed.contains("As")) { pattern = Pattern.compile("Dim(.+?)As", Pattern.CASE_INSENSITIVE); matcher = pattern.matcher(lineTrimmed); @@ -180,7 +191,7 @@ public static ConstStatement buildConstStatements(int index, String lineTrimmed) return statement; } - private static final Pattern COMMENT_PATTERN = Pattern.compile("' ? (.*)"); + private static final Pattern COMMENT_PATTERN = Pattern.compile("'(.*)"); public static Comment buildComments(int index, String lineTrimmed) { Matcher matcher = COMMENT_PATTERN.matcher(lineTrimmed); diff --git a/src/main/java/optic_fusion1/kitsune/parser/vbs/domain/DataType.java b/src/main/java/optic_fusion1/kitsune/parser/vbs/domain/DataType.java index c801596..67447d5 100644 --- a/src/main/java/optic_fusion1/kitsune/parser/vbs/domain/DataType.java +++ b/src/main/java/optic_fusion1/kitsune/parser/vbs/domain/DataType.java @@ -2,11 +2,13 @@ public enum DataType { + // TODO: Look to see if there's any other DataTypes that should be added to this STRING("String"), INT("Int"), VAR("var"), - ByVal("ByVal"), - ByRef("ByRef"), + BY_VAL("ByVal"), + BY_REF("ByRef"), + SINGLE("Single"), EMPTY(""); private final String name; diff --git a/src/main/java/optic_fusion1/kitsune/parser/vbs/domain/VariableInit.java b/src/main/java/optic_fusion1/kitsune/parser/vbs/domain/VariableInit.java index f41599a..a0d3013 100644 --- a/src/main/java/optic_fusion1/kitsune/parser/vbs/domain/VariableInit.java +++ b/src/main/java/optic_fusion1/kitsune/parser/vbs/domain/VariableInit.java @@ -5,6 +5,7 @@ public class VariableInit extends Statement { + private String name; private DataType variableType; private List variables = new ArrayList<>(); @@ -25,4 +26,12 @@ public void setVariableType(DataType variableType) { this.variableType = variableType; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } diff --git a/src/main/java/optic_fusion1/kitsune/tool/impl/analyze/analyzer/vbs/VBSAnalyzer.java b/src/main/java/optic_fusion1/kitsune/tool/impl/analyze/analyzer/vbs/VBSAnalyzer.java index 0b35bd9..099b317 100644 --- a/src/main/java/optic_fusion1/kitsune/tool/impl/analyze/analyzer/vbs/VBSAnalyzer.java +++ b/src/main/java/optic_fusion1/kitsune/tool/impl/analyze/analyzer/vbs/VBSAnalyzer.java @@ -8,6 +8,7 @@ import optic_fusion1.kitsune.parser.vbs.domain.MsgBoxStatement; import optic_fusion1.kitsune.parser.vbs.domain.SetStatement; import optic_fusion1.kitsune.parser.vbs.domain.Statement; +import optic_fusion1.kitsune.parser.vbs.domain.VariableInit; import optic_fusion1.kitsune.tool.impl.analyze.analyzer.Analyzer; public class VBSAnalyzer extends Analyzer { @@ -32,6 +33,12 @@ public void analyze(File input) { if (statement instanceof Comment comment) { LOGGER.info("Comment: " + comment.getText()); } + if (statement instanceof VariableInit stmnt) { + LOGGER.info("Name: " + stmnt.getName() + " Variable Type: " + stmnt.getVariableType()); + for (String variable : stmnt.getVariables()) { + LOGGER.info("Variable: " + variable); + } + } } }