类 LookaheadStream<T>

  • 直接已知子类:
    CommonTreeNodeStream, UnbufferedTokenStream

    public abstract class LookaheadStream<T>
    extends FastQueue<T>
    A lookahead queue that knows how to mark/release locations in the buffer for backtracking purposes. Any markers force the FastQueue superclass to keep all elements until no more markers; then can reset to avoid growing a huge buffer.
    • 方法概要

      所有方法 实例方法 抽象方法 具体方法 
      修饰符和类型 方法 说明
      void consume()
      Make sure we have at least one element to remove, even if EOF
      void fill​(int n)
      add n elements to buffer
      int index()  
      abstract boolean isEOF​(T o)  
      protected T LB​(int k)  
      T LT​(int k)  
      int mark()  
      abstract T nextElement()
      Implement nextElement to supply a stream of elements to this lookahead buffer.
      void release​(int marker)  
      T remove()
      Get and remove first element in queue; override FastQueue.remove(); it's the same, just checks for backtracking.
      void reset()  
      void rewind()  
      void rewind​(int marker)  
      void seek​(int index)
      Seek to a 0-indexed absolute token index.
      int size()
      Size of entire stream is unknown; we only know buffer size from FastQueue.
      protected void syncAhead​(int need)
      Make sure we have 'need' elements from current position p.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 字段详细资料

      • UNINITIALIZED_EOF_ELEMENT_INDEX

        public static final int UNINITIALIZED_EOF_ELEMENT_INDEX
        另请参阅:
        常量字段值
      • currentElementIndex

        protected int currentElementIndex
        Absolute token index. It's the index of the symbol about to be read via LT(1). Goes from 0 to numtokens.
      • prevElement

        protected T prevElement
        This is the LT(-1) element for the first element in FastQueue.data.
      • eof

        public T eof
        Track object returned by nextElement upon end of stream; Return it later when they ask for LT passed end of input.
      • lastMarker

        protected int lastMarker
        Track the last mark() call result value for use in rewind().
      • markDepth

        protected int markDepth
        tracks how deep mark() calls are nested
    • 构造器详细资料

      • LookaheadStream

        public LookaheadStream()
    • 方法详细资料

      • nextElement

        public abstract T nextElement()
        Implement nextElement to supply a stream of elements to this lookahead buffer. Return EOF upon end of the stream we're pulling from.
        另请参阅:
        isEOF(T)
      • isEOF

        public abstract boolean isEOF​(T o)
      • remove

        public T remove()
        Get and remove first element in queue; override FastQueue.remove(); it's the same, just checks for backtracking.
        覆盖:
        remove 在类中 FastQueue<T>
      • consume

        public void consume()
        Make sure we have at least one element to remove, even if EOF
      • syncAhead

        protected void syncAhead​(int need)
        Make sure we have 'need' elements from current position p. Last valid p index is data.size()-1. p+need-1 is the data index 'need' elements ahead. If we need 1 element, (p+1-1)==p must be < data.size().
      • fill

        public void fill​(int n)
        add n elements to buffer
      • size

        public int size()
        Size of entire stream is unknown; we only know buffer size from FastQueue.
        覆盖:
        size 在类中 FastQueue<T>
      • LT

        public T LT​(int k)
      • index

        public int index()
      • mark

        public int mark()
      • release

        public void release​(int marker)
      • rewind

        public void rewind​(int marker)
      • rewind

        public void rewind()
      • seek

        public void seek​(int index)
        Seek to a 0-indexed absolute token index. Normally used to seek backwards in the buffer. Does not force loading of nodes.

        To preserve backward compatibility, this method allows seeking past the end of the currently buffered data. In this case, the input pointer will be moved but the data will only actually be loaded upon the next call to consume() or LT(int) for k>0.

        抛出:
        java.lang.IllegalArgumentException - if index is less than 0
        java.lang.UnsupportedOperationException - if index lies before the beginning of the moving window buffer (index < currentElementIndex - p).
      • LB

        protected T LB​(int k)