Token.java 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
  2. package de.jplag.java15.grammar;
  3. /**
  4. * Describes the input token stream.
  5. */
  6. public class Token {
  7. /**
  8. * An integer that describes the kind of this token. This numbering
  9. * system is determined by JavaCCParser, and a table of these numbers is
  10. * stored in the file ...Constants.java.
  11. */
  12. public int kind;
  13. /**
  14. * beginLine and beginColumn describe the position of the first character
  15. * of this token; endLine and endColumn describe the position of the
  16. * last character of this token.
  17. */
  18. public int beginLine, beginColumn, endLine, endColumn;
  19. /**
  20. * The string image of the token.
  21. */
  22. public String image;
  23. /**
  24. * A reference to the next regular (non-special) token from the input
  25. * stream. If this is the last token from the input stream, or if the
  26. * token manager has not read tokens beyond this one, this field is
  27. * set to null. This is true only if this token is also a regular
  28. * token. Otherwise, see below for a description of the contents of
  29. * this field.
  30. */
  31. public Token next;
  32. /**
  33. * This field is used to access special tokens that occur prior to this
  34. * token, but after the immediately preceding regular (non-special) token.
  35. * If there are no such special tokens, this field is set to null.
  36. * When there are more than one such special token, this field refers
  37. * to the last of these special tokens, which in turn refers to the next
  38. * previous special token through its specialToken field, and so on
  39. * until the first special token (whose specialToken field is null).
  40. * The next fields of special tokens refer to other special tokens that
  41. * immediately follow it (without an intervening regular token). If there
  42. * is no such token, this field is null.
  43. */
  44. public Token specialToken;
  45. /**
  46. * Returns the image.
  47. */
  48. @Override
  49. public String toString()
  50. {
  51. return image;
  52. }
  53. /**
  54. * Returns a new Token object, by default. However, if you want, you
  55. * can create and return subclass objects based on the value of ofKind.
  56. * Simply add the cases to the switch for all those special cases.
  57. * For example, if you have a subclass of Token called IDToken that
  58. * you want to create if ofKind is ID, simlpy add something like :
  59. *
  60. * case MyParserConstants.ID : return new IDToken();
  61. *
  62. * to the following switch statement. Then you can cast matchedToken
  63. * variable to the appropriate type and use it in your lexical actions.
  64. */
  65. public static final Token newToken(int ofKind)
  66. {
  67. switch(ofKind)
  68. {
  69. case JavaParserConstants.RUNSIGNEDSHIFT:
  70. case JavaParserConstants.RSIGNEDSHIFT:
  71. case JavaParserConstants.GT:
  72. return new GTToken();
  73. default:
  74. return new Token();
  75. }
  76. }
  77. public static class GTToken extends Token {
  78. int realKind = JavaParserConstants.GT;
  79. }
  80. }