Top Description Inners Fields Constructors Methods
org.antlr.v4.runtime

public abstract Class CodePointCharStream

extends Object
implements UnicodeCharStream, CharStream
Class Inheritance
All Implemented Interfaces
org.antlr.v4.runtime.CharStream, org.antlr.v4.runtime.IntStream, org.antlr.v4.runtime.UnicodeCharStream
Known Direct Subclasses
org.antlr.v4.runtime.CodePointCharStream.CodePoint8BitCharStream, org.antlr.v4.runtime.CodePointCharStream.CodePoint16BitCharStream, org.antlr.v4.runtime.CodePointCharStream.CodePoint32BitCharStream
Imports
org.antlr.v4.runtime.misc.Interval, java.nio.charset.Charset

Alternative to 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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
protected final String
protected int
protected final int

Constructor Summary

AccessConstructor and Description
private
CodePointCharStream(int position, int remaining, String name)

Method Summary

Modifier and TypeMethod and Description
public final void
consume()

Implements org.antlr.v4.runtime.IntStream.consume.

Consumes the current symbol in the stream.
public static CodePointCharStream
fromBuffer(CodePointBuffer codePointBuffer)

Constructs a CodePointCharStream which provides access to the Unicode code points stored in codePointBuffer.

public static CodePointCharStream
fromBuffer(CodePointBuffer codePointBuffer, String name)

Constructs a named CodePointCharStream which provides access to the Unicode code points stored in codePointBuffer.

pack-priv abstract Object
public final String
getSourceName()

Implements org.antlr.v4.runtime.IntStream.getSourceName.

Gets the name of the underlying symbol source.
public final int
index()

Implements org.antlr.v4.runtime.IntStream.index.

Return the index into the stream of the input symbol referred to by LA(1).
public final int
mark()

Implements org.antlr.v4.runtime.IntStream.mark.

mark/release do nothing; we have entire buffer
public final void
release(int
A marker returned by a call to mark().
marker
)

Implements org.antlr.v4.runtime.IntStream.release.

This method releases a marked range created by a call to mark().
public final void
seek(int
The absolute index to seek to.
index
)

Implements org.antlr.v4.runtime.IntStream.seek.

Set the input cursor to the position indicated by index.
public final int
size()

Implements org.antlr.v4.runtime.IntStream.size.

Returns the total number of symbols in the stream, including a single EOF symbol.
public final boolean
supportsUnicodeCodePoints()

Implements org.antlr.v4.runtime.UnicodeCharStream.supportsUnicodeCodePoints.

Determines if the current stream supports Unicode code points.
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

nameback to summary
protected final String name
positionback to summary
protected int position
sizeback to summary
protected final int size

Constructor Detail

CodePointCharStreamback to summary
private CodePointCharStream(int position, int remaining, String name)

Method Detail

consumeback to summary
public final void consume()

Implements org.antlr.v4.runtime.IntStream.consume.

Doc from org.antlr.v4.runtime.IntStream.consume.

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).
Annotations
@Override
fromBufferback to summary
public static CodePointCharStream fromBuffer(CodePointBuffer codePointBuffer)

Constructs a CodePointCharStream which provides access to the Unicode code points stored in codePointBuffer.

fromBufferback to summary
public static CodePointCharStream fromBuffer(CodePointBuffer codePointBuffer, String name)

Constructs a named CodePointCharStream which provides access to the Unicode code points stored in codePointBuffer.

getInternalStorageback to summary
pack-priv abstract Object getInternalStorage()
getSourceNameback to summary
public final String getSourceName()

Implements org.antlr.v4.runtime.IntStream.getSourceName.

Doc from org.antlr.v4.runtime.IntStream.getSourceName.

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 UNKNOWN_SOURCE_NAME.

Annotations
@Override
indexback to summary
public final int index()

Implements org.antlr.v4.runtime.IntStream.index.

Doc from org.antlr.v4.runtime.IntStream.index.

