Token.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
  2. /**
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. package com.yahoo.jute.compiler.generated;
  20. /**
  21. * Describes the input token stream.
  22. */
  23. public class Token {
  24. /**
  25. * An integer that describes the kind of this token. This numbering
  26. * system is determined by JavaCCParser, and a table of these numbers is
  27. * stored in the file ...Constants.java.
  28. */
  29. public int kind;
  30. /**
  31. * beginLine and beginColumn describe the position of the first character
  32. * of this token; endLine and endColumn describe the position of the
  33. * last character of this token.
  34. */
  35. public int beginLine, beginColumn, endLine, endColumn;
  36. /**
  37. * The string image of the token.
  38. */
  39. public String image;
  40. /**
  41. * A reference to the next regular (non-special) token from the input
  42. * stream. If this is the last token from the input stream, or if the
  43. * token manager has not read tokens beyond this one, this field is
  44. * set to null. This is true only if this token is also a regular
  45. * token. Otherwise, see below for a description of the contents of
  46. * this field.
  47. */
  48. public Token next;
  49. /**
  50. * This field is used to access special tokens that occur prior to this
  51. * token, but after the immediately preceding regular (non-special) token.
  52. * If there are no such special tokens, this field is set to null.
  53. * When there are more than one such special token, this field refers
  54. * to the last of these special tokens, which in turn refers to the next
  55. * previous special token through its specialToken field, and so on
  56. * until the first special token (whose specialToken field is null).
  57. * The next fields of special tokens refer to other special tokens that
  58. * immediately follow it (without an intervening regular token). If there
  59. * is no such token, this field is null.
  60. */
  61. public Token specialToken;
  62. /**
  63. * Returns the image.
  64. */
  65. public String toString()
  66. {
  67. return image;
  68. }
  69. /**
  70. * Returns a new Token object, by default. However, if you want, you
  71. * can create and return subclass objects based on the value of ofKind.
  72. * Simply add the cases to the switch for all those special cases.
  73. * For example, if you have a subclass of Token called IDToken that
  74. * you want to create if ofKind is ID, simlpy add something like :
  75. *
  76. * case MyParserConstants.ID : return new IDToken();
  77. *
  78. * to the following switch statement. Then you can cast matchedToken
  79. * variable to the appropriate type and use it in your lexical actions.
  80. */
  81. public static final Token newToken(int ofKind)
  82. {
  83. switch(ofKind)
  84. {
  85. default : return new Token();
  86. }
  87. }
  88. }