Documentation
¶
Overview ¶
Package exprs answers, without the values, what go-tony evaluates in a charter's strings: which expressions a string holds, and which names each one reads.
A charter's values are expanded by go-tony (eval.ExpandStringWithOptions for text, eval.ExpandIRWithOptions for a value that is one `.[…]`), and a firing binds the names they read. Several things are decided before there are values to evaluate against: whether a value is bound at all (Templated), which part of the subject a firing has to read at a revision (Reads), and, at install, what a derive or a ceiling may assume about a value it cannot know yet. Each of those asks this package, so that what is decided and what is evaluated are the same expressions.
Index ¶
Constants ¶
const Env = "$env"
Env is expr-lang's name for the environment itself. `$env["pr-number"]` is a read of `pr-number`, and `$env` alone, or under a step that is not a constant, reads every name.
Variables ¶
This section is empty.
Functions ¶
func Templated ¶
Templated is whether v holds an expression a firing replaces: a `$[…]`, or a v that is one `.[…]` and nothing else (Whole). A `$` that opens none is text, as it is where the value is used: `$HOME`, `$5`; and so is a `.[` in a value it is not the whole of.
It is the cheap test, and errs toward bound: `$$[` and a `$[` nothing closes are text to the expansion and Templated here. Expressions is the exact one.
Types ¶
type Path ¶
type Path []string
Path is a name an expression reads from its environment, then each field or index under it that the expression names as a constant: `subject.value.round` and `subject?.value["round"]` are [subject value round], `items[0].id` is [items 0 id], and `items[i].id` is [items], since which element is not known until the expression runs (and `i` is a read of its own).
func Reads ¶
Reads is every name expr reads from its environment, as a Path each, in the order they are written; a name read twice is there twice.
A name the expression binds itself is not a read: one a `let` declares, within the expression the `let` is over, and `#` and the `.field` shorthand inside a predicate (`filter`, `map`, `all`, …), which are the element being walked. So `data.findings | filter(.status == "open")` reads `data.findings`, and nothing named `status`. A function's name is not a read either.
An expression that does not parse answers the parser's error, and no reads.
type Span ¶
Span is one expression in a string: its text as the evaluator gets it, escapes undone and trimmed, and where it stands, Start at its `$[` or `.[` and End just past its `]`.
func Expressions ¶
Expressions is each expression go-tony's expansion evaluates in s, in order: s whole, where it is one `.[…]` and nothing else (Whole), and otherwise each `$[…]`. `$$[` is a literal `$[`, and a `$[` that nothing closes is text to the end of s.
The scan is go-tony's own (eval's scanExpression, which is unexported: tony-format issue y5n12a3gh12kraxfx5n0 asks for it), copied rather than approximated, so a nested bracket, a `]` in a quoted string and an escaped `\]` end an expression here where they end it there.