StreamParser

interface StreamParser<State>

A stream parser parses or tokenizes content from start to end, emitting tokens as it goes. It keeps a mutable (but copyable) object with state.

Properties

Link copied to clipboard

Default language data to attach to this language.

Link copied to clipboard

By default, adjacent tokens of the same type are merged. Set to false to disable.

Link copied to clipboard
open val name: String

A name for this language.

Link copied to clipboard
open val tokenTable: Map<String, Any>

Extra tokens to use in this parser. When the tokenizer returns a token name that exists here, the corresponding tags will be assigned.

Functions

Link copied to clipboard
open fun blankLine(state: State, indentUnit: Int)

Called for blank lines. Can update state.

Link copied to clipboard
abstract fun copyState(state: State): State

Copy a given state.

Link copied to clipboard
open fun indent(state: State, textAfter: String, context: IndentContext): Int?

Compute automatic indentation for the line that starts with the given state and text.

Link copied to clipboard
abstract fun startState(indentUnit: Int): State

Produce a start state for the parser.

Link copied to clipboard
abstract fun token(stream: StringStream, state: State): String?

Read one token, advancing the stream past it, and returning a string indicating the token's style tag.