use of de.be4.classicalb.core.parser.node.PPredicate in project probparsers by bendisposto.
the class MachineContext method caseAAssertionsMachineClause.
@Override
public void caseAAssertionsMachineClause(AAssertionsMachineClause node) {
this.assertiondMachineClause = node;
this.contextTable = new ArrayList<LinkedHashMap<String, Node>>();
ArrayList<MachineContext> list = lookupReferencedMachines();
for (int i = 0; i < list.size(); i++) {
MachineContext s = list.get(i);
this.contextTable.add(s.getSetParamter());
this.contextTable.add(s.getScalarParameter());
this.contextTable.add(s.getDeferredSets());
this.contextTable.add(s.getEnumeratedSets());
this.contextTable.add(s.getEnumValues());
this.contextTable.add(s.getConstants());
this.contextTable.add(s.getDefinitions());
this.contextTable.add(s.getVariables());
}
List<PPredicate> copy = new ArrayList<PPredicate>(node.getPredicates());
for (PPredicate e : copy) {
e.apply(this);
}
}
use of de.be4.classicalb.core.parser.node.PPredicate in project probparsers by bendisposto.
the class RulesMachineChecker method checkOperationPredicateAttribute.
private void checkOperationPredicateAttribute(OccurredAttributes occurredAttributes, POperationAttribute pOperationAttribute) throws AssertionError {
APredicateAttributeOperationAttribute attr = (APredicateAttributeOperationAttribute) pOperationAttribute;
PPredicate predicate = attr.getPredicate();
final String attrName = attr.getName().getText();
occurredAttributes.add(attrName, pOperationAttribute);
switch(attrName) {
case RulesGrammar.ACTIVATION:
if (currentOperation instanceof FunctionOperation) {
errorList.add(new CheckException("ACTIVATION is not a valid attribute of a FUNCTION operation.", pOperationAttribute));
} else {
currentOperation.setActivationPredicate(predicate);
}
break;
case RulesGrammar.PRECONDITION:
if (currentOperation instanceof FunctionOperation) {
FunctionOperation func = (FunctionOperation) currentOperation;
func.setPreconditionPredicate(predicate);
} else {
errorList.add(new CheckException("PRECONDITION clause is not allowed for a RULE or COMPUTATION operation", pOperationAttribute));
}
break;
case RulesGrammar.POSTCONDITION:
if (currentOperation instanceof RuleOperation) {
errorList.add(new CheckException("POSTCONDITION attribute is not allowed for a RULE operation", pOperationAttribute));
} else {
currentOperation.setPostcondition(predicate);
}
break;
default:
throw new AssertionError("Unexpected operation attribute: " + attrName);
}
predicate.apply(this);
}
use of de.be4.classicalb.core.parser.node.PPredicate in project probparsers by bendisposto.
the class BMachine method addPropertiesPredicates.
public void addPropertiesPredicates(Map<String, String> constantStringValues) {
if (constantStringValues.size() == 0) {
return;
}
APropertiesMachineClause clause = new APropertiesMachineClause();
this.parseUnit.getMachineClauses().add(clause);
List<PPredicate> predList = new ArrayList<>();
for (Entry<String, String> entry : constantStringValues.entrySet()) {
AIdentifierExpression identifier = createIdentifier(entry.getKey());
AStringExpression value = new AStringExpression(new TStringLiteral(entry.getValue()));
AEqualPredicate equal = new AEqualPredicate(identifier, value);
predList.add(equal);
}
clause.setPredicates(createConjunction(predList));
}
use of de.be4.classicalb.core.parser.node.PPredicate in project probparsers by bendisposto.
the class SyntaxExtensionTranslator method outAIfPredicatePredicate.
@Override
public void outAIfPredicatePredicate(AIfPredicatePredicate node) {
// IF P THE P2 ELSE P3 END
// will be translated into
// (p => p2) & (not(p) => p3)
AImplicationPredicate imp1 = new AImplicationPredicate((PPredicate) cloneNode(node.getCondition()), (PPredicate) cloneNode(node.getThen()));
AImplicationPredicate imp2 = new AImplicationPredicate(new ANegationPredicate((PPredicate) cloneNode(node.getCondition())), (PPredicate) cloneNode(node.getElse()));
AConjunctPredicate con = new AConjunctPredicate(imp1, imp2);
con.setStartPos(node.getStartPos());
con.setEndPos(node.getEndPos());
node.replaceBy(con);
}
use of de.be4.classicalb.core.parser.node.PPredicate in project prob2 by bendisposto.
the class ContextTranslator method processAxiomsAndTheorems.
private List<PContextClause> processAxiomsAndTheorems() {
List<PContextClause> axiomsAndThms = new ArrayList<>();
List<PPredicate> axioms = new ArrayList<>();
List<PPredicate> thms = new ArrayList<>();
for (EventBAxiom axiom : context.getAxioms()) {
PPredicate ppred = (PPredicate) ((EventB) axiom.getPredicate()).getAst();
nodeInfos.put(ppred, new Tuple2<>(context.getName(), axiom.getName()));
if (axiom.isTheorem()) {
thms.add(ppred);
} else {
axioms.add(ppred);
}
}
axiomsAndThms.add(new AAxiomsContextClause(axioms));
axiomsAndThms.add(new ATheoremsContextClause(thms));
return axiomsAndThms;
}
Aggregations