use of de.be4.classicalb.core.parser.rules.ComputationOperation in project probparsers by bendisposto.
the class AbstractOperation method getImplicitDependenciesToComputations.
public List<TIdentifierLiteral> getImplicitDependenciesToComputations() {
List<TIdentifierLiteral> result = new ArrayList<>();
for (ComputationOperation comp : implicitDependenciesToComputations) {
TIdentifierLiteral nameLiteral = comp.getNameLiteral();
result.add(nameLiteral);
}
return result;
}
use of de.be4.classicalb.core.parser.rules.ComputationOperation in project probparsers by bendisposto.
the class RulesMachineChecker method outADefineSubstitution.
@Override
public void outADefineSubstitution(ADefineSubstitution node) {
// section
if (currentOperation != null && currentOperation instanceof ComputationOperation) {
ComputationOperation computationOperation = (ComputationOperation) currentOperation;
try {
computationOperation.addDefineVariable(node.getName());
this.knownIdentifier.addKnownIdentifier(node.getName());
} catch (CheckException e) {
this.errorList.add(e);
}
}
}
use of de.be4.classicalb.core.parser.rules.ComputationOperation in project probparsers by bendisposto.
the class RulesMachineChecker method caseAComputationOperation.
@Override
public void caseAComputationOperation(AComputationOperation node) {
currentOperation = new ComputationOperation(node.getName(), this.fileName, this.machineName, machineReferences);
computationMap.put(node, (ComputationOperation) currentOperation);
visitOperationAttributes(node.getAttributes());
node.getBody().apply(this);
currentOperation = null;
}
use of de.be4.classicalb.core.parser.rules.ComputationOperation in project probparsers by bendisposto.
the class RulesProject method checkDependsOnComputations.
private void checkDependsOnComputations(AbstractOperation operation) {
boolean errorOccured = false;
for (AIdentifierExpression aIdentifierExpression : operation.getDependsOnComputationList()) {
final String name = aIdentifierExpression.getIdentifier().get(0).getText();
if (allOperations.containsKey(name)) {
AbstractOperation abstractOperation = allOperations.get(name);
if (!(abstractOperation instanceof ComputationOperation)) {
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Identifier '" + name + "' is not a COMPUTATION.", aIdentifierExpression)));
errorOccured = true;
}
} else {
errorOccured = true;
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Unknown operation: '" + name + "'.", aIdentifierExpression)));
}
}
if (!errorOccured) {
checkVisibilityOfAIdentifierList(operation, operation.getDependsOnComputationList());
}
}
use of de.be4.classicalb.core.parser.rules.ComputationOperation in project prob2 by bendisposto.
the class RulesChecker method evalOperations.
public Map<AbstractOperation, OperationStatus> evalOperations(State state, Collection<AbstractOperation> operations) {
ArrayList<IEvalElement> formulas = new ArrayList<>();
for (AbstractOperation abstractOperation : operations) {
if (abstractOperation instanceof ComputationOperation || abstractOperation instanceof RuleOperation) {
formulas.add(rulesModel.getEvalElement(abstractOperation));
}
}
state.getStateSpace().subscribe(this, formulas);
Map<IEvalElement, AbstractEvalResult> values = state.getValues();
final Map<AbstractOperation, OperationStatus> states = new HashMap<>();
for (AbstractOperation op : operations) {
if (op instanceof RuleOperation) {
states.put(op, RuleStatus.valueOf(values.get(rulesModel.getEvalElement(op))));
} else if (op instanceof ComputationOperation) {
states.put(op, ComputationStatus.valueOf(values.get(rulesModel.getEvalElement(op))));
}
}
return states;
}
Aggregations