TOC Toolkit API - v0.1.0
    Preparing search index...

    A reader of a text from its start to its end, for the lexer of a notation. The scanner reads whole code points, so a character outside the basic plane, such as an emoji, is one step. Its position counts UTF-16 code units, so a span cuts the text with slice.

    Index
    • Parameters

      • text: string

      Returns Scanner

    text: string

    The text that the scanner reads.

    • get position(): number

      The offset of the next code point.

      Returns number

    • get done(): boolean

      Whether the whole text is read.

      Returns boolean

    • Returns the next code point without reading it, or undefined at the end of the text.

      Returns Maybe<string>

    • Reads the next code point and returns it, or returns undefined at the end of the text.

      Returns Maybe<string>

    • Whether the text ahead starts with expected. The call reads nothing.

      Parameters

      • expected: string

      Returns boolean

    • Reads expected when the text ahead starts with it, and returns whether it did.

      Parameters

      • expected: string

      Returns boolean

    • Reads code points as long as accepts holds for the next one, and returns what it read. The scanner stands in front of a code point while accepts judges it.

      Parameters

      • accepts: (point: string) => boolean

      Returns string

    • Reads the white space ahead.

      Returns void

    • Returns the span from start, an earlier position, to the current position.

      Parameters

      • start: number

      Returns Span