Semantic actions
A semantic action defines additional processing on abstract tree nodes. For example, you can enable a node to perform semantic checking, or to declare variables and variable scope.
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.
During the process of building the syntax tree, some nodes might require additional processing, for example, to perform semantic checking or to declare variables and variable scope. You define this processing using semantic actions.
A semantic action is a Java™ object that can be attached to an element of the abstract syntax, with the property semanticAction. The value of this property is the name of a Java class that extends the abstract class IlrBRLSemanticAction. This class defines an abstract method apply, with the following signature:
public abstract void apply(IlrBRLSemanticContext context,
IlrSyntaxTree.Node node);
This method is called when a rule is parsed, every time an instance of the syntax tree node where the semantic action is attached is added to the syntax tree.
This method has the following arguments:
IlrBRLSemanticContext context: the semantic context used during the parsing of the text. This semantic context provides information relative to the current state of the parser. You can use it to add error or warning markers to perform semantic checking. See IlrBRLSemanticContext for details.
IlrSyntaxTree.Node node: the syntax node being processed. You use this method to retrieve information about the current state of the syntax tree at this state of the parsing. See IlrSyntaxTree for details.
You can declare the implementation of this method to nodes of the abstract grammar:
<type>.<name>.semanticAction = [class-name]
or
<type>.semanticAction = [classname]