本文整理汇总了Java中org.antlr.v4.runtime.tree.RuleNode类的典型用法代码示例。如果您正苦于以下问题:Java RuleNode类的具体用法?Java RuleNode怎么用?Java RuleNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RuleNode类属于org.antlr.v4.runtime.tree包,在下文中一共展示了RuleNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enterParseTree
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
private void enterParseTree(ParseTree tree){
int cc = tree.getChildCount();
for(int i=0;i<cc;i++){
ParseTree c = tree.getChild(i);
if(c instanceof RuleNode){
enterParseTree(c);
}else if (c instanceof TerminalNode){
Token t = ((TerminalNode)c).getSymbol();
index2token.put(tokenCounter, t);
token2tree.put(t, c);
tokenCounter ++;
}else{
System.err.println("unknown node:" + c);
}
}
}
示例2: visitChildren
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object visitChildren(final RuleNode node) {
final int n = node.getChildCount();
for (int i = 0; i < n; i++) {
final ParseTree c = node.getChild(i);
c.accept(this);
}
final String textToFind = node.getText();
if (StringUtils.containsIgnoreCase(textToFind, tempText)
|| StringUtils.containsIgnoreCase(tempText, textToFind)) {
nodes.add(new ParsedNode(node));
}
return null;
}
示例3: interpretVariable
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected void interpretVariable(ParseTree tree) {
String varName = null;
Set<PQLTask> varValue = null;
for (int i = 0; i < tree.getChildCount(); i++) {
ParseTree child = tree.getChild(i);
if(child instanceof RuleNode) {
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_varName:
varName = interpretName(child);
break;
case PQLParser.RULE_setOfTasks:
varValue = interpretSetOfTasks(child);
break;
}
}
}
this.variables.put(varName,varValue);
}
示例4: interpretAttribute
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected void interpretAttribute(ParseTree tree) {
ParseTree child = tree.getChild(0);
if (child instanceof RuleNode) {
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_universe :
this.attributes.add(new PQLAttribute());
break;
case PQLParser.RULE_attributeName :
this.attributes.add(new PQLAttribute(this.interpretString(child)));
break;
}
}
}
示例5: interpretLocation
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected void interpretLocation(ParseTree tree) {
ParseTree child = tree.getChild(0);
if (child instanceof RuleNode) {
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_universe :
this.locations.add(new PQLLocation());
break;
case PQLParser.RULE_locationPath :
this.locations.add(new PQLLocation(this.interpretString(child)));
break;
}
}
}
示例6: interpretPredicate
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected boolean interpretPredicate(ParseTree tree) {
if (tree==null) return true; // WHERE clause is not specified for this query!
boolean result = false;
ParseTree child = tree.getChild(0);
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_proposition:
result = interpretProposition(child);
break;
case PQLParser.RULE_conjunction:
result = interpretConjunction(child);
break;
case PQLParser.RULE_disjunction:
result = interpretDisjunction(child);
break;
case PQLParser.RULE_logicalTest:
result = interpretLogicalTest(child);
break;
}
return result;
}
示例7: interpretSetComparison
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected boolean interpretSetComparison(ParseTree tree) {
Set<PQLTask> A = interpretSetOfTasks(tree.getChild(0));
Set<PQLTask> B = interpretSetOfTasks(tree.getChild(2));
ParseTree child = tree.getChild(1).getChild(0);
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_identical:
return A.equals(B) ? true : false;
case PQLParser.RULE_different:
return A.equals(B) ? false : true;
case PQLParser.RULE_overlapsWith:
for (PQLTask task : A)
if (B.contains(task)) return true;
return false;
case PQLParser.RULE_subsetOf:
return B.containsAll(A) ? true : false;
case PQLParser.RULE_properSubsetOf:
return B.containsAll(A) && !A.equals(B) ? true : false;
}
return false;
}
示例8: interpretTask
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected PQLTask interpretTask(ParseTree tree) {
String label = "";
double similarity = 1.0;
for (int i = 0; i < tree.getChildCount(); i++) {
ParseTree child = tree.getChild(i);
if (child instanceof RuleNode) {
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_approximate:
similarity = labelMngr.getDefaultLabelSimilarityThreshold();
break;
case PQLParser.RULE_label:
label = this.interpretLabel(child);
break;
case PQLParser.RULE_similarity:
similarity = this.interpretSimilarity(child);
break;
}
}
}
return new PQLTask(label, similarity);
}
示例9: interpretInsertTrace
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected PQLTrace interpretInsertTrace(ParseTree tree) {
PQLTrace trace = new PQLTrace();
for (int i = 0; i < tree.getChildCount(); i++) {
ParseTree child = tree.getChild(i).getChild(0); //getting a task or '*'
if(child instanceof RuleNode) {
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
if (ruleIndex == PQLParser.RULE_task) { //is task
trace.addTask(this.interpretTask(child));
}
else { // is '*'
trace.addTask(this.interpretTraceUniverse());
trace.setHasAsterisk(true);
}
}
}
return trace;
}
示例10: interpretParentheses
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected boolean interpretParentheses(ParseTree tree) {
ParseTree child = tree.getChild(1);
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_proposition:
return interpretProposition(child);
case PQLParser.RULE_conjunction:
return interpretConjunction(child);
case PQLParser.RULE_disjunction:
return interpretDisjunction(child);
case PQLParser.RULE_logicalTest:
return interpretLogicalTest(child);
}
return false;
}
示例11: interpretLogicalTest
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected boolean interpretLogicalTest(ParseTree tree) {
ParseTree child = tree.getChild(0);
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_isTrue:
return interpretLogicalTest(child,true,true);
case PQLParser.RULE_isNotTrue:
return interpretLogicalTest(child,false,true);
case PQLParser.RULE_isFalse:
return interpretLogicalTest(child,true,false);
case PQLParser.RULE_isNotFalse:
return interpretLogicalTest(child,false,false);
}
return false;
}
示例12: interpretSetOfTasks
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected Set<PQLTask> interpretSetOfTasks(ParseTree tree) {
ParseTree child = tree.getChild(0);
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_tasks:
return interpretTasks(child);
case PQLParser.RULE_union:
return interpretUnion(child);
case PQLParser.RULE_difference:
return interpretDifference(child);
case PQLParser.RULE_intersection:
return interpretIntersection(child);
}
return new HashSet<PQLTask>();
}
示例13: interpretTasks
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected Set<PQLTask> interpretTasks(ParseTree tree) {
ParseTree child = tree.getChild(0);
if (child instanceof RuleNode) {
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_varName:
return this.interpretVarNameSetOfTasks(child);
case PQLParser.RULE_setOfAllTasks:
return this.interpretSetOfAllTasks(child);
case PQLParser.RULE_setOfTasksLiteral:
return interpretSetOfTasksLiteral(child);
case PQLParser.RULE_setOfTasksConstruction:
return interpretSetOfTasksConstruction(child);
case PQLParser.RULE_setOfTasksParentheses:
return interpretSetOfTasksParentheses(child);
}
}
return new HashSet<PQLTask>();
}
示例14: interpretSetOfTasksConstruction
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected Set<PQLTask> interpretSetOfTasksConstruction(ParseTree tree) {
ParseTree child = tree.getChild(0);
if (child instanceof RuleNode) {
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
switch (ruleIndex) {
case PQLParser.RULE_unaryPredicateConstruction:
return interpretUnaryPredicateConstruction(child);
case PQLParser.RULE_binaryPredicateConstruction:
return interpretBinaryPredicateConstruction(child);
}
}
return new HashSet<PQLTask>();
}
示例15: interpretSetOfTasksLiteral
import org.antlr.v4.runtime.tree.RuleNode; //导入依赖的package包/类
protected Set<PQLTask> interpretSetOfTasksLiteral(ParseTree tree) {
Set<PQLTask> result = new HashSet<PQLTask>();
for (int i = 0; i < tree.getChildCount(); i++) {
ParseTree child = tree.getChild(i);
if(child instanceof RuleNode) {
int ruleIndex = ((RuleNode)child).getRuleContext().getRuleIndex();
if (ruleIndex == PQLParser.RULE_task) {
result.add(this.interpretTask(child));
}
}
}
return result;
}