Documentation
¶
Overview ¶
Package eval is the total tree-walking evaluator for the Runefile expression sublanguage: it turns an ast.Expr into a string Value. It has no loops or recursion in the language itself (Principle III) — the only branching is the if/else conditional. Variable resolution consults task params first, then run-time overrides, then module assignments (FR-006).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuiltinNames ¶ added in v0.3.0
func BuiltinNames() []string
BuiltinNames returns the sorted names of every built-in function. It is the authoritative set the language registry (internal/language) verifies itself against so completion/hover/validation never drift from evaluation (FR-027).
func ElementsKey ¶ added in v0.7.0
ElementsKey encodes a list so that different elements never give the same text, which the space-joined value cannot promise. Run-once and the cache fingerprint share it so the two identities cannot drift apart.
Types ¶
type Args ¶ added in v0.7.0
Args is one task invocation's bound parameters (spec 030 R1).
Values holds every parameter; a variadic's value is its elements joined by single spaces, the text every reader saw before spec 030. Lists holds the variadic's elements as given, which only quote_each, dependency forwarding, and invocation identity read.
Invariants:
- For every key `k` in `Lists`, `Values[k] == strings.Join(Lists[k], " ")`, except on the dependency path, where `Values[k]` keeps the written arguments' joined text so an empty forwarded list next to other arguments leaves the extra space it always did.
- `Lists` has at most one key.
- `Lists[k]` may be empty only for a `*` parameter, or for a `+` parameter that a dependency call forwarded an empty list into.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator walks expressions against a Scope.
func (*Evaluator) Interpolate ¶
Interpolate expands {{ expr }} placeholders in a body line's raw text using the evaluator. A literal "{{" is written as "{{{{" (and "}}" as "}}}}"). baseSpan locates the line for diagnostics; expression spans are approximate (anchored to the line) since body text is not pre-tokenized.
type Scope ¶
type Scope struct {
Params map[string]string
// Lists holds the current invocation's variadic elements; only
// quote_each reads it (spec 030).
Lists map[string][]string
Overrides map[string]string
Assigns map[string]*ast.Assignment
GOOS string
Arch string
Env func(string) (string, bool)
Now func() string
// contains filtered or unexported fields
}
Scope holds the bindings visible to an expression: task parameters, run-time overrides, and module-level assignments (evaluated lazily, with a cycle guard). Host hooks (env/os/arch/now) are injectable for deterministic tests.
func (*Scope) Fork ¶ added in v0.10.0
Fork returns a scope with the same bindings and host hooks and its own assignment cache, which starts as a copy of s's. A variable first read through the fork is not cached in s, so a check made before a run cannot fix the value the run would read later (spec 050).