Return the index into the stream of the input symbol referred to by LA(1).

The behavior of this method is unspecified if no call to an initializing method has occurred after this stream was constructed.

Annotations
@Override
markback to summary
public final int mark()

Implements org.antlr.v4.runtime.IntStream.mark.

mark/release do nothing; we have entire buffer

Returns:int

Doc from org.antlr.v4.runtime.IntStream.mark.

An opaque marker which should be passed to release() when the marked range is no longer required.

Annotations
@Override
releaseback to summary
public final void release(int marker)

Implements org.antlr.v4.runtime.IntStream.release.

Doc from org.antlr.v4.runtime.IntStream.release.

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 mark.

Parameters
marker:int

A marker returned by a call to mark().

Annotations
@Override
seekback to summary
public final void seek(int index)

Implements org.antlr.v4.runtime.IntStream.seek.

Doc from org.antlr.v4.runtime.IntStream.seek.

Set the input cursor to the position indicated by 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 EOF
This operation is guaranteed to not throw an exception if index lies within a marked region. For more information on marked regions, see mark. The behavior of this method is unspecified if no call to an initializing method has occurred after this stream was constructed.
Parameters
index:int

The absolute index to seek to.

Annotations
@Override
sizeback to summary
public final int size()

Implements org.antlr.v4.runtime.IntStream.size.

Doc from org.antlr.v4.runtime.IntStream.size.

Returns the total number of symbols in the stream, including a single EOF symbol.

Annotations
@Override
supportsUnicodeCodePointsback to summary
public final boolean supportsUnicodeCodePoints()

Implements org.antlr.v4.runtime.UnicodeCharStream.supportsUnicodeCodePoints.

Doc from org.antlr.v4.runtime.UnicodeCharStream.supportsUnicodeCodePoints.

Determines if the current stream supports Unicode code points.

Returns:boolean

true if the current input stream supports Unicode code points; otherwise, false if the current input stream returns UTF-16 code units for code points above U+FFFF.

Annotations
@Override
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.antlr.v4.runtime back to summary

private final Class CodePointCharStream.CodePoint16BitCharStream

extends CodePointCharStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final char[]
Inherited from org.antlr.v4.runtime.CodePointCharStream:
namepositionsize

Constructor Summary

AccessConstructor and Description
private
CodePoint16BitCharStream(int position, int remaining, String name, char[] charArray, int arrayOffset)

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
public String
getText(Interval
an interval within the stream
interval
)

Implements org.antlr.v4.runtime.CharStream.getText.

Return the UTF-16 encoded string for the given interval
public int
LA(int i)

Implements org.antlr.v4.runtime.IntStream.LA.

Gets the value of the symbol at offset i from the current position.
Inherited from org.antlr.v4.runtime.CodePointCharStream:
consumefromBufferfromBuffergetSourceNameindexmarkreleaseseeksizesupportsUnicodeCodePointstoString

Field Detail

charArrayback to summary
private final char[] charArray

Constructor Detail

CodePoint16BitCharStreamback to summary
private CodePoint16BitCharStream(int position, int remaining, String name, char[] charArray, int arrayOffset)

Method Detail

getInternalStorageback to summary
pack-priv Object getInternalStorage()

Implements abstract org.antlr.v4.runtime.CodePointCharStream.getInternalStorage.

Annotations
@Override
getTextback to summary
public String getText(Interval interval)

Implements org.antlr.v4.runtime.CharStream.getText.

Return the UTF-16 encoded string for the given interval

Parameters
interval:Interval

Doc from org.antlr.v4.runtime.CharStream.getText.

an interval within the stream

Returns:String

Doc from org.antlr.v4.runtime.CharStream.getText.

the text of the specified interval

Annotations
@Override
LAback to summary
public int LA(int i)

Implements org.antlr.v4.runtime.IntStream.LA.

Doc from org.antlr.v4.runtime.IntStream.LA.

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 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.

