public class IlrSyntaxTreeHelper
extends java.lang.Object
| Constructor and Description |
|---|
IlrSyntaxTreeHelper() |
| Modifier and Type | Method and Description |
|---|---|
static IlrSentence |
findEnclosingSentence(IlrSyntaxTree.Node node)
This method looks-up from the given node to find the first enclosing sentence
ignoring operators.
|
static IlrSyntaxTree.Node |
findRoleNode(IlrSyntaxTree.Node sentenceNode,
int synRoleIndex)
This method returns the syntactic node corresponding to the roleIndex in the sentence node.
|
static IlrSyntaxTree.Node |
findSubNode(IlrSyntaxTree.Node node,
java.lang.String path) |
static IlrVocabularyElement |
findVocabularyElement(IlrSyntaxTree.Node node,
IlrVocabulary vocabulary)
This helper method provides a look-up for a vocabulary element from the given syntax node.
|
static IlrSyntaxTree.Node |
getAndNode(IlrSyntaxTree.Node node,
int direction)
This method returns the 1st And node found in the given syntax tree starting from the given node
following the given direction (specified using IlrSyntaxTree.UP or IlrSyntaxTree.DOWN
|
static IlrConcept |
getConcept(IlrSyntaxTree.Node conceptNode,
IlrVocabulary voc)
Retrieves a concept from a target node.
|
static IlrConceptInstance |
getConceptInstance(IlrSyntaxTree.Node valueNode,
IlrVocabulary voc)
Retrieves a concept instance from a
T-voc-value Abstract Syntax Tree node. |
static java.lang.Object |
getConstrainedRoleValue(IlrSyntaxTree.Node node)
This method returns the value attached to the syntax tree corresponding to a role that is constrained
by a constraint relationship exising on the role given as argument.
|
static java.lang.String |
getNodePath(IlrSyntaxTree.Node node) |
static IlrSyntaxTree.Node |
getOrNode(IlrSyntaxTree.Node node,
int direction)
This method returns the 1st Or node found in the given syntax tree starting from the given node
following the given direction (specified using IlrSyntaxTree.UP or IlrSyntaxTree.DOWN
|
static int |
getRoleIndex(IlrSyntaxTree.Node roleNode)
This method, applied on a syntax node representing a role in a sentence, returns the index of the role in
the sentence.
|
static IlrSyntaxTree.Node |
getRoleNode(IlrSyntaxTree.Node roleNode)
This method retrieves a look-up in the syntax tree for a role node.
|
static IlrSentence |
getSentence(IlrSyntaxTree.Node sentenceNode,
IlrVocabulary voc)
Retrieves a sentence from a
sentence node. |
static java.util.List |
getTemplateInfo(IlrSyntaxTree tree)
This method retrieves the template information stored on the syntax tree.
|
static IlrTypeInfo |
getTypeInfo(IlrSyntaxTree.Node conceptNode,
IlrVocabulary voc)
Gets the type information from this node.
|
static java.util.Collection<IlrVocabularyElement> |
getVocabularyElements(IlrSyntaxTree syntaxTree,
java.util.Collection<IlrBRLMarker> errors)
Adds all the vocabulary elements referenced by a syntax tree to a Collection.
|
static boolean |
hasErrorRecovery(IlrSyntaxTree.Node node)
This method returns true if the given node is in error recovery
|
static boolean |
hasErrorRecovery(IlrSyntaxTree ast) |
static boolean |
hasPlaceHolders(IlrSyntaxTree.Node node)
This method returns
true if the node or one of its children has a placeholder. |
static boolean |
isEmpty(IlrSyntaxTree tree)
Tests if the syntax tree is empty.
|
static boolean |
isExternalVariable(IlrSyntaxTree.Node variableNode)
Tests if the variable node is a ruleset variable or parameter.
|
static boolean |
isRulesetParameter(IlrSyntaxTree.Node variableNode)
Tests if the variable node is a ruleset parameter.
|
static boolean |
isRulesetVariable(IlrSyntaxTree.Node variableNode)
Tests if the variable node is a ruleset variable.
|
static boolean |
isRuleVariable(IlrSyntaxTree.Node node)
Tests if a node is the automatic variable "the rule" used in the Select
ruleflow.
|
static java.util.List |
setTemplateInfo(java.util.List templateInfo,
IlrSyntaxTree tree)
This method applies the template information on the syntax tree.
|
public static IlrVocabularyElement findVocabularyElement(IlrSyntaxTree.Node node, IlrVocabulary vocabulary)
node - The syntax tree node from which look-up starts.vocabulary - The vocabulary that should contain the vocabulary element found, if any.null if none is found.public static IlrSentence getSentence(IlrSyntaxTree.Node sentenceNode, IlrVocabulary voc)
sentence node.sentenceNode - The node of type T-voc-sentence.voc - The vocabulary.null.IlrTranslationHelper.isSentenceNode(IlrSyntaxTree.Node)public static IlrConcept getConcept(IlrSyntaxTree.Node conceptNode, IlrVocabulary voc)
conceptNode - The Abstract Syntax Tree node.voc - The vocabulary.null.public static IlrTypeInfo getTypeInfo(IlrSyntaxTree.Node conceptNode, IlrVocabulary voc)
conceptNode - The node of type T-voc-concept.voc - The vocabulary.IlrTypeInfo corresponding to this concept node.public static IlrConceptInstance getConceptInstance(IlrSyntaxTree.Node valueNode, IlrVocabulary voc)
T-voc-value Abstract Syntax Tree node.valueNode - The node of type T-voc-value.voc - The vocabulary.null.public static IlrSyntaxTree.Node findRoleNode(IlrSyntaxTree.Node sentenceNode, int synRoleIndex)
sentenceNode - The sentence node, holding role nodes.synRoleIndex - The index of the looked-up role node (syntactic role).null if none is found.public static IlrSyntaxTree.Node getRoleNode(IlrSyntaxTree.Node roleNode)
roleNode - The node from which the look-up starts.null if none is found.public static int getRoleIndex(IlrSyntaxTree.Node roleNode)
roleNode - public static java.lang.Object getConstrainedRoleValue(IlrSyntaxTree.Node node)
node - The syntax tree node corresponding to a role of a sentence. This role is assumed to be constrained
by having declared a constraint using the property constraint=xx, where xx is the parameter index of
the target role.public static boolean hasErrorRecovery(IlrSyntaxTree ast)
true if the syntax tree as at least one syntax node in error recovery, otherwise return false.public static boolean hasErrorRecovery(IlrSyntaxTree.Node node)
node - the syntax node, must not be nullpublic static boolean isEmpty(IlrSyntaxTree tree)
true is returned.public static java.util.List getTemplateInfo(IlrSyntaxTree tree)
tree - The syntax tree from which to retrieve the template information.IlrBRLTemplateInfo, or null if no template information is stored on the syntax tree.public static java.util.List setTemplateInfo(java.util.List templateInfo,
IlrSyntaxTree tree)
templateInfo - A list of BRLTemplateInfo describing the template information.tree - The syntax tree on which to apply the template information.null if all has been applied.public static boolean hasPlaceHolders(IlrSyntaxTree.Node node)
true if the node or one of its children has a placeholder.
Placeholder information is stored on each incomplete syntax node. For example, a value node
that has not yet been filled.node - the root syntax nodetrue if at least one node in the tree, starting at the node passed to the
method, has a placeholder.IlrSyntaxTree.hasPlaceHolders()public static IlrSyntaxTree.Node getAndNode(IlrSyntaxTree.Node node, int direction)
node - direction - public static IlrSyntaxTree.Node getOrNode(IlrSyntaxTree.Node node, int direction)
node - direction - public static IlrSentence findEnclosingSentence(IlrSyntaxTree.Node node)
node - public static boolean isRulesetParameter(IlrSyntaxTree.Node variableNode)
variableNode - The node of type T-voc-variable.true if the variable node is a parameter.public static boolean isRulesetVariable(IlrSyntaxTree.Node variableNode)
variableNode - The node of type T-voc-variable.true if the variable node is a ruleset variable.public static boolean isExternalVariable(IlrSyntaxTree.Node variableNode)
variableNode - The node of type T-voc-variable.true if the variable node is a ruleset variable or parameter.public static boolean isRuleVariable(IlrSyntaxTree.Node node)
node - The node to check.node is the automatic variable, true is returned.public static java.util.Collection<IlrVocabularyElement> getVocabularyElements(IlrSyntaxTree syntaxTree, java.util.Collection<IlrBRLMarker> errors)
syntaxTree parameter should not be in error recovery.
If it is, the information returned by this method is not correct.
Nodes with errors in syntaxTree are not taken into account.syntaxTree - A non-null syntax tree to explore.errors - A collection of errors generated by the parser that
created this syntax tree. This collection may be null.IlrVocabularyElement objects
referenced in this syntax tree.public static java.lang.String getNodePath(IlrSyntaxTree.Node node)
public static IlrSyntaxTree.Node findSubNode(IlrSyntaxTree.Node node, java.lang.String path)
© Copyright IBM Corp. 1987, 2017