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(...), #figure(...), and #bibliography(...) directives, sharing the same key: value body grammar as #set plus an optional leading positional string literal (#image("path.png"), #bibliography("refs.bib")),
  • 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),
  • [@key] citations as inline InlineKind::Citation runs. Only the single-key form is recognised in this slice; bibliography loading and rendering are deferred to MVP 4.

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

Modules§

block 🔒
directive 🔒
inline 🔒
list 🔒
syntax 🔒

Structs§

Inline
Inline run produced by the markup tokenizer.
ListItem
One entry inside an Item::List.
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 directive shapes Item::Set can represent.
InlineKind
Item
Top-level construct in a .mos file.
LengthUnit
ListItemBlock
Ordered content inside a ListItem.
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 into a SyntaxTree.