public abstract class AbstractCharStream extends Object implements CharStream
| Modifier and Type | Field and Description |
|---|---|
protected int |
available
The number of unoccupied buffer array positions
|
protected char[] |
buffer
Internal circular buffer
|
protected int |
bufpos
Current read position in buffer.
|
protected int |
bufsize
Overall buffer size - same as buffer.length
|
static int |
DEFAULT_BUF_SIZE
Default buffer size if nothing is specified
|
protected int |
inBuf
Characters in the backup/pushBack buffer
|
protected int |
maxNextCharInd |
protected int |
tokenBegin
The first array index (of `buffer`) that the current token starts
|
| Constructor and Description |
|---|
AbstractCharStream(int nStartLine,
int nStartColumn,
int nBufferSize)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
adjustBeginLineColumn(int nNewLine,
int newCol)
Method to adjust line and column numbers for the start of a token.
|
void |
backup(int nAmount)
Backs up the input stream by amount steps.
|
char |
beginToken() |
void |
done()
The lexer calls this function to indicate that it is done with the stream
and hence implementations can free any resources held by this class.
|
protected void |
expandBuff(boolean bWrapAround) |
protected void |
fillBuff() |
int |
getBeginColumn() |
int |
getBeginLine() |
protected int |
getBufSizeAfterExpansion() |
protected int |
getColumn() |
int |
getEndColumn() |
int |
getEndLine() |
String |
getImage() |
protected int |
getLine() |
char[] |
getSuffix(int len) |
int |
getTabSize() |
protected void |
internalAdjustBuffSize() |
protected void |
internalSetBufLineColumn(int nLine,
int nColumn) |
protected void |
internalUpdateLineColumn(char c) |
boolean |
isTrackLineColumn() |
char |
readChar()
Get the next character from the selected input.
|
void |
reInit(int nStartLine,
int nStartColumn,
int nBufferSize)
Reinitialise.
|
void |
setTabSize(int nTabSize)
Set the tab size to use.
|
void |
setTrackLineColumn(boolean bTrackLineColumn)
Enable or disable line number and column number tracking.
|
protected abstract void |
streamClose()
Close the underlying stream.
|
protected abstract int |
streamRead(char[] aBuf,
int nOfs,
int nLen)
Read from the underlying stream.
|
public static final int DEFAULT_BUF_SIZE
protected char[] buffer
protected int bufsize
protected int bufpos
protected int available
protected int tokenBegin
protected int inBuf
protected int maxNextCharInd
public AbstractCharStream(int nStartLine,
int nStartColumn,
int nBufferSize)
public final void reInit(int nStartLine,
int nStartColumn,
int nBufferSize)
protected abstract int streamRead(char[] aBuf,
int nOfs,
int nLen)
throws IOException
aBuf - the buffer to be fillednOfs - The offset into the buffer. 0-basednLen - Number of chars to read.IOExceptionprotected abstract void streamClose()
throws IOException
IOException - If closing fails.protected int getBufSizeAfterExpansion()
protected void expandBuff(boolean bWrapAround)
protected final void internalAdjustBuffSize()
protected void fillBuff()
throws IOException
IOExceptionprotected final void internalSetBufLineColumn(int nLine,
int nColumn)
protected final void internalUpdateLineColumn(char c)
public char readChar()
throws IOException
CharStreamreadChar in interface CharStreamIOException - on IO errorpublic char beginToken()
throws IOException
beginToken in interface CharStreamIOExceptionpublic int getBeginColumn()
getBeginColumn in interface CharStreampublic int getBeginLine()
getBeginLine in interface CharStreampublic int getEndColumn()
getEndColumn in interface CharStreampublic int getEndLine()
getEndLine in interface CharStreampublic void backup(int nAmount)
CharStreambackup in interface CharStreamnAmount - Number of chars to back up.public String getImage()
getImage in interface CharStreampublic char[] getSuffix(int len)
getSuffix in interface CharStream
{
String t = getImage();
return t.substring(t.length() - len, t.length()).toCharArray();
}
public void done()
CharStreamdone in interface CharStreampublic final int getTabSize()
getTabSize in interface CharStreampublic final void setTabSize(int nTabSize)
CharStreamsetTabSize in interface CharStreamnTabSize - spaces per tabpublic final void adjustBeginLineColumn(int nNewLine,
int newCol)
protected final int getLine()
protected final int getColumn()
public final boolean isTrackLineColumn()
isTrackLineColumn in interface CharStreamtrue if line number and column numbers should be tracked.public final void setTrackLineColumn(boolean bTrackLineColumn)
CharStreamsetTrackLineColumn in interface CharStreambTrackLineColumn - true to track it, false to not do it.Copyright © 2007–2021. All rights reserved.