public abstract class CodePointCharStream extends Object implements CharStream
ANTLRInputStream
which treats the input
as a series of Unicode code points, instead of a series of UTF-16
code units.
Use this if you need to parse input which potentially contains
Unicode values > U+FFFF.Modifier and Type | Field and Description |
---|---|
protected String |
name |
protected int |
position |
protected int |
size |
EOF, UNKNOWN_SOURCE_NAME
Modifier and Type | Method and Description |
---|---|
void |
consume()
Consumes the current symbol in the stream.
|
static CodePointCharStream |
fromBuffer(CodePointBuffer codePointBuffer)
Constructs a
CodePointCharStream which provides access
to the Unicode code points stored in codePointBuffer . |
static CodePointCharStream |
fromBuffer(CodePointBuffer codePointBuffer,
String name)
Constructs a named
CodePointCharStream which provides access
to the Unicode code points stored in codePointBuffer . |
String |
getSourceName()
Gets the name of the underlying symbol source.
|
int |
index()
Return the index into the stream of the input symbol referred to by
LA(1) . |
int |
mark()
mark/release do nothing; we have entire buffer
|
void |
release(int marker)
This method releases a marked range created by a call to
mark() . |
void |
seek(int index)
Set the input cursor to the position indicated by
index . |
int |
size()
Returns the total number of symbols in the stream, including a single EOF
symbol.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getText
protected final int size
protected final String name
protected int position
public static CodePointCharStream fromBuffer(CodePointBuffer codePointBuffer)
CodePointCharStream
which provides access
to the Unicode code points stored in codePointBuffer
.public static CodePointCharStream fromBuffer(CodePointBuffer codePointBuffer, String name)
CodePointCharStream
which provides access
to the Unicode code points stored in codePointBuffer
.public final void consume()
IntStream
index()
before calling this method is less than the value of index()
after calling this method.LA(1)
before
calling this method becomes the value of LA(-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).public final int index()
IntStream
LA(1)
.
The behavior of this method is unspecified if no call to an
initializing method
has occurred after this stream was
constructed.
public final int size()
IntStream
public final int mark()
public final void release(int marker)
IntStream
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()
.
release
in interface IntStream
marker
- A marker returned by a call to mark()
.IntStream.mark()
public final void seek(int index)
IntStream
index
. If the
specified index lies past the end of the stream, the operation behaves as
though index
was the index of the EOF symbol. After this method
returns without throwing an exception, then at least one of the following
will be true.
index()
will return the index of the first symbol
appearing at or after the specified index
. Specifically,
implementations which filter their sources should automatically
adjust index
forward the minimum amount required for the
operation to target a non-ignored symbol.LA(1)
returns IntStream.EOF
index
lies within a marked region. For more information on marked regions, see
IntStream.mark()
. The behavior of this method is unspecified if no call to
an initializing method
has occurred after this stream
was constructed.public final String getSourceName()
IntStream
IntStream.UNKNOWN_SOURCE_NAME
.getSourceName
in interface IntStream
Copyright © 1992–2020 ANTLR. All rights reserved.