本文整理汇总了Java中org.antlr.runtime.tree.TreeAdaptor.create方法的典型用法代码示例。如果您正苦于以下问题:Java TreeAdaptor.create方法的具体用法?Java TreeAdaptor.create怎么用?Java TreeAdaptor.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.runtime.tree.TreeAdaptor
的用法示例。
在下文中一共展示了TreeAdaptor.create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAttribute
import org.antlr.runtime.tree.TreeAdaptor; //导入方法依赖的package包/类
/**
* Add a new attribute to a parent node.
* @param adaptor the tree helper
* @param parent parent node
* @param tokenType the new node token type
* @param tokenText the new node name
* @param value the new node value
* @return a new node that was just added to parent
*/
private Object addAttribute(
final TreeAdaptor adaptor,
final Object parent,
final int tokenType,
final String tokenText, final String value) {
Object node = adaptor.create(tokenType, tokenText);
if (value != null) {
String[] values = value.split("\\s\\|\\s");
for (String avalue : values) {
Object nodeValue = adaptor.create(CobolStructureParser.LITERAL, avalue);
adaptor.addChild(node, nodeValue);
}
}
adaptor.addChild(parent, node);
return node;
}
示例2: buildJDBCUrl
import org.antlr.runtime.tree.TreeAdaptor; //导入方法依赖的package包/类
public Object buildJDBCUrl(TreeAdaptor adaptor, String dbType, String hostname, String port, String dbname) {
StringBuilder buf = new StringBuilder();
buf.append("'");
buf.append("jdbc:");
if (dbType == null)
throw new ParserException(Pass.FIRST, "Malformed jdbc url: missing dbtype");
buf.append(dbType).append("://");
if (hostname == null)
throw new ParserException(Pass.FIRST, "Malformed jdbc url: missing host");
buf.append(hostname);
if (port != null)
buf.append(":").append(port);
if (dbname != null)
buf.append("/").append(dbname);
buf.append("'");
return adaptor.create(TokenTypes.Character_String_Literal, buf.toString());
}
示例3: buildKeywordEscapeIdentifier
import org.antlr.runtime.tree.TreeAdaptor; //导入方法依赖的package包/类
public Object buildKeywordEscapeIdentifier(TreeAdaptor adaptor, Object tree) {
if (tree instanceof CommonToken) {
Token tok = (Token) tree;
return adaptor.create(TokenTypes.Regular_Identifier, tok, tok.getText());
} else {
CommonTree ct = (CommonTree)tree;
return adaptor.create(TokenTypes.Regular_Identifier, ct.getToken(), ct.getText());
}
}
示例4: buildIdentifier
import org.antlr.runtime.tree.TreeAdaptor; //导入方法依赖的package包/类
public Object buildIdentifier(Parser parser, TreeAdaptor adaptor, String text) {
return adaptor.create(TokenTypes.Regular_Identifier, text);
}
示例5: makeTinyTree
import org.antlr.runtime.tree.TreeAdaptor; //导入方法依赖的package包/类
public Object makeTinyTree(TreeAdaptor adaptor, Token ct) {
return adaptor.create(ct);
}