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