Package org.antlr.runtime3_3_0.tree

Examples of org.antlr.runtime3_3_0.tree.TreeRewriter$fptr


  public String getErrorMessage(RecognitionException e, String[] tokenNames) {
    if ( this instanceof TreeParser ) {
      TreeAdaptor adaptor = ((TreeNodeStream)e.input).getTreeAdaptor();
      e.token = adaptor.getToken(e.node);
      if ( e.token==null ) { // could be an UP/DOWN node
        e.token = new CommonToken(adaptor.getType(e.node),
                      adaptor.getText(e.node));
      }
    }
    return super.getErrorMessage(e, tokenNames);
  }
View Full Code Here


    protected Object recoverFromMismatchedToken(IntStream input,
                                                int ttype,
                                                BitSet follow)
        throws RecognitionException
    {
        throw new MismatchedTreeNodeException(ttype, (TreeNodeStream)input);
    }
View Full Code Here

      String lineS = elements[3];
      String posS = elements[4];
      Class excClass = null;
      try {
        excClass = Class.forName(excName);
        RecognitionException e =
          (RecognitionException)excClass.newInstance();
        e.index = Integer.parseInt(indexS);
        e.line = Integer.parseInt(lineS);
        e.charPositionInLine = Integer.parseInt(posS);
        listener.recognitionException(e);
View Full Code Here

    protected TokenStream originalTokenStream;
    protected TreeAdaptor originalAdaptor;

    public TreeFilter(TreeNodeStream input) {
        this(input, new RecognizerSharedState());
    }
View Full Code Here

    public void applyOnce(Object t, fptr whichRule) {
        if ( t==null ) return;
        try {
            // share TreeParser object but not parsing-related state
            state = new RecognizerSharedState();
            input = new CommonTreeNodeStream(originalAdaptor, t);
            ((CommonTreeNodeStream)input).setTokenStream(originalTokenStream);
            setBacktrackingLevel(1);
            whichRule.rule();
            setBacktrackingLevel(0);
View Full Code Here

    protected TokenStream originalTokenStream;
    protected TreeAdaptor originalAdaptor;
   
    public TreeRewriter(TreeNodeStream input) {
        this(input, new RecognizerSharedState());
    }
View Full Code Here

    public Object applyOnce(Object t, fptr whichRule) {
        if ( t==null ) return null;
        try {
            // share TreeParser object but not parsing-related state
            state = new RecognizerSharedState();
            input = new CommonTreeNodeStream(originalAdaptor, t);
            ((CommonTreeNodeStream)input).setTokenStream(originalTokenStream);
            setBacktrackingLevel(1);
            TreeRuleReturnScope r = (TreeRuleReturnScope)whichRule.rule();
            setBacktrackingLevel(0);
View Full Code Here

    int type = adaptor.getType(t);
    buf.append("\t");
    buf.append(ID);
    buf.append("\t");
    buf.append(type);
    Token token = adaptor.getToken(t);
    int line = -1;
    int pos = -1;
    if ( token!=null ) {
      line = token.getLine();
      pos = token.getCharPositionInLine();
    }
    buf.append("\t");
    buf.append(line);
    buf.append("\t");
    buf.append(pos);
View Full Code Here

  /** Get num hidden tokens between i..j inclusive */
  public int getNumberOfHiddenTokens(int i, int j) {
    int n = 0;
    TokenStream input = parser.getTokenStream();
    for (int ti = i; ti<input.size() && ti <= j; ti++) {
      Token t = input.get(ti);
      if ( t.getChannel()!=Token.DEFAULT_CHANNEL ) {
        n++;
      }
    }
    return n;
  }
View Full Code Here

      }
      previousTokenIndex = t.getTokenIndex();
      listener.consumeHiddenToken(t);
    }
    else if ( elements[0].equals("LT") ) {
      Token t = deserializeToken(elements, 2);
      listener.LT(Integer.parseInt(elements[1]), t);
    }
    else if ( elements[0].equals("mark") ) {
      listener.mark(Integer.parseInt(elements[1]));
    }
View Full Code Here

TOP

Related Classes of org.antlr.runtime3_3_0.tree.TreeRewriter$fptr

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.