Movatterモバイル変換


[0]ホーム

URL:


repl

packagemodule
v0.0.0-...-6c59bf5Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License:Apache-2.0, BSD-3-ClauseImports:23Imported by:1

Details

Repository

github.com/google/cel-go

Links

Documentation

Overview

Package repl defines a set of utilities for working with command line processing of CEL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcParseType

func ParseType(tstring) (*exprpb.Type,error)

ParseType parses a human readable type string into the protobuf representation.

funcUnparseType

func UnparseType(t *exprpb.Type)string

UnparseType pretty-prints a type for the REPL.

Types

typeCmder

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 specificcommand type.

funcParse

func Parse(linestring) (Cmder,error)

Parse parses a repl command line into a command object. This providesthe normalized command name plus any parsed parameters (e.g. variable namesin let statements).

An error is returned if the statement isn't well formed. See the parserpacakage for details on the antlr grammar.

typeEvaluationContext

type EvaluationContext struct {// contains filtered or unexported fields}

EvaluationContext context for the repl.Handles maintaining state for multiple let expressions.

typeEvaluator

type Evaluator struct {// contains filtered or unexported fields}

Evaluator provides basic environment for evaluating an expression withapplied context.

funcNewEvaluator

func NewEvaluator() (*Evaluator,error)

NewEvaluator returns an inialized evaluator

func (*Evaluator)AddDeclFn

func (e *Evaluator) AddDeclFn(namestring, params []letFunctionParam, typeHint *exprpb.Type)error

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

func (e *Evaluator) AddDeclVar(namestring, typeHint *exprpb.Type)error

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(namestring, params []letFunctionParam, resultType *exprpb.Type, exprstring)error

AddLetFn adds a let function to the evaluation context.

func (*Evaluator)AddLetVar

func (e *Evaluator) AddLetVar(namestring, exprstring, typeHint *exprpb.Type)error

AddLetVar adds a let variable to the evaluation context.The expression is planned but evaluated lazily.

func (*Evaluator)AddOption

func (e *Evaluator) AddOption(optOptioner)error

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)Compile

func (e *Evaluator) Compile(exprstring) (*cel.Ast,error)

Compile compiles the input expression using the current REPL context.

func (*Evaluator)DelLetFn

func (e *Evaluator) DelLetFn(namestring)error

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

func (e *Evaluator) DelLetVar(namestring)error

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

func (e *Evaluator) EnablePartialEval()error

EnablePartialEval enables the option to allow partial evaluations.

func (*Evaluator)Evaluate

func (e *Evaluator) Evaluate(exprstring) (ref.Val, *exprpb.Type,error)

Evaluate sets up a CEL evaluation using the current REPL context.

func (*Evaluator)Parse

func (e *Evaluator) Parse(exprstring) (*cel.Ast,error)

Parse parses the input expression using the current REPL context.

func (*Evaluator)Process

func (e *Evaluator) Process(cmdCmder) (string,bool,error)

Process processes the command provided.

func (*Evaluator)Status

func (e *Evaluator) Status()string

Status returns a stringified view of the current evaluator state.

typeOptioner

type Optioner interface {// Option returns the cel.EnvOption that should be applied to the// environment.Option()cel.EnvOption}

Optioner interface represents an option set on the base CEL environment used bythe evaluator.

Source Files

View all Source files

Directories

PathSynopsis
appenginemodule
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 ”)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp