use of de.be4.classicalb.core.parser.node.AIntegerExpression 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.AIntegerExpression 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());
}
use of de.be4.classicalb.core.parser.node.AIntegerExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkSucceededRuleErrorTypeOperator.
private void checkSucceededRuleErrorTypeOperator(AOperatorPredicate node, final List<PExpression> arguments) {
if (arguments.size() != 2) {
this.errorList.add(new CheckException("The SUCCEEDED_RULE_ERROR_TYPE predicate operator expects exactly two arguments.", node));
return;
}
PExpression pExpression = node.getIdentifiers().get(0);
if (!(pExpression instanceof AIdentifierExpression)) {
this.errorList.add(new CheckException("The first argument of SUCCEEDED_RULE_ERROR_TYPE must be an identifier.", node));
return;
}
PExpression secondArg = node.getIdentifiers().get(1);
if (!(secondArg instanceof AIntegerExpression)) {
this.errorList.add(new CheckException("The second argument of SUCCEEDED_RULE_ERROR_TYPE must be an integer value.", node));
return;
}
this.referencedRuleOperations.add((AIdentifierExpression) arguments.get(0));
return;
}
Aggregations