Skip to main content

parse_module

Function parse_module 

Source
pub fn parse_module<'a>(seq: &Seq<'a>) -> Result<ModuleSyntax, ParseError>
Expand description

Parse a module source’s top-level sequence into its declarations: one name = body item or one import per non-comment chain, in source order. Unlike parse_program a module is a multi-chain sequence, and a body is not resolved here — crate::compile_module runs crate::resolve::resolve_module_bodies afterwards so a body may refer to any sibling regardless of order. An item’s left-hand side is a single bare name in v0 (no destructuring at module top level); duplicate names and non-name LHSs are rejected. See docs/done/2026-08-07_elly-modules-v0.md.

An import chain has no top-level = in its private form, so it is recognized before the = split rather than reported as a MalformedBinding. Its two forms are described on ImportDecl; Foo = import "spec" also pushes the item Foo that forwards the slot, since it is written as an item and should read as one from outside.

A const declaration is read the same way and follows the same privacy convention: const false and const (false, true) are private, false = const declares the iota and the item that exports it.

A local declaration is the ordinary binding under the same convention: local x = <expr> and the group local (x = <expr> …) bind a member the module’s own bodies reach and nothing outside can, where the bare x = <expr> beside them is the export form.