Package antlr

Examples of antlr.TokenWithIndex


    buf.append("\n");
    for (int i=ruleAST.ruleStartTokenIndex;
       i<=ruleAST.ruleStopTokenIndex && i<tokenBuffer.size();
       i++)
    {
      TokenWithIndex t = (TokenWithIndex)tokenBuffer.getToken(i);
      // undo the text deletions done by the lexer (ugh)
      if ( t.getType()==ANTLRParser.BLOCK ) {
        buf.append("(");
      }
      else if ( t.getType()==ANTLRParser.ACTION ) {
        buf.append("{");
        buf.append(t.getText());
        buf.append("}");
      }
      else if ( t.getType()==ANTLRParser.SEMPRED ||
            t.getType()==ANTLRParser.SYN_SEMPRED ||
            t.getType()==ANTLRParser.GATED_SEMPRED ||
            t.getType()==ANTLRParser.BACKTRACK_SEMPRED )
      {
        buf.append("{");
        buf.append(t.getText());
        buf.append("}?");
      }
      else if ( t.getType()==ANTLRParser.ARG_ACTION ) {
        buf.append("[");
        buf.append(t.getText());
        buf.append("]");
      }
      else {
        buf.append(t.getText());
      }
    }
    String ruleText = buf.toString();
    //System.out.println("[["+ruleText+"]]");
    // now put the rule into the lexer grammar template
View Full Code Here


  public GrammarAST(int t, String txt) {
    initialize(t,txt);
  }

  public void initialize(int i, String s) {
        token = new TokenWithIndex(i,s);
    }
View Full Code Here

    buf.append("\n");
    for (int i=ruleAST.ruleStartTokenIndex;
       i<=ruleAST.ruleStopTokenIndex && i<tokenBuffer.size();
       i++)
    {
      TokenWithIndex t = (TokenWithIndex)tokenBuffer.getToken(i);
      // undo the text deletions done by the lexer (ugh)
      if ( t.getType()==ANTLRParser.BLOCK ) {
        buf.append("(");
      }
      else if ( t.getType()==ANTLRParser.ACTION ) {
        buf.append("{");
        buf.append(t.getText());
        buf.append("}");
      }
      else if ( t.getType()==ANTLRParser.SEMPRED ||
        t.getType()==ANTLRParser.SYN_SEMPRED ||
        t.getType()==ANTLRParser.GATED_SEMPRED ||
        t.getType()==ANTLRParser.BACKTRACK_SEMPRED )
      {
        buf.append("{");
        buf.append(t.getText());
        buf.append("}?");
      }
      else if ( t.getType()==ANTLRParser.ARG_ACTION ) {
        buf.append("[");
        buf.append(t.getText());
        buf.append("]");
      }
      else {
        buf.append(t.getText());
      }
    }
    String ruleText = buf.toString();
    //System.out.println("[["+ruleText+"]]");
    // now put the rule into the lexer grammar template
View Full Code Here

  public GrammarAST(int t, String txt) {
    initialize(t,txt);
  }

  public void initialize(int i, String s) {
        token = new TokenWithIndex(i,s);
    }
View Full Code Here

  public GrammarAST(int t, String txt) {
    initialize(t,txt);
  }

  public void initialize(int i, String s) {
        token = new TokenWithIndex(i,s);
    }
View Full Code Here

  public GrammarAST(int t, String txt) {
    initialize(t,txt);
  }

  public void initialize(int i, String s) {
        token = new TokenWithIndex(i,s);
    }
View Full Code Here

TOP

Related Classes of antlr.TokenWithIndex

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.