Package antlr.collections.impl

Examples of antlr.collections.impl.Vector


    println("public static readonly string[] tokenNames_ = new string[] {");
    tabs++;

    // Walk the token vocabulary and generate a Vector of strings
    // from the tokens.
    Vector v = grammar.tokenManager.getVocabulary();
    for (int i = 0; i < v.size(); i++)
    {
      String s = (String)v.elementAt(i);
      if (s == null)
      {
        s = "<"+String.valueOf(i)+">";
      }
      if ( !s.startsWith("\"") && !s.startsWith("<") ) {
        TokenSymbol ts = (TokenSymbol)grammar.tokenManager.getTokenSymbol(s);
        if ( ts!=null && ts.getParaphrase()!=null ) {
          s = StringUtils.stripFrontBack(ts.getParaphrase(), "\"", "\"");
        }
      }
      else if (s.startsWith("\"")) {
        s = StringUtils.stripFrontBack(s, "\"", "\"");
      }
      print(charFormatter.literalString(s));
      if (i != v.size()-1) {
        _print(",");
      }
      _println("");
    }
View Full Code Here


    currentOutput = null;
    exitIfError();
  }
  protected void genTokenDefinitions(TokenManager tm) throws IOException {
    // Generate a definition for each token type
    Vector v = tm.getVocabulary();

    // Do special tokens manually
    println("public const int EOF = " + Token.EOF_TYPE + ";");
    println("public const int NULL_TREE_LOOKAHEAD = " + Token.NULL_TREE_LOOKAHEAD + ";");

    for (int i = Token.MIN_USER_TYPE; i < v.size(); i++) {
      String s = (String)v.elementAt(i);
      if (s != null) {
        if ( s.startsWith("\"") ) {
          // a string literal
          StringLiteralSymbol sl = (StringLiteralSymbol)tm.getTokenSymbol(s);
          if ( sl==null ) {
View Full Code Here

    protected Vector handlers;


    public ExceptionSpec(Token label_) {
        label = label_;
        handlers = new Vector();
    }
View Full Code Here

        // Header
        println(tm.getName() + "    // output token vocab name");

        // Generate a definition for each token type
        Vector v = tm.getVocabulary();
        for (int i = Token.MIN_USER_TYPE; i < v.size(); i++) {
            String s = (String)v.elementAt(i);
            if (DEBUG_CODE_GENERATOR) {
                System.out.println("gen persistence file entry for: " + s);
            }
            if (s != null && !s.startsWith("<")) {
                // if literal, find label
View Full Code Here

    /** Set all fields back like one just created */
    private void reset() {
        tabs = 0;
        // Allocate list of bitsets tagged for code generation
        bitsetsUsed = new Vector();
        currentOutput = null;
        grammar = null;
        DEBUG_CODE_GENERATOR = false;
        makeSwitchThreshold = DEFAULT_MAKE_SWITCH_THRESHOLD;
        bitsetTestThreshold = DEFAULT_BITSET_TEST_THRESHOLD;
View Full Code Here

    // Turning this off will suppress stuff
    // like the if-then-else ambig.

    public AlternativeBlock(Grammar g) {
        super(g);
        alternatives = new Vector(5);
        this.not = false;
        nblks++;
        ID = nblks;
    }
View Full Code Here

        ID = nblks;
    }

    public AlternativeBlock(Grammar g, Token start, boolean not) {
        super(g, start);
        alternatives = new Vector(5);
//    this.line = start.getLine();
//    this.column = start.getColumn();
        this.not = not;
        nblks++;
        ID = nblks;
View Full Code Here

    Token t=null;
    Token t2=null;
   
      StringBuffer buf = new StringBuffer();
      int n=0;
      Vector terms = new Vector(10);
   
   
    _saveIndex=text.length();
    match('(');
    text.setLength(_saveIndex);
    {
    switch ( LA(1)) {
    case '\t'case '\n'case '\r'case ' ':
    {
      _saveIndex=text.length();
      mWS(false);
      text.setLength(_saveIndex);
      break;
    }
    case '"'case '#'case '('case ':':
    case 'A'case 'B'case 'C'case 'D':
    case 'E'case 'F'case 'G'case 'H':
    case 'I'case 'J'case 'K'case 'L':
    case 'M'case 'N'case 'O'case 'P':
    case 'Q'case 'R'case 'S'case 'T':
    case 'U'case 'V'case 'W'case 'X':
    case 'Y'case 'Z'case '['case '_':
    case 'a'case 'b'case 'c'case 'd':
    case 'e'case 'f'case 'g'case 'h':
    case 'i'case 'j'case 'k'case 'l':
    case 'm'case 'n'case 'o'case 'p':
    case 'q'case 'r'case 's'case 't':
    case 'u'case 'v'case 'w'case 'x':
    case 'y'case 'z':
    {
      break;
    }
    default:
    {
      throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
    }
    }
    }
    _saveIndex=text.length();
    mTREE_ELEMENT(true);
    text.setLength(_saveIndex);
    t=_returnToken;
   
          terms.appendElement(
            generator.processStringForASTConstructor(t.getText())
                       );
       
    {
    switch ( LA(1)) {
    case '\t'case '\n'case '\r'case ' ':
    {
      _saveIndex=text.length();
      mWS(false);
      text.setLength(_saveIndex);
      break;
    }
    case ')'case ',':
    {
      break;
    }
    default:
    {
      throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
    }
    }
    }
    {
    _loop262:
    do {
      if ((LA(1)==',')) {
        _saveIndex=text.length();
        match(',');
        text.setLength(_saveIndex);
        {
        switch ( LA(1)) {
        case '\t'case '\n'case '\r'case ' ':
        {
          _saveIndex=text.length();
          mWS(false);
          text.setLength(_saveIndex);
          break;
        }
        case '"'case '#'case '('case ':':
        case 'A'case 'B'case 'C'case 'D':
        case 'E'case 'F'case 'G'case 'H':
        case 'I'case 'J'case 'K'case 'L':
        case 'M'case 'N'case 'O'case 'P':
        case 'Q'case 'R'case 'S'case 'T':
        case 'U'case 'V'case 'W'case 'X':
        case 'Y'case 'Z'case '['case '_':
        case 'a'case 'b'case 'c'case 'd':
        case 'e'case 'f'case 'g'case 'h':
        case 'i'case 'j'case 'k'case 'l':
        case 'm'case 'n'case 'o'case 'p':
        case 'q'case 'r'case 's'case 't':
        case 'u'case 'v'case 'w'case 'x':
        case 'y'case 'z':
        {
          break;
        }
        default:
        {
          throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
        }
        }
        }
        _saveIndex=text.length();
        mTREE_ELEMENT(true);
        text.setLength(_saveIndex);
        t2=_returnToken;
       
                terms.appendElement(
                  generator.processStringForASTConstructor(t2.getText())
                              );
             
        {
        switch ( LA(1)) {
View Full Code Here

        println("token identifiers.  Some tokens are literals, and because of that");
        println("they have no identifiers.  Literals are double-quoted.");
        tabs++;

        // Enumerate all the valid token types
        Vector v = tm.getVocabulary();
        for (int i = Token.MIN_USER_TYPE; i < v.size(); i++) {
            String s = (String)v.elementAt(i);
            if (s != null) {
                println(s + " = " + i);
            }
        }
View Full Code Here

    /** Construct a named rule. */
    public RuleBlock(Grammar g, String r) {
        super(g);
        ruleName = r;
        labeledElements = new Vector();
        cache = new Lookahead[g.maxk + 1];
        exceptionSpecs = new Hashtable();
        setAutoGen(g instanceof ParserGrammar);
    }
View Full Code Here

TOP

Related Classes of antlr.collections.impl.Vector

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.