Token.java

  1. /* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
  2. /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
  3. package org.apache.commons.configuration2.plist;

  4. /**
  5.  * Describes the input token stream.
  6.  */

  7. public class Token implements java.io.Serializable {

  8.   /**
  9.    * The version identifier for this Serializable class.
  10.    * Increment only if the <i>serialized</i> form of the
  11.    * class changes.
  12.    */
  13.   private static final long serialVersionUID = 1L;

  14.   /**
  15.    * An integer that describes the kind of this token.  This numbering
  16.    * system is determined by JavaCCParser, and a table of these numbers is
  17.    * stored in the file ...Constants.java.
  18.    */
  19.   public int kind;

  20.   /** The line number of the first character of this Token. */
  21.   public int beginLine;
  22.   /** The column number of the first character of this Token. */
  23.   public int beginColumn;
  24.   /** The line number of the last character of this Token. */
  25.   public int endLine;
  26.   /** The column number of the last character of this Token. */
  27.   public int endColumn;

  28.   /**
  29.    * The string image of the token.
  30.    */
  31.   public String image;

  32.   /**
  33.    * A reference to the next regular (non-special) token from the input
  34.    * stream.  If this is the last token from the input stream, or if the
  35.    * token manager has not read tokens beyond this one, this field is
  36.    * set to null.  This is true only if this token is also a regular
  37.    * token.  Otherwise, see below for a description of the contents of
  38.    * this field.
  39.    */
  40.   public Token next;

  41.   /**
  42.    * This field is used to access special tokens that occur prior to this
  43.    * token, but after the immediately preceding regular (non-special) token.
  44.    * If there are no such special tokens, this field is set to null.
  45.    * When there are more than one such special token, this field refers
  46.    * to the last of these special tokens, which in turn refers to the next
  47.    * previous special token through its specialToken field, and so on
  48.    * until the first special token (whose specialToken field is null).
  49.    * The next fields of special tokens refer to other special tokens that
  50.    * immediately follow it (without an intervening regular token).  If there
  51.    * is no such token, this field is null.
  52.    */
  53.   public Token specialToken;

  54.   /**
  55.    * An optional attribute value of the Token.
  56.    * Tokens which are not used as syntactic sugar will often contain
  57.    * meaningful values that will be used later on by the compiler or
  58.    * interpreter. This attribute value is often different from the image.
  59.    * Any subclass of Token that actually wants to return a non-null value can
  60.    * override this method as appropriate.
  61.    */
  62.   public Object getValue() {
  63.     return null;
  64.   }

  65.   /**
  66.    * No-argument constructor
  67.    */
  68.   public Token() {}

  69.   /**
  70.    * Constructs a new token for the specified Image.
  71.    */
  72.   public Token(int kind)
  73.   {
  74.     this(kind, null);
  75.   }

  76.   /**
  77.    * Constructs a new token for the specified Image and Kind.
  78.    */
  79.   public Token(int kind, String image)
  80.   {
  81.     this.kind = kind;
  82.     this.image = image;
  83.   }

  84.   /**
  85.    * Returns the image.
  86.    */
  87.   public String toString()
  88.   {
  89.     return image;
  90.   }

  91.   /**
  92.    * Returns a new Token object, by default. However, if you want, you
  93.    * can create and return subclass objects based on the value of ofKind.
  94.    * Simply add the cases to the switch for all those special cases.
  95.    * For example, if you have a subclass of Token called IDToken that
  96.    * you want to create if ofKind is ID, simply add something like :
  97.    *
  98.    *    case MyParserConstants.ID : return new IDToken(ofKind, image);
  99.    *
  100.    * to the following switch statement. Then you can cast matchedToken
  101.    * variable to the appropriate type and use sit in your lexical actions.
  102.    */
  103.   public static Token newToken(int ofKind, String image)
  104.   {
  105.     switch(ofKind)
  106.     {
  107.       default : return new Token(ofKind, image);
  108.     }
  109.   }

  110.   public static Token newToken(int ofKind)
  111.   {
  112.     return newToken(ofKind, null);
  113.   }

  114. }
  115. /* JavaCC - OriginalChecksum=3d2e91ebfbd5613c7471a7af4ec5a1cf (do not edit this line) */