LazyReader

alpaca.internal.lexer.LazyReader
See theLazyReader companion object
final class LazyReader(reader: Reader, var size: Long) extends CharSequence, Closeable

A lazy character sequence that reads from a Reader on demand.

This class is useful for tokenizing large files without loading them entirely into memory. It buffers characters as they are accessed and can efficiently skip over processed characters.

Value parameters

reader

the underlying Reader to read from

size

the total size of the input (if known)

Attributes

Companion
object
Experimental
true
Source
LazyReader.scala
Graph
Supertypes
trait Closeable
trait AutoCloseable
trait CharSequence
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def charAt(pos: Int): Char

Gets the character at the specified position.

Gets the character at the specified position.

This will read from the underlying Reader if necessary.

Value parameters

pos

the position (0-based)

Attributes

Returns

the character at that position

Throws
IndexOutOfBoundsException

if the position is beyond the end of input

Source
LazyReader.scala
override def close(): Unit

Attributes

Definition Classes
Closeable -> AutoCloseable
Source
LazyReader.scala
def from(count: Int): LazyReader

Skips the first count characters.

Skips the first count characters.

This is used to advance past tokens that have been processed. Uses O(1) logical offset advancement instead of O(n) buffer shifting. Periodically compacts the buffer when offset exceeds 64KB to bound memory waste.

Value parameters

count

the number of characters to skip

Attributes

Returns

this LazyReader for chaining

Source
LazyReader.scala
def length: Int

Gets the length of the input.

Gets the length of the input.

Attributes

Returns

the length, capped at Int.MaxValue

Source
LazyReader.scala
def subSequence(start: Int, end: Int): CharSequence

Creates a subsequence.

Creates a subsequence.

Value parameters

end

the end position (exclusive)

start

the start position (inclusive)

Attributes

Returns

a string containing the subsequence

Source
LazyReader.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
CharSequence -> Any
Source
LazyReader.scala

Inherited methods

def chars(): IntStream

Attributes

Inherited from:
CharSequence
def codePoints(): IntStream

Attributes

Inherited from:
CharSequence
def isEmpty(): Boolean

Attributes

Inherited from:
CharSequence