use of de.be4.classicalb.core.parser.exceptions.BParseException in project probparsers by bendisposto.
the class PrologExceptionPrinter method printBParseException.
private static void printBParseException(final IPrologTermOutput pto, final BParseException e, final String filename, final boolean useIndentation, final boolean lineOneOff) {
final Token token = e.getToken();
final SourcePosition pos = token == null ? null : new SourcePosition(token.getLine(), token.getPos());
printExceptionWithSourcePosition(pto, e, filename, pos, useIndentation, lineOneOff);
}
use of de.be4.classicalb.core.parser.exceptions.BParseException in project probparsers by bendisposto.
the class PrologExceptionPrinter method printBException.
public static void printBException(IPrologTermOutput pto, final BException e, boolean useIndentation, boolean lineOneOff) {
Throwable cause = e.getCause();
String filename = e.getFilename();
if (cause == null) {
printGeneralException(pto, e, filename, useIndentation, lineOneOff, true);
} else {
while (cause.getClass().equals(BException.class) && cause.getCause() != null) {
BException bex = (BException) cause;
cause = bex.getCause();
filename = bex.getFilename();
}
if (cause instanceof BLexerException) {
printBLexerException(pto, (BLexerException) cause, filename, useIndentation, lineOneOff);
} else if (cause instanceof LexerException) {
printLexerException(pto, (LexerException) cause, filename, useIndentation, lineOneOff);
} else if (cause instanceof BParseException) {
printBParseException(pto, (BParseException) cause, filename, useIndentation, lineOneOff);
} else if (cause instanceof PreParseException) {
printPreParseException(pto, (PreParseException) cause, filename, useIndentation, lineOneOff);
} else if (cause instanceof CheckException) {
printCheckException(pto, (CheckException) cause, filename, useIndentation, lineOneOff);
} else {
printGeneralException(pto, cause, filename, useIndentation, lineOneOff, false);
}
}
}
use of de.be4.classicalb.core.parser.exceptions.BParseException in project probparsers by bendisposto.
the class PredicatesTest method testNoPredicateSubstitutionsInNormalMode.
@Test
public void testNoPredicateSubstitutionsInNormalMode() {
final String testMachine = "#PREDICATE ! a,5. (a=5 => a/=5 )";
try {
getTreeAsString(testMachine);
fail("Expected exception");
} catch (final BCompoundException e) {
assertTrue(e.getFirstException().getCause() instanceof BParseException);
}
}
use of de.be4.classicalb.core.parser.exceptions.BParseException in project probparsers by bendisposto.
the class PredicatesTest method testNonIdentifiersInQuantificationFormula.
@Test
public void testNonIdentifiersInQuantificationFormula() {
final String testMachine = "#FORMULA ! a,5. (a=5 => a/=5 )";
try {
getTreeAsString(testMachine);
fail("Expected exception");
} catch (final BCompoundException e) {
assertTrue(e.getFirstException().getCause() instanceof BParseException);
}
}
Aggregations