~ubuntu-branches/ubuntu/vivid/herold/vivid

« back to all changes in this revision

Viewing changes to java/org/dbdoclet/trafo/xml/tokenizer/parser/Token.java

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2012-09-20 10:00:14 UTC
  • Revision ID: package-import@ubuntu.com-20120920100014-5pcwbw2err6on8yg
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (C) 2001-2012 Michael Fuchs
 
3
 *
 
4
 * This file is part of herold.
 
5
 * 
 
6
 * herold is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation, either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 * 
 
11
 * herold is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 * 
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with herold.  If not, see <http://www.gnu.org/licenses/>.  
 
18
 */
 
19
package org.dbdoclet.trafo.xml.tokenizer.parser;
 
20
 
 
21
/**
 
22
 * Describes the input token stream.
 
23
 */
 
24
 
 
25
@SuppressWarnings("all")
 
26
public class Token implements java.io.Serializable {
 
27
 
 
28
  /**
 
29
   * The version identifier for this Serializable class.
 
30
   * Increment only if the <i>serialized</i> form of the
 
31
   * class changes.
 
32
   */
 
33
  private static final long serialVersionUID = 1L;
 
34
 
 
35
  /**
 
36
   * An integer that describes the kind of this token.  This numbering
 
37
   * system is determined by JavaCCParser, and a table of these numbers is
 
38
   * stored in the file ...Constants.java.
 
39
   */
 
40
  public int kind;
 
41
 
 
42
  /** The line number of the first character of this Token. */
 
43
  public int beginLine;
 
44
  /** The column number of the first character of this Token. */
 
45
  public int beginColumn;
 
46
  /** The line number of the last character of this Token. */
 
47
  public int endLine;
 
48
  /** The column number of the last character of this Token. */
 
49
  public int endColumn;
 
50
 
 
51
  /**
 
52
   * The string image of the token.
 
53
   */
 
54
  public String image;
 
55
 
 
56
  /**
 
57
   * A reference to the next regular (non-special) token from the input
 
58
   * stream.  If this is the last token from the input stream, or if the
 
59
   * token manager has not read tokens beyond this one, this field is
 
60
   * set to null.  This is true only if this token is also a regular
 
61
   * token.  Otherwise, see below for a description of the contents of
 
62
   * this field.
 
63
   */
 
64
  public Token next;
 
65
 
 
66
  /**
 
67
   * This field is used to access special tokens that occur prior to this
 
68
   * token, but after the immediately preceding regular (non-special) token.
 
69
   * If there are no such special tokens, this field is set to null.
 
70
   * When there are more than one such special token, this field refers
 
71
   * to the last of these special tokens, which in turn refers to the next
 
72
   * previous special token through its specialToken field, and so on
 
73
   * until the first special token (whose specialToken field is null).
 
74
   * The next fields of special tokens refer to other special tokens that
 
75
   * immediately follow it (without an intervening regular token).  If there
 
76
   * is no such token, this field is null.
 
77
   */
 
78
  public Token specialToken;
 
79
 
 
80
  /**
 
81
   * An optional attribute value of the Token.
 
82
   * Tokens which are not used as syntactic sugar will often contain
 
83
   * meaningful values that will be used later on by the compiler or
 
84
   * interpreter. This attribute value is often different from the image.
 
85
   * Any subclass of Token that actually wants to return a non-null value can
 
86
   * override this method as appropriate.
 
87
   */
 
88
  public Object getValue() {
 
89
    return null;
 
90
  }
 
91
 
 
92
  /**
 
93
   * No-argument constructor
 
94
   */
 
95
  public Token() {}
 
96
 
 
97
  /**
 
98
   * Constructs a new token for the specified Image.
 
99
   */
 
100
  public Token(int kind)
 
101
  {
 
102
    this(kind, null);
 
103
  }
 
104
 
 
105
  /**
 
106
   * Constructs a new token for the specified Image and Kind.
 
107
   */
 
108
  public Token(int kind, String image)
 
109
  {
 
110
    this.kind = kind;
 
111
    this.image = image;
 
112
  }
 
113
 
 
114
  /**
 
115
   * Returns the image.
 
116
   */
 
117
  public String toString()
 
118
  {
 
119
    return image;
 
120
  }
 
121
 
 
122
  /**
 
123
   * Returns a new Token object, by default. However, if you want, you
 
124
   * can create and return subclass objects based on the value of ofKind.
 
125
   * Simply add the cases to the switch for all those special cases.
 
126
   * For example, if you have a subclass of Token called IDToken that
 
127
   * you want to create if ofKind is ID, simply add something like :
 
128
   *
 
129
   *    case MyParserConstants.ID : return new IDToken(ofKind, image);
 
130
   *
 
131
   * to the following switch statement. Then you can cast matchedToken
 
132
   * variable to the appropriate type and use sit in your lexical actions.
 
133
   */
 
134
  public static Token newToken(int ofKind, String image)
 
135
  {
 
136
    switch(ofKind)
 
137
    {
 
138
      default : return new Token(ofKind, image);
 
139
    }
 
140
  }
 
141
 
 
142
  public static Token newToken(int ofKind)
 
143
  {
 
144
    return newToken(ofKind, null);
 
145
  }
 
146
 
 
147
}
 
148
/* JavaCC - OriginalChecksum=32dcceb3d060b8c3753de8b101388514 (do not edit this line) */