Search in sources :

Example 6 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.

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 7 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.

the class TraversalHelper method accept_v_FirstChild_v_SecondChild_v___LastChild_v.

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

Example 8 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.

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 9 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.

the class TraversalHelper method accept_FirstSecondAndThirdChild_v_v_ForthChild.

protected void accept_FirstSecondAndThirdChild_v_v_ForthChild(GroovySourceAST t) {
    GroovySourceAST child1 = (GroovySourceAST) t.getFirstChild();
    if (child1 != null) {
        accept(child1);
        GroovySourceAST child2 = (GroovySourceAST) child1.getNextSibling();
        if (child2 != null) {
            accept(child2);
            GroovySourceAST child3 = (GroovySourceAST) child2.getNextSibling();
            if (child3 != null) {
                accept(child3);
                openingVisit(t);
                GroovySourceAST child4 = (GroovySourceAST) child3.getNextSibling();
                if (child4 != null) {
                    subsequentVisit(t);
                    accept(child4);
                }
            }
        }
    }
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST)

Example 10 with GroovySourceAST

use of org.codehaus.groovy.antlr.GroovySourceAST in project groovy by apache.

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