Package-level declarations

Types

Link copied to clipboard

Unicode character classification, and the narrower ASCII whitespace class the syntax rules are defined in.

Link copied to clipboard
object CustomIds

Parsing of the {#custom-id} cross-reference suffix.

Link copied to clipboard

Column arithmetic over raw source text.

Link copied to clipboard
class Line(source: CharSequence, val start: Int, val end: Int, val nextStart: Int)

A single line of a scanned source, with its indentation precomputed. Lines are produced once per source by Lines.of and never re-sliced.

Link copied to clipboard
class LineCursor(lines: List<Line>, val index: Int)

An immutable view over the lines of a source, positioned at one of them. Recognizers receive a cursor and never mutate it, so no state is shared between them.

Link copied to clipboard
object Lines

Factory of Lines.

Link copied to clipboard
object Matchers

Leaf matchers shared by the scanners and by the better-parse grammars. Each returns how many characters it matches at an index, or zero for no match, which is the signature better-parse's Token.match takes.

Link copied to clipboard
class Scanner(val source: CharSequence, val limit: Int = source.length, var index: Int = 0)

A cursor over a bounded slice of a source.

Link copied to clipboard
class TrailingCustomId(val contentEnd: Int, val value: String?)

The outcome of looking for a {#custom-id} suffix.

Properties

Link copied to clipboard

What may precede a function call, as an alternation: the start of a line, whitespace, or a character that is not a letter, a digit, a dot or a backslash.

Link copied to clipboard
const val MAX_BLOCK_INDENT: Int = 3

Highest indentation, in columns, a block-level construct may have before it becomes indented code.

Link copied to clipboard
const val TAB_WIDTH: Int = 4

Width of a tab stop, in columns, as defined by CommonMark.

Functions

Link copied to clipboard
fun commentEndAt(source: CharSequence, index: Int): Int?

A comment closes either abruptly, with > or -> right after the opening, or at the first -->.

Link copied to clipboard
Link copied to clipboard

Detects where a call may begin, without consuming anything. A call begins either at its own . followed by an identifier character, or at the { of a wrapped call.

Link copied to clipboard

The same rule as FUNCTION_CALL_PATTERN_BEFORE, as a predicate: the two must agree, since the compiler lexes with this one and the language server matches with that one.

Link copied to clipboard
fun Line.scanner(from: Int = start, to: Int = end): Scanner
Link copied to clipboard

Consumes a {#identifier} suffix.

Link copied to clipboard

Consumes a title enclosed in double quotes, single quotes or parentheses. A backslash escapes the next character, and the closing delimiter may not appear unescaped inside. The title may span lines, but not a blank one, since the construct it belongs to ends where a paragraph does.

Link copied to clipboard

Consumes a backslash and the character it escapes, which may not be a line terminator.

Link copied to clipboard
fun Scanner.takeOnelineMath(accepts: Scanner.() -> Boolean = { true }): String?

Consumes a one-line math expression. It opens with a dollar sign and one space or tab and closes with one space or tab and a dollar sign; an inner dollar sign belongs to the expression as long as it is not adjacent to whitespace.

Link copied to clipboard

Removes every comment, leaving the rest of the text untouched. A <!-- that never closes is text, not a comment, so it survives.