Search in sources :

Example 91 with Start

use of de.be4.classicalb.core.parser.node.Start in project probparsers by bendisposto.

the class PositionAspectTest method testComposedNode.

@Test
public void testComposedNode() throws Exception {
    final String testMachine = "#EXPRESSION x+1";
    final BParser parser = new BParser("testcase");
    final Start startNode = parser.parse(testMachine, true);
    // test top node
    final PExpression expression = ((AExpressionParseUnit) startNode.getPParseUnit()).getExpression();
    SourcePosition startPos = expression.getStartPos();
    SourcePosition endPos = expression.getEndPos();
    assertNotNull(startNode);
    assertNotNull(endPos);
    assertEquals(1, startPos.getLine());
    assertEquals(13, startPos.getPos());
    assertEquals(1, endPos.getLine());
    assertEquals(16, endPos.getPos());
    // test left child: 13-14
    final PExpression leftExpr = ((AAddExpression) expression).getLeft();
    startPos = leftExpr.getStartPos();
    endPos = leftExpr.getEndPos();
    assertNotNull(startNode);
    assertNotNull(endPos);
    assertEquals(1, startPos.getLine());
    assertEquals(13, startPos.getPos());
    assertEquals(1, endPos.getLine());
    assertEquals(14, endPos.getPos());
    // test right child: 15-16
    final PExpression rightExpr = ((AAddExpression) expression).getRight();
    startPos = rightExpr.getStartPos();
    endPos = rightExpr.getEndPos();
    assertNotNull(startNode);
    assertNotNull(endPos);
    assertEquals(1, startPos.getLine());
    assertEquals(15, startPos.getPos());
    assertEquals(1, endPos.getLine());
    assertEquals(16, endPos.getPos());
}
Also used : AExpressionParseUnit(de.be4.classicalb.core.parser.node.AExpressionParseUnit) AAddExpression(de.be4.classicalb.core.parser.node.AAddExpression) Start(de.be4.classicalb.core.parser.node.Start) SourcePosition(de.hhu.stups.sablecc.patch.SourcePosition) BParser(de.be4.classicalb.core.parser.BParser) PExpression(de.be4.classicalb.core.parser.node.PExpression) Test(org.junit.Test)

Example 92 with Start

use of de.be4.classicalb.core.parser.node.Start in project probparsers by bendisposto.

the class PositionAspectTest method testNodeSubclassOfPositionedNode.

@Test
public void testNodeSubclassOfPositionedNode() throws Exception {
    final String testMachine = "#EXPRESSION 1+2";
    final BParser parser = new BParser("testcase");
    final Start startNode = parser.parse(testMachine, true);
    assertTrue(startNode instanceof PositionedNode);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) PositionedNode(de.hhu.stups.sablecc.patch.PositionedNode) Test(org.junit.Test)

Example 93 with Start

use of de.be4.classicalb.core.parser.node.Start in project probparsers by bendisposto.

the class ByteOrderMarkTests method testParsable.

@Test
public void testParsable() throws Exception {
    final BParser parser = new BParser(machine.getName());
    Start start = parser.parseFile(machine, false);
    start.apply(new PositionTester());
    assertNotNull(start);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) AbstractParseMachineTest(util.AbstractParseMachineTest) Test(org.junit.Test)

Example 94 with Start

use of de.be4.classicalb.core.parser.node.Start 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);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) File(java.io.File) Test(org.junit.Test)

Example 95 with Start

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

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