001/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
002/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
003/*
004
005 Copyright (c) 1998-2008 The Regents of the University of California.
006 All rights reserved.
007 Permission is hereby granted, without written agreement and without
008 license or royalty fees, to use, copy, modify, and distribute this
009 software and its documentation for any purpose, provided that the above
010 copyright notice and the following two paragraphs appear in all copies
011 of this software.
012
013 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
014 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
015 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
016 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
017 SUCH DAMAGE.
018
019 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
020 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
022 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
023 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
024 ENHANCEMENTS, OR MODIFICATIONS.
025
026                                        PT_COPYRIGHT_VERSION_3
027                                        COPYRIGHTENDKEY
028 */
029
030package ptolemy.moml.unit;
031
032/**
033 * Describes the input token stream.
034 */
035
036public class Token implements java.io.Serializable {
037
038    /**
039     * The version identifier for this Serializable class.
040     * Increment only if the <i>serialized</i> form of the
041     * class changes.
042     */
043    private static final long serialVersionUID = 1L;
044
045    /**
046     * An integer that describes the kind of this token.  This numbering
047     * system is determined by JavaCCParser, and a table of these numbers is
048     * stored in the file ...Constants.java.
049     */
050    public int kind;
051
052    /** The line number of the first character of this Token. */
053    public int beginLine;
054    /** The column number of the first character of this Token. */
055    public int beginColumn;
056    /** The line number of the last character of this Token. */
057    public int endLine;
058    /** The column number of the last character of this Token. */
059    public int endColumn;
060
061    /**
062     * The string image of the token.
063     */
064    public String image;
065
066    /**
067     * A reference to the next regular (non-special) token from the input
068     * stream.  If this is the last token from the input stream, or if the
069     * token manager has not read tokens beyond this one, this field is
070     * set to null.  This is true only if this token is also a regular
071     * token.  Otherwise, see below for a description of the contents of
072     * this field.
073     */
074    public Token next;
075
076    /**
077     * This field is used to access special tokens that occur prior to this
078     * token, but after the immediately preceding regular (non-special) token.
079     * If there are no such special tokens, this field is set to null.
080     * When there are more than one such special token, this field refers
081     * to the last of these special tokens, which in turn refers to the next
082     * previous special token through its specialToken field, and so on
083     * until the first special token (whose specialToken field is null).
084     * The next fields of special tokens refer to other special tokens that
085     * immediately follow it (without an intervening regular token).  If there
086     * is no such token, this field is null.
087     */
088    public Token specialToken;
089
090    /**
091     * An optional attribute value of the Token.
092     * Tokens which are not used as syntactic sugar will often contain
093     * meaningful values that will be used later on by the compiler or
094     * interpreter. This attribute value is often different from the image.
095     * Any subclass of Token that actually wants to return a non-null value can
096     * override this method as appropriate.
097     */
098    public Object getValue() {
099        return null;
100    }
101
102    /**
103     * No-argument constructor
104     */
105    public Token() {
106    }
107
108    /**
109     * Constructs a new token for the specified Image.
110     */
111    public Token(int kind) {
112        this(kind, null);
113    }
114
115    /**
116     * Constructs a new token for the specified Image and Kind.
117     */
118    public Token(int kind, String image) {
119        this.kind = kind;
120        this.image = image;
121    }
122
123    /**
124     * Returns the image.
125     */
126    @Override
127    public String toString() {
128        return image;
129    }
130
131    /**
132     * Returns a new Token object, by default. However, if you want, you
133     * can create and return subclass objects based on the value of ofKind.
134     * Simply add the cases to the switch for all those special cases.
135     * For example, if you have a subclass of Token called IDToken that
136     * you want to create if ofKind is ID, simply add something like :
137     *
138     *    case MyParserConstants.ID : return new IDToken(ofKind, image);
139     *
140     * to the following switch statement. Then you can cast matchedToken
141     * variable to the appropriate type and use sit in your lexical actions.
142     */
143    public static Token newToken(int ofKind, String image) {
144        switch (ofKind) {
145        default:
146            return new Token(ofKind, image);
147        }
148    }
149
150    public static Token newToken(int ofKind) {
151        return newToken(ofKind, null);
152    }
153
154}
155/* JavaCC - OriginalChecksum=9d61a4099088670f2e0ffa3dbdc0936a (do not edit this line) */