View Javadoc

    1   /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
    2   /***
    3    * JSP Parser for PMD.
    4    * @author Pieter � Application Engineers NV/SA � http://www.ae.be
    5    */
    6
    7   package net.sourceforge.pmd.jsp.ast;
    8
    9   /***
    10   * Describes the input token stream.
    11   */
    12
    13  public class Token {
    14
    15      /***
    16       * An integer that describes the kind of this token.  This numbering
    17       * system is determined by JavaCCParser, and a table of these numbers is
    18       * stored in the file ...Constants.java.
    19       */
    20      public int kind;
    21
    22      /***
    23       * beginLine and beginColumn describe the position of the first character
    24       * of this token; endLine and endColumn describe the position of the
    25       * last character of this token.
    26       */
    27      public int beginLine, beginColumn, endLine, endColumn;
    28
    29      /***
    30       * The string image of the token.
    31       */
    32      public String image;
    33
    34      /***
    35       * A reference to the next regular (non-special) token from the input
    36       * stream.  If this is the last token from the input stream, or if the
    37       * token manager has not read tokens beyond this one, this field is
    38       * set to null.  This is true only if this token is also a regular
    39       * token.  Otherwise, see below for a description of the contents of
    40       * this field.
    41       */
    42      public Token next;
    43
    44      /***
    45       * This field is used to access special tokens that occur prior to this
    46       * token, but after the immediately preceding regular (non-special) token.
    47       * If there are no such special tokens, this field is set to null.
    48       * When there are more than one such special token, this field refers
    49       * to the last of these special tokens, which in turn refers to the next
    50       * previous special token through its specialToken field, and so on
    51       * until the first special token (whose specialToken field is null).
    52       * The next fields of special tokens refer to other special tokens that
    53       * immediately follow it (without an intervening regular token).  If there
    54       * is no such token, this field is null.
    55       */
    56      public Token specialToken;
    57
    58      /***
    59       * Returns the image.
    60       */
    61      public String toString() {
    62          return image;
    63      }
    64
    65      /***
    66       * Returns a new Token object, by default. However, if you want, you
    67       * can create and return subclass objects based on the value of ofKind.
    68       * Simply add the cases to the switch for all those special cases.
    69       * For example, if you have a subclass of Token called IDToken that
    70       * you want to create if ofKind is ID, simlpy add something like :
    71       * <p/>
    72       * case MyParserConstants.ID : return new IDToken();
    73       * <p/>
    74       * to the following switch statement. Then you can cast matchedToken
    75       * variable to the appropriate type and use it in your lexical actions.
    76       */
    77      public static final Token newToken(int ofKind) {
    78          switch (ofKind) {
    79              default :
    80                  return new Token();
    81          }
    82      }
    83
    84  }