Skip to main content

lex_core/
lib.rs

1//! # lex-parser
2//!
3//!     A parser for the Lex plain text document format.
4//!
5//! Overview
6//!
7//!     Lex is a plain text format for structured information that can scale from a quick one-line
8//!     note to scientific writings, while being easy to write without tooling. The parser transforms
9//!     Lex source text into an abstract syntax tree (AST).
10//!
11//! Parser Architecture
12//!
13//!     The parser uses a multi-stage design that breaks down complexity into simple chunks:
14//!
15//!     1. **Lexing** - Tokenization, semantic indentation, and line classification
16//!     2. **Tree Building** - Creates hierarchical LineContainer structure
17//!     3. **Parsing** - Pattern-based semantic analysis producing IR nodes
18//!     4. **Building** - Constructs AST from IR nodes with location tracking
19//!     5. **Assembly** - Attaches annotations and resolves references
20//!
21//!     This design enables single-pass parsing with each nesting level parsed in isolation.
22//!
23//! Getting Started
24//!
25//!     - For the complete parser design and pipeline details, see the [lex](lex) module
26//!     - For the end-to-end processing pipeline, see [lex::parsing]
27//!     - For AST node types and structure, see [lex::ast]
28//!     - For testing guidelines, see [lex::testing]
29//!
30//! File Layout
31//!
32//!     For the time being, and probably at times, we will be running multiple lexer and parser
33//!     designs side by side. As the code gets more complicated comparing versions is key, and
34//!     having them side by side makes this easier, including comparison testing. These versions
35//!     might, as they do now, have different lexer outputs and parser inputs The contract is to
36//!     have the same global input (the lex source) and the same global output (the AST).
37//!
38//!     But various designs will make different tradeoffs on what gets done in lexing and parsing,
39//!     so we do not commit to a common lexer or parser outputs. But often different designs do
40//!     share a significant amount of code.
41//!
42//!     Hence the layout should be:
43//!         src/lex/parser
44//!           ├── parser       The current parser design
45//!           └── <common>     Shared code for AST building and IR
46//!
47//!     So the general form is src/lex/parser|lexer|design|common
48//!
49//! Testing
50//!
51//!     For comprehensive testing guidelines, see the [testing module](lex::testing).
52//!     All parser tests must follow strict rules using verified lex sources and AST assertions.
53
54#![allow(rustdoc::invalid_html_tags)]
55
56pub mod lex;
57
58/// A simple function to demonstrate the library works
59pub fn hello() -> &'static str {
60    "Hello from lex!"
61}
62
63#[cfg(test)]
64mod tests {
65    use super::*;
66
67    #[test]
68    fn test_hello() {
69        assert_eq!(hello(), "Hello from lex!");
70    }
71}