22 namespace Lucene.Net.QueryParsers
33 internal char[] buffer = null;
35 internal int bufferLength = 0;
36 internal int bufferPosition = 0;
38 internal int tokenStart = 0;
39 internal int bufferStart = 0;
41 internal System.IO.TextReader input;
49 public char ReadChar()
51 if (bufferPosition >= bufferLength)
53 return buffer[bufferPosition++];
58 int newPosition = bufferLength - tokenStart;
66 buffer =
new char[2048];
68 else if (bufferLength == buffer.Length)
71 char[] newBuffer =
new char[buffer.Length * 2];
72 Array.Copy(buffer, 0, newBuffer, 0, bufferLength);
79 Array.Copy(buffer, tokenStart, buffer, 0, newPosition);
82 bufferLength = newPosition;
83 bufferPosition = newPosition;
84 bufferStart += tokenStart;
87 int charsRead = input.Read(buffer, newPosition, buffer.Length - newPosition);
89 throw new System.IO.IOException(
"read past eof");
91 bufferLength += charsRead;
94 public char BeginToken()
96 tokenStart = bufferPosition;
100 public void Backup(
int amount)
102 bufferPosition -= amount;
107 get {
return new System.String(buffer, tokenStart, bufferPosition - tokenStart); }
110 public char[] GetSuffix(
int len)
112 char[] value_Renamed =
new char[len];
113 Array.Copy(buffer, bufferPosition - len, value_Renamed, 0, len);
114 return value_Renamed;
123 catch (System.IO.IOException e)
125 System.Console.Error.WriteLine(
"Caught: " + e +
"; ignoring.");
131 get {
return bufferStart + bufferPosition; }
141 get {
return bufferStart + bufferPosition; }
149 public int BeginColumn
151 get {
return bufferStart + tokenStart; }