Ejemplo n.º 1
0
  /**
   * Returns the first token in the linked list of tokens generated from <code>text</code>. This
   * method must be implemented by subclasses so they can correctly implement syntax highlighting.
   *
   * @param text The text from which to get tokens.
   * @param initialTokenType The token type we should start with.
   * @param startOffset The offset into the document at which <code>text</code> starts.
   * @return The first <code>Token</code> in a linked list representing the syntax highlighted text.
   */
  public Token getTokenList(Segment text, int initialTokenType, int startOffset) {

    resetTokenList();
    this.offsetShift = -text.offset + startOffset;

    // Start off in the proper state.
    int state = Token.NULL;
    switch (initialTokenType) {
      case Token.LITERAL_STRING_DOUBLE_QUOTE:
        state = STRING;
        start = text.offset;
        break;
      case Token.LITERAL_CHAR:
        state = CHAR;
        start = text.offset;
        break;
      default:
        state = Token.NULL;
    }

    s = text;
    try {
      yyreset(zzReader);
      yybegin(state);
      return yylex();
    } catch (IOException ioe) {
      ioe.printStackTrace();
      return new Token();
    }
  }
Ejemplo n.º 2
0
  /**
   * Returns the first token in the linked list of tokens generated from <code>text</code>. This
   * method must be implemented by subclasses so they can correctly implement syntax highlighting.
   *
   * @param text The text from which to get tokens.
   * @param initialTokenType The token type we should start with.
   * @param startOffset The offset into the document at which <code>text</code> starts.
   * @return The first <code>Token</code> in a linked list representing the syntax highlighted text.
   */
  public Token getTokenList(Segment text, int initialTokenType, int startOffset) {

    resetTokenList();
    this.offsetShift = -text.offset + startOffset;
    cssPrevState = YYINITIAL; // Shouldn't be necessary

    // Start off in the proper state.
    int state = Token.NULL;
    switch (initialTokenType) {
      case Token.LITERAL_STRING_DOUBLE_QUOTE:
        state = CSS_STRING;
        break;
      case Token.LITERAL_CHAR:
        state = CSS_CHAR_LITERAL;
        break;
      case Token.COMMENT_MULTILINE:
        state = CSS_C_STYLE_COMMENT;
        break;
      case INTERNAL_CSS_PROPERTY:
        state = CSS_PROPERTY;
        break;
      case INTERNAL_CSS_VALUE:
        state = CSS_VALUE;
        break;
      default:
        if (initialTokenType < -1024) {
          int main = -(-initialTokenType & 0xffffff00);
          switch (main) {
            default: // Should never happen
            case INTERNAL_CSS_STRING:
              state = CSS_STRING;
              break;
            case INTERNAL_CSS_CHAR:
              state = CSS_CHAR_LITERAL;
              break;
            case INTERNAL_CSS_MLC:
              state = CSS_C_STYLE_COMMENT;
              break;
          }
          cssPrevState = -initialTokenType & 0xff;
        } else {
          state = Token.NULL;
        }
    }

    start = text.offset;
    s = text;
    try {
      yyreset(zzReader);
      yybegin(state);
      return yylex();
    } catch (IOException ioe) {
      ioe.printStackTrace();
      return new TokenImpl();
    }
  }
Ejemplo n.º 3
0
  /**
   * Returns the first token in the linked list of tokens generated from <code>text</code>. This
   * method must be implemented by subclasses so they can correctly implement syntax highlighting.
   *
   * @param text The text from which to get tokens.
   * @param initialTokenType The token type we should start with.
   * @param startOffset The offset into the document at which <code>text</code> starts.
   * @return The first <code>Token</code> in a linked list representing the syntax highlighted text.
   */
  public Token getTokenList(Segment text, int initialTokenType, int startOffset) {

    resetTokenList();
    this.offsetShift = -text.offset + startOffset;

    // Start off in the proper state.
    int state = Token.NULL;

    s = text;
    try {
      yyreset(zzReader);
      yybegin(state);
      return yylex();
    } catch (IOException ioe) {
      ioe.printStackTrace();
      return new TokenImpl();
    }
  }