当前位置: 首页>>代码示例>>Java>>正文


Java ParseTree.getClass方法代码示例

本文整理汇总了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;
}
 
开发者ID:waterguo,项目名称:antsdb,代码行数:21,代码来源:InstructionGenerator.java

示例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;
}
 
开发者ID:waterguo,项目名称:antsdb,代码行数:21,代码来源:InstructionGenerator.java

示例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;
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:9,代码来源:WalkerUtil.java

示例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;
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:14,代码来源:Visitor.java

示例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;
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:13,代码来源:ProgramParser.java

示例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());
        }
    }
}
 
开发者ID:nradov,项目名称:abnffuzzer,代码行数:37,代码来源:Element.java

示例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;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:13,代码来源:ProgramParser.java

示例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;

}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:35,代码来源:ComplexityVisitor.java

示例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));
}
 
开发者ID:marcelganczak,项目名称:swift-js-transpiler,代码行数:7,代码来源:WalkerUtil.java

示例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));
}
 
开发者ID:marcelganczak,项目名称:swift-js-transpiler,代码行数:6,代码来源:WalkerUtil.java


注:本文中的org.antlr.v4.runtime.tree.ParseTree.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。