本文整理匯總了Java中org.antlr.runtime.tree.Tree.toStringTree方法的典型用法代碼示例。如果您正苦於以下問題:Java Tree.toStringTree方法的具體用法?Java Tree.toStringTree怎麽用?Java Tree.toStringTree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.antlr.runtime.tree.Tree
的用法示例。
在下文中一共展示了Tree.toStringTree方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CosmasCondition
import org.antlr.runtime.tree.Tree; //導入方法依賴的package包/類
public CosmasCondition (Tree cond) {
String nodeString = cond.toStringTree();
if (nodeString.startsWith("-")) {
negated = true;
nodeString = nodeString.substring(1);
}
else if (nodeString.startsWith("+")) {
nodeString = nodeString.substring(1);
}
elem = nodeString.substring(0, 1);
nodeString = nodeString.substring(1);
position = nodeString.equals("a") ? "frames:startswith"
: "frames:endswith";
}
示例2: getNodeCat
import org.antlr.runtime.tree.Tree; //導入方法依賴的package包/類
/**
* Returns the category (or 'label') of the root of a (sub-)
* ParseTree (ANTLR 3).
*
* @param node
* The tree node.
* @return The category of the node.
*/
protected static String getNodeCat (Tree node) {
String nodeCat = node.toStringTree();
// from opening parenthesis to 1st whitespace
Pattern p = Pattern.compile("\\((.*?)\\s");
Matcher m = p.matcher(node.toStringTree());
if (m.find()) {
nodeCat = m.group(1);
}
return nodeCat;
}