use of de.be4.classicalb.core.parser.node.TKwPredicateOperator in project probparsers by bendisposto.
the class RulesGrammar method createNewToken.
@Override
public Token createNewToken(Token token) {
Class<? extends Token> clazz = map.get(token.getText());
try {
// default constructor
Token newToken = clazz.newInstance();
newToken.setLine(token.getLine());
newToken.setPos(token.getPos());
return newToken;
} catch (InstantiationException e) {
// if the class has not default constructor we call the
// construct with a text string as the single argument
// e.g. TKwPredicateOperator(token.getText)
Class<?>[] cArg = new Class<?>[] { String.class };
try {
Token newInstance = clazz.getDeclaredConstructor(cArg).newInstance(token.getText());
newInstance.setLine(token.getLine());
newInstance.setPos(token.getPos());
return newInstance;
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e1) {
throw new AssertionError(INSTANTIATION_ERROR_MESSAGE + clazz.getName(), e1);
}
} catch (IllegalAccessException e) {
throw new AssertionError(INSTANTIATION_ERROR_MESSAGE + clazz.getName(), e);
}
}
use of de.be4.classicalb.core.parser.node.TKwPredicateOperator 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