/bundles/plugins-trunk/XML/sidekick/css/parser/CharStream.java

# · Java · 110 lines · 15 code · 15 blank · 80 comment · 0 complexity · 7d60f505329ffb4e6839ee457b72e760 MD5 · raw file

  1. /* Generated By:JavaCC: Do not edit this line. CharStream.java Version 4.0 */
  2. package sidekick.css.parser;
  3. /**
  4. * This interface describes a character stream that maintains line and
  5. * column number positions of the characters. It also has the capability
  6. * to backup the stream to some extent. An implementation of this
  7. * interface is used in the TokenManager implementation generated by
  8. * JavaCCParser.
  9. *
  10. * All the methods except backup can be implemented in any fashion. backup
  11. * needs to be implemented correctly for the correct operation of the lexer.
  12. * Rest of the methods are all used to get information like line number,
  13. * column number and the String that constitutes a token and are not used
  14. * by the lexer. Hence their implementation won't affect the generated lexer's
  15. * operation.
  16. */
  17. public interface CharStream {
  18. /**
  19. * Returns the next character from the selected input. The method
  20. * of selecting the input is the responsibility of the class
  21. * implementing this interface. Can throw any java.io.IOException.
  22. */
  23. char readChar() throws java.io.IOException;
  24. /**
  25. * Returns the column position of the character last read.
  26. * @deprecated
  27. * @see #getEndColumn
  28. */
  29. int getColumn();
  30. /**
  31. * Returns the line number of the character last read.
  32. * @deprecated
  33. * @see #getEndLine
  34. */
  35. int getLine();
  36. /**
  37. * Returns the column number of the last character for current token (being
  38. * matched after the last call to BeginTOken).
  39. */
  40. int getEndColumn();
  41. /**
  42. * Returns the line number of the last character for current token (being
  43. * matched after the last call to BeginTOken).
  44. */
  45. int getEndLine();
  46. /**
  47. * Returns the column number of the first character for current token (being
  48. * matched after the last call to BeginTOken).
  49. */
  50. int getBeginColumn();
  51. /**
  52. * Returns the line number of the first character for current token (being
  53. * matched after the last call to BeginTOken).
  54. */
  55. int getBeginLine();
  56. /**
  57. * Backs up the input stream by amount steps. Lexer calls this method if it
  58. * had already read some characters, but could not use them to match a
  59. * (longer) token. So, they will be used again as the prefix of the next
  60. * token and it is the implemetation's responsibility to do this right.
  61. */
  62. void backup(int amount);
  63. /**
  64. * Returns the next character that marks the beginning of the next token.
  65. * All characters must remain in the buffer between two successive calls
  66. * to this method to implement backup correctly.
  67. */
  68. char BeginToken() throws java.io.IOException;
  69. /**
  70. * Returns a string made up of characters from the marked token beginning
  71. * to the current buffer position. Implementations have the choice of returning
  72. * anything that they want to. For example, for efficiency, one might decide
  73. * to just return null, which is a valid implementation.
  74. */
  75. String GetImage();
  76. /**
  77. * Returns an array of characters that make up the suffix of length 'len' for
  78. * the currently matched token. This is used to build up the matched string
  79. * for use in actions in the case of MORE. A simple and inefficient
  80. * implementation of this is as follows :
  81. *
  82. * {
  83. * String t = GetImage();
  84. * return t.substring(t.length() - len, t.length()).toCharArray();
  85. * }
  86. */
  87. char[] GetSuffix(int len);
  88. /**
  89. * The lexer calls this function to indicate that it is done with the stream
  90. * and hence implementations can free any resources held by this class.
  91. * Again, the body of this function can be just empty and it will not
  92. * affect the lexer's operation.
  93. */
  94. void Done();
  95. }