Class ANTLRInputStream

java.lang.Object
org.antlr.v4.runtime.ANTLRInputStream
All Implemented Interfaces:
CharStream, IntStream
Direct Known Subclasses:
ANTLRFileStream

public class ANTLRInputStream extends Object implements CharStream
Deprecated.
as of 4.7 Please use CharStreams interface.
Vacuum all input from a Reader/InputStream and then treat it like a char[] buffer. Can also pass in a String or char[] to use.

If you need encoding, pass in stream/reader with correct encoding.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected char[]
    Deprecated.
    The data being scanned
    static final int
    Deprecated.
     
    protected int
    Deprecated.
    How many characters are actually in the buffer
    Deprecated.
    What is name or source of this char stream?
    protected int
    Deprecated.
    0..n-1 index into string of next char
    static final int
    Deprecated.
     

    Fields inherited from interface org.antlr.v4.runtime.IntStream

    EOF, UNKNOWN_SOURCE_NAME
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
     
    ANTLRInputStream(char[] data, int numberOfActualCharsInArray)
    Deprecated.
    This is the preferred constructor for strings as no data is copied
    Deprecated.
     
    ANTLRInputStream(InputStream input, int initialSize)
    Deprecated.
     
    ANTLRInputStream(InputStream input, int initialSize, int readChunkSize)
    Deprecated.
     
    Deprecated.
     
    ANTLRInputStream(Reader r, int initialSize)
    Deprecated.
     
    ANTLRInputStream(Reader r, int initialSize, int readChunkSize)
    Deprecated.
     
    Deprecated.
    Copy data in string to a local char array
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated.
    Consumes the current symbol in the stream.
    Deprecated.
    Gets the name of the underlying symbol source.
    getText(Interval interval)
    Deprecated.
    This method returns the text for a range of characters within this input stream.
    int
    Deprecated.
    Return the current input symbol index 0..n where n indicates the last symbol has been read.
    int
    LA(int i)
    Deprecated.
    Gets the value of the symbol at offset i from the current position.
    void
    load(Reader r, int size, int readChunkSize)
    Deprecated.
     
    int
    LT(int i)
    Deprecated.
     
    int
    Deprecated.
    mark/release do nothing; we have entire buffer
    void
    release(int marker)
    Deprecated.
    This method releases a marked range created by a call to mark().
    void
    Deprecated.
    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
    seek(int index)
    Deprecated.
    consume() ahead until p==index; can't just set p=index as we must update line and charPositionInLine.
    int
    Deprecated.
    Returns the total number of symbols in the stream, including a single EOF symbol.
    Deprecated.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • READ_BUFFER_SIZE

      public static final int READ_BUFFER_SIZE
      Deprecated.
      See Also:
    • INITIAL_BUFFER_SIZE

      public static final int INITIAL_BUFFER_SIZE
      Deprecated.
      See Also:
    • data

      protected char[] data
      Deprecated.
      The data being scanned
    • n

      protected int n
      Deprecated.
      How many characters are actually in the buffer
    • p

      protected int p
      Deprecated.
      0..n-1 index into string of next char
    • name

      public String name
      Deprecated.
      What is name or source of this char stream?
  • Constructor Details

    • ANTLRInputStream

      public ANTLRInputStream()
      Deprecated.
    • ANTLRInputStream

      public ANTLRInputStream(String input)
      Deprecated.
      Copy data in string to a local char array
    • ANTLRInputStream

      public ANTLRInputStream(char[] data, int numberOfActualCharsInArray)
      Deprecated.
      This is the preferred constructor for strings as no data is copied
    • ANTLRInputStream

      public ANTLRInputStream(Reader r) throws IOException
      Deprecated.
      Throws:
      IOException
    • ANTLRInputStream

      public ANTLRInputStream(Reader r, int initialSize) throws IOException
      Deprecated.
      Throws:
      IOException
    • ANTLRInputStream

      public ANTLRInputStream(Reader r, int initialSize, int readChunkSize) throws IOException
      Deprecated.
      Throws:
      IOException
    • ANTLRInputStream

      public ANTLRInputStream(InputStream input) throws IOException
      Deprecated.
      Throws:
      IOException
    • ANTLRInputStream

      public ANTLRInputStream(InputStream input, int initialSize) throws IOException
      Deprecated.
      Throws:
      IOException
    • ANTLRInputStream

      public ANTLRInputStream(InputStream input, int initialSize, int readChunkSize) throws IOException
      Deprecated.
      Throws:
      IOException
  • Method Details

    • load

      public void load(Reader r, int size, int readChunkSize) throws IOException
      Deprecated.
      Throws:
      IOException
    • reset

      public void reset()
      Deprecated.
      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.
    • consume

      public void consume()
      Deprecated.
      Description copied from interface: IntStream
      Consumes the current symbol in the stream. 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 LA(1) before calling this method becomes the value of LA(-1) after calling this method.
      Note that calling this method does not guarantee that index() is incremented by exactly 1, as that would preclude the ability to implement filtering streams (e.g. CommonTokenStream which distinguishes between "on-channel" and "off-channel" tokens).
      Specified by:
      consume in interface IntStream
    • LA

      public int LA(int i)
      Deprecated.
      Description copied from interface: IntStream
      Gets the value of the symbol at offset i from the current position. When i==1, this method returns the value of the current symbol in the stream (which is the next symbol to be consumed). When i==-1, this method returns the value of the previously read symbol in the stream. It is not valid to call this method with i==0, but the specific behavior is unspecified because this method is frequently called from performance-critical code.

      This method is guaranteed to succeed if any of the following are true:

      • i>0
      • i==-1 and index() returns a value greater than the value of index() after the stream was constructed and LA(1) was called in that order. Specifying the current index() relative to the index after the stream was created allows for filtering implementations that do not return every symbol from the underlying source. Specifying the call to LA(1) allows for lazily initialized streams.
      • LA(i) refers to a symbol consumed within a marked region that has not yet been released.

      If i represents a position at or beyond the end of the stream, this method returns IntStream.EOF.

      The return value is unspecified if i<0 and fewer than -i calls to consume() have occurred from the beginning of the stream before calling this method.

      Specified by:
      LA in interface IntStream
    • LT

      public int LT(int i)
      Deprecated.
    • index

      public int index()
      Deprecated.
      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).
      Specified by:
      index in interface IntStream
    • size

      public int size()
      Deprecated.
      Description copied from interface: IntStream
      Returns the total number of symbols in the stream, including a single EOF symbol.
      Specified by:
      size in interface IntStream
    • mark

      public int mark()
      Deprecated.
      mark/release do nothing; we have entire buffer
      Specified by:
      mark in interface IntStream
      Returns:
      An opaque marker which should be passed to release() when the marked range is no longer required.
    • release

      public void release(int marker)
      Deprecated.
      Description copied from interface: IntStream
      This method releases a marked range created by a call to mark(). Calls to release() must appear in the reverse order of the corresponding calls to mark(). If a mark is released twice, or if marks are not released in reverse order of the corresponding calls to mark(), the behavior is unspecified.

      For more information and an example, see IntStream.mark().

      Specified by:
      release in interface IntStream
      Parameters:
      marker - A marker returned by a call to mark().
      See Also:
    • seek

      public void seek(int index)
      Deprecated.
      consume() ahead until p==index; can't just set p=index as we must update line and charPositionInLine. If we seek backwards, just set p
      Specified by:
      seek in interface IntStream
      Parameters:
      index - The absolute index to seek to.
    • getText

      public String getText(Interval interval)
      Deprecated.
      Description copied from interface: CharStream
      This method returns the text for a range of characters within this input stream. This method is guaranteed to not throw an exception if the specified interval lies entirely within a marked range. For more information about marked ranges, see IntStream.mark().
      Specified by:
      getText in interface CharStream
      Parameters:
      interval - an interval within the stream
      Returns:
      the text of the specified interval
    • getSourceName

      public String getSourceName()
      Deprecated.
      Description copied from interface: IntStream
      Gets the name of the underlying symbol source. This method returns a non-null, non-empty string. If such a name is not known, this method returns IntStream.UNKNOWN_SOURCE_NAME.
      Specified by:
      getSourceName in interface IntStream
    • toString

      public String toString()
      Deprecated.
      Overrides:
      toString in class Object