001/* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */ 002/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ 003package jmri.jmrix.srcp.parser; 004 005/* 006 * Describes the input token stream. 007 */ 008 009public class Token implements java.io.Serializable { 010 011 /* 012 * The version identifier for this Serializable class. 013 * Increment only if the <i>serialized</i> form of the 014 * class changes. 015 */ 016 private static final long serialVersionUID = 1L; 017 018 /* 019 * An integer that describes the kind of this token. This numbering 020 * system is determined by JavaCCParser, and a table of these numbers is 021 * stored in the file ...Constants.java. 022 */ 023 public int kind; 024 025 /* The line number of the first character of this Token. */ 026 public int beginLine; 027 /* The column number of the first character of this Token. */ 028 public int beginColumn; 029 /* The line number of the last character of this Token. */ 030 public int endLine; 031 /* The column number of the last character of this Token. */ 032 public int endColumn; 033 034 /* 035 * The string image of the token. 036 */ 037 public String image; 038 039 /* 040 * A reference to the next regular (non-special) token from the input 041 * stream. If this is the last token from the input stream, or if the 042 * token manager has not read tokens beyond this one, this field is 043 * set to null. This is true only if this token is also a regular 044 * token. Otherwise, see below for a description of the contents of 045 * this field. 046 */ 047 public Token next; 048 049 /* 050 * This field is used to access special tokens that occur prior to this 051 * token, but after the immediately preceding regular (non-special) token. 052 * If there are no such special tokens, this field is set to null. 053 * When there are more than one such special token, this field refers 054 * to the last of these special tokens, which in turn refers to the next 055 * previous special token through its specialToken field, and so on 056 * until the first special token (whose specialToken field is null). 057 * The next fields of special tokens refer to other special tokens that 058 * immediately follow it (without an intervening regular token). If there 059 * is no such token, this field is null. 060 */ 061 public Token specialToken; 062 063 /* 064 * An optional attribute value of the Token. 065 * Tokens which are not used as syntactic sugar will often contain 066 * meaningful values that will be used later on by the compiler or 067 * interpreter. This attribute value is often different from the image. 068 * Any subclass of Token that actually wants to return a non-null value can 069 * override this method as appropriate. 070 */ 071 public Object getValue() { 072 return null; 073 } 074 075 /* 076 * No-argument constructor 077 */ 078 public Token() {} 079 080 /* 081 * Constructs a new token for the specified Image. 082 */ 083 public Token(int kind) 084 { 085 this(kind, null); 086 } 087 088 /* 089 * Constructs a new token for the specified Image and Kind. 090 */ 091 public Token(int kind, String image) 092 { 093 this.kind = kind; 094 this.image = image; 095 } 096 097 /* 098 * Returns the image. 099 */ 100 @Override 101 public String toString() 102 { 103 return image; 104 } 105 106 /* 107 * Returns a new Token object, by default. However, if you want, you 108 * can create and return subclass objects based on the value of ofKind. 109 * Simply add the cases to the switch for all those special cases. 110 * For example, if you have a subclass of Token called IDToken that 111 * you want to create if ofKind is ID, simply add something like : 112 * 113 * case MyParserConstants.ID : return new IDToken(ofKind, image); 114 * 115 * to the following switch statement. Then you can cast matchedToken 116 * variable to the appropriate type and use sit in your lexical actions. 117 */ 118 public static Token newToken(int ofKind, String image) 119 { 120 switch(ofKind) 121 { 122 default : return new Token(ofKind, image); 123 } 124 } 125 126 public static Token newToken(int ofKind) 127 { 128 return newToken(ofKind, null); 129 } 130 131} 132/* JavaCC - OriginalChecksum=5ca78608f3b3dd49ead75046f6109d26 (do not edit this line) */