Documentation ¶
Overview ¶
Package repl defines a set of utilities for working with command line processing of CEL.
Index ¶
- func ParseType(t string) (*exprpb.Type, error)
- func UnparseType(t *exprpb.Type) string
- type Cmder
- type EvaluationContext
- type Evaluator
- func (e *Evaluator) AddDeclFn(name string, params []letFunctionParam, typeHint *exprpb.Type) error
- func (e *Evaluator) AddDeclVar(name string, typeHint *exprpb.Type) error
- func (e *Evaluator) AddLetFn(name string, params []letFunctionParam, resultType *exprpb.Type, expr string) error
- func (e *Evaluator) AddLetVar(name string, expr string, typeHint *exprpb.Type) error
- func (e *Evaluator) AddOption(opt Optioner) error
- func (e *Evaluator) Compile(expr string) (*cel.Ast, error)
- func (e *Evaluator) DelLetFn(name string) error
- func (e *Evaluator) DelLetVar(name string) error
- func (e *Evaluator) EnablePartialEval() error
- func (e *Evaluator) Evaluate(expr string) (ref.Val, *exprpb.Type, error)
- func (e *Evaluator) Parse(expr string) (*cel.Ast, error)
- func (e *Evaluator) Process(cmd Cmder) (string, bool, error)
- func (e *Evaluator) Status() string
- type Optioner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseType ¶
ParseType parses a human readable type string into the protobuf representation. TODO(issue/538): add support for abstract types and validating message types.
func UnparseType ¶
UnparseType pretty-prints a type for the REPL.
TODO(issue/538): This is slightly different from core CEL's built-in formatter. Should converge if possible.
Types ¶
type Cmder ¶
type Cmder interface { // Cmd returns the normalized name for the command. Cmd() string }
Cmder interface provides normalized command name from a repl command. Command specifics are available via checked type casting to the specific command type.
type EvaluationContext ¶
type EvaluationContext struct {
// contains filtered or unexported fields
}
EvaluationContext context for the repl. Handles maintaining state for multiple let expressions.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator provides basic environment for evaluating an expression with applied context.
func NewEvaluator ¶
NewEvaluator returns an inialized evaluator
func (*Evaluator) AddDeclFn ¶
AddDeclFn declares a function in the environment but doesn't register an expr with it. This allows planning to succeed, but with no value for the function at runtime.
func (*Evaluator) AddDeclVar ¶
AddDeclVar declares a variable in the environment but doesn't register an expr with it. This allows planning to succeed, but with no value for the variable at runtime.
func (*Evaluator) AddLetFn ¶
func (e *Evaluator) AddLetFn(name string, params []letFunctionParam, resultType *exprpb.Type, expr string) error
AddLetFn adds a let function to the evaluation context.
func (*Evaluator) AddLetVar ¶
AddLetVar adds a let variable to the evaluation context. The expression is planned but evaluated lazily.
func (*Evaluator) AddOption ¶
AddOption adds an option to the basic environment. Options are applied before evaluating any of the let statements. Returns an error if setting the option prevents planning any of the defined let expressions.
func (*Evaluator) DelLetFn ¶
DelLetFn removes a function from the evaluation context. If deleting the function breaks a later expression, this function will return an error without modifying the context.
func (*Evaluator) DelLetVar ¶
DelLetVar removes a variable from the evaluation context. If deleting the variable breaks a later expression, this function will return an error without modifying the context.
func (*Evaluator) EnablePartialEval ¶
EnablePartialEval enables the option to allow partial evaluations.
Directories ¶
Path | Synopsis |
---|---|
appengine
module
|
|
cel-repl> %let x = 42 cel-repl> %let y = {'a': x, 'b': y} Adding let failed: Error updating y = {'a': x, 'b': y} ERROR: <input>:1:15: undeclared reference to 'y' (in container ”)
|
cel-repl> %let x = 42 cel-repl> %let y = {'a': x, 'b': y} Adding let failed: Error updating y = {'a': x, 'b': y} ERROR: <input>:1:15: undeclared reference to 'y' (in container ”) |