001 /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
002 package bsh;
003 /*
004 This file has been modified for BeanShell to make Token serializable.
005 If this file is regenerated please make this change.
006
007 All BeanShell modifications are demarcated by "Begin BeanShell
008 Modification - ... " and "End BeanShell Modification - ..."
009 */
010
011 /**
012 * Describes the input token stream.
013 */
014
015 // Begin BeanShell Modification - serializable
016 public class Token implements java.io.Serializable {
017 // End BeanShell Modification - serializable
018
019 /**
020 * An integer that describes the kind of this token. This numbering
021 * system is determined by JavaCCParser, and a table of these numbers is
022 * stored in the file ...Constants.java.
023 */
024 public int kind;
025
026 /**
027 * beginLine and beginColumn describe the position of the first character
028 * of this token; endLine and endColumn describe the position of the
029 * last character of this token.
030 */
031 public int beginLine, beginColumn, endLine, endColumn;
032
033 /**
034 * The string image of the token.
035 */
036 public String image;
037
038 /**
039 * A reference to the next regular (non-special) token from the input
040 * stream. If this is the last token from the input stream, or if the
041 * token manager has not read tokens beyond this one, this field is
042 * set to null. This is true only if this token is also a regular
043 * token. Otherwise, see below for a description of the contents of
044 * this field.
045 */
046 public Token next;
047
048 /**
049 * This field is used to access special tokens that occur prior to this
050 * token, but after the immediately preceding regular (non-special) token.
051 * If there are no such special tokens, this field is set to null.
052 * When there are more than one such special token, this field refers
053 * to the last of these special tokens, which in turn refers to the next
054 * previous special token through its specialToken field, and so on
055 * until the first special token (whose specialToken field is null).
056 * The next fields of special tokens refer to other special tokens that
057 * immediately follow it (without an intervening regular token). If there
058 * is no such token, this field is null.
059 */
060 public Token specialToken;
061
062 /**
063 * Returns the image.
064 */
065 public String toString()
066 {
067 return image;
068 }
069
070 /**
071 * Returns a new Token object, by default. However, if you want, you
072 * can create and return subclass objects based on the value of ofKind.
073 * Simply add the cases to the switch for all those special cases.
074 * For example, if you have a subclass of Token called IDToken that
075 * you want to create if ofKind is ID, simlpy add something like :
076 *
077 * case MyParserConstants.ID : return new IDToken();
078 *
079 * to the following switch statement. Then you can cast matchedToken
080 * variable to the appropriate type and use it in your lexical actions.
081 */
082 public static final Token newToken(int ofKind)
083 {
084 switch(ofKind)
085 {
086 default : return new Token();
087 }
088 }
089
090 }