Search in sources :

Example 1 with RulesModelFactory

use of de.prob.model.brules.RulesModelFactory in project prob2 by bendisposto.

the class Api method brules_load.

/**
 * Load a B rules machine from the given file.
 *
 * @param file the path of the file to load
 * @param prefs the preferences to use
 * @return the {@link StateSpace} for the loaded machine
 */
public StateSpace brules_load(final String file, final Map<String, String> prefs) throws IOException {
    final RulesModelFactory bRulesFactory = modelFactoryProvider.getBRulesFactory();
    final RulesProject rulesProject = new RulesProject();
    final ParsingBehaviour parsingBehaviour = new ParsingBehaviour();
    parsingBehaviour.setAddLineNumbers(true);
    rulesProject.setParsingBehaviour(parsingBehaviour);
    rulesProject.parseProject(new File(file));
    rulesProject.checkAndTranslateProject();
    if (rulesProject.hasErrors()) {
        throw new ProBError(new BCompoundException(rulesProject.getBExceptionList()));
    }
    return bRulesFactory.extract(new File(file), rulesProject).load(prefs);
}
Also used : RulesModelFactory(de.prob.model.brules.RulesModelFactory) RulesProject(de.be4.classicalb.core.parser.rules.RulesProject) ParsingBehaviour(de.be4.classicalb.core.parser.ParsingBehaviour) File(java.io.File) ProBError(de.prob.exception.ProBError) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Aggregations

ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)1 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)1 RulesProject (de.be4.classicalb.core.parser.rules.RulesProject)1 ProBError (de.prob.exception.ProBError)1 RulesModelFactory (de.prob.model.brules.RulesModelFactory)1 File (java.io.File)1