Skip to main content

Crate mos_parse

Crate mos_parse 

Source
Expand description

Parser for the Mosaic source language (.mos).

See manifest §3 (language design) and §6 stages 1–2 (parse + lower). Currently covers:

  • = Heading / == Subheading / === Subsubheading,
  • paragraphs (newline-joined non-empty line groups),
  • inline *emphasis*, **strong**, and `inline code`,
  • #set name(...) blocks, recorded with span and name but interpreted later by the evaluator,
  • #image(...) and #figure(...) directives, sharing the same key: value body grammar as #set plus an optional leading positional string literal (#image("path.png")),
  • raw #pre[[...]] and #code[[...]] long-bracket blocks,
  • <label> attached to the preceding block (trailing on a heading or leading on a paragraph), and @label cross-references as inline InlineKind::Reference runs (manifest §3.3 and the MVP 1 resolver).

Anything outside that subset is preserved as text and a recoverable diagnostic is emitted; the parser never panics on user input (manifest §31).

Structs§

Inline
Inline run produced by the markup tokenizer.
ListItem
One entry inside an Item::List. inlines is the item’s own text (markers stripped, parsed with the same inline tokenizer as paragraphs); children carries nested blocks, currently restricted to further Item::Lists per the MVP scope.
ParseResult
Output of crate::parse. Diagnostics may include warnings even when the tree is structurally usable; callers decide what to do per ParseResult::has_errors.
RawBlockView
Borrowed view of an Item::RawBlock payload.
SyntaxTree
Concrete syntax tree for a single .mos source file.

Enums§

DirectiveKind
Tag for the three directive shapes Item::Set can represent — the #set <target>(...) configuration directive vs the standalone #image(...) and #figure(...) calls. The lowerer dispatches on this rather than the Item::Set::name string so #set image(...) can never collide with #image(...).
InlineKind
Item
Top-level construct in a .mos file.
LengthUnit
RawBlockKind
SetArg
One argument inside a directive body — either a key: value pair (the only form #set accepts) or a positional value (a leading string literal allowed on #image(...) / #figure(...)).
SetValue
Literal values recognised inside a #set body. Full expression evaluation (#let, function calls, if) is deferred to MVP 5; this covers what the manifest examples actually use.

Functions§

parse
Parse a Mosaic source string. Always returns a ParseResult; the parser is recoverable per manifest §6 stage 1.