excellent

package
v0.10.14 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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, expression 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(expression string) *errorListener

func NewXScanner added in v0.6.2

func NewXScanner(r io.Reader, identifierTopLevels []string) *xscanner

NewXScanner returns a new instance of our excellent scanner

func ResolveValue added in v0.8.0

func ResolveValue(env utils.Environment, variable types.XValue, key string) types.XValue

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

func (*TemplateErrors) Add added in v0.10.1

func (e *TemplateErrors) Add(expression, message string)

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

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

func (v *Visitor) Visit(tree antlr.ParseTree) interface{}

Visit the top level parse tree

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] or foo["key with spaces"]

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) 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` reserved word

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) VisitNull added in v0.9.2

func (v *Visitor) VisitNull(ctx *gen.NullContext) interface{}

VisitNull deals with the `null` reserved word

func (*Visitor) VisitNumberLiteral added in v0.9.4

func (v *Visitor) VisitNumberLiteral(ctx *gen.NumberLiteralContext) interface{}

VisitNumberLiteral deals with numbers like 123 or 1.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) VisitTextLiteral added in v0.9.4

func (v *Visitor) VisitTextLiteral(ctx *gen.TextLiteralContext) interface{}

VisitTextLiteral deals with string literals such as "asdf"

func (*Visitor) VisitTrue

func (v *Visitor) VisitTrue(ctx *gen.TrueContext) interface{}

VisitTrue deals with the `true` reserved word

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL