Example of a custom node translator: New expression type
As an example of a custom node translator, you can implement a node translator for a new expression type.
Support for custom business rule
languages is deprecated in V8.8.1. This feature will be removed in
a future release of the product. See Deprecated features for migration
details.
Suppose you want to create a new kind of action for the instance of operator. In this case you create a subtype of <T-expression>.
You implement the node translator for a new expression type as follows:
/**
* The node translator for <T-kind-of> node type.
*/
public static class KindOfNodeTranslator implements IlrNodeTranslator {
public IlrStatement process(IlrSyntaxTree.Node node,
IlrTranslationContext context) {
// forward the processing to subnodes
return context.processNode(node.getSubNode(0));
}
}
In this code, the process method forwards the processing to the subnodes of the abstract syntax. This action is mandatory because if you do not process the subnodes, the creation of bindings for automatic variables might be skipped.
You then register this node translator in the concrete syntax as follows:
<T-kind-of>.translatorClass = balsample_extensions.brl.KindOfNodeTranslator