Annotations
@Override
org.antlr.v4.runtime back to summary

private final Class CodePointCharStream.CodePoint32BitCharStream

extends CodePointCharStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int[]
Inherited from org.antlr.v4.runtime.CodePointCharStream:
namepositionsize

Constructor Summary

AccessConstructor and Description
private
CodePoint32BitCharStream(int position, int remaining, String name, int[] intArray, int arrayOffset)

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
public String
getText(Interval
an interval within the stream
interval
)

Implements org.antlr.v4.runtime.CharStream.getText.

Return the UTF-16 encoded string for the given interval
public int
LA(int i)

Implements org.antlr.v4.runtime.IntStream.LA.

Gets the value of the symbol at offset i from the current position.
Inherited from org.antlr.v4.runtime.CodePointCharStream:
consumefromBufferfromBuffergetSourceNameindexmarkreleaseseeksizesupportsUnicodeCodePointstoString

Field Detail

intArrayback to summary
private final int[] intArray

Constructor Detail

CodePoint32BitCharStreamback to summary
private CodePoint32BitCharStream(int position, int remaining, String name, int[] intArray, int arrayOffset)

Method Detail

getInternalStorageback to summary
pack-priv Object getInternalStorage()

Implements abstract org.antlr.v4.runtime.CodePointCharStream.getInternalStorage.

Annotations
@Override
getTextback to summary
public String getText(Interval interval)

Implements org.antlr.v4.runtime.CharStream.getText.

Return the UTF-16 encoded string for the given interval

Parameters
interval:Interval

Doc from org.antlr.v4.runtime.CharStream.getText.

an interval within the stream

Returns:String

Doc from org.antlr.v4.runtime.CharStream.getText.

the text of the specified interval

Annotations
@Override
LAback to summary
public int LA(int i)

Implements org.antlr.v4.runtime.IntStream.LA.

Doc from org.antlr.v4.runtime.IntStream.LA.

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 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.

Annotations
@Override
org.antlr.v4.runtime back to summary

private final Class CodePointCharStream.CodePoint8BitCharStream

extends CodePointCharStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final byte[]
Inherited from org.antlr.v4.runtime.CodePointCharStream:
namepositionsize

Constructor Summary

AccessConstructor and Description
private
CodePoint8BitCharStream(int position, int remaining, String name, byte[] byteArray, int arrayOffset)

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
public String
getText(Interval
an interval within the stream
interval
)

Implements org.antlr.v4.runtime.CharStream.getText.

Return the UTF-16 encoded string for the given interval
public int
LA(int i)

Implements org.antlr.v4.runtime.IntStream.LA.

Gets the value of the symbol at offset i from the current position.
Inherited from org.antlr.v4.runtime.CodePointCharStream:
consumefromBufferfromBuffergetSourceNameindexmarkreleaseseeksizesupportsUnicodeCodePointstoString

Field Detail

byteArrayback to summary
private final byte[] byteArray

Constructor Detail

CodePoint8BitCharStreamback to summary
private CodePoint8BitCharStream(int position, int remaining, String name, byte[] byteArray, int arrayOffset)

Method Detail

getInternalStorageback to summary
pack-priv Object getInternalStorage()

Implements abstract org.antlr.v4.runtime.CodePointCharStream.getInternalStorage.

Annotations
@Override
getTextback to summary
public String getText(Interval interval)

Implements org.antlr.v4.runtime.CharStream.getText.

Return the UTF-16 encoded string for the given interval

Parameters
interval:Interval

Doc from org.antlr.v4.runtime.CharStream.getText.

an interval within the stream

Returns:String

Doc from org.antlr.v4.runtime.CharStream.getText.

the text of the specified interval

Annotations
@Override
LAback to summary
public int LA(int i)

Implements org.antlr.v4.runtime.IntStream.LA.

Doc from org.antlr.v4.runtime.IntStream.LA.

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 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.

Annotations
@Override