Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

API Overview

Reference for the LTX library crates, for Rust consumers embedding LTX as a library. The workspace is seven crates; each owns its domain and its errors. Errors flow through the shared ltx_diagnostics infrastructure to render, but are defined in the crate that produces them.

Crate map

CrateResponsibilityErrors owned
ltx_diagnosticsPure infrastructure — spans, source maps, sinks, miette rendering, ErrorCode registrynone (infra only)
ltx_lexerByte-level tokenizer; catcode handlingLexerError (LTX::LEXER::E001E011)
ltx_parserRecursive-descent parser; AST constructionParserError (LTX::PARSER::E001E006)
ltx_configltx.toml model, validation, scaffoldingConfigError (LTX::CONFIG::E001E008)
ltx_compilerCompilation orchestration; engine dispatchCompilerError (LTX::COMPILER::E001E004, W001)
ltx_utilsLow-level filesystem helpersnone
ltx_cliBinary entry point; subcommand dispatchCliError (CLI-only)

Dependency direction

Dependencies point inward toward reusable infrastructure. ltx_diagnostics never depends on the other crates, so the graph stays acyclic:

ltx_utils ──► ltx_config ──► ltx_compiler ──► ltx_cli
                    │              │
                    ▼              ▼
ltx_lexer ──► ltx_parser ──► ltx_diagnostics (shared rendering)

The diagnostic pipeline

Any error type implements LtxDiagnosticSource and is wrapped in an LtxDiagnostic together with the LtxSourceMap needed to render it. Diagnostics accumulate in an LtxDiagnosticSink, then render with miette or serialize to JSON — the diagnostics crate never needs to know which phase produced an error.

Lexer ──► LexerError ──┐
                       ├─► LtxDiagnostic ──► LtxDiagnosticSink ──► miette renderer
Parser ──► ParserError ┘                                  └─────► JSON

Code registry

Each crate exports a pub const ALL_CODES: &[ErrorCode] table. The CLI aggregates all of them for ltx code:

NamespaceCountSeverities
LTX::LEXER::E0xx11errors
LTX::PARSER::E0xx6errors
LTX::CONFIG::E0xx8errors
LTX::COMPILER::E0xx, W0xx5errors + 1 warning

See the Error codes section for full tables.