use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.
the class DefinitionFilesTest method testOneDefinitionFile.
@Test
public void testOneDefinitionFile() throws BCompoundException {
final String testMachine = "MACHINE Test\nDEFINITIONS \"DefFile\"; def1 == xx\nINVARIANT def2 = def3\nEND";
final BParser parser = new BParser("testcase");
parser.parse(testMachine, true, this);
final IDefinitions definitions = parser.getDefinitions();
final AExpressionDefinitionDefinition def1 = (AExpressionDefinitionDefinition) definitions.getDefinition("def1");
assertEquals("def1", def1.getName().getText());
assertEquals(0, def1.getParameters().size());
assertTrue(def1.getRhs() instanceof AIdentifierExpression);
final AExpressionDefinitionDefinition def2 = (AExpressionDefinitionDefinition) definitions.getDefinition("def2");
assertEquals("def2", def2.getName().getText());
assertEquals(0, def2.getParameters().size());
assertTrue(def2.getRhs() instanceof AIdentifierExpression);
}
use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.
the class DefinitionsOrderTest method testLinearOrder.
@Test
public void testLinearOrder() throws IOException, BCompoundException {
machine = new File(PATH + "DefinitionsOccurInLinearOrder.mch");
final BParser parser = new BParser(machine.getName());
Start start = parser.parseFile(machine, false);
assertNotNull(start);
}
use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.
the class StructuralTest method testClause1.
@Test
public void testClause1() 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);
assertNotNull(startNode);
// TODO more tests
}
use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.
the class StructuralTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
// System.out.println("Parsing: \"" + testMachine + "\":");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println();
return string;
}
use of de.be4.classicalb.core.parser.BParser 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);
}
Aggregations