當前位置: 首頁>>代碼示例>>Java>>正文


Java RuleContext.getParent方法代碼示例

本文整理匯總了Java中org.antlr.v4.runtime.RuleContext.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java RuleContext.getParent方法的具體用法?Java RuleContext.getParent怎麽用?Java RuleContext.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.antlr.v4.runtime.RuleContext的用法示例。


在下文中一共展示了RuleContext.getParent方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: underAbs

import org.antlr.v4.runtime.RuleContext; //導入方法依賴的package包/類
/**
 * En partant d'une noeud permet de déterminer si il est dans l'expression d'une abstraction ou non.
 *
 * @param ctx Le noeud courant
 * @return Retourne vrai si le noeud est sous une abstraction et faux dans l'autre cas.
 */
private boolean underAbs(RuleContext ctx) {
    RuleContext parent = ctx.parent;

    if (parent == null) {
        return false;
    }

    while (parent.getParent() != null) {
        if (parent instanceof LambdaParser.AbstractionContext) {
            return true;
        }
        parent = parent.parent;
    }
    return false;
}
 
開發者ID:Tirke,項目名稱:Lambda-Interpreter,代碼行數:22,代碼來源:ReduceVisitor.java

示例2: findParentNode

import org.antlr.v4.runtime.RuleContext; //導入方法依賴的package包/類
private RuleContext findParentNode(RuleContext ctx, Class<?> classtype) {
  RuleContext p = ctx.getParent();
  while(p!=null) {
    if(p.getClass().equals(classtype)) {
      return p;
    }
    p = p.getParent();
  }
  return null;
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:11,代碼來源:GroovyNodeCompletion.java

示例3: findLeftSibling

import org.antlr.v4.runtime.RuleContext; //導入方法依賴的package包/類
private ParseTree findLeftSibling(RuleContext ctx) {
  RuleContext p = ctx.getParent();
  if(p!=null) {
    for(int i=0; i<p.getChildCount(); i++) {
      if(p.getChild(i).equals(ctx)) {
        if(i>0)
          return p.getChild(i-1);
        break;
      }
    }
  }
  return null;
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:14,代碼來源:GroovyNodeCompletion.java

示例4: findParentVarSpecContext

import org.antlr.v4.runtime.RuleContext; //導入方法依賴的package包/類
private VarSpecContext findParentVarSpecContext(RuleContext ctx) {
    if (ctx instanceof VarSpecContext) {
        return (VarSpecContext) ctx;
    } else if (ctx.getParent() != null) {
        return findParentVarSpecContext(ctx.getParent());
    } else {
        return null;
    }
}
 
開發者ID:Zir0-93,項目名稱:clarpse,代碼行數:10,代碼來源:GoLangTreeListener.java

示例5: ifIsInABlockContext

import org.antlr.v4.runtime.RuleContext; //導入方法依賴的package包/類
private boolean ifIsInABlockContext(final RuleContext myParentArg) {
	RuleContext myParent = myParentArg;
	boolean retval = false;
	while (myParent instanceof ProgramContext == false) {
		if (myParent instanceof BlockContext) {
			retval = true;
			break;
		} else if (myParent instanceof Expr_and_decl_listContext) {
			myParent = myParent.getParent();
		} else {
			break;
		}
	}
	return retval;
}
 
開發者ID:jcoplien,項目名稱:trygve,代碼行數:16,代碼來源:Pass1Listener.java

示例6: analyzeKeywords

import org.antlr.v4.runtime.RuleContext; //導入方法依賴的package包/類
@RuleDependencies({
    @RuleDependency(recognizer=GrammarParser.class, rule=GrammarParser.RULE_lexerCommandName, version=0, dependents=Dependents.SELF),
    @RuleDependency(recognizer=GrammarParser.class, rule=GrammarParser.RULE_id, version=6, dependents=Dependents.PARENTS),
})
private void analyzeKeywords(Map<RuleContext, CaretReachedException> parseTrees, Map<String, CompletionItem> intermediateResults) {
    boolean maybeLexerCommand = false;

    IntervalSet remainingKeywords = new IntervalSet(KeywordCompletionItem.KEYWORD_TYPES);
    for (Map.Entry<RuleContext, CaretReachedException> entry : parseTrees.entrySet()) {
        CaretReachedException caretReachedException = entry.getValue();
        if (caretReachedException == null || caretReachedException.getTransitions() == null) {
            continue;
        }

        RuleContext finalContext = caretReachedException.getFinalContext();
        if (finalContext.getRuleIndex() == GrammarParser.RULE_id) {
            RuleContext parent = finalContext.getParent();
            if (parent != null && parent.getRuleIndex() == GrammarParser.RULE_lexerCommandName) {
                maybeLexerCommand = true;
            }

            continue;
        }

        Map<ATNConfig, List<Transition>> transitions = caretReachedException.getTransitions();
        for (List<Transition> transitionList : transitions.values()) {
            for (Transition transition : transitionList) {
                if (transition.isEpsilon() || transition instanceof WildcardTransition || transition instanceof NotSetTransition) {
                    continue;
                }

                IntervalSet label = transition.label();
                if (label == null) {
                    continue;
                }

                for (int keyword : remainingKeywords.toArray()) {
                    if (label.contains(keyword)) {
                        remainingKeywords.remove(keyword);
                        KeywordCompletionItem item = KeywordCompletionItem.KEYWORD_ITEMS.get(keyword);
                        intermediateResults.put(item.getInsertPrefix().toString(), item);
                    }
                }
            }
        }
    }

    if (maybeLexerCommand) {
        addLexerCommands(intermediateResults);
    }
}
 
開發者ID:tunnelvisionlabs,項目名稱:goworks,代碼行數:52,代碼來源:GrammarCompletionQuery.java


注:本文中的org.antlr.v4.runtime.RuleContext.getParent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。