use of de.be4.classicalb.core.parser.node.AAssignSubstitution in project probparsers by bendisposto.
the class ASTPrologTest method testEvent.
@Test
public void testEvent() throws BCompoundException {
final AEventBModelParseUnit model = new AEventBModelParseUnit();
model.setName(new TIdentifierLiteral("mm"));
final AEventsModelClause events = new AEventsModelClause();
model.setModelClauses(Arrays.asList((PModelClause) events));
AEvent event = new AEvent();
events.setEvent(Arrays.asList((PEvent) event));
event.setEventName(new TIdentifierLiteral("testevent"));
event.setVariables(Arrays.asList(createId("param")));
event.setGuards(Arrays.asList((PPredicate) new ATruthPredicate()));
PSubstitution subst1 = new AAssignSubstitution(Arrays.asList(createId("x")), Arrays.asList(createId("param")));
event.setAssignments(Arrays.asList(subst1));
PWitness witness = new AWitness(new TIdentifierLiteral("ab"), new AEqualPredicate(createId("ab"), createId("y")));
event.setWitness(Arrays.asList(witness));
event.setRefines(Arrays.asList(new TIdentifierLiteral("abstract1"), new TIdentifierLiteral("abstract2")));
checkAST(0, "event_b_model($,mm,[events($,[" + "event($,testevent,[abstract1,abstract2],[identifier($,param)],[truth($)],[]," + "[assign($,[identifier($,x)],[identifier($,param)])]," + "[witness($,identifier(%,ab),equal($,identifier($,ab),identifier($,y)))])])])", model);
}
use of de.be4.classicalb.core.parser.node.AAssignSubstitution in project probparsers by bendisposto.
the class RulesMachineChecker method inAAssignSubstitution.
@Override
public void inAAssignSubstitution(AAssignSubstitution node) {
ArrayList<PExpression> righthand = new ArrayList<>(node.getRhsExpressions());
for (PExpression pExpression : righthand) {
pExpression.apply(this);
}
List<PExpression> copy = new ArrayList<>(node.getLhsExpression());
checkThatIdentifiersAreLocalVariables(copy);
}
use of de.be4.classicalb.core.parser.node.AAssignSubstitution in project probparsers by bendisposto.
the class IdentListCheck method runChecks.
/**
* <p>
* See class description. First {@link AAssignSubstitution} nodes are
* checked, then the other nodes.
* </p>
* <p>
* An {@link CheckException} is thrown if there are
* {@link AAssignSubstitution} or {@link AOperationCallSubstitution} nodes
* with illegal elements in the LHS. Otherwise the other relevant nodes are
* checked for illegal entries in their identifier lists.
* </p>
* <p>
* In both cases the erroneous nodes are collected, so that only one
* exception is thrown for the {@link AAssignSubstitution} and
* {@link AOperationCallSubstitution} nodes respectively one for all other
* nodes.
* </p>
*
* @param rootNode
* the start node of the AST
*/
public void runChecks(final Start rootNode) {
nonIdentifiers.clear();
/*
* First check all assignment nodes if the LHS only contains identifiers
* or functions.
*/
final AssignCheck assignCheck = new AssignCheck();
rootNode.apply(assignCheck);
final Set<Node> assignErrorNodes = assignCheck.nonIdentifiers;
if (!assignErrorNodes.isEmpty()) {
exceptions.add(new CheckException("Identifier or function expected", assignErrorNodes.toArray(new Node[assignErrorNodes.size()])));
}
/*
* Then check other constructs which can only contain identifiers at
* special places.
*/
rootNode.apply(this);
if (!nonIdentifiers.isEmpty()) {
// at least one error was found
exceptions.add(new CheckException("Identifier expected", nonIdentifiers.toArray(new Node[nonIdentifiers.size()])));
}
}
Aggregations