Skip to main content

Crate lex_syntax

Crate lex_syntax 

Source
Expand description

M1: lexer, parser, syntax tree, pretty-printer for Lex.

See spec §3 for the grammar.

Re-exports§

pub use loader::load_program;
pub use loader::load_program_from_str;
pub use loader::LoadError;
pub use workspace::find_manifest;
pub use workspace::Manifest;
pub use workspace::PackageError;
pub use parser::parse;
pub use parser::ParseError;
pub use printer::print_program;
pub use token::lex;
pub use token::LexError;
pub use token::Token;
pub use token::TokenKind;
pub use syntax::*;

Modules§

loader
Multi-file loader: resolves import "./...", import "../...", and import "/abs/..." statements relative to the importer, recursively parses, and produces a single Program with all stages merged.
parser
Recursive-descent parser for Lex. Pratt-style precedence climbing for binary operators; everything else is straightforward LL(1)-with-lookahead.
printer
Pretty-printer for the syntax tree. Designed so parse(text) → print → parse round-trips on the canonical AST.
syntax
Syntax tree (the parser’s direct output, before canonicalization in §5).
token
workspace
lex.toml manifest parsing and package resolution.

Enums§

SyntaxError

Functions§

parse_source
Convenience: lex + parse a source string.
parse_source_with_positions
Variant of parse_source that also returns the byte-offset position of each top-level fn declaration in src. Used by the lex check CLI (and any other LLM-facing tooling) to stamp source positions onto lex_types::PositionedErrors.

Type Aliases§

FnPositions
Byte-offset start position of each fn declaration, keyed by function name (#306 slice 1). Used by lex_types::Position renderers to map a type error back to its fn location.