Expand description
edikt core.
Home of the Value model, the Feature capability enum, and the
expression language (lexer, parse, evaluator). The evaluator is built and
tested here against a plain in-memory Value so the language is correct
independent of any format-preserving CST; the format modules wire the same
AST to their CSTs.
The format-agnostic Document and Convert seams arrive with the JSONC
slice, once there is a concrete CST to shape them against.
Modules§
- convert
- Data-model helpers for format conversion.
- wrap
- Comment wrapping - the shared “use the space as it exists” rule.
Structs§
- Commented
- A
Valueenriched with per-node comments - what conversion carries so a commented source survives-Tinto a commented target. - Comments
- The comments attached to one node, by kind.
- Edit
Error - A format-preserving edit failure (bad path, wrong type for the operation, unsupported construct).
- Eval
Error - An evaluation failure (type error, unknown function, arity mismatch).
- Flat
Entry - One flattened
key = valueline with the comments it carries - the shape the flat emitters (INI sections,.env) place comments through. - Parse
Error - A parse failure with a byte offset into the source expression.
Enums§
- BinOp
- A binary operator.
- Comment
Kind - One of the three comment kinds in the uniform model. Which kinds a format
supports is its comment capability - each format declares a
COMMENT_KINDS: &[CommentKind](empty => no comments, subsuming the booleanFeature::Comments). The#accessor addresses a node’s comment by kind. - Commented
Node - The shape of a
Commentednode, mirroringValue. - Expr
- An expression node.
- Feature
- A capability a config format may or may not support.
- Step
- One navigation step within a path, applied to the current input.
- Value
Traits§
- Document
- A parsed config document.
Functions§
- apply_
comment_ mutation - Apply a comment-mutation expression via the document’s comment write
methods, returning any warnings (layout expansion, kind remap). Comment-free
mutations never reach here - the CLI routes on
Expr::has_comment. - eval
- Evaluate
expragainstinput, returning the output stream. - eval_
with_ comments - Evaluate a query that may address comments (
#) against the document’s commented projection. Comment-free sub-expressions fall back to the plain value evaluator; a comment path resolves the comment text of each selected node. Supported in v0.2 Phase 1 as a read surface: a comment path (.foo.#,.foo.#.inline,.items[].#) optionally piped or defaulted (| ascii_upcase,// "none"). Comment access after a value pipe, or as an assignment target, is not yet served and errors clearly. - flatten_
commented - Flatten a commented tree to dotted-key entries (the commented analogue of
crate::convert::flatten). A container’s own comments ride along: itshead(andinline, which has no line of its own once flattened) prepend to its first entry’shead; itsfootappends to its last entry’sfoot. An empty container vanishes, its comments carried to… nowhere - the caller sees them dropped viaCommented::has_commentson the re-projected result; in practice empty containers with comments are vanishingly rare. - line_
index - The 0-based line index containing byte offset
at. - parse
- Parse a complete expression, consuming all of
src. - place_
line_ comment - Place (or clear) an own-line comment block around a node’s line, on the
source text - for the line-oriented formats (
.env, INI).target_lineis the 0-based index of the node’s own line;is_headputs the block above (else below, for foot). Contiguous existing comment lines on that side (detected byis_comment_line) are replaced;wrapped == Nonedeletes. Untouched lines are preserved verbatim, so the moat holds. - render_
path - Render a path of steps back to jq-ish source text (
.a.b[0],.["a.b"]) for error messages. An empty path is.(identity).