Search in sources :

Example 1 with CachingDefinitionFileProvider

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

the class RulesParseUnit method parse.

public void parse() {
    if (this.bCompoundException != null) {
        return;
    }
    try {
        bParser = null;
        if (machineFile != null) {
            bParser = new BParser(machineFile.getPath());
            bParser.setDirectory(machineFile.getParentFile());
        } else {
            bParser = new BParser();
        }
        ParseOptions parseOptions = new ParseOptions();
        parseOptions.setGrammar(RulesGrammar.getInstance());
        bParser.setParseOptions(parseOptions);
        start = bParser.parse(content, debugOuput, new CachingDefinitionFileProvider());
        refFinder = new RulesReferencesFinder(machineFile, start);
        refFinder.findReferencedMachines();
        this.machineReferences = refFinder.getReferences();
        this.machineName = refFinder.getName();
        this.rulesMachineChecker = new RulesMachineChecker(machineFile, bParser.getFileName(), machineReferences, start);
        rulesMachineChecker.runChecks();
        this.operationList.addAll(rulesMachineChecker.getOperations());
    } catch (BCompoundException e) {
        // store parser exceptions
        this.bCompoundException = e;
    }
}
Also used : CachingDefinitionFileProvider(de.be4.classicalb.core.parser.CachingDefinitionFileProvider) ParseOptions(de.be4.classicalb.core.parser.ParseOptions) BParser(de.be4.classicalb.core.parser.BParser) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 2 with CachingDefinitionFileProvider

use of de.be4.classicalb.core.parser.CachingDefinitionFileProvider 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)

Aggregations

BParser (de.be4.classicalb.core.parser.BParser)2 CachingDefinitionFileProvider (de.be4.classicalb.core.parser.CachingDefinitionFileProvider)2 ParseOptions (de.be4.classicalb.core.parser.ParseOptions)1 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)1 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)1 ClassicalBModel (de.prob.model.classicalb.ClassicalBModel)1 File (java.io.File)1