|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.runtime.ANTLRStringStream
public class ANTLRStringStream
A pretty quick CharStream that pulls all data from an array directly. Every method call counts in the lexer. Java's strings aren't very good so I'm avoiding.
Field Summary | |
---|---|
protected int |
charPositionInLine
The index of the character relative to the beginning of the line 0..n-1 |
protected char[] |
data
The data being scanned |
protected int |
lastMarker
Track the last mark() call result value for use in rewind(). |
protected int |
line
line number 1..n within the input |
protected int |
markDepth
tracks how deep mark() calls are nested |
protected java.util.List |
markers
A list of CharStreamState objects that tracks the stream state values line, charPositionInLine, and p that can change as you move through the input stream. |
protected int |
n
How many characters are actually in the buffer |
java.lang.String |
name
What is name or source of this char stream? |
protected int |
p
0..n-1 index into string of next char |
Fields inherited from interface org.antlr.runtime.CharStream |
---|
EOF |
Constructor Summary | |
---|---|
ANTLRStringStream()
|
|
ANTLRStringStream(char[] data,
int numberOfActualCharsInArray)
This is the preferred constructor as no data is copied |
|
ANTLRStringStream(java.lang.String input)
Copy data in string to a local char array |
Method Summary | |
---|---|
void |
consume()
|
int |
getCharPositionInLine()
The index of the character relative to the beginning of the line 0..n-1 |
int |
getLine()
ANTLR tracks the line information automatically |
java.lang.String |
getSourceName()
Where are you getting symbols from? Normally, implementations will pass the buck all the way to the lexer who can ask its input stream for the file name or whatever. |
int |
index()
Return the current input symbol index 0..n where n indicates the last symbol has been read. |
int |
LA(int i)
Get int at current input pointer + i ahead where i=1 is next int. |
int |
LT(int i)
Get the ith character of lookahead. |
int |
mark()
Tell the stream to start buffering if it hasn't already. |
void |
release(int marker)
You may want to commit to a backtrack but don't want to force the stream to keep bookkeeping objects around for a marker that is no longer necessary. |
void |
reset()
Reset the stream so that it's in the same state it was when the object was created *except* the data array is not touched. |
void |
rewind()
Rewind to the input position of the last marker. |
void |
rewind(int m)
Reset the stream so that next call to index would return marker. |
void |
seek(int index)
consume() ahead until p==index; can't just set p=index as we must update line and charPositionInLine. |
void |
setCharPositionInLine(int pos)
|
void |
setLine(int line)
Because this stream can rewind, we need to be able to reset the line |
int |
size()
Only makes sense for streams that buffer everything up probably, but might be useful to display the entire stream or for testing. |
java.lang.String |
substring(int start,
int stop)
For infinite streams, you don't need this; primarily I'm providing a useful interface for action code. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected char[] data
protected int n
protected int p
protected int line
protected int charPositionInLine
protected int markDepth
protected java.util.List markers
protected int lastMarker
public java.lang.String name
Constructor Detail |
---|
public ANTLRStringStream()
public ANTLRStringStream(java.lang.String input)
public ANTLRStringStream(char[] data, int numberOfActualCharsInArray)
Method Detail |
---|
public void reset()
public void consume()
consume
in interface IntStream
public int LA(int i)
IntStream
LA
in interface IntStream
public int LT(int i)
CharStream
LT
in interface CharStream
public int index()
index
in interface IntStream
public int size()
IntStream
size
in interface IntStream
public int mark()
IntStream
mark
in interface IntStream
public void rewind(int m)
IntStream
rewind
in interface IntStream
public void rewind()
IntStream
rewind
in interface IntStream
public void release(int marker)
IntStream
release
in interface IntStream
public void seek(int index)
seek
in interface IntStream
public java.lang.String substring(int start, int stop)
CharStream
substring
in interface CharStream
public int getLine()
CharStream
getLine
in interface CharStream
public int getCharPositionInLine()
CharStream
getCharPositionInLine
in interface CharStream
public void setLine(int line)
CharStream
setLine
in interface CharStream
public void setCharPositionInLine(int pos)
setCharPositionInLine
in interface CharStream
public java.lang.String getSourceName()
IntStream
getSourceName
in interface IntStream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |