moonbitlang/core/lexbuf does not have a README file

    AsyncLexbuf

    pub struct AsyncLexbuf {
    // private fields
    }

    An asynchronous UTF-16 input buffer for lexscan, fed by string chunks. Chunks may be released after lexscan has finished consuming them.

    AsyncLexbuf::from_fn

    fn AsyncLexbuf::from_fn(source : async () -> String?) -> AsyncLexbuf

    Creates an initially empty lexbuf. source asynchronously returns the next chunk, or None at EOF. Empty chunks are ignored.

    Lexbuf

    pub struct Lexbuf {
    // private fields
    }

    A synchronous UTF-16 input buffer for lexscan, fed by string chunks. Chunks may be released after lexscan has finished consuming them.

    Lexbuf::from_fn

    fn Lexbuf::from_fn(source : () -> String?) -> Lexbuf

    Creates an initially empty lexbuf. source returns the next chunk, or None at EOF. Empty chunks are ignored.

    Lexbuf::from_string

    #deprecated("Use `StringScanner` instead")
    fn Lexbuf::from_string(content : String) -> Lexbuf

    Creates a lexbuf whose complete input is already available.

    Deprecated: use StringScanner instead.

    StringScanner

    pub(all) struct StringScanner {
    data : StringView
    cursor : Int
    }

    A lightweight scanner for a StringView input.

    StringScanner is a non-streaming target for lexscan. Unlike Lexbuf and AsyncLexbuf, it does not refill its input and does not support retention. The generated scanner advances cursor after each selected case, so the same value can be passed to successive lexscan expressions.

    Both data offsets and cursor are measured in UTF-16 code units. The cursor is relative to data: it starts at 0 and remains in the range 0..=data.length(). A StringView slice is therefore a valid input, and scanning it does not read outside the slice.

    let scanner = @lexbuf.StringScanner::{ data: "hello 42"[:], cursor: 0, }

    let token = scanner {
    as word => word
    => " "
    _ => "?"
    }