Search in sources :

Example 1 with ClassicalBModel

use of de.prob.model.classicalb.ClassicalBModel in project prob2 by bendisposto.

the class ClassicalBFactory method create.

public ExtractedModel<ClassicalBModel> create(final Start model) {
    ClassicalBModel classicalBModel = modelCreator.get();
    BParser bparser = new BParser();
    final RecursiveMachineLoader rml = parseAllMachines(model, ".", new File(""), new CachingDefinitionFileProvider(), bparser);
    classicalBModel = classicalBModel.create(model, rml, new File("from_string"), bparser);
    return new ExtractedModel<>(classicalBModel, classicalBModel.getMainMachine());
}
Also used : CachingDefinitionFileProvider(de.be4.classicalb.core.parser.CachingDefinitionFileProvider) ClassicalBModel(de.prob.model.classicalb.ClassicalBModel) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) File(java.io.File)

Example 2 with ClassicalBModel

use of de.prob.model.classicalb.ClassicalBModel in project prob2 by bendisposto.

the class ClassicalBFactory method create.

public ExtractedModel<ClassicalBModel> create(final String model) {
    ClassicalBModel classicalBModel = modelCreator.get();
    BParser bparser = new BParser();
    Start ast = parseString(model, bparser);
    final RecursiveMachineLoader rml = parseAllMachines(ast, ".", new File(""), bparser.getContentProvider(), bparser);
    classicalBModel = classicalBModel.create(ast, rml, new File("from_string"), bparser);
    return new ExtractedModel<>(classicalBModel, classicalBModel.getMainMachine());
}
Also used : ClassicalBModel(de.prob.model.classicalb.ClassicalBModel) Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) File(java.io.File)

Example 3 with ClassicalBModel

use of de.prob.model.classicalb.ClassicalBModel in project prob2 by bendisposto.

the class ClassicalBFactory method extract.

@Override
public ExtractedModel<ClassicalBModel> extract(final String modelPath) throws IOException, ModelTranslationError {
    ClassicalBModel classicalBModel = modelCreator.get();
    File f = new File(modelPath);
    BParser bparser = new BParser();
    Start ast = parseFile(f, bparser);
    RecursiveMachineLoader rml = parseAllMachines(ast, f.getParent(), f, bparser.getContentProvider(), bparser);
    classicalBModel = classicalBModel.create(ast, rml, f, bparser);
    return new ExtractedModel<>(classicalBModel, classicalBModel.getMainMachine());
}
Also used : ClassicalBModel(de.prob.model.classicalb.ClassicalBModel) Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) File(java.io.File)

Example 4 with ClassicalBModel

use of de.prob.model.classicalb.ClassicalBModel 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)4 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)4 ClassicalBModel (de.prob.model.classicalb.ClassicalBModel)4 File (java.io.File)4 Start (de.be4.classicalb.core.parser.node.Start)3 CachingDefinitionFileProvider (de.be4.classicalb.core.parser.CachingDefinitionFileProvider)1 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)1 TLA2BException (de.tla2b.exceptions.TLA2BException)1 Translator (de.tla2bAst.Translator)1 FileNotFoundException (java.io.FileNotFoundException)1