pub trait IntStream {
// Required methods
fn consume(&mut self);
fn la(&mut self, i: isize) -> isize;
fn mark(&mut self) -> isize;
fn release(&mut self, marker: isize);
fn index(&self) -> isize;
fn seek(&mut self, index: isize);
fn size(&self) -> isize;
fn get_source_name(&self) -> String;
}Expand description
A simple stream of symbols whose values are represented as integers. This interface provides marked ranges with support for a minimum level of buffering necessary to implement arbitrary lookahead during prediction.
Required Methods§
Sourcefn consume(&mut self)
fn consume(&mut self)
Consumes the current symbol in the stream. Advances this stream to the next element.
This method has the following effects:
- Forward movement: The value of
indexbefore calling this method is less than the value ofindexafter calling this method. - Ordered lookahead: The value of {@code LA(1)} before calling this method becomes the value of {@code LA(-1)} after calling this method.
Note that calling this method does not guarantee that index() is
incremented by exactly 1.
Allowed to panic if trying to consume EOF
Sourcefn la(&mut self, i: isize) -> isize
fn la(&mut self, i: isize) -> isize
Lookaheads (or loopbacks if i is negative)
Gets the value of the symbol at offset {@code i} from the current position. When {@code i==1}, this method returns the value of the current symbol in the stream (which is the next symbol to be consumed). When {@code i==-1}, this method returns the value of the previously read symbol in the stream. It is not valid to call this method with {@code i==0}, but the specific behavior is unspecified because this method is frequently called from performance-critical code.
Note that default Lexer does not call this method with anything other than -1
so it can be used for optimizations in downstream implementations.
Must return EOF if i points to position at or beyond the end of the stream
Sourcefn mark(&mut self) -> isize
fn mark(&mut self) -> isize
After this call subsequent calls to seek must succeed if seek index is greater than mark index
Returns marker that should be used later by release call to release this stream from
Sourcefn index(&self) -> isize
fn index(&self) -> isize
Returns current position of the input stream
If there is active marker from mark then calling seek later with result of this call
should put stream in same state it is currently in.
Sourcefn seek(&mut self, index: isize)
fn seek(&mut self, index: isize)
Put stream back in state it was when it was in index position
Allowed to panic if index does not belong to marked region(via mark-release calls)
Sourcefn get_source_name(&self) -> String
fn get_source_name(&self) -> String
Returns name of the source this stream operates over if any