use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class RulesLanguageExceptionTest method testUnkownExpressionOperatorException.
@Test(expected = AssertionError.class)
public void testUnkownExpressionOperatorException() throws Exception {
AOperatorExpression operator = new AOperatorExpression(new TKwExpressionOperator("foo"), new ArrayList<PExpression>());
RulesMachineChecker rulesMachineVisitor = new RulesMachineChecker(null, null, null, null);
operator.apply(rulesMachineVisitor);
}
use of de.be4.classicalb.core.parser.node.PExpression in project prob2 by bendisposto.
the class ContextTranslator method processConstants.
private List<PContextClause> processConstants() {
List<PContextClause> constants = new ArrayList<>();
List<PExpression> concrete = new ArrayList<>();
List<PExpression> abstractC = new ArrayList<>();
for (EventBConstant eventBConstant : context.getConstants()) {
if (eventBConstant.isAbstract()) {
abstractC.add((PExpression) ((EventB) eventBConstant.getExpression()).getAst());
} else {
concrete.add((PExpression) ((EventB) eventBConstant.getExpression()).getAst());
}
}
constants.add(new AConstantsContextClause(concrete));
constants.add(new AAbstractConstantsContextClause(abstractC));
return constants;
}
use of de.be4.classicalb.core.parser.node.PExpression in project prob2 by bendisposto.
the class DomBuilder method createExpressionAST.
private Start createExpressionAST(final PExpression expression) {
Start start = new Start();
AExpressionParseUnit node = new AExpressionParseUnit();
start.setPParseUnit(node);
start.setEOF(EOF);
node.setExpression((PExpression) expression.clone());
node.getExpression().apply(new RenameIdentifiers());
return start;
}
use of de.be4.classicalb.core.parser.node.PExpression 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());
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class RulesLanguageExceptionTest method testUnkownPredicateOperatorException.
@Test(expected = AssertionError.class)
public void testUnkownPredicateOperatorException() throws Exception {
AOperatorPredicate operator = new AOperatorPredicate(new TKwPredicateOperator("foo"), new ArrayList<PExpression>());
RulesMachineChecker rulesMachineVisitor = new RulesMachineChecker(null, null, null, null);
operator.apply(rulesMachineVisitor);
}
Aggregations