Example usage for org.antlr.v4.runtime RuleContext getParent

List of usage examples for org.antlr.v4.runtime RuleContext getParent

Introduction

In this page you can find the example usage for org.antlr.v4.runtime RuleContext getParent.

Prototype

@Override
    public RuleContext getParent() 

Source Link

Usage

From source file:com.twosigma.beaker.groovy.autocomplete.GroovyNodeCompletion.java

License:Apache License

private RuleContext findParentNode(RuleContext ctx, Class<?> classtype) {
    RuleContext p = ctx.getParent();
    while (p != null) {
        if (p.getClass().equals(classtype)) {
            return p;
        }//from   w w w . j  a  v a  2s.c  o m
        p = p.getParent();
    }
    return null;
}

From source file:com.twosigma.beaker.groovy.autocomplete.GroovyNodeCompletion.java

License:Apache License

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;
            }/*from   w  w w . j a v a 2s  .c  o  m*/
        }
    }
    return null;
}

From source file:info.fulloo.trygve.parser.Pass1Listener.java

License:Open Source License

private boolean ifIsInABlockContext(final RuleContext myParentArg) {
    RuleContext myParent = myParentArg;
    boolean retval = false;
    while (myParent instanceof ProgramContext == false) {
        if (myParent instanceof BlockContext) {
            retval = true;//from w w  w  . j a  v  a 2s.c  o  m
            break;
        } else if (myParent instanceof Expr_and_decl_listContext) {
            myParent = myParent.getParent();
        } else {
            break;
        }
    }
    return retval;
}