bobzhang/codemirror-lang/tokenizer does not have a README file

    Line

    pub struct Line {
    text : String
    start : Int
    // private fields
    }

    An immutable source line shared by an outer language and its embedded readers. Offsets count UTF-16 units. A virtual start hides its prefix from column and indentation, after tabs expand from the physical column zero.

    Line::block_trivia_end

    fn Line::block_trivia_end(self : Line, from : Int) -> Int

    Skip whitespace and C-style block comments inside this visible fragment. Siblings ending at the same physical cutoff can reuse the continuation at each opener. A new right edge invalidates the old results.

    Line::closing_delimiter

    fn Line::closing_delimiter(self : Line, needle : String, from : Int, shared? : Bool) -> (Int?, Bool)

    Share closing-delimiter searches across embedded readers on an immutable line. Escape parity starts at the caller's offset, including inside a run.

    Line::column

    fn Line::column(self : Line, offset : Int) -> Int

    The visual column of a UTF-16 offset. Embedded fragments share the physical tab index, including when an outer mode alternates between virtual origins.

    Line::find_literal

    fn Line::find_literal(self : Line, needle : String, from : Int, shared? : Bool) -> Int?

    Find a nonempty literal at or after a UTF-16 offset, within this fragment. Embedded readers of one physical line share forward delimiter searches. Set shared=false for a progressive reader restricted to its current segment.

    Line::indentation

    fn Line::indentation(self : Line) -> Int

    The visual width of this line's leading ECMAScript whitespace.

    Line::new

    fn Line::new(text : String, tab_size? : Int, start? : Int) -> Line

    The optional virtual start is a signed UTF-16 offset. Embedding modes can place it outside a short line. Each unit beyond either end has width one.

    Line::physical_view

    fn Line::physical_view(self : Line) -> StringView

    A view of this fragment backed by the physical line. Its start offset and backing text support lookbehind without allocating a prefix.

    Line::segment

    fn Line::segment(self : Line, from : Int, to : Int) -> Line

    Read an embedded fragment with local offsets, inherited indentation and the same physical tab stops.

    Line::segment_with_start

    fn Line::segment_with_start(self : Line, from : Int, to : Int, start : Int) -> Line

    Read an embedded fragment with a virtual start relative to this source. Code units beyond its visible end each have width one.

    Line::tab_size

    fn Line::tab_size(self : Line) -> Int

    The caller-supplied tab size, including zero, passed to embedded readers.

    Line::whitespace_end

    fn Line::whitespace_end(self : Line) -> Int

    Offset of the physical line's first non-whitespace code unit, relative to this segment. A negative value places it before the embedded fragment.

    Line::whitespace_start

    fn Line::whitespace_start(self : Line, at : Int) -> Int

    Start of the physical whitespace run immediately before this offset, relative to the visible fragment. A negative result lies in the enclosing prefix.

    Span

    pub(all) struct Span {
    start : Int
    end : Int
    style : String?
    } derive(Eq,
    Debug
    )

    Half-open UTF-16 code-unit offsets into a well-formed source line. Standalone tokenizers return endpoints on Unicode scalar boundaries.

    block_trivia_end

    fn block_trivia_end(line : String, from : Int) -> Int

    Skip ECMAScript whitespace and consecutive C-style block comments. An incomplete comment extends to the end of the input.

    closing_delimiter

    fn closing_delimiter(line : String, needle : String, from : Int) -> (Int?, Bool)

    Find the first literal closer that follows an even number of backslashes. When there is no closer, the boolean reports an unmatched final backslash.

    is_space

    fn is_space(c : UInt16) -> Bool

    ECMAScript WhiteSpace and LineTerminator, as matched by StringStream.eatSpace.

    lines

    fn lines(text : String) -> Iter[String]

    Iterate over lines split by LF, CRLF or CR, including a final empty line.

    scalar_width

    fn scalar_width(first : UInt16) -> Int

    Number of UTF-16 code units in a scalar, given its first code unit in well-formed source text.

    spans

    fn spans(line : String, read : (Int) -> (Int, String?)) -> Iter[Span]

    Visit tokens in a well-formed UTF-16 line. The mode returns an exclusive end offset and style for the token at start. Every token must advance to a scalar boundary within the line.

    whitespace_end

    fn whitespace_end(text : String, start : Int) -> Int