[][src]Trait antlr_rust::int_stream::IntStream

pub trait IntStream {
    pub fn consume(&mut self);
pub fn la(&mut self, i: isize) -> isize;
pub fn mark(&mut self) -> isize;
pub fn release(&mut self, marker: isize);
pub fn index(&self) -> isize;
pub fn seek(&mut self, index: isize);
pub fn size(&self) -> isize;
pub fn get_source_name(&self) -> String; }

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

pub fn consume(&mut self)[src]

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 index before calling this method is less than the value of index after 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

pub fn la(&mut self, i: isize) -> isize[src]

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

pub fn mark(&mut self) -> isize[src]

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

pub fn release(&mut self, marker: isize)[src]

Releases marker

pub fn index(&self) -> isize[src]

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.

pub fn seek(&mut self, index: isize)[src]

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)

pub fn size(&self) -> isize[src]

Returns the total number of symbols in the stream.

pub fn get_source_name(&self) -> String[src]

Returns name of the source this stream operates over if any

Loading content...

Implementors

impl<'a, Data: Deref> IntStream for InputStream<Data> where
    Data::Target: InputData
[src]

impl<'input, T: TokenSource<'input>> IntStream for CommonTokenStream<'input, T>[src]

impl<'input, T: TokenSource<'input>> IntStream for UnbufferedTokenStream<'input, T>[src]

Loading content...