InputStream

Tokenizers interact with the input through this interface. It presents the input as a stream of characters, tracking lookahead and hiding the complexity of ranges from tokenizer code.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var end: Int
Link copied to clipboard
Link copied to clipboard
var next: Int

The character code of the next code unit in the input, or -1 at EOF.

Link copied to clipboard
var pos: Int

The current position of the stream.

Link copied to clipboard

Functions

Link copied to clipboard
fun acceptToken(token: Int, endOffset: Int = 0)

Accept a token. By default, the end of the token is set to the current stream position, but you can pass an offset (relative to the stream position) to change that.

Link copied to clipboard
fun acceptTokenTo(token: Int, endPos: Int)

Accept a token ending at a specific given position.

Link copied to clipboard
fun advance(n: Int = 1): Int

Move the stream forward N (defaults to 1) code units. Returns the new value of next.

Link copied to clipboard
fun clipPos(pos: Int): Int
Link copied to clipboard
fun peek(offset: Int): Int

Look at a code unit near the stream position. .peek(0) equals .next, .peek(-1) gives you the previous character, and so on.

Link copied to clipboard
fun read(from: Int, to: Int): String
Link copied to clipboard
fun resolveOffset(offset: Int, assoc: Int): Int?