Sign in

    moonrockz/gleam-parser/cst does not have a README file

    DefinitionCst

    The tokens of one definition, with their trivia. name is the module path of an import, the name of a constant, function or type, or None for a skipped run or an anonymous head. span runs from the first token's start to the last token's end (trivia not included); 0..0 when there is no token.

    DefinitionCst::new

    DefinitionCst::to_source

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

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

    DefinitionKind

    pub(all) enum DefinitionKind {
    Import
    Constant
    Function
    CustomType
    TypeAlias
    Skipped
    } derive(Eq, Hash,
    Debug
    )

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

    ModuleCst

    Every token of a module, grouped per definition. definitions tile tokens in order; trivia is the stream's trivia for a text with no token.

    test {
    let stream = @scanner.tokenize_text("const x = 1\n")
    let d = @cst.DefinitionCst::new(
    kind=Constant,
    name=Some("x"),
    tokens=stream.tokens,
    )
    let cst = @cst.ModuleCst::new(stream, [d])
    inspect(cst.to_source(), content="const x = 1\n")
    }

    ModuleCst::to_source

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

    The scanned text, byte for byte.

    trivia_extra

    The ModuleExtra positions that come from trivia, as the compiler's Parser::next_token gathers them: the content span of every comment by kind; the start of every line end (\r for \r\n); and an empty line, recorded as the previous line end's start plus one, for every line end that follows another line end in the same gap between two tokens with no comment between them (whitespace does not break the pair). The trailing commas come from the parser; here the list is empty.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io