StreamReader

class StreamReader(loadSettings: LoadSettings, stream: Source)(source)

Reads the provided stream of code points, and implements look-ahead operations.

Checks if code points are in the allowed range. If stream contains invalid UTF-8-encoded bytes, they will be replaced with ?.

Parameters

loadSettings

configuration options

stream

the input

Constructors

Link copied to clipboard
constructor(loadSettings: LoadSettings, stream: String)

Read the provided String into a Buffer and implement look-ahead operations.

constructor(loadSettings: LoadSettings, stream: Source)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
var column: Int

Current position as number (in characters) from the beginning of the current line

Link copied to clipboard

index of the current position from the beginning of the current document.

Link copied to clipboard
var index: Int

Current position as number (in characters) from the beginning stream.

Link copied to clipboard
var line: Int

Current line from the beginning of the stream.

Functions

Link copied to clipboard
fun forward(length: Int = 1)

Read the next length characters and move the pointer.

Link copied to clipboard
fun getMark(): Mark?

Generate Mark of the current position, or null if LoadSettings.useMarks is false.

Link copied to clipboard
fun peek(): Int

Peek the next code point.

fun peek(index: Int): Int

Peek the next index-th code point.

Link copied to clipboard
fun prefix(length: Int): String

Create String from code points.

Link copied to clipboard
fun prefixForward(length: Int): String

prefix(length) immediately followed by forward(length)

Link copied to clipboard

Reset the position to start (at the start of a new document in the stream)