Documentation ¶
Index ¶
- Constants
- func EvaluateExpression(env utils.Environment, context types.XValue, template string) (types.XValue, error)
- func EvaluateTemplate(env utils.Environment, context types.XValue, template string, ...) (types.XValue, error)
- func EvaluateTemplateAsString(env utils.Environment, context types.XValue, template string, urlEncode bool, ...) (string, error)
- func NewErrorListener() *errorListener
- func NewXScanner(r io.Reader, identifierTopLevels []string) *xscanner
- func ResolveValue(env utils.Environment, variable types.XValue, key string) types.XValue
- type TemplateErrors
- type Visitor
- func (v *Visitor) Visit(tree antlr.ParseTree) interface{}
- func (v *Visitor) VisitAdditionOrSubtraction(ctx *gen.AdditionOrSubtractionContext) interface{}
- func (v *Visitor) VisitArrayLookup(ctx *gen.ArrayLookupContext) interface{}
- func (v *Visitor) VisitAtomReference(ctx *gen.AtomReferenceContext) interface{}
- func (v *Visitor) VisitComparison(ctx *gen.ComparisonContext) interface{}
- func (v *Visitor) VisitConcatenation(ctx *gen.ConcatenationContext) interface{}
- func (v *Visitor) VisitContextReference(ctx *gen.ContextReferenceContext) interface{}
- func (v *Visitor) VisitDecimalLiteral(ctx *gen.DecimalLiteralContext) interface{}
- func (v *Visitor) VisitDotLookup(ctx *gen.DotLookupContext) interface{}
- func (v *Visitor) VisitEquality(ctx *gen.EqualityContext) interface{}
- func (v *Visitor) VisitExponent(ctx *gen.ExponentContext) interface{}
- func (v *Visitor) VisitFalse(ctx *gen.FalseContext) interface{}
- func (v *Visitor) VisitFunctionCall(ctx *gen.FunctionCallContext) interface{}
- func (v *Visitor) VisitFunctionParameters(ctx *gen.FunctionParametersContext) interface{}
- func (v *Visitor) VisitMultiplicationOrDivision(ctx *gen.MultiplicationOrDivisionContext) interface{}
- func (v *Visitor) VisitNegation(ctx *gen.NegationContext) interface{}
- func (v *Visitor) VisitParentheses(ctx *gen.ParenthesesContext) interface{}
- func (v *Visitor) VisitParse(ctx *gen.ParseContext) interface{}
- func (v *Visitor) VisitStringLiteral(ctx *gen.StringLiteralContext) interface{}
- func (v *Visitor) VisitTrue(ctx *gen.TrueContext) interface{}
Constants ¶
const ( // BODY - Not in expression BODY xToken = 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 )
Variables ¶
This section is empty.
Functions ¶
func EvaluateExpression ¶
func EvaluateExpression(env utils.Environment, context types.XValue, template string) (types.XValue, error)
EvaluateExpression evalutes the passed in template, returning the raw value it evaluates to
func EvaluateTemplate ¶
func EvaluateTemplate(env utils.Environment, context types.XValue, template string, allowedTopLevels []string) (types.XValue, error)
EvaluateTemplate tries to evaluate the passed in template into an object, this only works if the template is a single identifier or expression, ie: "@contact" or "@(first(contact.urns))". In cases which are not a single identifier or expression, we return the stringified value
func EvaluateTemplateAsString ¶
func EvaluateTemplateAsString(env utils.Environment, context types.XValue, template string, urlEncode bool, allowedTopLevels []string) (string, error)
EvaluateTemplateAsString evaluates the passed in template returning the string value of its execution
func NewErrorListener ¶ added in v0.6.2
func NewErrorListener() *errorListener
func NewXScanner ¶ added in v0.6.2
NewXScanner returns a new instance of our excellent scanner
func ResolveValue ¶ added in v0.8.0
ResolveValue will resolve the passed in string variable given in dot notation and return the value as defined by the Resolvable passed in.
Example syntaxes:
foo.bar.0 - 0th element of bar slice within foo, could also be "0" key in bar map within foo foo.bar[0] - same as above
Types ¶
type TemplateErrors ¶
type TemplateErrors []error
TemplateErrors represents the list of errors we may have received during execution
func (TemplateErrors) Error ¶
func (e TemplateErrors) Error() string
Error returns a single string describing all the errors encountered
type Visitor ¶
type Visitor struct { gen.BaseExcellent2Visitor // contains filtered or unexported fields }
func NewVisitor ¶
func NewVisitor(env utils.Environment, resolver types.XValue) *Visitor
NewVisitor creates a new Excellent visitor
func (*Visitor) VisitAdditionOrSubtraction ¶
func (v *Visitor) VisitAdditionOrSubtraction(ctx *gen.AdditionOrSubtractionContext) interface{}
VisitAdditionOrSubtraction deals with addition and subtraction like 5+5 and 5-3
func (*Visitor) VisitArrayLookup ¶
func (v *Visitor) VisitArrayLookup(ctx *gen.ArrayLookupContext) interface{}
VisitArrayLookup deals with lookups such as foo[5]
func (*Visitor) VisitAtomReference ¶
func (v *Visitor) VisitAtomReference(ctx *gen.AtomReferenceContext) interface{}
VisitAtomReference deals with visiting a single atom in our expression
func (*Visitor) VisitComparison ¶
func (v *Visitor) VisitComparison(ctx *gen.ComparisonContext) interface{}
VisitComparison deals with visiting a comparison between two values, such as 5<3 or 3>5
func (*Visitor) VisitConcatenation ¶
func (v *Visitor) VisitConcatenation(ctx *gen.ConcatenationContext) interface{}
VisitConcatenation deals with string concatenations like "foo" & "bar"
func (*Visitor) VisitContextReference ¶
func (v *Visitor) VisitContextReference(ctx *gen.ContextReferenceContext) interface{}
VisitContextReference deals with references to variables in the context such as "foo"
func (*Visitor) VisitDecimalLiteral ¶
func (v *Visitor) VisitDecimalLiteral(ctx *gen.DecimalLiteralContext) interface{}
VisitDecimalLiteral deals with decimals like 1.5
func (*Visitor) VisitDotLookup ¶
func (v *Visitor) VisitDotLookup(ctx *gen.DotLookupContext) interface{}
VisitDotLookup deals with lookups like foo.0 or foo.bar
func (*Visitor) VisitEquality ¶
func (v *Visitor) VisitEquality(ctx *gen.EqualityContext) interface{}
VisitEquality deals with equality or inequality tests 5 = 5 and 5 != 5
func (*Visitor) VisitExponent ¶
func (v *Visitor) VisitExponent(ctx *gen.ExponentContext) interface{}
VisitExponent deals with exponenets such as 5^5
func (*Visitor) VisitFalse ¶
func (v *Visitor) VisitFalse(ctx *gen.FalseContext) interface{}
VisitFalse deals with the "false" literal
func (*Visitor) VisitFunctionCall ¶
func (v *Visitor) VisitFunctionCall(ctx *gen.FunctionCallContext) interface{}
VisitFunctionCall deals with function calls like TITLE(foo.bar)
func (*Visitor) VisitFunctionParameters ¶
func (v *Visitor) VisitFunctionParameters(ctx *gen.FunctionParametersContext) interface{}
VisitFunctionParameters deals with the parameters to a function call
func (*Visitor) VisitMultiplicationOrDivision ¶
func (v *Visitor) VisitMultiplicationOrDivision(ctx *gen.MultiplicationOrDivisionContext) interface{}
VisitMultiplicationOrDivision deals with division and multiplication such as 5*5 or 5/2
func (*Visitor) VisitNegation ¶
func (v *Visitor) VisitNegation(ctx *gen.NegationContext) interface{}
VisitNegation deals with negations such as -5
func (*Visitor) VisitParentheses ¶
func (v *Visitor) VisitParentheses(ctx *gen.ParenthesesContext) interface{}
VisitParentheses deals with expressions in parentheses such as (1+2)
func (*Visitor) VisitParse ¶
func (v *Visitor) VisitParse(ctx *gen.ParseContext) interface{}
VisitParse handles our top level parser
func (*Visitor) VisitStringLiteral ¶
func (v *Visitor) VisitStringLiteral(ctx *gen.StringLiteralContext) interface{}
VisitStringLiteral deals with string literals such as "asdf"
func (*Visitor) VisitTrue ¶
func (v *Visitor) VisitTrue(ctx *gen.TrueContext) interface{}
VisitTrue deals with the "true" literal