use of de.be4.classicalb.core.parser.node.AExpressionParseUnit 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());
}
use of de.be4.classicalb.core.parser.node.AExpressionParseUnit in project probparsers by bendisposto.
the class SourcePositionsTest method testComment1.
@Test
public void testComment1() throws Exception {
final String testMachine = "#EXPRESSION xx /* comment */ + 5";
final Start result = getAst(testMachine);
final AExpressionParseUnit exprParseUnit = (AExpressionParseUnit) result.getPParseUnit();
final AAddExpression addExpression = (AAddExpression) exprParseUnit.getExpression();
final AIntegerExpression intExpression = (AIntegerExpression) addExpression.getRight();
assertEquals(1, intExpression.getStartPos().getLine());
assertEquals(32, intExpression.getStartPos().getPos());
assertEquals(1, intExpression.getEndPos().getLine());
assertEquals(testMachine.length() + 1, intExpression.getEndPos().getPos());
}
Aggregations