Package ca.phon.phontalk.parser
Class AntlrUtils
java.lang.Object
ca.phon.phontalk.parser.AntlrUtils
Utility methods for working with antlr3
CommonTree
s.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addTextNode
(org.antlr.runtime.tree.CommonTree parent, AntlrTokens tokens, String data) add a text nodestatic org.antlr.runtime.tree.CommonTree
createToken
(int tokenType) static org.antlr.runtime.tree.CommonTree
createToken
(AntlrTokens tokens, String tokenName) Create a new common tree node with the given token type.static List<org.antlr.runtime.tree.CommonTree>
findAllChildrenWithType
(org.antlr.runtime.tree.CommonTree tree, int type) Find all children and sub-children with the given type.static List<org.antlr.runtime.tree.CommonTree>
findAllChildrenWithType
(org.antlr.runtime.tree.CommonTree tree, AntlrTokens tokens, String typeName) Find all children and sub-children with the given type.static List<org.antlr.runtime.tree.CommonTree>
findAllChildrenWithType
(org.antlr.runtime.tree.CommonTree tree, AntlrTokens tokens, String... typeNames) Find all children and sub-children with the given type.static List<org.antlr.runtime.tree.CommonTree>
findChildrenWithType
(org.antlr.runtime.tree.CommonTree tree, int type) Find all children with the given type in the provided tree.static List<org.antlr.runtime.tree.CommonTree>
findChildrenWithType
(org.antlr.runtime.tree.CommonTree tree, AntlrTokens tokens, String typeName) Find all children with the given type in the provided tree.static void
printTree
(AntlrTokens chatTokens, org.antlr.runtime.tree.CommonTree tree, int indent, PrintStream stream) static void
printTree
(org.antlr.runtime.tree.CommonTree tree) static void
printTree
(org.antlr.runtime.tree.CommonTree tree, OutputStream out)
-
Constructor Details
-
AntlrUtils
public AntlrUtils()
-
-
Method Details
-
createToken
Create a new common tree node with the given token type. -
createToken
public static org.antlr.runtime.tree.CommonTree createToken(int tokenType) -
printTree
public static void printTree(org.antlr.runtime.tree.CommonTree tree) -
printTree
-
printTree
public static void printTree(AntlrTokens chatTokens, org.antlr.runtime.tree.CommonTree tree, int indent, PrintStream stream) -
addTextNode
public static void addTextNode(org.antlr.runtime.tree.CommonTree parent, AntlrTokens tokens, String data) add a text node -
findChildrenWithType
public static List<org.antlr.runtime.tree.CommonTree> findChildrenWithType(org.antlr.runtime.tree.CommonTree tree, int type) Find all children with the given type in the provided tree. Will only check 1st level children (i.e., this method is not recursive.)- Parameters:
tree
-type
-- Returns:
- all children found with the given token type
-
findChildrenWithType
public static List<org.antlr.runtime.tree.CommonTree> findChildrenWithType(org.antlr.runtime.tree.CommonTree tree, AntlrTokens tokens, String typeName) Find all children with the given type in the provided tree. Will only check 1st level children (i.e., this method is not recursive.)- Parameters:
tree
-tokens
-typeName
-- Returns:
- all children found with the given token type
-
findAllChildrenWithType
public static List<org.antlr.runtime.tree.CommonTree> findAllChildrenWithType(org.antlr.runtime.tree.CommonTree tree, int type) Find all children and sub-children with the given type. This method will recursivly search the children of the given tree.- Parameters:
tree
-type
-- Returns:
- the list of children found with the given type
-
findAllChildrenWithType
public static List<org.antlr.runtime.tree.CommonTree> findAllChildrenWithType(org.antlr.runtime.tree.CommonTree tree, AntlrTokens tokens, String typeName) Find all children and sub-children with the given type. This method will recursively search the children of the given tree.- Parameters:
tree
-tokens
-typeName
-- Returns:
- the list of children found with the given type
-
findAllChildrenWithType
public static List<org.antlr.runtime.tree.CommonTree> findAllChildrenWithType(org.antlr.runtime.tree.CommonTree tree, AntlrTokens tokens, String... typeNames) Find all children and sub-children with the given type. This method will recursively search the children of the given tree.- Parameters:
tree
-tokens
-typeName
-- Returns:
- the list of children found with the given type
-