public abstract class AbstractCharStream extends Object implements CharStream
| Modifier and Type | Field and Description |
|---|---|
protected int |
available |
protected int[] |
bufcolumn |
protected char[] |
buffer |
protected static int |
BUFFER_INCREASE
By how much should the buffer be increase?
|
protected int[] |
bufline |
protected int |
bufpos
Position in buffer.
|
protected int |
bufsize |
protected int |
column |
static int |
DEFAULT_BUF_SIZE
Default buffer size if nothing is specified
|
protected int |
inBuf |
protected int |
line |
protected int |
maxNextCharInd |
protected boolean |
prevCharIsCR |
protected boolean |
prevCharIsLF |
protected int |
tokenBegin |
| Constructor and Description |
|---|
AbstractCharStream(int startline,
int startcolumn,
int buffersize)
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 amount)
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 wrapAround) |
protected void |
fillBuff() |
int |
getBeginColumn() |
int |
getBeginLine() |
int |
getEndColumn() |
int |
getEndLine() |
String |
getImage() |
char[] |
getSuffix(int len) |
int |
getTabSize() |
boolean |
isTrackLineColumn() |
char |
readChar()
Read a character.
|
void |
reInit(int startline,
int startcolumn,
int buffersize)
Reinitialise.
|
void |
setTabSize(int i)
Set the tab size to use.
|
void |
setTrackLineColumn(boolean tlc)
Enable or disable line number and column number tracking.
|
protected abstract void |
streamClose() |
protected abstract int |
streamRead(char[] aBuf,
int nOfs,
int nLen) |
protected void |
updateLineColumn(char c) |
public static final int DEFAULT_BUF_SIZE
protected static final int BUFFER_INCREASE
protected int bufpos
protected int bufsize
protected int available
protected int tokenBegin
protected char[] buffer
protected int inBuf
protected int maxNextCharInd
protected int[] bufline
protected int[] bufcolumn
protected int column
protected int line
protected boolean prevCharIsCR
protected boolean prevCharIsLF
public AbstractCharStream(int startline,
int startcolumn,
int buffersize)
public void setTabSize(int i)
CharStreamsetTabSize in interface CharStreami - spaces per tabpublic int getTabSize()
getTabSize in interface CharStreamprotected void expandBuff(boolean wrapAround)
protected abstract int streamRead(char[] aBuf,
int nOfs,
int nLen)
throws IOException
IOExceptionprotected abstract void streamClose()
throws IOException
IOExceptionprotected void fillBuff()
throws IOException
IOExceptionpublic char beginToken()
throws IOException
beginToken in interface CharStreamIOExceptionprotected void updateLineColumn(char c)
public char readChar()
throws IOException
readChar in interface CharStreamIOException - on IO errorpublic 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 amount)
CharStreambackup in interface CharStreamamount - Number of chars to back up.public void reInit(int startline,
int startcolumn,
int buffersize)
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 void adjustBeginLineColumn(int nNewLine,
int newCol)
public void setTrackLineColumn(boolean tlc)
CharStreamsetTrackLineColumn in interface CharStreamtlc - true to track it, false to not do it.public boolean isTrackLineColumn()
isTrackLineColumn in interface CharStreamtrue if line number and column numbers should be tracked.Copyright © 2007–2020. All rights reserved.