public abstract class AbstractCharStream extends Object implements CharStream
Modifier and Type | Field and Description |
---|---|
protected int |
available |
protected int[] |
bufcolumn |
protected char[] |
buffer |
protected int[] |
bufline |
protected int |
bufpos
Position in buffer.
|
protected int |
bufsize |
protected int |
column |
static int |
DEFAULT_BUF_SIZE |
protected int |
inBuf |
protected int |
line |
protected int |
maxNextCharInd |
protected char[] |
nextCharBuf |
protected int |
nextCharInd |
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[] buf,
int offset,
int len) |
protected void |
updateLineColumn(char c) |
public static final int DEFAULT_BUF_SIZE
protected int bufpos
protected int bufsize
protected int available
protected int tokenBegin
protected int[] bufline
protected int[] bufcolumn
protected int column
protected int line
protected boolean prevCharIsCR
protected boolean prevCharIsLF
protected char[] buffer
protected int maxNextCharInd
protected int inBuf
protected char[] nextCharBuf
protected int nextCharInd
public AbstractCharStream(int startline, int startcolumn, int buffersize)
public void setTabSize(int i)
CharStream
setTabSize
in interface CharStream
i
- spaces per tabpublic int getTabSize()
getTabSize
in interface CharStream
protected void expandBuff(boolean wrapAround)
protected abstract int streamRead(char[] buf, int offset, int len) throws IOException
IOException
protected abstract void streamClose() throws IOException
IOException
protected void fillBuff() throws IOException
IOException
public char beginToken() throws IOException
beginToken
in interface CharStream
IOException
protected void updateLineColumn(char c)
public char readChar() throws IOException
readChar
in interface CharStream
IOException
- on IO errorpublic int getBeginColumn()
getBeginColumn
in interface CharStream
public int getBeginLine()
getBeginLine
in interface CharStream
public int getEndColumn()
getEndColumn
in interface CharStream
public int getEndLine()
getEndLine
in interface CharStream
public void backup(int amount)
CharStream
backup
in interface CharStream
amount
- Number of chars to back up.public void reInit(int startline, int startcolumn, int buffersize)
public String getImage()
getImage
in interface CharStream
public char[] getSuffix(int len)
getSuffix
in interface CharStream
{ String t = getImage(); return t.substring(t.length() - len, t.length()).toCharArray(); }
public void done()
CharStream
done
in interface CharStream
public void adjustBeginLineColumn(int nNewLine, int newCol)
public void setTrackLineColumn(boolean tlc)
CharStream
setTrackLineColumn
in interface CharStream
tlc
- true
to track it, false
to not do it.public boolean isTrackLineColumn()
isTrackLineColumn
in interface CharStream
true
if line number and column numbers should be tracked.Copyright © 2007–2020. All rights reserved.