Package org.codehaus.groovy.antlr

Examples of org.codehaus.groovy.antlr.GroovySourceAST


    public void push(GroovySourceAST t) {
        Iterator itr = visitors.iterator();
        while (itr.hasNext()) {((Visitor)itr.next()).push(t);}
    }
    public GroovySourceAST pop() {
        GroovySourceAST lastNodePopped = null;
        Iterator itr = backToFrontVisitors.iterator();
        while (itr.hasNext()) {lastNodePopped = (GroovySourceAST) ((Visitor)itr.next()).pop();}
        return lastNodePopped;
    }
View Full Code Here


    public FlatNodeListTraversal(Visitor visitor) {
        super(visitor);
    }

    public AST process(AST t) {
        GroovySourceAST node = (GroovySourceAST) t;

        // fetch all the nodes in this AST into a List
        NodeCollector collector = new NodeCollector();
        AntlrASTProcessor internalTraversal = new PreOrderTraversal(collector);
        internalTraversal.process(t);
        List listOfAllNodesInThisAST = collector.getNodes();
       
        // process each node in turn
        setUp(node);       
        Iterator itr = listOfAllNodesInThisAST.iterator();
        while (itr.hasNext()) {
            GroovySourceAST currentNode = (GroovySourceAST) itr.next();
            accept(currentNode);
        }
        tearDown(node);
        return null;
    }
View Full Code Here

    // visitEmptyStat ...
    //   token type EMPTY_STAT obsolete and should be removed, never visited/created
   
    public void visitEnumConstantDef(GroovySourceAST t,int visit) {
        GroovySourceAST sibling = (GroovySourceAST)t.getNextSibling();
        if (sibling != null && sibling.getType() == GroovyTokenTypes.ENUM_CONSTANT_DEF) {
            print(t,visit,null,null,", ");
        }
    }
View Full Code Here

    }
   
    // visit TripleDot, not used in the AST
   
    public void visitType(GroovySourceAST t,int visit) {
        GroovySourceAST parent = getParentNode();
        GroovySourceAST modifiers = parent.childOfType(GroovyTokenTypes.MODIFIERS);

        // No need to print 'def' if we already have some modifiers
        if (modifiers == null || modifiers.getNumberOfChildren() == 0) {

            if (visit == OPENING_VISIT) {
                if (t.getNumberOfChildren() == 0 &&
                        parent.getType() != GroovyTokenTypes.PARAMETER_DEF) { // no need for 'def' if in a parameter list
                    print(t,visit,"def");
View Full Code Here

     * </pre>
     */
  private void visitJavaArrayInit(GroovySourceAST t) {
    // given that we might have a grandParent...
    if (stack.size() > 2) {
      GroovySourceAST grandParent = getGrandParentNode();
      if (grandParent.getType() == JavaTokenTypes.EXPR) {
        grandParent.setType(JavaTokenTypes.ARRAY_INIT); //set type as indicator for Java2GroovyConvertor to turn into LIST_CONSTRUCTOR
        grandParent.setFirstChild(t);
        t.setType(JavaTokenTypes.ELIST);
      }
    }
  }
View Full Code Here

   *
   * todo - build API of basic tree mutations like this method.
   */
    public void swapTwoChildren(GroovySourceAST t) {
    // this swaps the two child nodes, see javadoc above for explanation of implementation
    GroovySourceAST a = (GroovySourceAST) t.getFirstChild();
    GroovySourceAST b = (GroovySourceAST) a.getNextSibling();

    t.setFirstChild(b);
    a.setNextSibling(null);
    b.setNextSibling(a);
    }
View Full Code Here

    protected abstract void accept(GroovySourceAST currentNode);

    protected void accept_v_FirstChildsFirstChild_v_Child2_Child3_v_Child4_v___v_LastChild(GroovySourceAST t) {
        openingVisit(t);
        GroovySourceAST expr2 = t.childAt(0);
        skip(expr2);
        accept(expr2.childAt(0));
        closingVisit(t);

        GroovySourceAST sibling = (GroovySourceAST) expr2.getNextSibling();
        boolean firstSList = true;
        while (sibling != null) {
            if (!firstSList) {
                subsequentVisit(t);
            }
            firstSList = false;
            accept(sibling);
            sibling = (GroovySourceAST) sibling.getNextSibling();
        }
    }
View Full Code Here

        }
    }

    protected void accept_v_FirstChildsFirstChild_v_RestOfTheChildren(GroovySourceAST t) {
        openingVisit(t);
        GroovySourceAST expr = t.childAt(0);
        skip(expr);
        accept(expr.childAt(0));
        closingVisit(t);
        acceptSiblings(expr);
    }
View Full Code Here

    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);
    }
View Full Code Here

        accept(t.childAt(2));
        closingVisit(t);
    }

    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);
                    }
                }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.antlr.GroovySourceAST

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.