use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class StructureTest method testIdentifierTick.
@Test
public void testIdentifierTick() throws Exception {
final Start root = parseInput("machine Mac variables x' y end", false);
final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
final LinkedList<PVariable> variables = parseUnit.getVariables();
assertEquals(2, variables.size());
assertEquals("x'", ((AVariable) variables.get(0)).getName().getText());
assertEquals("y", ((AVariable) variables.get(1)).getName().getText());
}
use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class StructureTest method testWitnessTick.
@Test
public void testWitnessTick() throws Exception {
final Start root = parseInput("machine WitnessTick\nevents\nevent Eve\nwith\n@x' x' :: NAT\nend\nend", false);
final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
final LinkedList<PEvent> events = parseUnit.getEvents();
assertEquals(1, events.size());
final AEvent event = (AEvent) events.get(0);
final LinkedList<PWitness> witnesses = event.getWitnesses();
assertEquals(1, witnesses.size());
assertEquals("x'", ((AWitness) witnesses.get(0)).getName().getText());
}
use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class LexerTest method testStringVariant.
@Test
public void testStringVariant() throws BException {
final Start rootNode = parseInput("machine Test\nvariant y-x\nend", false);
final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
final AVariant variantClause = (AVariant) parseUnit.getVariant();
assertEquals("y-x", variantClause.getExpression().getText());
}
use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.
the class SourcePositionsTest method testGetEndLine.
@Test
public void testGetEndLine() throws Exception {
final Start root = parser.parse("machine\nTestMachine\n\nvariables\nx\n\nend", false);
final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
assertEquals(7, ((PositionedNode) parseUnit).getEndPos().getLine());
final LinkedList<PVariable> variables = parseUnit.getVariables();
assertEquals(5, ((PositionedNode) variables.get(0)).getEndPos().getLine());
}
use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project prob2 by bendisposto.
the class ComponentExtractor method caseAMachineParseUnit.
@Override
public void caseAMachineParseUnit(final AMachineParseUnit node) {
String name = node.getName().getText();
MachineModifier machineM = new MachineModifier(new EventBMachine(name), typeEnv);
ModelElementList<Context> seen = new ModelElementList<>();
for (TIdentifierLiteral contextName : node.getSeenNames()) {
String cName = contextName.getText();
AbstractElement context = getContext(cName);
seen = seen.addElement((Context) context);
}
machineM = machineM.setSees(seen);
if (node.getRefinesNames().size() == 1) {
String mname = node.getRefinesNames().getFirst().getText();
EventBMachine machine = getMachine(mname);
machineM = machineM.setRefines(machine);
} else if (node.getRefinesNames().size() > 1) {
throw new IllegalArgumentException("Machines can only refine one abstract machine. Found " + node.getRefinesNames().size() + " refined machines");
}
machineM = machineM.addComment(getComment(node.getComments()));
MachineExtractor mE = new MachineExtractor(machineM, typeEnv);
node.apply(mE);
modelM = modelM.addMachine(mE.getMachine());
}
Aggregations