Search in sources :

Example 6 with ProBError

use of de.prob.exception.ProBError in project prob2 by bendisposto.

the class ClassicalBFactory method parseAllMachines.

/**
 * Given an {@link Start} ast, {@link File} f, and {@link BParser} bparser, all
 * machines are loaded.
 *
 * @param ast
 *            {@link Start} representing the abstract syntax tree for the
 *            machine
 * @param directory
 *            the directory relative to which machines should be loaded
 * @param f
 *            {@link File} containing machine
 * @param contentProvider
 *            the content provider to use
 * @param bparser
 *            {@link BParser} for parsing
 * @return {@link RecursiveMachineLoader} rml with all loaded machines
 * @throws ProBError
 *             if the model could not be loaded
 */
public RecursiveMachineLoader parseAllMachines(final Start ast, final String directory, final File f, final IDefinitionFileProvider contentProvider, final BParser bparser) {
    try {
        ParsingBehaviour parsingBehaviour = new ParsingBehaviour();
        parsingBehaviour.setAddLineNumbers(true);
        final RecursiveMachineLoader rml = new RecursiveMachineLoader(directory, contentProvider, parsingBehaviour);
        rml.loadAllMachines(f, ast, bparser.getDefinitions());
        logger.trace("Done parsing '{}'", f.getAbsolutePath());
        return rml;
    } catch (BCompoundException e) {
        throw new ProBError(e);
    }
}
Also used : RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) ParsingBehaviour(de.be4.classicalb.core.parser.ParsingBehaviour) ProBError(de.prob.exception.ProBError) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 7 with ProBError

use of de.prob.exception.ProBError in project prob2 by bendisposto.

the class ClassicalBFactory method parseString.

private Start parseString(final String model, final BParser bparser) {
    try {
        logger.trace("Parsing file");
        Start ast = null;
        ast = bparser.parse(model, false);
        return ast;
    } catch (BCompoundException e) {
        throw new ProBError(e);
    }
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) ProBError(de.prob.exception.ProBError) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Aggregations

ProBError (de.prob.exception.ProBError)7 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)4 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)2 Start (de.be4.classicalb.core.parser.node.Start)2 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)1 BException (de.be4.classicalb.core.parser.exceptions.BException)1 RulesProject (de.be4.classicalb.core.parser.rules.RulesProject)1 GetTotalNumberOfErrorsCommand (de.prob.animator.command.GetTotalNumberOfErrorsCommand)1 SetBGoalCommand (de.prob.animator.command.SetBGoalCommand)1 StateError (de.prob.animator.domainobjects.StateError)1 RulesModelFactory (de.prob.model.brules.RulesModelFactory)1 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)1 PrologTerm (de.prob.prolog.term.PrologTerm)1 State (de.prob.statespace.State)1 File (java.io.File)1 Collection (java.util.Collection)1