Skip to main content

parse_document

Function parse_document 

Source
pub fn parse_document(source: &str) -> Result<Node, ParseDocumentError>
Expand description

Parse a Relon document into the legacy Node tree.

The entry point routes every call through the rowan CST (cst::parse_cst) first, then hands off to lower::lower_document for the typed-tree construction. The CST is the single source of truth for what input the parser accepts; downstream consumers (analyzer / evaluator / fmt / wasm / lsp / cli) keep seeing the same Node / Expr shape they did pre-rowan-rewrite. See the lower module for the migration design note.

This is the strict-parsing entry point — any CST error or lowering failure surfaces as a typed ParseDocumentError. Use it from the analyzer’s main entry, the evaluator, fmt, and the CLI where the caller wants a hard fail on broken input. For IDE features (completion, hover, goto-def) that must tolerate in-progress edits, prefer parse_document_recovering — it never returns Err and yields a partial ParsedDocument + diagnostics.