Package org.antlr.v4.runtime
Class ANTLRInputStream
- java.lang.Object
-
- org.antlr.v4.runtime.ANTLRInputStream
-
- All Implemented Interfaces:
CharStream
,IntStream
- Direct Known Subclasses:
ANTLRFileStream
@Deprecated public class ANTLRInputStream extends Object implements CharStream
Deprecated.as of 4.7 Please useCharStreams
interface.Vacuum all input from aReader
/InputStream
and then treat it like achar[]
buffer. Can also pass in aString
orchar[]
to use.If you need encoding, pass in stream/reader with correct encoding.
-
-
Field Summary
Fields Modifier and Type Field Description protected char[]
data
Deprecated.The data being scannedstatic int
INITIAL_BUFFER_SIZE
Deprecated.protected int
n
Deprecated.How many characters are actually in the bufferString
name
Deprecated.What is name or source of this char stream?protected int
p
Deprecated.0..n-1 index into string of next charstatic int
READ_BUFFER_SIZE
Deprecated.-
Fields inherited from interface org.antlr.v4.runtime.IntStream
EOF, UNKNOWN_SOURCE_NAME
-
-
Constructor Summary
Constructors Constructor Description ANTLRInputStream()
Deprecated.ANTLRInputStream(char[] data, int numberOfActualCharsInArray)
Deprecated.This is the preferred constructor for strings as no data is copiedANTLRInputStream(InputStream input)
Deprecated.ANTLRInputStream(InputStream input, int initialSize)
Deprecated.ANTLRInputStream(InputStream input, int initialSize, int readChunkSize)
Deprecated.ANTLRInputStream(Reader r)
Deprecated.ANTLRInputStream(Reader r, int initialSize)
Deprecated.ANTLRInputStream(Reader r, int initialSize, int readChunkSize)
Deprecated.ANTLRInputStream(String input)
Deprecated.Copy data in string to a local char array
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
consume()
Deprecated.Consumes the current symbol in the stream.String
getSourceName()
Deprecated.Gets the name of the underlying symbol source.String
getText(Interval interval)
Deprecated.This method returns the text for a range of characters within this input stream.int
index()
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 offseti
from the current position.void
load(Reader r, int size, int readChunkSize)
Deprecated.int
LT(int i)
Deprecated.int
mark()
Deprecated.mark/release do nothing; we have entire buffervoid
release(int marker)
Deprecated.This method releases a marked range created by a call tomark()
.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.void
seek(int index)
Deprecated.consume() ahead until p==index; can't just set p=index as we must update line and charPositionInLine.int
size()
Deprecated.Returns the total number of symbols in the stream, including a single EOF symbol.String
toString()
Deprecated.
-
-
-
Field Detail
-
READ_BUFFER_SIZE
public static final int READ_BUFFER_SIZE
Deprecated.- See Also:
- Constant Field Values
-
INITIAL_BUFFER_SIZE
public static final int INITIAL_BUFFER_SIZE
Deprecated.- See Also:
- Constant Field Values
-
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 Detail
-
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 Detail
-
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 ofindex()
after calling this method. - Ordered lookahead: The value of
LA(1)
before calling this method becomes the value ofLA(-1)
after calling this method.
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). - Forward movement: The value of
-
LA
public int LA(int i)
Deprecated.Description copied from interface:IntStream
Gets the value of the symbol at offseti
from the current position. Wheni==1
, this method returns the value of the current symbol in the stream (which is the next symbol to be consumed). Wheni==-1
, this method returns the value of the previously read symbol in the stream. It is not valid to call this method withi==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
andindex()
returns a value greater than the value ofindex()
after the stream was constructed andLA(1)
was called in that order. Specifying the currentindex()
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 toLA(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 returnsIntStream.EOF
.The return value is unspecified if
i<0
and fewer than-i
calls toconsume()
have occurred from the beginning of the stream before calling this method.
-
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).
-
size
public int size()
Deprecated.Description copied from interface:IntStream
Returns the total number of symbols in the stream, including a single EOF symbol.
-
mark
public int mark()
Deprecated.mark/release do nothing; we have entire buffer
-
release
public void release(int marker)
Deprecated.Description copied from interface:IntStream
This method releases a marked range created by a call tomark()
. Calls torelease()
must appear in the reverse order of the corresponding calls tomark()
. If a mark is released twice, or if marks are not released in reverse order of the corresponding calls tomark()
, the behavior is unspecified.For more information and an example, see
IntStream.mark()
.- Specified by:
release
in interfaceIntStream
- Parameters:
marker
- A marker returned by a call tomark()
.- See Also:
IntStream.mark()
-
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
-
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 specifiedinterval
lies entirely within a marked range. For more information about marked ranges, seeIntStream.mark()
.- Specified by:
getText
in interfaceCharStream
- 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 returnsIntStream.UNKNOWN_SOURCE_NAME
.- Specified by:
getSourceName
in interfaceIntStream
-
-