mirror of
https://github.com/uwol/proleap-vb6-parser.git
synced 2025-12-18 12:34:35 +03:00
exceptions
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package io.proleap.vb6.asg.exception;
|
||||
|
||||
public class VbParserException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public VbParserException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import io.proleap.vb6.VisualBasic6Parser.PropertySetStmtContext;
|
||||
import io.proleap.vb6.VisualBasic6Parser.SubStmtContext;
|
||||
import io.proleap.vb6.VisualBasic6Parser.TypeStmtContext;
|
||||
import io.proleap.vb6.VisualBasic6Parser.TypeStmt_ElementContext;
|
||||
import io.proleap.vb6.asg.exception.VbParserException;
|
||||
import io.proleap.vb6.asg.metamodel.Attribute;
|
||||
import io.proleap.vb6.asg.metamodel.DefType;
|
||||
import io.proleap.vb6.asg.metamodel.Literal;
|
||||
@@ -196,7 +197,7 @@ public abstract class ModuleImpl extends ScopeImpl implements Module {
|
||||
} else if (ctx.DEFVAR() != null) {
|
||||
vbType = VbBaseType.VARIANT;
|
||||
} else {
|
||||
throw new RuntimeException("unknown deftype " + ctx);
|
||||
throw new VbParserException("unknown deftype " + ctx);
|
||||
}
|
||||
|
||||
result = new DefTypeImpl(vbType);
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.proleap.vb6.asg.exception.VbParserException;
|
||||
import io.proleap.vb6.asg.metamodel.ClazzModule;
|
||||
import io.proleap.vb6.asg.metamodel.Module;
|
||||
import io.proleap.vb6.asg.metamodel.Program;
|
||||
@@ -219,7 +220,7 @@ public class ProgramImpl extends ScopeImpl implements Program {
|
||||
} else if (module instanceof StandardModule) {
|
||||
registerStandardModule((StandardModule) module);
|
||||
} else {
|
||||
throw new RuntimeException("unknown module type " + module);
|
||||
throw new VbParserException("unknown module type " + module);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import io.proleap.vb6.VisualBasic6Parser.VsNewContext;
|
||||
import io.proleap.vb6.VisualBasic6Parser.VsNotContext;
|
||||
import io.proleap.vb6.VisualBasic6Parser.VsOrContext;
|
||||
import io.proleap.vb6.VisualBasic6Parser.VsXorContext;
|
||||
import io.proleap.vb6.asg.exception.VbParserException;
|
||||
import io.proleap.vb6.asg.metamodel.Program;
|
||||
import io.proleap.vb6.asg.metamodel.type.Type;
|
||||
import io.proleap.vb6.asg.metamodel.type.VbBaseType;
|
||||
@@ -90,7 +91,7 @@ public class TypeResolverImpl implements TypeResolver {
|
||||
} else if (literal.NOTHING() != null) {
|
||||
result = null;
|
||||
} else {
|
||||
throw new RuntimeException("unknown literal " + literal);
|
||||
throw new VbParserException("unknown literal " + literal);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -12,11 +12,13 @@ import org.antlr.v4.runtime.BaseErrorListener;
|
||||
import org.antlr.v4.runtime.RecognitionException;
|
||||
import org.antlr.v4.runtime.Recognizer;
|
||||
|
||||
import io.proleap.vb6.asg.exception.VbParserException;
|
||||
|
||||
public class ThrowingErrorListener extends BaseErrorListener {
|
||||
|
||||
@Override
|
||||
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
|
||||
final int charPositionInLine, final String msg, final RecognitionException e) {
|
||||
throw new RuntimeException("syntax error in line " + line + ":" + charPositionInLine + " " + msg);
|
||||
throw new VbParserException("syntax error in line " + line + ":" + charPositionInLine + " " + msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user