Sign in

    #cst

    The token stream grouped per statement. IdlCst::to_source() is the text byte for byte, also when the parser skipped a statement.

    ///|
    test {
    let s = @scanner.tokenize_text("string Foo\n")
    let st = @cst.StatementCst::new(
    kind=Shape(Simple(String)),
    name=Some("Foo"),
    tokens=s.tokens,
    )
    inspect(@cst.IdlCst::new(s, [st]).to_source(), content="string Foo\n")
    }

    IdlCst

    Every token of a file, grouped per statement. statements tile tokens in order; trivia is the stream's trivia for a text with no token.

    IdlCst::new

    The CST of a scanned stream with its statements.

    IdlCst::skipped

    fn IdlCst::skipped(self : IdlCst) -> Array[StatementCst]

    The runs the parser skipped.

    IdlCst::to_source

    fn IdlCst::to_source(self : IdlCst) -> String

    The scanned text, byte for byte.

    StatementCst

    The tokens of one statement, with their trivia. name is the control key, metadata key, namespace, used shape ID, shape name or apply target; None for a skipped run. span runs from the first token's start to the last token's end, trivia excluded; empty at 0 with no token.

    StatementCst::new

    Group tokens as one statement; the span runs from the first token's start to the last token's end.

    StatementCst::to_source

    fn StatementCst::to_source(self : StatementCst) -> String

    The text of the statement's tokens with their trivia.

    StatementKind

    pub(all) enum StatementKind {
    Control
    Metadata
    Namespace
    Use
    Shape(
    ShapeKind
    )
    Apply
    Skipped
    } derive(Eq,
    Debug
    )

    What a statement's tokens parsed as. Skipped is a run the parser reported and skipped (recovery per statement).

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io