Documentation ¶
Index ¶
- func EvaluateExpression(env envs.Environment, ctx *types.XObject, expression string) types.XValue
- func EvaluateTemplate(env envs.Environment, ctx *types.XObject, template string, escaping Escaping) (string, error)
- func EvaluateTemplateValue(env envs.Environment, ctx *types.XObject, template string) (types.XValue, error)
- func HasExpressions(template string, allowedTopLevels []string) bool
- func VisitTemplate(template string, allowedTopLevels []string, ...) error
- type Addition
- type AnonFunction
- type ArrayLookup
- type BooleanLiteral
- type Concatenation
- type ContextReference
- type Division
- type DotLookup
- type Equality
- type ErrorListener
- type Escaping
- type Exponent
- type Expression
- type FunctionCall
- type GreaterThan
- type GreaterThanOrEqual
- type InEquality
- type LessThan
- type LessThanOrEqual
- type Multiplication
- type Negation
- type NullLiteral
- type NumberLiteral
- type Parentheses
- type Scanner
- type Scope
- type Subtraction
- type TemplateError
- type TemplateErrors
- type TextLiteral
- type XTokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateExpression ¶
EvaluateExpression evalutes the passed in Excellent expression, returning the typed value it evaluates to, which might be an error, e.g. "2 / 3" or "contact.fields.age"
func EvaluateTemplate ¶
func EvaluateTemplate(env envs.Environment, ctx *types.XObject, template string, escaping Escaping) (string, error)
EvaluateTemplate evaluates the passed in template
func EvaluateTemplateValue ¶ added in v0.28.14
func EvaluateTemplateValue(env envs.Environment, ctx *types.XObject, template string) (types.XValue, error)
EvaluateTemplateValue is equivalent to EvaluateTemplate except in the case where the template contains a single identifier or expression, ie: "@contact" or "@(first(contact.urns))". In these cases we return the typed value from EvaluateExpression instead of stringifying the result.
func HasExpressions ¶ added in v0.76.1
HasExpressions returns whether the given template contains any expressions or identifiers
func VisitTemplate ¶ added in v0.28.14
func VisitTemplate(template string, allowedTopLevels []string, callback func(XTokenType, string) error) error
VisitTemplate scans the given template and calls the callback for each token encountered
Types ¶
type Addition ¶ added in v0.141.0
type Addition struct {
// contains filtered or unexported fields
}
type AnonFunction ¶ added in v0.141.0
type AnonFunction struct {
// contains filtered or unexported fields
}
func (*AnonFunction) Evaluate ¶ added in v0.141.0
func (x *AnonFunction) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*AnonFunction) String ¶ added in v0.141.0
func (x *AnonFunction) String() string
type ArrayLookup ¶ added in v0.141.0
type ArrayLookup struct {
// contains filtered or unexported fields
}
func (*ArrayLookup) Evaluate ¶ added in v0.141.0
func (x *ArrayLookup) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*ArrayLookup) String ¶ added in v0.141.0
func (x *ArrayLookup) String() string
type BooleanLiteral ¶ added in v0.141.0
type BooleanLiteral struct {
// contains filtered or unexported fields
}
BooleanLiteral is a literal bool
func (*BooleanLiteral) Evaluate ¶ added in v0.141.0
func (x *BooleanLiteral) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*BooleanLiteral) String ¶ added in v0.141.0
func (x *BooleanLiteral) String() string
type Concatenation ¶ added in v0.141.0
type Concatenation struct {
// contains filtered or unexported fields
}
func (*Concatenation) Evaluate ¶ added in v0.141.0
func (x *Concatenation) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*Concatenation) String ¶ added in v0.141.0
func (x *Concatenation) String() string
type ContextReference ¶ added in v0.141.0
type ContextReference struct {
// contains filtered or unexported fields
}
ContextReference is an identifier which is a function name or root variable in the context
func (*ContextReference) Evaluate ¶ added in v0.141.0
func (x *ContextReference) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*ContextReference) String ¶ added in v0.141.0
func (x *ContextReference) String() string
type Division ¶ added in v0.141.0
type Division struct {
// contains filtered or unexported fields
}
type DotLookup ¶ added in v0.141.0
type DotLookup struct {
// contains filtered or unexported fields
}
type Equality ¶ added in v0.141.0
type Equality struct {
// contains filtered or unexported fields
}
type ErrorListener ¶ added in v0.28.14
type ErrorListener struct { *antlr.DefaultErrorListener // contains filtered or unexported fields }
ErrorListener records syntax errors
func NewErrorListener ¶ added in v0.6.2
func NewErrorListener(expression string) *ErrorListener
NewErrorListener creates a new error listener
func (*ErrorListener) Errors ¶ added in v0.28.14
func (l *ErrorListener) Errors() []error
Errors returns the errors encountered so far
func (*ErrorListener) SyntaxError ¶ added in v0.28.14
func (l *ErrorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException)
SyntaxError handles a new syntax error encountered by the recognizer
type Escaping ¶ added in v0.55.0
Escaping is a function applied to expressions in a template after they've been evaluated
type Exponent ¶ added in v0.141.0
type Exponent struct {
// contains filtered or unexported fields
}
type Expression ¶ added in v0.141.0
Expression is the base interface of all syntax elements
type FunctionCall ¶ added in v0.141.0
type FunctionCall struct {
// contains filtered or unexported fields
}
func (*FunctionCall) Evaluate ¶ added in v0.141.0
func (x *FunctionCall) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*FunctionCall) String ¶ added in v0.141.0
func (x *FunctionCall) String() string
type GreaterThan ¶ added in v0.141.0
type GreaterThan struct {
// contains filtered or unexported fields
}
func (*GreaterThan) Evaluate ¶ added in v0.141.0
func (x *GreaterThan) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*GreaterThan) String ¶ added in v0.141.0
func (x *GreaterThan) String() string
type GreaterThanOrEqual ¶ added in v0.141.0
type GreaterThanOrEqual struct {
// contains filtered or unexported fields
}
func (*GreaterThanOrEqual) Evaluate ¶ added in v0.141.0
func (x *GreaterThanOrEqual) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*GreaterThanOrEqual) String ¶ added in v0.141.0
func (x *GreaterThanOrEqual) String() string
type InEquality ¶ added in v0.141.0
type InEquality struct {
// contains filtered or unexported fields
}
func (*InEquality) Evaluate ¶ added in v0.141.0
func (x *InEquality) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*InEquality) String ¶ added in v0.141.0
func (x *InEquality) String() string
type LessThan ¶ added in v0.141.0
type LessThan struct {
// contains filtered or unexported fields
}
type LessThanOrEqual ¶ added in v0.141.0
type LessThanOrEqual struct {
// contains filtered or unexported fields
}
func (*LessThanOrEqual) Evaluate ¶ added in v0.141.0
func (x *LessThanOrEqual) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*LessThanOrEqual) String ¶ added in v0.141.0
func (x *LessThanOrEqual) String() string
type Multiplication ¶ added in v0.141.0
type Multiplication struct {
// contains filtered or unexported fields
}
func (*Multiplication) Evaluate ¶ added in v0.141.0
func (x *Multiplication) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*Multiplication) String ¶ added in v0.141.0
func (x *Multiplication) String() string
type Negation ¶ added in v0.141.0
type Negation struct {
// contains filtered or unexported fields
}
type NullLiteral ¶ added in v0.141.0
type NullLiteral struct{}
func (*NullLiteral) Evaluate ¶ added in v0.141.0
func (x *NullLiteral) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*NullLiteral) String ¶ added in v0.141.0
func (x *NullLiteral) String() string
type NumberLiteral ¶ added in v0.141.0
type NumberLiteral struct {
// contains filtered or unexported fields
}
NumberLiteral is a literal number like 123 or 1.5
func (*NumberLiteral) Evaluate ¶ added in v0.141.0
func (x *NumberLiteral) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*NumberLiteral) String ¶ added in v0.141.0
func (x *NumberLiteral) String() string
type Parentheses ¶ added in v0.141.0
type Parentheses struct {
// contains filtered or unexported fields
}
func (*Parentheses) Evaluate ¶ added in v0.141.0
func (x *Parentheses) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*Parentheses) String ¶ added in v0.141.0
func (x *Parentheses) String() string
type Scanner ¶ added in v0.13.3
type Scanner interface { Scan() (XTokenType, string) SetUnescapeBody(bool) }
Scanner is something which can scan tokens from input
type Scope ¶ added in v0.141.0
type Scope struct {
// contains filtered or unexported fields
}
Scope provides access to context objects
type Subtraction ¶ added in v0.141.0
type Subtraction struct {
// contains filtered or unexported fields
}
func (*Subtraction) Evaluate ¶ added in v0.141.0
func (x *Subtraction) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*Subtraction) String ¶ added in v0.141.0
func (x *Subtraction) String() string
type TemplateError ¶ added in v0.10.1
type TemplateError struct {
// contains filtered or unexported fields
}
TemplateError is an error which occurs during evaluation of an expression
func (TemplateError) Error ¶ added in v0.10.1
func (e TemplateError) Error() string
type TemplateErrors ¶
type TemplateErrors struct {
// contains filtered or unexported fields
}
TemplateErrors represents the list of all errors encountered during evaluation of a template
func NewTemplateErrors ¶ added in v0.10.1
func NewTemplateErrors() *TemplateErrors
NewTemplateErrors creates a new empty lsit of template errors
func (*TemplateErrors) Add ¶ added in v0.10.1
func (e *TemplateErrors) Add(expression, message string)
Add adds an error for the given expression
func (*TemplateErrors) Error ¶
func (e *TemplateErrors) Error() string
Error returns a single string describing all the errors encountered
func (*TemplateErrors) HasErrors ¶ added in v0.10.1
func (e *TemplateErrors) HasErrors() bool
HasErrors returns whether there are errors
type TextLiteral ¶ added in v0.141.0
type TextLiteral struct {
// contains filtered or unexported fields
}
func (*TextLiteral) Evaluate ¶ added in v0.141.0
func (x *TextLiteral) Evaluate(env envs.Environment, scope *Scope) types.XValue
func (*TextLiteral) String ¶ added in v0.141.0
func (x *TextLiteral) String() string
type XTokenType ¶ added in v0.13.3
type XTokenType int
XTokenType is a set of types than can be scanned
const ( // BODY - Not in expression BODY XTokenType = iota // IDENTIFIER - 'contact.age' in '@contact.age' IDENTIFIER // EXPRESSION - the body of an expression '1+2' in '@(1+2)' EXPRESSION // EOF - end of expression EOF )