Documentation
¶
Overview ¶
Package projection adds the `{ ... }` projection syntax. The parser dispatches the opening `{` through this bundle's PrimaryExtension; the ProjectionExpr it produces is lowered at build time to the projection runtime action, which evaluates the body with expr-lang. Without this bundle, `{ }` in expression position is a syntax error.
Typical use:
{ name: "Maksymilian", extra: true } -> { name: .name }
{ id: 1, status: "new" } -> { ..., status: "active" }
Index ¶
Constants ¶
const ID = "projection"
Variables ¶
This section is empty.
Functions ¶
func DefaultEvaluator ¶
DefaultEvaluator returns the input unchanged.
func Library ¶
Library returns the runtime projection action bound to eval. A nil eval falls back to DefaultEvaluator, which is a pass-through — used only in isolated parser tests.
func Primary ¶
func Primary() core.PrimaryExtension
Primary returns the parser extension. Exposed so tests can build a parser without spinning up the whole bundle.
Types ¶
type Evaluator ¶
Evaluator converts a projection body into a value. NewExprEvaluator is the production implementation; DefaultEvaluator is a pass-through used only in isolated tests.
func NewExprEvaluator ¶
func NewExprEvaluator() Evaluator
NewExprEvaluator compiles each projection body once and caches it. The transformation rules are documented in buildProgramSource and preprocessDots.