Package java_cup.runtime

Examples of java_cup.runtime.Symbol


    private Symbol makeSymbol(int id, Object o) {
        int iPrevPrevChar = iPrevChar;
        this.iPrevChar = iChar;
        this.previousSymbol = id;
        return trace(new Symbol(id, iPrevPrevChar, iChar, o));
    }
View Full Code Here


    for (int i = 0; i < argv.length; i++) {
      try {
        System.out.println("Lexing ["+argv[i]+"]");
        Scanner scanner = new Scanner(new UnicodeEscapes(new FileReader(argv[i])));
               
        Symbol s;
        do {
          s = scanner.debug_next_token();
          System.out.println("token: "+s);
        } while (s.sym != sym.EOF);
       
View Full Code Here

  public void setFile(File file) {
    this.file = file;
  }

  private Symbol symbol(int type, Object value) {
    return new Symbol(type, yyline, yycolumn, value);
  }
View Full Code Here

  private Symbol symbol(int type, Object value) {
    return new Symbol(type, yyline, yycolumn, value);
  }

  private Symbol symbol(int type) {
    return new Symbol(type, yyline, yycolumn);
  }
View Full Code Here

     for (int i=0; i < text.length(); i++) {
      char c = text.charAt(i);

      if (c != '\n' && c != '\r' && c != ' ' && c != '\t' )
        return new Symbol(type, lc, cc, value);

      if (c == '\n') {
        lc++;
        cc = 0;
      }
      else
        cc++;
    }
  
    return new Symbol(type, yyline, yycolumn, value);
  }
View Full Code Here

          { isPublic = true;
          }
        case 165: break;
        case 112:
          { actionText.setLength(0); yybegin(JAVA_CODE);
                                Symbol s = symbol_countUpdate(EOFRULE, null);
                                action_line = s.left+1;
                                return s;
          }
        case 166: break;
        case 40:
View Full Code Here

    advance();
  }

      /* advance past the closer and build a return Symbol */
      advance(); advance();
      return new Symbol(sym.CODE_STRING, result.toString());
    }
View Full Code Here

      result_str = result.toString();
      keyword_num = (Integer)keywords.get(result_str);

      /* if we found something, return that keyword */
      if (keyword_num != null)
  return new Symbol(keyword_num.intValue());

      /* otherwise build and return an id Symbol with an attached string */
      return new Symbol(sym.ID, result_str);
    }
View Full Code Here

   *  routine, prints a message on System.out indicating what the Symbol is,
   *  then returns it.
   */
  public static Symbol debug_next_token() throws java.io.IOException
    {
      Symbol result = real_next_token();
      System.out.println("# next_Symbol() => " + result.sym);
      return result;
    }
View Full Code Here

    sym_num = find_single_char(next_char);
    if (sym_num != -1)
      {
        /* found one -- advance past it and return a Symbol for it */
        advance();
        return new Symbol(sym_num);
      }

    /* look for : or ::= */
    if (next_char == ':')
      {
        /* if we don't have a second ':' return COLON */
        if (next_char2 != ':')
    {
      advance();
      return new Symbol(sym.COLON);
    }

        /* move forward and look for the '=' */
        advance();
        if (next_char2 == '=')
    {
      advance(); advance();
      return new Symbol(sym.COLON_COLON_EQUALS);
    }
        else
    {
      /* return just the colon (already consumed) */
      return new Symbol(sym.COLON);
    }
      }

    /* find a "%prec" string and return it.  otherwise, a '%' was found,
       which has no right being in the specification otherwise */
    if (next_char == '%') {
      advance();
      if ((next_char == 'p') && (next_char2 == 'r') && (next_char3 == 'e') &&
    (next_char4 == 'c')) {
        advance();
        advance();
        advance();
        advance();
        return new Symbol(sym.PERCENT_PREC);
      } else {
        emit_error("Found extraneous percent sign");
      }
    }

    /* look for a comment */
    if (next_char == '/' && (next_char2 == '*' || next_char2 == '/'))
      {
        /* swallow then continue the scan */
        swallow_comment();
        continue;
      }

    /* look for start of code string */
    if (next_char == '{' && next_char2 == ':')
      return do_code_string();

    /* look for an id or keyword */
    if (id_start_char(next_char)) return do_id();

    /* look for EOF */
    if (next_char == EOF_CHAR) return new Symbol(sym.EOF);

    /* if we get here, we have an unrecognized character */
    emit_warn("Unrecognized character '" +
      new Character((char)next_char) + "'(" + next_char +
      ") -- ignored");
View Full Code Here

TOP

Related Classes of java_cup.runtime.Symbol

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.