Examples of TreeAdaptor


Examples of org.antlr.runtime.tree.TreeAdaptor

    CommonTree oldRoot = new CommonTree(new CommonToken(101));
    oldRoot.addChild(new CommonTree(new CommonToken(102)));
    oldRoot.addChild(new CommonTree(new CommonToken(103)));

    TreeAdaptor adaptor = new CommonTreeAdaptor();
    adaptor.becomeRoot(newRoot, oldRoot);
    newRoot.sanityCheckParentAndChildIndexes();
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeAdaptor

    CommonTree oldRoot = new CommonTree((Token)null);
    oldRoot.addChild(new CommonTree(new CommonToken(101)));
    oldRoot.addChild(new CommonTree(new CommonToken(102)));
    oldRoot.addChild(new CommonTree(new CommonToken(103)));

    TreeAdaptor adaptor = new CommonTreeAdaptor();
    adaptor.becomeRoot(newRoot, oldRoot);
    newRoot.sanityCheckParentAndChildIndexes();
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeAdaptor

    CommonTree oldRoot = new CommonTree(new CommonToken(101));
    oldRoot.addChild(new CommonTree(new CommonToken(102)));
    oldRoot.addChild(new CommonTree(new CommonToken(103)));

    TreeAdaptor adaptor = new CommonTreeAdaptor();
    adaptor.becomeRoot(newRoot, oldRoot);
    newRoot.sanityCheckParentAndChildIndexes();
  }
View Full Code Here

Examples of org.antlr.runtime.tree.TreeAdaptor

            public void emitErrorMessage(String msg) {
                throw new DqlParseException(msg);
            }
        };
       
        final TreeAdaptor adaptor = new CommonTreeAdaptor() {
            @Override
            public Object create(Token payload) {
                return new CommonTree(payload);
            }
        };
View Full Code Here

Examples of org.antlr.runtime3_3_0.tree.TreeAdaptor

    if ( input instanceof TokenStream ) {
      return token.getType();
    }
    else if ( input instanceof TreeNodeStream ) {
      TreeNodeStream nodes = (TreeNodeStream)input;
      TreeAdaptor adaptor = nodes.getTreeAdaptor();
      return adaptor.getType(node);
    }
    else {
      return c;
    }
  }
View Full Code Here

Examples of org.antlr.runtime3_3_0.tree.TreeAdaptor

  }

  protected void extractInformationFromTreeNodeStream(IntStream input) {
    TreeNodeStream nodes = (TreeNodeStream)input;
    this.node = nodes.LT(1);
    TreeAdaptor adaptor = nodes.getTreeAdaptor();
    Token payload = adaptor.getToken(node);
    if ( payload!=null ) {
      this.token = payload;
      if ( payload.getLine()<= 0 ) {
        // imaginary node; no line/pos info; scan backwards
        int i = -1;
        Object priorNode = nodes.LT(i);
        while ( priorNode!=null ) {
          Token priorPayload = adaptor.getToken(priorNode);
          if ( priorPayload!=null && priorPayload.getLine()>0 ) {
            // we found the most recent real line / pos info
            this.line = priorPayload.getLine();
            this.charPositionInLine = priorPayload.getCharPositionInLine();
            this.approximateLineInfo = true;
            break;
          }
          --i;
          priorNode = nodes.LT(i);
        }
      }
      else { // node created from real token
        this.line = payload.getLine();
        this.charPositionInLine = payload.getCharPositionInLine();
      }
    }
    else if ( this.node instanceof Tree) {
      this.line = ((Tree)this.node).getLine();
      this.charPositionInLine = ((Tree)this.node).getCharPositionInLine();
      if ( this.node instanceof CommonTree) {
        this.token = ((CommonTree)this.node).token;
      }
    }
    else {
      int type = adaptor.getType(this.node);
      String text = adaptor.getText(this.node);
      this.token = new CommonToken(type, text);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.