Search in sources :

Example 96 with Start

use of de.be4.classicalb.core.preparser.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;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Example 97 with Start

use of de.be4.classicalb.core.preparser.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);
}
Also used : AMachineHeader(de.be4.classicalb.core.parser.node.AMachineHeader) Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String) AAbstractMachineParseUnit(de.be4.classicalb.core.parser.node.AAbstractMachineParseUnit) PMachineClause(de.be4.classicalb.core.parser.node.PMachineClause) Test(org.junit.Test)

Example 98 with Start

use of de.be4.classicalb.core.preparser.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
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String) Test(org.junit.Test)

Example 99 with Start

use of de.be4.classicalb.core.preparser.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
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String) Test(org.junit.Test)

Example 100 with Start

use of de.be4.classicalb.core.preparser.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;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)104 Test (org.junit.Test)84 BParser (de.be4.classicalb.core.parser.BParser)43 Ast2String (util.Ast2String)32 File (java.io.File)20 Start (de.be4.eventbalg.core.parser.node.Start)19 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)18 Start (de.be4.eventb.core.parser.node.Start)18 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)14 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)14 IOException (java.io.IOException)12 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)11 PushbackReader (java.io.PushbackReader)11 StringReader (java.io.StringReader)11 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)8 AExpressionParseUnit (de.be4.classicalb.core.parser.node.AExpressionParseUnit)7 AbstractParseMachineTest (util.AbstractParseMachineTest)7 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)6 ClassicalPositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter)6 ASTPrinter (de.be4.classicalb.core.parser.visualisation.ASTPrinter)6