Expand description
Typed abstract syntax tree derived from the CST.
Abstract Syntax Tree (AST) for .cabal files.
The AST is a typed, ergonomic view derived from the CST. It provides
structured access to package metadata, components, dependencies, and
conditionals. Every AST node carries a NodeId back-reference to the
corresponding CST node so that edits can be mapped back to the concrete tree.
The AST does not own the source text: it borrows from the CabalCst’s
source string.
§Usage
use cabalist_parser::{parse, ast::derive_ast};
let source = "cabal-version: 3.0\nname: my-pkg\nversion: 0.1.0.0\n";
let result = parse(source);
let ast = derive_ast(&result.cst);
assert_eq!(ast.name, Some("my-pkg"));Structs§
- Benchmark
- A benchmark component.
- Cabal
File - The top-level AST for a parsed
.cabalfile. - Cabal
Version - The
cabal-versionspecification. - Common
Stanza - A
commonstanza. - Component
Fields - Shared fields across all component types (library, executable, etc.).
- Conditional
- A conditional block (
if/elifwith optionalelse) inside a component. - Dependency
- A parsed dependency from
build-depends. - Executable
- An executable component.
- Field
- A field that was not specifically parsed into a typed representation.
- Flag
- A
flagsection. - Library
- A library component.
- Source
Repository - A
source-repositorysection. - Test
Suite - A test-suite component.
- Version
- A parsed version number like
0.1.0.0.
Enums§
- Component
- A reference to any component type.
- Condition
- A parsed condition expression from
if/elifblocks. - Version
Range - A version constraint expression.
Functions§
- canonicalize_
field_ name - Canonicalize a
.cabalfield name to lowercase with hyphens. - derive_
ast - Derive a typed AST from a parsed CST.
- parse_
condition - Parse a condition expression string.
- parse_
version_ range - Parse a version range string.
- version_
satisfies - Check if a version satisfies a version range (best-effort).