Search in sources :

Example 71 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class TraversalHelper method accept_FirstChild_v_SecondChildsChildren_v.

protected void accept_FirstChild_v_SecondChildsChildren_v(GroovySourceAST t) {
    accept(t.childAt(0));
    openingVisit(t);
    GroovySourceAST secondChild = t.childAt(1);
    if (secondChild != null) {
        acceptChildren(secondChild);
    }
    closingVisit(t);
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 72 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class TraversalHelper method accept_v_FirstChild_2ndv_SecondChild_v___LastChild_v.

protected void accept_v_FirstChild_2ndv_SecondChild_v___LastChild_v(GroovySourceAST t) {
    openingVisit(t);
    GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
    if (child != null) {
        accept(child);
        GroovySourceAST sibling = (GroovySourceAST) child.getNextSibling();
        if (sibling != null) {
            secondVisit(t);
            accept(sibling);
            sibling = (GroovySourceAST) sibling.getNextSibling();
            while (sibling != null) {
                subsequentVisit(t);
                accept(sibling);
                sibling = (GroovySourceAST) sibling.getNextSibling();
            }
        }
    }
    closingVisit(t);
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 73 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class TraversalHelper method accept_FirstChild_v_RestOfTheChildren_v_LastChild.

protected void accept_FirstChild_v_RestOfTheChildren_v_LastChild(GroovySourceAST t) {
    int count = 0;
    accept(t.childAt(0));
    count++;
    openingVisit(t);
    if (t.childAt(0) != null) {
        GroovySourceAST sibling = (GroovySourceAST) t.childAt(0).getNextSibling();
        while (sibling != null) {
            if (count == t.getNumberOfChildren() - 1) {
                closingVisit(t);
            }
            accept(sibling);
            count++;
            sibling = (GroovySourceAST) sibling.getNextSibling();
        }
    }
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 74 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class TraversalHelper method acceptSiblings.

protected void acceptSiblings(GroovySourceAST t) {
    if (t != null) {
        GroovySourceAST sibling = (GroovySourceAST) t.getNextSibling();
        while (sibling != null) {
            accept(sibling);
            sibling = (GroovySourceAST) sibling.getNextSibling();
        }
    }
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 75 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy-core by groovy.

the class TraversalHelper method process.

public AST process(AST t) {
    GroovySourceAST node = (GroovySourceAST) t;
    // process each node in turn
    setUp(node);
    accept(node);
    acceptSiblings(node);
    tearDown(node);
    return null;
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Aggregations

GroovySourceAST (org.codehaus.groovy.antlr.GroovySourceAST)77 AST (antlr.collections.AST)4 Iterator (java.util.Iterator)2 List (java.util.List)2 AntlrASTProcessor (org.codehaus.groovy.antlr.AntlrASTProcessor)2 LineColumn (org.codehaus.groovy.antlr.LineColumn)2