Search in sources :

Example 71 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project prob2 by bendisposto.

the class RulesMachineRun method start.

public void start() {
    logger.info("Starting rules machine run: {}", this.runnerFile.getAbsolutePath());
    stopWatch.start(Timer.PARSING);
    boolean hasParseErrors = parseAndTranslateRulesProject();
    logger.info("Time to parse rules project: {} ms", stopWatch.stop(Timer.PARSING));
    if (hasParseErrors) {
        logger.error("RULES_MACHINE has errors!");
        return;
    }
    this.executeRun = rulesMachineRunner.createRulesMachineExecuteRun(this.rulesProject, runnerFile, this.proBCorePreferences, continueAfterErrors, this.getStateSpace());
    try {
        stopWatch.start(Timer.EXECUTE_RUN);
        logger.info("Start execute ...");
        this.executeRun.start();
        logger.info("Execute run finished. Time: {} ms", stopWatch.stop(Timer.EXECUTE_RUN));
    } catch (ProBError e) {
        logger.error("ProBError: {}", e.getMessage());
        if (executeRun.getExecuteModelCommand() != null) {
            try {
                State finalState = executeRun.getExecuteModelCommand().getFinalState();
                // explores the final state and can throw a ProBError
                Collection<StateError> stateErrors = finalState.getStateErrors();
                for (StateError stateError : stateErrors) {
                    this.errors.add(new Error(ERROR_TYPES.PROB_ERROR, stateError.getLongDescription(), e));
                }
            } catch (ProBError e2) {
                // Enumeration errors
                this.errors.add(new Error(ERROR_TYPES.PROB_ERROR, e2.getMessage(), e2));
                return;
            }
        } else {
            /*- static errors such as type errors or errors while loading the  state space */
            this.errors.add(new Error(ERROR_TYPES.PROB_ERROR, e.getMessage(), e));
            /*- no final state is available and thus we can not create RuleResults */
            return;
        }
    } catch (Exception e) {
        logger.error("Unexpected error occured: {}", e.getMessage(), e);
        // storing all error messages
        this.errors.add(new Error(ERROR_TYPES.PROB_ERROR, e.getMessage(), e));
        return;
    } finally {
        if (executeRun.getUsedStateSpace() != null) {
            GetTotalNumberOfErrorsCommand totalNumberOfErrorsCommand = new GetTotalNumberOfErrorsCommand();
            executeRun.getUsedStateSpace().execute(totalNumberOfErrorsCommand);
            totalNumberOfProBCliErrors = totalNumberOfErrorsCommand.getTotalNumberOfErrors();
        }
    }
    this.stateSpace = this.executeRun.getUsedStateSpace();
    stopWatch.start(Timer.EXTRACT_RESULTS);
    this.ruleResults = new RuleResults(this.rulesProject, executeRun.getExecuteModelCommand().getFinalState(), maxNumberOfReportedCounterExamples);
    logger.info("Time to extract results from final state: {}", stopWatch.stop(Timer.EXTRACT_RESULTS));
}
Also used : StateError(de.prob.animator.domainobjects.StateError) State(de.prob.statespace.State) GetTotalNumberOfErrorsCommand(de.prob.animator.command.GetTotalNumberOfErrorsCommand) Collection(java.util.Collection) ProBError(de.prob.exception.ProBError) StateError(de.prob.animator.domainobjects.StateError) ProBError(de.prob.exception.ProBError) BException(de.be4.classicalb.core.parser.exceptions.BException)

Example 72 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project prob2 by bendisposto.

the class ModelGenerator method addComponent.

private ModelModifier addComponent(ModelModifier modelM, String name, String componentDesc, Map<String, String> components) throws BException {
    EventBParser parser = new EventBParser();
    Start ast = parser.parse(componentDesc, false);
    ReferenceExtractor e = new ReferenceExtractor();
    ast.apply(e);
    if (e.isContext()) {
        for (String s : e.getExtends()) {
            String fileN = s + ".ctx";
            if (modelM.getModel().getComponent(fileN) == null) {
                if (components.get(fileN) == null) {
                    throw new IllegalArgumentException("no component description for context " + s);
                }
                modelM = addComponent(modelM, s, components.get(fileN), components);
            }
        }
        modelM = addComponent(modelM, ast);
    } else if (e.isMachine()) {
        for (String s : e.getSees()) {
            String fileN = s + ".ctx";
            if (modelM.getModel().getComponent(fileN) == null) {
                if (components.get(fileN) == null) {
                    throw new IllegalArgumentException("no component description for context " + s);
                }
                modelM = addComponent(modelM, s, components.get(fileN), components);
            }
        }
        for (String s : e.getRefines()) {
            String fileN = s + ".emch";
            if (modelM.getModel().getComponent(fileN) == null) {
                if (components.get(fileN) == null) {
                    throw new IllegalArgumentException("no component description for machine " + s);
                }
                modelM = addComponent(modelM, s, components.get(fileN), components);
            }
        }
        modelM = addComponent(modelM, ast);
    }
    return modelM;
}
Also used : Start(de.be4.eventbalg.core.parser.node.Start) EventBParser(de.be4.eventbalg.core.parser.EventBParser)

Example 73 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project prob2 by bendisposto.

the class DependencyWalker method makeMachine.

private ClassicalBMachine makeMachine(final String dest, final String prefix) {
    final DomBuilder builder = new DomBuilder(prefix);
    final Start start = map.get(dest);
    start.apply(builder);
    return builder.getMachine();
}
Also used : Start(de.be4.classicalb.core.parser.node.Start)

Example 74 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project prob2 by bendisposto.

the class DomBuilder method createExpressionAST.

private Start createExpressionAST(final PExpression expression) {
    Start start = new Start();
    AExpressionParseUnit node = new AExpressionParseUnit();
    start.setPParseUnit(node);
    start.setEOF(EOF);
    node.setExpression((PExpression) expression.clone());
    node.getExpression().apply(new RenameIdentifiers());
    return start;
}
Also used : AExpressionParseUnit(de.be4.classicalb.core.parser.node.AExpressionParseUnit) Start(de.be4.classicalb.core.parser.node.Start)

Example 75 with Start

use of de.be4.ltl.core.ctlparser.node.Start in project prob2 by bendisposto.

the class DomBuilder method createPredicateAST.

private Start createPredicateAST(final PPredicate pPredicate) {
    Start start = new Start();
    APredicateParseUnit node2 = new APredicateParseUnit();
    start.setPParseUnit(node2);
    start.setEOF(EOF);
    node2.setPredicate((PPredicate) pPredicate.clone());
    node2.getPredicate().apply(new RenameIdentifiers());
    return start;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) APredicateParseUnit(de.be4.classicalb.core.parser.node.APredicateParseUnit)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)104 Test (org.junit.Test)84 BParser (de.be4.classicalb.core.parser.BParser)43 Ast2String (util.Ast2String)32 File (java.io.File)20 Start (de.be4.eventbalg.core.parser.node.Start)19 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)18 Start (de.be4.eventb.core.parser.node.Start)18 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)14 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)14 IOException (java.io.IOException)12 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)11 PushbackReader (java.io.PushbackReader)11 StringReader (java.io.StringReader)11 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)8 AExpressionParseUnit (de.be4.classicalb.core.parser.node.AExpressionParseUnit)7 AbstractParseMachineTest (util.AbstractParseMachineTest)7 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)6 ClassicalPositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter)6 ASTPrinter (de.be4.classicalb.core.parser.visualisation.ASTPrinter)6