Search in sources :

Example 1 with TLA2BException

use of de.tla2b.exceptions.TLA2BException in project prob2 by bendisposto.

the class TLAFactory method extract.

@Override
public ExtractedModel<ClassicalBModel> extract(final String fileName) throws IOException, ModelTranslationError {
    ClassicalBModel classicalBModel = modelCreator.get();
    File f = new File(fileName);
    if (!f.exists()) {
        throw new FileNotFoundException("The TLA Model" + fileName + " was not found.");
    }
    Translator translator;
    Start ast;
    try {
        translator = new Translator(f.getAbsolutePath());
        ast = translator.translate();
    } catch (TLA2BException e) {
        throw new ModelTranslationError("Translation Error: " + e.getMessage(), e);
    }
    BParser bparser = new BParser();
    bparser.getDefinitions().addDefinitions(translator.getBDefinitions());
    try {
        final RecursiveMachineLoader rml = parseAllMachines(ast, f, bparser);
        classicalBModel = classicalBModel.create(ast, rml, f, bparser);
    } catch (BCompoundException e) {
        throw new ModelTranslationError(e.getMessage(), e);
    }
    return new ExtractedModel<>(classicalBModel, classicalBModel.getMainMachine());
}
Also used : ClassicalBModel(de.prob.model.classicalb.ClassicalBModel) Translator(de.tla2bAst.Translator) Start(de.be4.classicalb.core.parser.node.Start) TLA2BException(de.tla2b.exceptions.TLA2BException) FileNotFoundException(java.io.FileNotFoundException) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) File(java.io.File) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Aggregations

BParser (de.be4.classicalb.core.parser.BParser)1 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)1 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)1 Start (de.be4.classicalb.core.parser.node.Start)1 ClassicalBModel (de.prob.model.classicalb.ClassicalBModel)1 TLA2BException (de.tla2b.exceptions.TLA2BException)1 Translator (de.tla2bAst.Translator)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1