Documentation ¶
Index ¶
- Constants
- Variables
- func EqualsComparison(left, right interface{}) bool
- func GreaterThanComparison(left, right interface{}) bool
- func GreaterThanOrEqualComparison(left, right interface{}) bool
- func IntBuiltin(value interface{}) interface{}
- func LenBuiltin(value interface{}) int
- func LessThanComparison(left, right interface{}) bool
- func LessThanOrEqualComparison(left, right interface{}) bool
- func NotEqualsComparison(left, right interface{}) bool
- func RegisterAlias(packageName, memberName string, f interface{})
- func RegisterAliases(packageName string, data ...interface{})
- func RegisterBuiltin(name string, f interface{})
- func YieldBuiltin(name string, context *Context) interface{}
- type AdditiveValue
- type Assignment
- func (c *Assignment) AddCode(Code) error
- func (c *Assignment) AddExecutable(Executable)
- func (c *Assignment) Execute(context *Context) ExecutionState
- func (c *Assignment) IsCodeContainer() bool
- func (c *Assignment) IsContentContainer() bool
- func (c *Assignment) IsSibling() bool
- func (c *Assignment) Rollback(context *Context)
- type BooleanCondition
- type Code
- type Codes
- type Coercable
- type ComparisonOperator
- type Condition
- type ConditionGroup
- type ConditionResolver
- type Context
- type DefaultLogger
- type DefaultYieldValue
- type DynamicFieldType
- type DynamicValue
- type Executable
- type ExecutionState
- type Literal
- type Logger
- type LogicalOperator
- type ModulatedValue
- type MultiplicativeValue
- type NormalContainer
- type OperationFactory
- type Parser
- func (p *Parser) Backwards(length int)
- func (p *Parser) Consume() byte
- func (p *Parser) ConsumeIf(bytes []byte) bool
- func (p *Parser) Dump(prefix string)
- func (p *Parser) Error(s string) error
- func (p *Parser) Next() byte
- func (p *Parser) Peek() byte
- func (p *Parser) Prev() byte
- func (p *Parser) ReadArgs() ([]Value, error)
- func (p *Parser) ReadAssignment() (*Assignment, error)
- func (p *Parser) ReadBuiltin(invert bool) (Value, bool)
- func (p *Parser) ReadChar(negate, invert bool) (Value, error)
- func (p *Parser) ReadCloseTag() error
- func (p *Parser) ReadComment() (trim bool, err error)
- func (p *Parser) ReadComparisonOperator() ComparisonOperator
- func (p *Parser) ReadConditionGroup(parentheses bool) (Verifiable, error)
- func (p *Parser) ReadDynamic(negate, invert bool) (Value, error)
- func (p *Parser) ReadIndexing() ([]Value, error)
- func (p *Parser) ReadLiteral(trim bool) *Literal
- func (p *Parser) ReadLogicalOperator() LogicalOperator
- func (p *Parser) ReadNumber(negate, invert bool) (Value, error)
- func (p *Parser) ReadString(negate, invert bool, end byte, allowEscape bool) (Value, error)
- func (p *Parser) ReadTagType() TagType
- func (p *Parser) ReadToken() (string, error)
- func (p *Parser) ReadTokenList() ([]string, error)
- func (p *Parser) ReadValue() (Value, error)
- func (p *Parser) ReadValueList() ([]Value, error)
- func (p *Parser) SkipSpaces() byte
- func (p *Parser) SkipUntil(b byte) bool
- func (p *Parser) TagContains(b byte) bool
- type PlusEqualValue
- type SilentLogger
- type StaticValue
- type TagType
- type Type
- type UnaryOperationFactory
- type Value
- func AddOperation(a, b Value) Value
- func DecrementOperation(a Value) Value
- func DivideOperation(a, b Value) Value
- func IncrementOperation(a Value) Value
- func MinusEqualOperation(a, b Value) Value
- func ModuloOperation(a, b Value) Value
- func MultiplyOperation(a, b Value) Value
- func PlusEqualOperation(a, b Value) Value
- func SubOperation(a, b Value) Value
- type Verifiable
Constants ¶
View Source
const ( OR LogicalOperator = iota AND UnknownLogicalOperator Equals ComparisonOperator = iota NotEquals LessThan GreaterThan LessThanOrEqual GreaterThanOrEqual UnknownComparisonOperator String Type = iota Nil Int Int64 Uint Float64 Complex128 Bool Time Today Array Unknown )
View Source
const ( NormalState ExecutionState = iota BreakState ContinueState OutputTag TagType = iota UnsafeTag CodeTag CommentTag NoTag )
Variables ¶
View Source
var ( TrueCondition = &BooleanCondition{&StaticValue{true}} FalseCondition = &BooleanCondition{&StaticValue{false}} )
View Source
var Builtins = make(map[string]interface{})
View Source
var BytePool = bytepool.New(65536, 64)
View Source
var ConditionLookup = map[ComparisonOperator]ConditionResolver{ Equals: EqualsComparison, NotEquals: NotEqualsComparison, LessThan: LessThanComparison, GreaterThan: GreaterThanComparison, LessThanOrEqual: LessThanOrEqualComparison, GreaterThanOrEqual: GreaterThanOrEqualComparison, }
View Source
var FunctionAliases = make(map[string]map[string]interface{})
View Source
var KindToType = map[reflect.Kind]Type{ reflect.String: String, reflect.Int: Int, reflect.Int64: Int64, reflect.Uint: Uint, reflect.Float64: Float64, reflect.Complex128: Complex128, reflect.Bool: Bool, reflect.Array: Array, reflect.Slice: Array, reflect.Map: Array, }
View Source
var OneStaticValue = &StaticValue{1}
View Source
var Operations = map[string]OperationFactory{ "+=": PlusEqualOperation, "-=": MinusEqualOperation, "+": AddOperation, "-": SubOperation, "*": MultiplyOperation, "/": DivideOperation, "%": ModuloOperation, }
View Source
var OtherAliases = make(map[string]map[string]interface{})
View Source
var TypeOperations = map[Type]map[ComparisonOperator]ConditionResolver{ String: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left.(string) == right.(string) }, LessThan: func(left, right interface{}) bool { return left.(string) < right.(string) }, }, Nil: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left == nil && right == nil }, LessThan: func(left, right interface{}) bool { return false }, }, Int: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left.(int) == right.(int) }, LessThan: func(left, right interface{}) bool { return left.(int) < right.(int) }, }, Int64: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left.(int64) == right.(int64) }, LessThan: func(left, right interface{}) bool { return left.(int64) < right.(int64) }, }, Uint: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left.(uint) == right.(uint) }, LessThan: func(left, right interface{}) bool { return left.(uint) < right.(uint) }, }, Float64: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left.(float64) == right.(float64) }, LessThan: func(left, right interface{}) bool { return left.(float64) < right.(float64) }, }, Complex128: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left.(complex128) == right.(complex128) }, LessThan: func(left, right interface{}) bool { return false }, }, Bool: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left.(bool) == right.(bool) }, LessThan: func(left, right interface{}) bool { return false }, }, Time: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return left.(time.Time).Unix() == right.(time.Time).Unix() }, LessThan: func(left, right interface{}) bool { return left.(time.Time).Unix() < right.(time.Time).Unix() }, }, Today: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { l, r := left.(time.Time), right.(time.Time) return l.YearDay() == r.YearDay() && l.Year() == r.Year() }, LessThan: func(left, right interface{}) bool { l, r := left.(time.Time), right.(time.Time) if l.Year() > r.Year() { return false } if l.Year() < r.Year() { return true } return l.YearDay() < r.YearDay() }, }, Array: map[ComparisonOperator]ConditionResolver{ Equals: func(left, right interface{}) bool { return reflect.DeepEqual(left, right) }, LessThan: func(left, right interface{}) bool { return reflect.ValueOf(left).Len() < reflect.ValueOf(right).Len() }, }, }
View Source
var UnaryOperations = map[string]UnaryOperationFactory{ "++": IncrementOperation, "--": DecrementOperation, }
Functions ¶
func EqualsComparison ¶
func EqualsComparison(left, right interface{}) bool
func GreaterThanComparison ¶
func GreaterThanComparison(left, right interface{}) bool
func GreaterThanOrEqualComparison ¶
func GreaterThanOrEqualComparison(left, right interface{}) bool
func IntBuiltin ¶
func IntBuiltin(value interface{}) interface{}
func LenBuiltin ¶
func LenBuiltin(value interface{}) int
func LessThanComparison ¶
func LessThanComparison(left, right interface{}) bool
func LessThanOrEqualComparison ¶
func LessThanOrEqualComparison(left, right interface{}) bool
func NotEqualsComparison ¶
func NotEqualsComparison(left, right interface{}) bool
func RegisterAlias ¶
func RegisterAlias(packageName, memberName string, f interface{})
func RegisterAliases ¶
func RegisterAliases(packageName string, data ...interface{})
func RegisterBuiltin ¶
func RegisterBuiltin(name string, f interface{})
func YieldBuiltin ¶
Types ¶
type AdditiveValue ¶
type AdditiveValue struct {
// contains filtered or unexported fields
}
func (*AdditiveValue) Id ¶
func (v *AdditiveValue) Id() string
func (*AdditiveValue) Resolve ¶
func (v *AdditiveValue) Resolve(context *Context) interface{}
func (*AdditiveValue) ResolveAll ¶
func (v *AdditiveValue) ResolveAll(context *Context) []interface{}
type Assignment ¶
type Assignment struct {
// contains filtered or unexported fields
}
func (*Assignment) AddCode ¶
func (c *Assignment) AddCode(Code) error
func (*Assignment) AddExecutable ¶
func (c *Assignment) AddExecutable(Executable)
func (*Assignment) Execute ¶
func (c *Assignment) Execute(context *Context) ExecutionState
func (*Assignment) IsCodeContainer ¶
func (c *Assignment) IsCodeContainer() bool
func (*Assignment) IsContentContainer ¶
func (c *Assignment) IsContentContainer() bool
func (*Assignment) IsSibling ¶
func (c *Assignment) IsSibling() bool
func (*Assignment) Rollback ¶
func (c *Assignment) Rollback(context *Context)
type BooleanCondition ¶
type BooleanCondition struct {
// contains filtered or unexported fields
}
func (*BooleanCondition) IsTrue ¶
func (c *BooleanCondition) IsTrue(context *Context) bool
type Code ¶
type Code interface { Executable IsCodeContainer() bool IsContentContainer() bool IsSibling() bool AddExecutable(Executable) AddCode(Code) error }
type ComparisonOperator ¶
type ComparisonOperator int
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
represents a conditions (such as x == y)
type ConditionGroup ¶
type ConditionGroup struct {
// contains filtered or unexported fields
}
represents a group of conditions
func (*ConditionGroup) IsTrue ¶
func (g *ConditionGroup) IsTrue(context *Context) bool
type ConditionResolver ¶
type ConditionResolver func(left, right interface{}) bool
Resolves a condition
type DefaultLogger ¶
type DefaultLogger struct {
// contains filtered or unexported fields
}
func (*DefaultLogger) Error ¶
func (l *DefaultLogger) Error(v ...interface{})
type DefaultYieldValue ¶
type DefaultYieldValue struct{}
func (*DefaultYieldValue) Id ¶
func (v *DefaultYieldValue) Id() string
func (*DefaultYieldValue) Resolve ¶
func (v *DefaultYieldValue) Resolve(context *Context) interface{}
func (*DefaultYieldValue) ResolveAll ¶
func (v *DefaultYieldValue) ResolveAll(context *Context) []interface{}
type DynamicFieldType ¶
type DynamicFieldType int
const ( FieldType DynamicFieldType = iota MethodType IndexedType )
type DynamicValue ¶
type DynamicValue struct {
// contains filtered or unexported fields
}
func (*DynamicValue) Id ¶
func (v *DynamicValue) Id() string
func (*DynamicValue) Resolve ¶
func (v *DynamicValue) Resolve(context *Context) interface{}
func (*DynamicValue) ResolveAll ¶
func (v *DynamicValue) ResolveAll(context *Context) []interface{}
func (*DynamicValue) ResolveCorece ¶
func (v *DynamicValue) ResolveCorece(context *Context, to reflect.Type) interface{}
type Executable ¶
type Executable interface {
Execute(context *Context) ExecutionState
}
type ExecutionState ¶
type ExecutionState int
type Literal ¶
type Literal struct {
// contains filtered or unexported fields
}
func (*Literal) Execute ¶
func (l *Literal) Execute(context *Context) ExecutionState
type LogicalOperator ¶
type LogicalOperator int
type ModulatedValue ¶
type ModulatedValue struct {
// contains filtered or unexported fields
}
func (*ModulatedValue) Id ¶
func (v *ModulatedValue) Id() string
func (*ModulatedValue) Resolve ¶
func (v *ModulatedValue) Resolve(context *Context) interface{}
func (*ModulatedValue) ResolveAll ¶
func (v *ModulatedValue) ResolveAll(context *Context) []interface{}
type MultiplicativeValue ¶
type MultiplicativeValue struct {
// contains filtered or unexported fields
}
func (*MultiplicativeValue) Id ¶
func (v *MultiplicativeValue) Id() string
func (*MultiplicativeValue) Resolve ¶
func (v *MultiplicativeValue) Resolve(context *Context) interface{}
func (*MultiplicativeValue) ResolveAll ¶
func (v *MultiplicativeValue) ResolveAll(context *Context) []interface{}
type NormalContainer ¶
type NormalContainer struct {
// contains filtered or unexported fields
}
func (*NormalContainer) AddExecutable ¶
func (c *NormalContainer) AddExecutable(executable Executable)
func (*NormalContainer) Execute ¶
func (c *NormalContainer) Execute(context *Context) ExecutionState
type OperationFactory ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ReadAssignment ¶
func (p *Parser) ReadAssignment() (*Assignment, error)
func (*Parser) ReadCloseTag ¶
func (*Parser) ReadComment ¶
func (*Parser) ReadComparisonOperator ¶
func (p *Parser) ReadComparisonOperator() ComparisonOperator
func (*Parser) ReadConditionGroup ¶
func (p *Parser) ReadConditionGroup(parentheses bool) (Verifiable, error)
func (*Parser) ReadIndexing ¶
func (*Parser) ReadLiteral ¶
func (*Parser) ReadLogicalOperator ¶
func (p *Parser) ReadLogicalOperator() LogicalOperator
func (*Parser) ReadString ¶
func (*Parser) ReadTagType ¶
func (*Parser) ReadTokenList ¶
func (*Parser) ReadValueList ¶
func (*Parser) SkipSpaces ¶
func (*Parser) TagContains ¶
type PlusEqualValue ¶
type PlusEqualValue struct {
// contains filtered or unexported fields
}
func (*PlusEqualValue) Id ¶
func (v *PlusEqualValue) Id() string
func (*PlusEqualValue) Resolve ¶
func (v *PlusEqualValue) Resolve(context *Context) interface{}
func (*PlusEqualValue) ResolveAll ¶
func (v *PlusEqualValue) ResolveAll(context *Context) []interface{}
type SilentLogger ¶
type SilentLogger struct{}
func (*SilentLogger) Error ¶
func (l *SilentLogger) Error(v ...interface{})
type StaticValue ¶
type StaticValue struct {
// contains filtered or unexported fields
}
func (*StaticValue) Id ¶
func (v *StaticValue) Id() string
func (*StaticValue) Resolve ¶
func (v *StaticValue) Resolve(context *Context) interface{}
func (*StaticValue) ResolveAll ¶
func (v *StaticValue) ResolveAll(context *Context) []interface{}
func (*StaticValue) ResolveCoerce ¶
type UnaryOperationFactory ¶
type Value ¶
type Value interface { Resolve(context *Context) interface{} ResolveAll(context *Context) []interface{} Id() string }
func AddOperation ¶
func DecrementOperation ¶
func DivideOperation ¶
func IncrementOperation ¶
func MinusEqualOperation ¶
func ModuloOperation ¶
func MultiplyOperation ¶
func PlusEqualOperation ¶
func SubOperation ¶
type Verifiable ¶
Click to show internal directories.
Click to hide internal directories.