--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.sql.compile.CharStream\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.sql.compile;\r
+\r
+/**\r
+ * This interface describes a character stream that maintains line and\r
+ * column number positions of the characters. It also has the capability\r
+ * to backup the stream to some extent. An implementation of this\r
+ * interface is used in the TokenManager implementation generated by\r
+ * JavaCCParser.\r
+ *\r
+ * All the methods except backup can be implemented in any fashion. backup\r
+ * needs to be implemented correctly for the correct operation of the lexer.\r
+ * Rest of the methods are all used to get information like line number,\r
+ * column number and the String that constitutes a token and are not used\r
+ * by the lexer. Hence their implementation won't affect the generated lexer's\r
+ * operation.\r
+ */\r
+\r
+public interface CharStream {\r
+\r
+ /**\r
+ * Returns the next character from the selected input. The method\r
+ * of selecting the input is the responsibility of the class\r
+ * implementing this interface. Can throw any java.io.IOException.\r
+ */\r
+ char readChar() throws java.io.IOException;\r
+\r
+ /**\r
+ * Returns the column position of the character last read.\r
+ * @deprecated\r
+ * @see #getEndColumn\r
+ */\r
+ int getColumn();\r
+\r
+ /**\r
+ * Returns the line number of the character last read.\r
+ * @deprecated\r
+ * @see #getEndLine\r
+ */\r
+ int getLine();\r
+\r
+ /**\r
+ * Returns the column number of the last character for current token (being\r
+ * matched after the last call to BeginTOken).\r
+ */\r
+ int getEndColumn();\r
+\r
+ /**\r
+ * Returns the line number of the last character for current token (being\r
+ * matched after the last call to BeginTOken).\r
+ */\r
+ int getEndLine();\r
+\r
+ /**\r
+ * Returns the column number of the first character for current token (being\r
+ * matched after the last call to BeginTOken).\r
+ */\r
+ int getBeginColumn();\r
+\r
+ /**\r
+ * Returns the line number of the first character for current token (being\r
+ * matched after the last call to BeginTOken).\r
+ */\r
+ int getBeginLine();\r
+\r
+ /**\r
+ * Backs up the input stream by amount steps. Lexer calls this method if it\r
+ * had already read some characters, but could not use them to match a\r
+ * (longer) token. So, they will be used again as the prefix of the next\r
+ * token and it is the implemetation's responsibility to do this right.\r
+ */\r
+ void backup(int amount);\r
+\r
+ /**\r
+ * Returns the next character that marks the beginning of the next token.\r
+ * All characters must remain in the buffer between two successive calls\r
+ * to this method to implement backup correctly.\r
+ */\r
+ char BeginToken() throws java.io.IOException;\r
+\r
+ /**\r
+ * Returns a string made up of characters from the marked token beginning\r
+ * to the current buffer position. Implementations have the choice of returning\r
+ * anything that they want to. For example, for efficiency, one might decide\r
+ * to just return null, which is a valid implementation.\r
+ */\r
+ String GetImage();\r
+\r
+ /**\r
+ * Returns an array of characters that make up the suffix of length 'len' for\r
+ * the currently matched token. This is used to build up the matched string\r
+ * for use in actions in the case of MORE. A simple and inefficient\r
+ * implementation of this is as follows :\r
+ *\r
+ * {\r
+ * String t = GetImage();\r
+ * return t.substring(t.length() - len, t.length()).toCharArray();\r
+ * }\r
+ */\r
+ char[] GetSuffix(int len);\r
+\r
+ /**\r
+ * The lexer calls this function to indicate that it is done with the stream\r
+ * and hence implementations can free any resources held by this class.\r
+ * Again, the body of this function can be just empty and it will not\r
+ * affect the lexer's operation.\r
+ */\r
+ void Done();\r
+\r
+\r
+ // This method was added to support ability to get the input\r
+ // between two tokens.\r
+ abstract int getBeginOffset();\r
+\r
+ // This method was added to support ability to get the input\r
+ // between two tokens.\r
+ abstract int getEndOffset();\r
+\r
+ // These methods were added to support re-initialization of CharStreams\r
+ abstract void ReInit(java.io.Reader dstream,\r
+ int startline, int startcolumn, int buffersize);\r
+\r
+ abstract void ReInit(java.io.Reader dstream, int startline, int startcolumn);\r
+\r
+ abstract void ReInit(java.io.InputStream dstream, int startline,\r
+ int startcolumn, int buffersize);\r
+\r
+ abstract void ReInit(java.io.InputStream dstream, int startline,\r
+ int startcolumn);\r
+\r
+}\r