Class CharArrayCharStream
java.lang.Object
net.emustudio.emulib.plugin.compiler.antlr.CharArrayCharStream
- All Implemented Interfaces:
org.antlr.v4.runtime.CharStream, org.antlr.v4.runtime.IntStream
A zero-copy
CharStream backed directly by a char[] slice.
Unlike CharStreams.fromString(String), this
implementation avoids:
- Allocating an intermediate
String - Allocating a
CharBuffer - Allocating a
CodePointBuffer - Copying character data (3× in the standard path)
This makes it suitable for per-line tokenization in RSyntaxTextArea where
getTokenList() is called for every visible line on every keystroke.
Limitation: Assumes all characters are in the BMP (U+0000–U+FFFF), which is true for assembly language source code.
-
Field Summary
Fields inherited from interface org.antlr.v4.runtime.IntStream
EOF, UNKNOWN_SOURCE_NAME -
Constructor Summary
ConstructorsConstructorDescriptionCharArrayCharStream(char[] data, int offset, int length) Wrap a slice of a char array as a CharStream with zero copies. -
Method Summary
-
Constructor Details
-
CharArrayCharStream
public CharArrayCharStream(char[] data, int offset, int length) Wrap a slice of a char array as a CharStream with zero copies.- Parameters:
data- the backing array (NOT copied)offset- first character index in the arraylength- number of characters to expose
-
-
Method Details
-
getText
- Specified by:
getTextin interfaceorg.antlr.v4.runtime.CharStream
-
consume
public void consume()- Specified by:
consumein interfaceorg.antlr.v4.runtime.IntStream
-
LA
public int LA(int i) - Specified by:
LAin interfaceorg.antlr.v4.runtime.IntStream
-
mark
public int mark()- Specified by:
markin interfaceorg.antlr.v4.runtime.IntStream
-
release
public void release(int marker) - Specified by:
releasein interfaceorg.antlr.v4.runtime.IntStream
-
index
public int index()- Specified by:
indexin interfaceorg.antlr.v4.runtime.IntStream
-
seek
public void seek(int index) - Specified by:
seekin interfaceorg.antlr.v4.runtime.IntStream
-
size
public int size()- Specified by:
sizein interfaceorg.antlr.v4.runtime.IntStream
-
getSourceName
- Specified by:
getSourceNamein interfaceorg.antlr.v4.runtime.IntStream
-