Public Member Functions | |
def | __init__ |
def | 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. | |
def | consume |
def | LA |
Get int at current input pointer + i ahead where i=1 is next int. | |
def | LT |
Get the ith character of lookahead. | |
def | index |
Return the current input symbol index 0. | |
def | size |
Only makes sense for streams that buffer everything up probably, but might be useful to display the entire stream or for testing. | |
def | mark |
Tell the stream to start buffering if it hasn't already. | |
def | rewind |
Reset the stream so that next call to index would return marker. | |
def | release |
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. | |
def | seek |
consume() ahead until p==index; can't just set p=index as we must update line and charPositionInLine. | |
def | substring |
For infinite streams, you don't need this; primarily I'm providing a useful interface for action code. | |
def | getLine |
Using setter/getter methods is deprecated. | |
def | getCharPositionInLine |
Using setter/getter methods is deprecated. | |
def | setLine |
Using setter/getter methods is deprecated. | |
def | setCharPositionInLine |
Using setter/getter methods is deprecated. | |
def | 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. | |
Public Attributes | |
strdata | |
data | |
n | |
p | |
line | |
charPositionInLine | |
lastMarker | |
markDepth | |
name | |
Private Attributes | |
_markers |
A pretty quick CharStream that pulls all data from an array directly. Every method call counts in the lexer.
Definition at line 1269 of file antlr3.py.
def antlr3.ANTLRStringStream.__init__ | ( | self, | ||
data | ||||
) |
def antlr3.ANTLRStringStream.reset | ( | self | ) |
def antlr3.ANTLRStringStream.consume | ( | self | ) |
def antlr3.ANTLRStringStream.LA | ( | self, | ||
i | ||||
) |
Get int at current input pointer + i ahead where i=1 is next int.
Negative indexes are allowed. LA(-1) is previous token (token just matched). LA(-i) where i is before first token should yield -1, invalid char / EOF.
Reimplemented from antlr3.IntStream.
def antlr3.ANTLRStringStream.LT | ( | self, | ||
i | ||||
) |
Get the ith character of lookahead.
This is the same usually as LA(i). This will be used for labels in the generated lexer code. I'd prefer to return a char here type-wise, but it's probably better to be 32-bit clean and be consistent with LA.
Reimplemented from antlr3.CharStream.
def antlr3.ANTLRStringStream.index | ( | self | ) |
Return the current input symbol index 0.
.n where n indicates the last symbol has been read. The index is the index of char to be returned from LA(1).
Reimplemented from antlr3.IntStream.
def antlr3.ANTLRStringStream.size | ( | self | ) |
Only makes sense for streams that buffer everything up probably, but might be useful to display the entire stream or for testing.
This value includes a single EOF.
Reimplemented from antlr3.IntStream.
def antlr3.ANTLRStringStream.mark | ( | self | ) |
Tell the stream to start buffering if it hasn't already.
Return current input position, index(), or some other marker so that when passed to rewind() you get back to the same spot. rewind(mark()) should not affect the input cursor. The Lexer track line/col info as well as input index so its markers are not pure input indexes. Same for tree node streams.
Reimplemented from antlr3.IntStream.
def antlr3.ANTLRStringStream.rewind | ( | self, | ||
marker = None | ||||
) |
Reset the stream so that next call to index would return marker.
The marker will usually be index() but it doesn't have to be. It's just a marker to indicate what state the stream was in. This is essentially calling release() and seek(). If there are markers created after this marker argument, this routine must unroll them like a stack. Assume the state the stream was in when this marker was created.
If marker is None: Rewind to the input position of the last marker. Used currently only after a cyclic DFA and just before starting a sem/syn predicate to get the input position back to the start of the decision. Do not "pop" the marker off the state. mark(i) and rewind(i) should balance still. It is like invoking rewind(last marker) but it should not "pop" the marker off. It's like seek(last marker's input position).
Reimplemented from antlr3.IntStream.
def antlr3.ANTLRStringStream.release | ( | self, | ||
marker = None | ||||
) |
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.
This will have the same behavior as rewind() except it releases resources without the backward seek. This must throw away resources for all markers back to the marker argument. So if you're nested 5 levels of mark(), and then release(2) you have to release resources for depths 2..5.
Reimplemented from antlr3.IntStream.
def antlr3.ANTLRStringStream.seek | ( | self, | ||
index | ||||
) |
consume() ahead until p==index; can't just set p=index as we must update line and charPositionInLine.
Reimplemented from antlr3.IntStream.
def antlr3.ANTLRStringStream.substring | ( | self, | ||
start, | ||||
stop | ||||
) |
For infinite streams, you don't need this; primarily I'm providing a useful interface for action code.
Just make sure actions don't use this on streams that don't support it.
Reimplemented from antlr3.CharStream.
def antlr3.ANTLRStringStream.getLine | ( | self | ) |
Using setter/getter methods is deprecated.
Use o.line instead.
Reimplemented from antlr3.CharStream.
def antlr3.ANTLRStringStream.getCharPositionInLine | ( | self | ) |
Using setter/getter methods is deprecated.
Use o.charPositionInLine instead.
Reimplemented from antlr3.CharStream.
def antlr3.ANTLRStringStream.setLine | ( | self, | ||
line | ||||
) |
Using setter/getter methods is deprecated.
Use o.line instead.
Reimplemented from antlr3.CharStream.
def antlr3.ANTLRStringStream.setCharPositionInLine | ( | self, | ||
pos | ||||
) |
Using setter/getter methods is deprecated.
Use o.charPositionInLine instead.
Reimplemented from antlr3.CharStream.
def antlr3.ANTLRStringStream.getSourceName | ( | self | ) |
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.
Reimplemented from antlr3.IntStream.
Reimplemented in antlr3.ANTLRFileStream.
antlr3.ANTLRStringStream._markers [private] |