Expand description
Relon parser.
Two public entry points cover the full surface:
parse_document— strict-parse. ReturnsResult<Node, ParseDocumentError>and rejects any input that doesn’t form a complete document. Use it from the analyzer’s main entry, the evaluator, the formatter, and the CLI — they all want a hard fail on broken input.parse_document_recovering— IDE-facing partial-AST entry. Returns aParsedDocument(partial AST + diagnostics) that is always populated, even on completely broken input. Use it from completion / hover / goto-def callers that must keep offering features while the user is mid-edit (#,&,@,{a:, …).
Internals:
cst/syntax— rowan CST, the single source of truth for what input the parser accepts.ast— typed wrappers over the CST nodes.lower— CST → legacyNode/Expr/TokenKeytree. The legacy tree is still public because the analyzer and evaluator depend on its semantic shape; new consumers should prefer theastwrappers (cheap, ranged, error-tolerant).
Re-exports§
pub use fast_path::parse_document_fast;pub use token::*;
Modules§
- ast
- Typed-AST wrappers over the rowan CST.
- cst
- Concrete syntax tree (CST) builder over the lossless
lexoutput. P2 of the rowan rewrite — translates the existing winnow grammar into rowanGreenNodes while preserving every source byte (including whitespace and comments) as first-class tokens. - directive
- Directive name constants and shape-by-name lookup.
- fast_
path - v6-fix-D2-I cold-start parser fast-path.
- lex
- Round-trip lexer for the v2 (rowan-backed) parser.
- rewrite
- Shared, post-analyze AST pattern recognition for high-level rewrites.
- syntax
- Concrete syntax tree (CST) foundation built on
rowan. - token
Structs§
- Parse
Diagnostic - One span-bearing diagnostic from a partial parse. Emitted by
parse_document_recoveringfor every CST recovery point plus any sub-tree the lowering walker could not turn into aNode. - Parsed
Document - Result of
parse_document_recovering. Always populated — even completely unrecoverable input yields an emptynodes+ a non-emptydiagnosticslist.
Enums§
Functions§
- child_
nodes - Yield the expression-shaped child nodes of
nodefor AST walkers (analyzer passes, LSP enclosing-scope lookups, …). Decorators, directives, and type hints are intentionally not included — those have their own dedicated walkers that need different semantics. - combine_
ranges - Combine two
TokenRanges — start fromstart.start, end fromend.end. Used by binary-expression lowering to compute the operand-bounded range. - parse_
document - Parse a Relon document into the legacy
Nodetree. - parse_
document_ recovering - Parse
sourceinto a partial AST + diagnostics. Never returnsErrfor any byte input — even completely broken sources produce an emptynodesvec + a populateddiagnosticslist. - parse_
leading_ comments - Extract leading comments as a single doc string. Walks the byte
prefix of
sourceconsuming whitespace +//line //* */block comments until the first non-trivia byte. Returns the joined doc-comment text (if any) plus the number of bytes consumed — callers use the count to advance their cursor.