本文整理汇总了Java中org.antlr.v4.runtime.tree.ParseTree.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java ParseTree.getClass方法的具体用法?Java ParseTree.getClass怎么用?Java ParseTree.getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.v4.runtime.tree.ParseTree
的用法示例。
在下文中一共展示了ParseTree.getClass方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGenerator
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static public Generator<ParseTree> getGenerator(ParseTree ctx) throws OrcaException {
Class<?> klass = ctx.getClass();
Generator<ParseTree> generator = _generatorByName.get(klass);
if (generator == null) {
String key = StringUtils.removeStart(klass.getSimpleName(), "MysqlParser$");
key = StringUtils.removeEnd(key, "Context");
key += "Generator";
try {
key = InstructionGenerator.class.getPackage().getName() + "." + key;
Class<?> generatorClass = Class.forName(key);
generator = (Generator<ParseTree>)generatorClass.newInstance();
_generatorByName.put(klass, generator);
}
catch (Exception x) {
throw new OrcaException("instruction geneartor is not found: " + key, x);
}
}
return generator;
}
示例2: getGenerator
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static public Generator<ParseTree> getGenerator(ParseTree ctx) throws OrcaException {
Class<?> klass = ctx.getClass();
Generator<ParseTree> generator = _generatorByName.get(klass);
if (generator == null) {
String key = StringUtils.removeStart(klass.getSimpleName(), "FishParser$");
key = StringUtils.removeEnd(key, "Context");
key += "Generator";
try {
key = InstructionGenerator.class.getPackage().getName() + "." + key;
Class<?> generatorClass = Class.forName(key);
generator = (Generator<ParseTree>)generatorClass.newInstance();
_generatorByName.put(klass, generator);
}
catch (Exception x) {
throw new OrcaException("instruction geneartor is not found: " + key, x);
}
}
return generator;
}
示例3: has
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static boolean has(Class nodeType, ParseTree node) {
if(node == null) return false;
if(node.getClass() == nodeType) return true;
for(int i = 0; i < node.getChildCount(); i++) {
if(has(nodeType, node.getChild(i))) return true;
}
return false;
}
示例4: visitWithoutClasses
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public String visitWithoutClasses(RuleNode node, Class nodeType) {
String result = this.defaultResult();
int n = node.getChildCount();
for(int i = 0; i < n && this.shouldVisitNextChild(node, result); ++i) {
ParseTree c = node.getChild(i);
if(c.getClass() == nodeType) continue;
String childResult = c instanceof TerminalNode ? printTerminalNode((TerminalNode) c) : c.accept(this);
result = this.aggregateResult(result, childResult);
}
return result;
}
示例5: toLocation
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private Location toLocation(Scope scope, ParseTree node) {
Token start;
if (node instanceof ParserRuleContext) {
start = ((ParserRuleContext) node).start;
} else if (node instanceof TerminalNode) {
start = ((TerminalNode) node).getSymbol();
} else {
throw new ProgramCompileException("Location is not available for type " + node.getClass());
}
Location location = new Location(scope != null ? scope.programName : "<string>", start.getLine(), start.getCharPositionInLine());
return location;
}
示例6: Element
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
Element(final ParseTree elements) {
for (int i = 0; i < elements.getChildCount(); i++) {
final ParseTree child = elements.getChild(i);
if (child instanceof AlternationContext) {
this.elements.add(new Alternation((AlternationContext) child));
} else if (child instanceof ConcatenationContext) {
this.elements
.add(new Concatenation((ConcatenationContext) child));
} else if (child instanceof ConcatenationContext) {
this.elements
.add(new Concatenation((ConcatenationContext) child));
} else if (child instanceof ElementContext) {
this.elements.add(new Element(child));
} else if (child instanceof GroupContext) {
this.elements.add(new Group((GroupContext) child));
} else if (child instanceof OptionContext) {
this.elements.add(new Option((OptionContext) child));
} else if (child instanceof RepeatContext) {
this.elements.add(new Repeat((RepeatContext) child));
} else if (child instanceof RepetitionContext) {
this.elements.add(new Repetition((RepetitionContext) child));
} else if (child instanceof TerminalNode) {
final TerminalNode tn = (TerminalNode) child;
final String value = tn.toString();
// we don't want to store nodes for separators
if (!(value.startsWith("[") || value.startsWith("]")
|| value.startsWith("(") || value.startsWith(")")
|| value.startsWith("/") || value.startsWith("*"))) {
this.elements.add(new com.github.nradov.abnffuzzer.Terminal(tn));
}
} else {
throw new IllegalArgumentException(
"illegal child " + i + " type: " + child.getClass());
}
}
}
示例7: toLocation
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private Location toLocation(Scope scope, ParseTree node) {
Token start;
if (node instanceof ParserRuleContext) {
start = ((ParserRuleContext)node).start;
} else if (node instanceof TerminalNode) {
start = ((TerminalNode)node).getSymbol();
} else {
throw new ProgramCompileException("Location is not available for type " + node.getClass());
}
Location location = new Location(scope != null? scope.programName: "<string>", start.getLine(), start.getCharPositionInLine());
return location;
}
示例8: visit
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
@Override
public Integer visit(final ParseTree tree) {
final int n = tree.getChildCount();
int s = 0;
for (int i = 0; i < n; i++) {
final ParseTree c = tree.getChild(i);
s += visit(c);
}
final Class<? extends ParseTree> classz = tree.getClass();
if (Sql_unionContext.class.equals(classz)) {
s++;
}
if (Function_callContext.class.isAssignableFrom(classz)) {
s++;
}
if (Join_partContext.class.equals(classz)) {
s++;
}
if (Order_by_expressionContext.class.equals(classz)) {
s++;
}
if (Select_list_elemContext.class.equals(classz)) {
s++;
}
if (Search_condition_notContext.class.equals(classz)) {
s++;
}
if (Dml_clauseContext.class.equals(classz)) {
s++;
}
return s;
}
示例9: isDirectDescendant
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static boolean isDirectDescendant(Class nodeType, ParseTree node) {
if(node == null) return false;
if(node.getClass() == nodeType) return true;
if(node.getChildCount() != 1) return false;
return isDirectDescendant(nodeType, node.getChild(0));
}
示例10: isRightMostDescendant
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static boolean isRightMostDescendant(Class nodeType, ParseTree node) {
if(node == null) return false;
if(node.getClass() == nodeType) return true;
return isRightMostDescendant(nodeType, node.getChild(node.getChildCount() - 1));
}