当前位置: 首页>>代码示例>>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;未经允许,请勿转载。