use of de.be4.classicalb.core.parser.node.AMachineHeader in project probparsers by bendisposto.
the class MachineContext method caseAMachineHeader.
@Override
public void caseAMachineHeader(AMachineHeader node) {
this.header = node;
if (machineName == null) {
List<TIdentifierLiteral> nameList = new ArrayList<TIdentifierLiteral>(node.getName());
this.machineName = Utils.getTIdentifierListAsString(nameList);
}
List<PExpression> copy = new ArrayList<PExpression>(node.getParameters());
for (PExpression e : copy) {
AIdentifierExpression p = (AIdentifierExpression) e;
String name = Utils.getTIdentifierListAsString(p.getIdentifier());
exist(p.getIdentifier());
if (Character.isUpperCase(name.charAt(0))) {
this.machineSetParameter.put(name, p);
} else {
this.machineScalarParameter.put(name, p);
}
}
}
use of de.be4.classicalb.core.parser.node.AMachineHeader in project probparsers by bendisposto.
the class CreateFreetypeTest method createMachine.
private Start createMachine(String name) {
final AFreetypesMachineClause freetypes = createFreetype();
final AConstantsMachineClause variables = new AConstantsMachineClause(createIdentifiers(VAR_NAME));
final AMemberPredicate member = new AMemberPredicate(createIdentifier(VAR_NAME), new APowSubsetExpression(createIdentifier(FREETYPE_NAME)));
final AInvariantMachineClause inv = new AInvariantMachineClause(member);
final AInitialisationMachineClause init = new AInitialisationMachineClause(createAssignment(VAR_NAME, new AEmptySetExpression()));
final AOperationsMachineClause operations = createOperations();
final AMachineHeader header = new AMachineHeader(createIdLits(name), EMPTY_EXPRS);
final AAbstractMachineParseUnit machine = new AAbstractMachineParseUnit(new AMachineMachineVariant(), header, Arrays.asList(freetypes, variables, inv, init, operations));
return new Start(machine, new EOF());
}
use of de.be4.classicalb.core.parser.node.AMachineHeader in project probparsers by bendisposto.
the class RulesMachineChecker method caseAMachineHeader.
@Override
public void caseAMachineHeader(AMachineHeader node) {
if (!node.getParameters().isEmpty()) {
errorList.add(new CheckException("A RULES_MACHINE must not have any machine parameters", node));
}
LinkedList<TIdentifierLiteral> nameList = node.getName();
if (nameList.size() > 1) {
errorList.add(new CheckException("Renaming of a RULES_MACHINE name is not allowed.", node));
}
this.nameLiteral = nameList.get(0);
this.machineName = nameLiteral.getText();
}
use of de.be4.classicalb.core.parser.node.AMachineHeader in project probparsers by bendisposto.
the class StructuralTest method testEmptyMachine.
@Test
public void testEmptyMachine() throws Exception {
final String testMachine = "MACHINE SimplyStructure END";
// System.out.println("Parsing: \"" + testMachine + "\":");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, true);
final AAbstractMachineParseUnit machine = (AAbstractMachineParseUnit) startNode.getPParseUnit();
final AMachineHeader header = (AMachineHeader) machine.getHeader();
assertEquals("Machine name not as expected", "SimplyStructure", header.getName().get(0).getText());
assertNotNull("Machine header parameter list is null", header.getParameters());
assertTrue("More machine header parameters than expected", header.getParameters().size() == 0);
final LinkedList<PMachineClause> machineClauses = machine.getMachineClauses();
assertNotNull("Machine clause list is null", machineClauses);
assertTrue("More machine clauses than expected", machineClauses.size() == 0);
}
use of de.be4.classicalb.core.parser.node.AMachineHeader in project probparsers by bendisposto.
the class ReferencedMachines method caseAMachineHeader.
@Override
public void caseAMachineHeader(AMachineHeader node) {
machineName = Utils.getTIdentifierListAsString(node.getName());
final String fileNameWithoutExtension = Utils.getFileWithoutExtension(mainFile.getName());
if (isMachineNameMustMatchFileName && !machineName.equals(fileNameWithoutExtension)) {
CheckException ch = new CheckException(String.format("Machine name does not match the file name: '%s' vs '%s'", machineName, fileNameWithoutExtension), node);
throw new VisitorException(ch);
}
}
Aggregations