use of de.be4.classicalb.core.parser.node.Start 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.node.Start 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.Start in project probparsers by bendisposto.
the class StructuralTest method testVariablesClause.
@Test
public void testVariablesClause() throws Exception {
final String testMachine = "MACHINE SimplyStructure\nVARIABLES aa, b, Cc\nINVARIANT aa : NAT & b : NAT & Cc : NAT\nINITIALISATION aa:=1 || b:=2 || c:=3\nEND";
// 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.node.Start in project probparsers by bendisposto.
the class StructuralTest method testSetsClause.
@Test
public void testSetsClause() throws Exception {
final String testMachine = "MACHINE SimplyStructure SETS GGG; Hhh; JJ = {dada, dudu, TUTUT}; iII; kkk = {LLL} 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.node.Start in project probparsers by bendisposto.
the class SyntaxErrorsDetectedOnTokenStreamTest 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;
}
Aggregations