Search in sources :

Example 1 with TIntegerLiteral

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

the class ASTPrologTest method testPartition.

@Test
public void testPartition() {
    final PExpression set = createId("set");
    final PExpression one = new AIntegerExpression(new TIntegerLiteral("1"));
    final PExpression two = new AIntegerExpression(new TIntegerLiteral("2"));
    final PExpression three = new AIntegerExpression(new TIntegerLiteral("3"));
    final APartitionPredicate pred = new APartitionPredicate(set, Arrays.asList(one, two, three));
    final String expected = "partition($,identifier($,set),[integer($,1),integer($,2),integer($,3)])";
    checkAST(0, expected, pred);
}
Also used : AIntegerExpression(de.be4.classicalb.core.parser.node.AIntegerExpression) APartitionPredicate(de.be4.classicalb.core.parser.node.APartitionPredicate) TIntegerLiteral(de.be4.classicalb.core.parser.node.TIntegerLiteral) PExpression(de.be4.classicalb.core.parser.node.PExpression) Test(org.junit.Test)

Example 2 with TIntegerLiteral

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

the class SourcePositionsTest method testTokenAsPositionedNode.

@Test
public void testTokenAsPositionedNode() throws Exception {
    final String testMachine = "#EXPRESSION xx + 5";
    final Start result = getAst(testMachine);
    final AExpressionParseUnit exprParseUnit = (AExpressionParseUnit) result.getPParseUnit();
    final AAddExpression addExpression = (AAddExpression) exprParseUnit.getExpression();
    final AIntegerExpression intExpression = (AIntegerExpression) addExpression.getRight();
    assertTrue(intExpression instanceof PositionedNode);
    final PositionedNode intNode = (PositionedNode) intExpression;
    assertNotNull(intNode.getStartPos());
    assertNotNull(intNode.getEndPos());
    final TIntegerLiteral intLiteral = intExpression.getLiteral();
    assertTrue(intLiteral instanceof PositionedNode);
    final PositionedNode posNode = (PositionedNode) intLiteral;
    assertNotNull(posNode.getStartPos());
    assertNotNull(posNode.getEndPos());
}
Also used : AExpressionParseUnit(de.be4.classicalb.core.parser.node.AExpressionParseUnit) AIntegerExpression(de.be4.classicalb.core.parser.node.AIntegerExpression) AAddExpression(de.be4.classicalb.core.parser.node.AAddExpression) Start(de.be4.classicalb.core.parser.node.Start) PositionedNode(de.hhu.stups.sablecc.patch.PositionedNode) TIntegerLiteral(de.be4.classicalb.core.parser.node.TIntegerLiteral) Test(org.junit.Test)

Aggregations

AIntegerExpression (de.be4.classicalb.core.parser.node.AIntegerExpression)2 TIntegerLiteral (de.be4.classicalb.core.parser.node.TIntegerLiteral)2 Test (org.junit.Test)2 AAddExpression (de.be4.classicalb.core.parser.node.AAddExpression)1 AExpressionParseUnit (de.be4.classicalb.core.parser.node.AExpressionParseUnit)1 APartitionPredicate (de.be4.classicalb.core.parser.node.APartitionPredicate)1 PExpression (de.be4.classicalb.core.parser.node.PExpression)1 Start (de.be4.classicalb.core.parser.node.Start)1 PositionedNode (de.hhu.stups.sablecc.patch.PositionedNode)1