mirror of
https://github.com/uwol/proleap-vb6-parser.git
synced 2025-12-18 20:44:35 +03:00
switched to slf4j
This commit is contained in:
18
pom.xml
18
pom.xml
@@ -18,7 +18,6 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<antlr.version>4.7</antlr.version>
|
<antlr.version>4.7</antlr.version>
|
||||||
<log4j.version>2.8.2</log4j.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
@@ -141,6 +140,13 @@
|
|||||||
<artifactId>antlr4-maven-plugin</artifactId>
|
<artifactId>antlr4-maven-plugin</artifactId>
|
||||||
<version>${antlr.version}</version>
|
<version>${antlr.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.7.25</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
@@ -151,16 +157,6 @@
|
|||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-api</artifactId>
|
|
||||||
<version>${log4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-core</artifactId>
|
|
||||||
<version>${log4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import io.proleap.vb6.asg.metamodel.Module;
|
|||||||
import io.proleap.vb6.asg.metamodel.DefType.LetterRange;
|
import io.proleap.vb6.asg.metamodel.DefType.LetterRange;
|
||||||
import io.proleap.vb6.asg.metamodel.type.Type;
|
import io.proleap.vb6.asg.metamodel.type.Type;
|
||||||
import io.proleap.vb6.asg.metamodel.type.VbBaseType;
|
import io.proleap.vb6.asg.metamodel.type.VbBaseType;
|
||||||
import io.proleap.vb6.asg.util.StringUtils;
|
import io.proleap.vb6.asg.util.AsgStringUtils;
|
||||||
|
|
||||||
public class TypeInferenceImpl implements TypeInference {
|
public class TypeInferenceImpl implements TypeInference {
|
||||||
|
|
||||||
@@ -110,8 +110,8 @@ public class TypeInferenceImpl implements TypeInference {
|
|||||||
upper = null;
|
upper = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean geq = StringUtils.geq(firstLetter, lower);
|
final boolean geq = AsgStringUtils.geq(firstLetter, lower);
|
||||||
final boolean leq = StringUtils.leq(firstLetter, upper);
|
final boolean leq = AsgStringUtils.leq(firstLetter, upper);
|
||||||
|
|
||||||
if (geq && leq) {
|
if (geq && leq) {
|
||||||
typeFromDefType = defType.getBaseType();
|
typeFromDefType = defType.getBaseType();
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ import io.proleap.vb6.asg.metamodel.statement.sub.Sub;
|
|||||||
import io.proleap.vb6.asg.metamodel.statement.sub.impl.SubImpl;
|
import io.proleap.vb6.asg.metamodel.statement.sub.impl.SubImpl;
|
||||||
import io.proleap.vb6.asg.metamodel.type.Type;
|
import io.proleap.vb6.asg.metamodel.type.Type;
|
||||||
import io.proleap.vb6.asg.metamodel.type.VbBaseType;
|
import io.proleap.vb6.asg.metamodel.type.VbBaseType;
|
||||||
import io.proleap.vb6.asg.util.StringUtils;
|
import io.proleap.vb6.asg.util.AsgStringUtils;
|
||||||
|
|
||||||
public abstract class ModuleImpl extends ScopeImpl implements Module {
|
public abstract class ModuleImpl extends ScopeImpl implements Module {
|
||||||
|
|
||||||
@@ -299,13 +299,13 @@ public abstract class ModuleImpl extends ScopeImpl implements Module {
|
|||||||
@Override
|
@Override
|
||||||
public void addModuleHeader(final ModuleHeaderContext ctx) {
|
public void addModuleHeader(final ModuleHeaderContext ctx) {
|
||||||
final String versionString = ctx.DOUBLELITERAL().getText();
|
final String versionString = ctx.DOUBLELITERAL().getText();
|
||||||
version = StringUtils.parseDouble(versionString);
|
version = AsgStringUtils.parseDouble(versionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOptionBase(final OptionBaseStmtContext ctx) {
|
public void addOptionBase(final OptionBaseStmtContext ctx) {
|
||||||
final String optionBaseString = ctx.INTEGERLITERAL().getText();
|
final String optionBaseString = ctx.INTEGERLITERAL().getText();
|
||||||
optionBase = StringUtils.parseInteger(optionBaseString);
|
optionBase = AsgStringUtils.parseInteger(optionBaseString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.ParserRuleContext;
|
import org.antlr.v4.runtime.ParserRuleContext;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ import io.proleap.vb6.asg.util.ANTLRUtils;
|
|||||||
|
|
||||||
public abstract class ScopeImpl extends ScopedElementImpl implements Scope {
|
public abstract class ScopeImpl extends ScopedElementImpl implements Scope {
|
||||||
|
|
||||||
private final static Logger LOG = LogManager.getLogger(ScopeImpl.class);
|
private final static Logger LOG = LoggerFactory.getLogger(ScopeImpl.class);
|
||||||
|
|
||||||
public final static String ME = "ME";
|
public final static String ME = "ME";
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
package io.proleap.vb6.asg.metamodel.impl;
|
package io.proleap.vb6.asg.metamodel.impl;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.ParserRuleContext;
|
import org.antlr.v4.runtime.ParserRuleContext;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import io.proleap.vb6.asg.metamodel.Module;
|
import io.proleap.vb6.asg.metamodel.Module;
|
||||||
import io.proleap.vb6.asg.metamodel.Program;
|
import io.proleap.vb6.asg.metamodel.Program;
|
||||||
@@ -59,6 +59,6 @@ public abstract class ScopedElementImpl extends ASGElementImpl implements Scoped
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String getSymbol(final String name) {
|
protected String getSymbol(final String name) {
|
||||||
return Strings.isBlank(name) ? name : name.toLowerCase();
|
return StringUtils.isBlank(name) ? name : name.toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import io.proleap.vb6.asg.metamodel.Program;
|
|||||||
import io.proleap.vb6.asg.metamodel.type.Type;
|
import io.proleap.vb6.asg.metamodel.type.Type;
|
||||||
import io.proleap.vb6.asg.metamodel.type.VbBaseType;
|
import io.proleap.vb6.asg.metamodel.type.VbBaseType;
|
||||||
import io.proleap.vb6.asg.resolver.TypeResolver;
|
import io.proleap.vb6.asg.resolver.TypeResolver;
|
||||||
import io.proleap.vb6.asg.util.StringUtils;
|
import io.proleap.vb6.asg.util.AsgStringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves and returns types of AST elements on a syntactic declarative level
|
* Resolves and returns types of AST elements on a syntactic declarative level
|
||||||
@@ -374,9 +374,9 @@ public class TypeResolverImpl implements TypeResolver {
|
|||||||
|
|
||||||
if (value.toLowerCase().equals("true") || value.toLowerCase().equals("false")) {
|
if (value.toLowerCase().equals("true") || value.toLowerCase().equals("false")) {
|
||||||
result = VbBaseType.BOOLEAN;
|
result = VbBaseType.BOOLEAN;
|
||||||
} else if (StringUtils.isInteger(value)) {
|
} else if (AsgStringUtils.isInteger(value)) {
|
||||||
result = VbBaseType.LONG;
|
result = VbBaseType.LONG;
|
||||||
} else if (StringUtils.isDouble(value)) {
|
} else if (AsgStringUtils.isDouble(value)) {
|
||||||
result = VbBaseType.DOUBLE;
|
result = VbBaseType.DOUBLE;
|
||||||
} else if (value.length() > 1 && value.startsWith("\"") && value.endsWith("\"")) {
|
} else if (value.length() > 1 && value.startsWith("\"") && value.endsWith("\"")) {
|
||||||
result = VbBaseType.STRING;
|
result = VbBaseType.STRING;
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import org.antlr.v4.runtime.CommonTokenStream;
|
|||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import io.proleap.vb6.VisualBasic6Lexer;
|
import io.proleap.vb6.VisualBasic6Lexer;
|
||||||
import io.proleap.vb6.VisualBasic6Parser;
|
import io.proleap.vb6.VisualBasic6Parser;
|
||||||
@@ -57,7 +57,7 @@ import io.proleap.vb6.asg.visitor.impl.VbTypeVisitorImpl;
|
|||||||
|
|
||||||
public class VbParserRunnerImpl implements VbParserRunner {
|
public class VbParserRunnerImpl implements VbParserRunner {
|
||||||
|
|
||||||
protected final static Logger LOG = LogManager.getLogger(VbParserRunnerImpl.class);
|
private final static Logger LOG = LoggerFactory.getLogger(VbParserRunnerImpl.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* determines, how deep expressions and their type assignments should be
|
* determines, how deep expressions and their type assignments should be
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
package io.proleap.vb6.asg.util;
|
package io.proleap.vb6.asg.util;
|
||||||
|
|
||||||
public class StringUtils {
|
public class AsgStringUtils {
|
||||||
|
|
||||||
public static boolean geq(final Character ch1, final Character ch2) {
|
public static boolean geq(final Character ch1, final Character ch2) {
|
||||||
return Character.toLowerCase(ch1) >= Character.toLowerCase(ch2);
|
return Character.toLowerCase(ch1) >= Character.toLowerCase(ch2);
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Configuration>
|
|
||||||
<Appenders>
|
|
||||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
|
||||||
<PatternLayout pattern="%m%n"/>
|
|
||||||
</Console>
|
|
||||||
</Appenders>
|
|
||||||
<Loggers>
|
|
||||||
<Logger name="org.apache.log4j.xml" level="info"/>
|
|
||||||
<Root level="info">
|
|
||||||
<AppenderRef ref="STDOUT"/>
|
|
||||||
</Root>
|
|
||||||
</Loggers>
|
|
||||||
</Configuration>
|
|
||||||
@@ -19,9 +19,9 @@ import java.util.Arrays;
|
|||||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
import org.antlr.v4.runtime.CommonTokenStream;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import io.proleap.vb6.VisualBasic6Parser.StartRuleContext;
|
import io.proleap.vb6.VisualBasic6Parser.StartRuleContext;
|
||||||
import io.proleap.vb6.util.TreeUtils;
|
import io.proleap.vb6.util.TreeUtils;
|
||||||
@@ -34,7 +34,7 @@ public class TestGenerator {
|
|||||||
|
|
||||||
private static final String JAVA_EXTENSION = ".java";
|
private static final String JAVA_EXTENSION = ".java";
|
||||||
|
|
||||||
private final static Logger LOG = LogManager.getLogger(TestGenerator.class);
|
private final static Logger LOG = LoggerFactory.getLogger(TestGenerator.class);
|
||||||
|
|
||||||
private final static File OUTPUT_DIRECTORY = new File("src/test/java");
|
private final static File OUTPUT_DIRECTORY = new File("src/test/java");
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ public class TestGenerator {
|
|||||||
subOutputDirectory.mkdirs();
|
subOutputDirectory.mkdirs();
|
||||||
|
|
||||||
// determine the package name of test classes
|
// determine the package name of test classes
|
||||||
final String subPackageName = Strings.isBlank(packageName) ? subInputDirectoryName
|
final String subPackageName = StringUtils.isBlank(packageName) ? subInputDirectoryName
|
||||||
: packageName + "." + subInputDirectoryName;
|
: packageName + "." + subInputDirectoryName;
|
||||||
|
|
||||||
generateTestClasses(subInputDirectory, subOutputDirectory, subPackageName);
|
generateTestClasses(subInputDirectory, subOutputDirectory, subPackageName);
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ import org.antlr.v4.runtime.CommonTokenStream;
|
|||||||
import org.antlr.v4.runtime.tree.Trees;
|
import org.antlr.v4.runtime.tree.Trees;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import io.proleap.vb6.VisualBasic6Lexer;
|
import io.proleap.vb6.VisualBasic6Lexer;
|
||||||
import io.proleap.vb6.VisualBasic6Parser;
|
import io.proleap.vb6.VisualBasic6Parser;
|
||||||
@@ -38,7 +38,7 @@ import io.proleap.vb6.runner.VbParseTestRunner;
|
|||||||
*/
|
*/
|
||||||
public class VbParseTestRunnerImpl implements VbParseTestRunner {
|
public class VbParseTestRunnerImpl implements VbParseTestRunner {
|
||||||
|
|
||||||
private final static Logger LOG = LogManager.getLogger(VbParseTestRunnerImpl.class);
|
private final static Logger LOG = LoggerFactory.getLogger(VbParseTestRunnerImpl.class);
|
||||||
|
|
||||||
public final static String TREE_SUFFIX = ".tree";
|
public final static String TREE_SUFFIX = ".tree";
|
||||||
|
|
||||||
@@ -57,12 +57,12 @@ public class VbParseTestRunnerImpl implements VbParseTestRunner {
|
|||||||
|
|
||||||
final String treeFileData = FileUtils.readFileToString(treeFile);
|
final String treeFileData = FileUtils.readFileToString(treeFile);
|
||||||
|
|
||||||
if (!Strings.isBlank(treeFileData)) {
|
if (!StringUtils.isBlank(treeFileData)) {
|
||||||
LOG.info("Comparing parse tree with file {}.", treeFile.getName());
|
LOG.info("Comparing parse tree with file {}.", treeFile.getName());
|
||||||
|
|
||||||
final String inputFileTree = Trees.toStringTree(startRule, parser);
|
final String inputFileTree = Trees.toStringTree(startRule, parser);
|
||||||
final String cleanedInputFileTree = io.proleap.vb6.util.StringUtils.cleanFileTree(inputFileTree);
|
final String cleanedInputFileTree = io.proleap.vb6.util.VbTestStringUtils.cleanFileTree(inputFileTree);
|
||||||
final String cleanedTreeFileData = io.proleap.vb6.util.StringUtils.cleanFileTree(treeFileData);
|
final String cleanedTreeFileData = io.proleap.vb6.util.VbTestStringUtils.cleanFileTree(treeFileData);
|
||||||
|
|
||||||
assertEquals(cleanedTreeFileData, cleanedInputFileTree);
|
assertEquals(cleanedTreeFileData, cleanedInputFileTree);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.proleap.vb6.util;
|
package io.proleap.vb6.util;
|
||||||
|
|
||||||
public class StringUtils {
|
public class VbTestStringUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To be removed, as soon as the grammar does not require NEWLINEs and WS
|
* To be removed, as soon as the grammar does not require NEWLINEs and WS
|
||||||
Reference in New Issue
Block a user