本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
}