| Constructor: |
public ASCII_CharStream(Reader dstream,
int startline,
int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
|
public ASCII_CharStream(InputStream dstream,
int startline,
int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
|
public ASCII_CharStream(Reader dstream,
int startline,
int startcolumn,
int buffersize) {
inputStream = dstream;
line = startline;
column = startcolumn - 1;
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
}
|
public ASCII_CharStream(InputStream dstream,
int startline,
int startcolumn,
int buffersize) {
this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
|
| Method from net.bonzoun.cocodonkey.ASCII_CharStream Detail: |
public final char BeginToken() throws IOException {
tokenBegin = -1;
char c = readChar();
tokenBegin = bufpos;
return c;
}
|
public void Done() {
buffer = null;
bufline = null;
bufcolumn = null;
}
|
public final String GetImage() {
if (bufpos >= tokenBegin)
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
else
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
new String(buffer, 0, bufpos + 1);
}
|
public final char[] GetSuffix(int len) {
char[] ret = new char[len];
if ((bufpos + 1) >= len)
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
else
{
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
len - bufpos - 1);
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
}
return ret;
}
|
public void ReInit(Reader dstream,
int startline,
int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
|
public void ReInit(InputStream dstream,
int startline,
int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
|
public void ReInit(Reader dstream,
int startline,
int startcolumn,
int buffersize) {
inputStream = dstream;
line = startline;
column = startcolumn - 1;
if (buffer == null || buffersize != buffer.length)
{
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
}
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
bufpos = -1;
}
|
public void ReInit(InputStream dstream,
int startline,
int startcolumn,
int buffersize) {
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
|
public void adjustBeginLineColumn(int newLine,
int newCol) {
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextColDiff = 0, columnDiff = 0;
while (i < len &&
bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
{
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
i++;
}
if (i < len)
{
bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len)
{
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
bufline[j] = newLine++;
else
bufline[j] = newLine;
}
}
line = bufline[j];
column = bufcolumn[j];
}
Method to adjust line and column numbers for the start of a token.
|
public final void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
bufpos += bufsize;
}
|
public final int getBeginColumn() {
return bufcolumn[tokenBegin];
}
|
public final int getBeginLine() {
return bufline[tokenBegin];
}
|
public final int getColumn() {
return bufcolumn[bufpos];
} Deprecated!
|
public final int getEndColumn() {
return bufcolumn[bufpos];
}
|
public final int getEndLine() {
return bufline[bufpos];
}
|
public final int getLine() {
return bufline[bufpos];
} Deprecated!
|
public final char readChar() throws IOException {
if (inBuf > 0)
{
--inBuf;
return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]);
}
if (++bufpos >= maxNextCharInd)
FillBuff();
char c = (char)((char)0xff & buffer[bufpos]);
UpdateLineColumn(c);
return (c);
}
|