use of de.be4.classicalb.core.parser.node.APredicateDefinitionDefinition in project probparsers by bendisposto.
the class MachineContext method caseADefinitionsMachineClause.
/**
* Definitions
*/
@Override
public void caseADefinitionsMachineClause(ADefinitionsMachineClause node) {
definitionMachineClause = node;
DefinitionsSorter.sortDefinitions(node);
List<PDefinition> copy = node.getDefinitions();
/*
* The definitions are not in a predefined order. In particular
* definitions can depend on each other. First all definitions are added
* to the definitions context table. Then all definitions are visited.
*/
Collection<PDefinition> definitionsToRemove = new HashSet<PDefinition>();
for (PDefinition e : copy) {
if (e instanceof AExpressionDefinitionDefinition) {
AExpressionDefinitionDefinition def = (AExpressionDefinitionDefinition) e;
String name = def.getName().getText();
if (name.startsWith("ASSERT_LTL")) {
LTLFormulaVisitor visitor = new LTLFormulaVisitor(name, this);
visitor.parseDefinition(def);
this.ltlVisitors.add(visitor);
definitionsToRemove.add(def);
} else if (name.startsWith("ANIMATION_")) {
definitionsToRemove.add(def);
}
evalDefinitionName(((AExpressionDefinitionDefinition) e).getName().getText().toString(), e);
} else if (e instanceof APredicateDefinitionDefinition) {
evalDefinitionName(((APredicateDefinitionDefinition) e).getName().getText().toString(), e);
} else if (e instanceof ASubstitutionDefinitionDefinition) {
evalDefinitionName(((ASubstitutionDefinitionDefinition) e).getName().getText().toString(), e);
}
}
/*
* At this point all LTL definitions (ASSERT_LTL) are removed. LTL
* formulas are stored in the Arraylist {@value #ltlVisitors}.
*/
copy.removeAll(definitionsToRemove);
this.contextTable = new ArrayList<LinkedHashMap<String, Node>>();
ArrayList<MachineContext> list = lookupReferencedMachines();
for (int i = 0; i < list.size(); i++) {
MachineContext s = list.get(i);
contextTable.add(s.getDeferredSets());
contextTable.add(s.getEnumeratedSets());
contextTable.add(s.getEnumValues());
contextTable.add(s.getConstants());
contextTable.add(s.getVariables());
contextTable.add(s.getDefinitions());
}
for (PDefinition e : copy) {
e.apply(this);
}
}
use of de.be4.classicalb.core.parser.node.APredicateDefinitionDefinition in project probparsers by bendisposto.
the class DefinitionFilesTest method testRealFiles.
/*
* test with real files
*/
@Test
public void testRealFiles() throws Exception {
final BParser parser = new BParser("testcase");
File machine = new File("src/test/resources/parsable/DefinitionFileTest.mch");
parser.parseFile(machine, false);
final IDefinitions definitions = parser.getDefinitions();
final APredicateDefinitionDefinition def1 = (APredicateDefinitionDefinition) definitions.getDefinition("GRD2");
assertEquals("GRD2", def1.getName().getText());
assertEquals(0, def1.getParameters().size());
assertTrue(def1.getRhs() instanceof PPredicate);
final APredicateDefinitionDefinition def2 = (APredicateDefinitionDefinition) definitions.getDefinition("GRD1");
assertEquals("GRD1", def2.getName().getText());
assertEquals(0, def2.getParameters().size());
assertTrue(def2.getRhs() instanceof PPredicate);
}
use of de.be4.classicalb.core.parser.node.APredicateDefinitionDefinition in project probparsers by bendisposto.
the class DefinitionCollector method inAPredicateDefinitionDefinition.
@Override
public void inAPredicateDefinitionDefinition(final APredicateDefinitionDefinition node) {
final String defName = node.getName().getText();
final Type type = defTypes.getType(defName);
addDefinition(node, type, defName);
}
Aggregations