Search in sources :

Example 6 with BCompoundException

use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.

the class RulesMachineChecker method runChecks.

public void runChecks() throws BCompoundException {
    start.apply(this);
    if (!errorList.isEmpty()) {
        final List<BException> bExceptionList = new ArrayList<>();
        final String filePath = file == null ? "UnknownFile" : file.getAbsolutePath();
        for (CheckException checkException : errorList) {
            final BException bException = new BException(filePath, checkException);
            bExceptionList.add(bException);
        }
        throw new BCompoundException(bExceptionList);
    }
}
Also used : CheckException(de.be4.classicalb.core.parser.exceptions.CheckException) ArrayList(java.util.ArrayList) BException(de.be4.classicalb.core.parser.exceptions.BException) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 7 with BCompoundException

use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.

the class RulesParseUnit method readMachineFromFile.

public void readMachineFromFile(File file) {
    this.machineFile = file;
    try {
        content = Utils.readFile(file);
        this.machineFile = machineFile.getCanonicalFile();
    } catch (IOException e) {
        bCompoundException = new BCompoundException(new BException(file.getAbsolutePath(), e));
    }
}
Also used : IOException(java.io.IOException) BException(de.be4.classicalb.core.parser.exceptions.BException) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 8 with BCompoundException

use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.

the class RulesReferencesFinder method findReferencedMachines.

public void findReferencedMachines() throws BCompoundException {
    this.start.apply(this);
    if (!errorList.isEmpty()) {
        final List<BException> bExceptionList = new ArrayList<>();
        for (CheckException checkException : errorList) {
            final BException bException = new BException(mainFile.getAbsolutePath(), checkException);
            bExceptionList.add(bException);
        }
        throw new BCompoundException(bExceptionList);
    }
}
Also used : CheckException(de.be4.classicalb.core.parser.exceptions.CheckException) ArrayList(java.util.ArrayList) BException(de.be4.classicalb.core.parser.exceptions.BException) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 9 with BCompoundException

use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.

the class RulesProject method printPrologOutput.

public int printPrologOutput(final PrintStream out, final PrintStream err) {
    if (!this.bExceptionList.isEmpty()) {
        BCompoundException comp = new BCompoundException(bExceptionList);
        PrologExceptionPrinter.printException(err, comp, parsingBehaviour.isUseIndention(), false);
        return -2;
    } else {
        final IPrologTermOutput pout = new PrologTermOutput(new PrintWriter(out), false);
        printProjectAsPrologTerm(pout);
        pout.flush();
        return 0;
    }
}
Also used : PrologTermOutput(de.prob.prolog.output.PrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) PrintWriter(java.io.PrintWriter)

Example 10 with BCompoundException

use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.

the class RulesTransformation method runTransformation.

public void runTransformation() throws BCompoundException {
    start.apply(this);
    DefinitionInjector.injectDefinitions(start, iDefinitions);
    MissingPositionsAdder.injectPositions(start);
    if (!this.errorList.isEmpty()) {
        List<BException> list = new ArrayList<>();
        for (CheckException checkException : this.errorList) {
            list.add(new BException(this.rulesMachineChecker.getFileName(), checkException));
        }
        throw new BCompoundException(list);
    }
}
Also used : CheckException(de.be4.classicalb.core.parser.exceptions.CheckException) ArrayList(java.util.ArrayList) BException(de.be4.classicalb.core.parser.exceptions.BException) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Aggregations

BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)73 Test (org.junit.Test)64 Ast2String (util.Ast2String)62 Start (de.be4.classicalb.core.parser.node.Start)52 BParser (de.be4.classicalb.core.parser.BParser)29 CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)19 File (java.io.File)15 BParseException (de.be4.classicalb.core.parser.exceptions.BParseException)9 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)7 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)7 BException (de.be4.classicalb.core.parser.exceptions.BException)7 Helpers.getTreeAsString (util.Helpers.getTreeAsString)7 BLexerException (de.be4.classicalb.core.parser.exceptions.BLexerException)5 PreParseException (de.be4.classicalb.core.parser.exceptions.PreParseException)5 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)5 Node (de.be4.classicalb.core.parser.node.Node)5 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)4 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)4