Documentation ¶
Index ¶
- func EvaluateExpression(env envs.Environment, context *types.XObject, expression string) types.XValue
- func EvaluateTemplate(env envs.Environment, context *types.XObject, template string, ...) (string, error)
- func EvaluateTemplateValue(env envs.Environment, context *types.XObject, template string) (types.XValue, error)
- func VisitExpression(expression string, visitor antlr.ParseTreeVisitor) (interface{}, error)
- func VisitTemplate(template string, allowedTopLevels []string, ...) error
- type ErrorListener
- type Escaping
- type Scanner
- type TemplateError
- type TemplateErrors
- type XTokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateExpression ¶
func EvaluateExpression(env envs.Environment, context *types.XObject, expression string) types.XValue
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, context *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, context *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 VisitExpression ¶ added in v0.28.14
func VisitExpression(expression string, visitor antlr.ParseTreeVisitor) (interface{}, error)
VisitExpression parses and visits the given expression with the given visitor
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 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 Scanner ¶ added in v0.13.3
type Scanner interface { Scan() (XTokenType, string) SetUnescapeBody(bool) }
Scanner is something which can scan tokens from input
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 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 )