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 samekey: valuebody grammar as#setplus 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@labelcross-references as inlineInlineKind::Referenceruns (manifest §3.3 and the MVP 1 resolver),[@key]citations as inlineInlineKind::Citationruns. 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§
Structs§
- Inline
- Inline run produced by the markup tokenizer.
- List
Item - One entry inside an
Item::List.inlinesis the item’s own text (markers stripped, parsed with the same inline tokenizer as paragraphs);childrencarries nested blocks, currently restricted to furtherItem::Lists per the MVP scope. - Parse
Result - Output of
crate::parse. Diagnostics may include warnings even when the tree is structurally usable; callers decide what to do perParseResult::has_errors. - RawBlock
View - Borrowed view of an
Item::RawBlockpayload. - Syntax
Tree - Concrete syntax tree for a single
.mossource file.
Enums§
- Directive
Kind - Tag for the directive shapes
Item::Setcan represent: the#set <target>(...)configuration directive vs the standalone#image(...),#figure(...), and#bibliography(...)calls. The lowerer dispatches on this rather than theItem::Set::namestring so#set image(...)can never collide with#image(...). - Inline
Kind - Item
- Top-level construct in a
.mosfile. - Length
Unit - RawBlock
Kind - SetArg
- One argument inside a directive body: either a
key: valuepair (the only form#setaccepts) or a positional value (a leading string literal allowed on#image(...)/#figure(...)). - SetValue
- Literal values recognised inside a
#setbody. 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, emitting recoverable diagnostics to
sink(manifest §6 stage 1). Returns theSyntaxTree; the parser never structurally aborts, so theErrarm only fires if the sink itself asks to stop.