You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Token.java 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright 2000-2013 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. /* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
  17. /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
  18. package com.vaadin.sass.internal.parser;
  19. /**
  20. * Describes the input token stream.
  21. */
  22. public class Token implements java.io.Serializable {
  23. /**
  24. * The version identifier for this Serializable class.
  25. * Increment only if the <i>serialized</i> form of the
  26. * class changes.
  27. */
  28. private static final long serialVersionUID = 1L;
  29. /**
  30. * An integer that describes the kind of this token. This numbering
  31. * system is determined by JavaCCParser, and a table of these numbers is
  32. * stored in the file ...Constants.java.
  33. */
  34. public int kind;
  35. /** The line number of the first character of this Token. */
  36. public int beginLine;
  37. /** The column number of the first character of this Token. */
  38. public int beginColumn;
  39. /** The line number of the last character of this Token. */
  40. public int endLine;
  41. /** The column number of the last character of this Token. */
  42. public int endColumn;
  43. /**
  44. * The string image of the token.
  45. */
  46. public String image;
  47. /**
  48. * A reference to the next regular (non-special) token from the input
  49. * stream. If this is the last token from the input stream, or if the
  50. * token manager has not read tokens beyond this one, this field is
  51. * set to null. This is true only if this token is also a regular
  52. * token. Otherwise, see below for a description of the contents of
  53. * this field.
  54. */
  55. public Token next;
  56. /**
  57. * This field is used to access special tokens that occur prior to this
  58. * token, but after the immediately preceding regular (non-special) token.
  59. * If there are no such special tokens, this field is set to null.
  60. * When there are more than one such special token, this field refers
  61. * to the last of these special tokens, which in turn refers to the next
  62. * previous special token through its specialToken field, and so on
  63. * until the first special token (whose specialToken field is null).
  64. * The next fields of special tokens refer to other special tokens that
  65. * immediately follow it (without an intervening regular token). If there
  66. * is no such token, this field is null.
  67. */
  68. public Token specialToken;
  69. /**
  70. * An optional attribute value of the Token.
  71. * Tokens which are not used as syntactic sugar will often contain
  72. * meaningful values that will be used later on by the compiler or
  73. * interpreter. This attribute value is often different from the image.
  74. * Any subclass of Token that actually wants to return a non-null value can
  75. * override this method as appropriate.
  76. */
  77. public Object getValue() {
  78. return null;
  79. }
  80. /**
  81. * No-argument constructor
  82. */
  83. public Token() {}
  84. /**
  85. * Constructs a new token for the specified Image.
  86. */
  87. public Token(int kind)
  88. {
  89. this(kind, null);
  90. }
  91. /**
  92. * Constructs a new token for the specified Image and Kind.
  93. */
  94. public Token(int kind, String image)
  95. {
  96. this.kind = kind;
  97. this.image = image;
  98. }
  99. /**
  100. * Returns the image.
  101. */
  102. public String toString()
  103. {
  104. return image;
  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. public static Token newToken(int ofKind)
  126. {
  127. return newToken(ofKind, null);
  128. }
  129. }
  130. /* JavaCC - OriginalChecksum=dad2146dc89e68f66e77382c9e448fb7 (do not edit this line) */