Documentation
¶
Index ¶
- Constants
- Variables
- func CompareValues(leftVal, rightVal any) int
- func EvalString(input string, varsList ...string) (any, error)
- func EvalStringWithScope(input string, scope Scope) (any, error)
- func ParseTemporalValue(temporalStr string) (interface{}, error)
- type ArgSizeError
- type ArgTypeError
- type ArrayNode
- type Binop
- type BoolNode
- type DotOp
- type EmptyNode
- type EvalError
- func NewErrBadOp(leftType, op, rightType string) *EvalError
- func NewErrIndex(msg string) *EvalError
- func NewErrKeyNotFound(keyName string) *EvalError
- func NewErrKeywordArgument(argName string) *EvalError
- func NewErrTooFewArguments(required []string) *EvalError
- func NewErrTooManyArguments() *EvalError
- func NewErrTypeMismatch(expectType string) *EvalError
- func NewErrValue(msg string) *EvalError
- func NewEvalError(code int, short string, msgs ...string) *EvalError
- type EveryExpr
- type FEELDate
- type FEELDatetime
- func (sdt *FEELDatetime) Add(dur *FEELDuration) *FEELDatetime
- func (sdt FEELDatetime) Compare(other FEELDatetime) int
- func (sdt FEELDatetime) Date() time.Time
- func (sdt FEELDatetime) Equal(other FEELDatetime) bool
- func (sdt FEELDatetime) GetAttr(name string) (interface{}, bool)
- func (sdt FEELDatetime) MarshalJSON() ([]byte, error)
- func (sdt FEELDatetime) String() string
- func (sdt *FEELDatetime) Sub(v HasTime) *FEELDuration
- func (sdt FEELDatetime) Time() time.Time
- type FEELDuration
- type FEELTime
- type ForExpr
- type FunCall
- func (node FunCall) Eval(intp *Interpreter) (any, error)
- func (node FunCall) EvalFunDef(intp *Interpreter, funDef *FunDef) (any, error)
- func (node FunCall) EvalMacro(intp *Interpreter, macro *Macro) (any, error)
- func (node FunCall) EvalNativeFun(intp *Interpreter, funDef *NativeFun) (any, error)
- func (fc FunCall) Repr() string
- func (fc FunCall) TextRange() TextRange
- type FunDef
- type HasAttrs
- type HasDate
- type HasTime
- type IfExpr
- type Interpreter
- func (intp *Interpreter) Bind(name string, value any)
- func (intp Interpreter) Len() int
- func (intp *Interpreter) Pop() Scope
- func (intp *Interpreter) Push(scp Scope)
- func (intp *Interpreter) PushEmpty()
- func (intp Interpreter) Resolve(name string) (any, bool)
- func (intp Interpreter) Set(name string, value any) bool
- func (intp Interpreter) String() string
- type Macro
- type MacroDef
- type MapNode
- type MultiTests
- type NativeFun
- func (nfun NativeFun) ArgNameAt(at int) (string, bool)
- func (nfun *NativeFun) Call(intp *Interpreter, args map[string]interface{}) (interface{}, error)
- func (nfun *NativeFun) Help(help string) *NativeFun
- func (nfun *NativeFun) Optional(argNames ...string) *NativeFun
- func (nfun *NativeFun) Required(argNames ...string) *NativeFun
- func (nfun *NativeFun) Vararg(argName string) *NativeFun
- type NativeFunDef
- type Node
- type NullNode
- type NullValue
- type Number
- func (number *Number) Add(other *Number) *Number
- func (number *Number) Cmp(other *Number) int
- func (number Number) Compare(other Number) int
- func (number Number) Equal(other Number) bool
- func (number Number) Float64() float64
- func (number *Number) FloatDiv(other *Number) *Number
- func (number Number) Int() int
- func (number Number) Int64() int64
- func (number *Number) IntDiv(other *Number) *Number
- func (number *Number) IntMod(other *Number) *Number
- func (number Number) MarshalJSON() ([]byte, error)
- func (number *Number) Mul(other *Number) *Number
- func (number Number) String() string
- func (number *Number) Sub(other *Number) *Number
- type NumberNode
- type Parser
- type Prelude
- type RangeNode
- type RangeValue
- func (rv RangeValue) AfterPoint(p any) (bool, error)
- func (rv RangeValue) AfterRange(other RangeValue) (bool, error)
- func (rv RangeValue) BeforePoint(p any) (bool, error)
- func (rv RangeValue) BeforeRange(other RangeValue) (bool, error)
- func (rv RangeValue) Contains(p any) bool
- func (rv RangeValue) Includes(other RangeValue) (bool, error)
- func (rv RangeValue) Position(p any) (int, error)
- type ScanPosition
- type Scanner
- type ScannerToken
- type Scope
- type SomeExpr
- type StringNode
- type TemporalNode
- type TextRange
- type UnexpectedToken
- type Var
Constants ¶
View Source
const ( TokenEOF = "eof" TokenSpace = "space" TokenCommentSingleLine = "comment/singleline" TokenCommentMultiline = "comment/multiline" TokenName = "name" //TokenFuncall = "funcall" TokenTemporal = "temporal" TokenString = "string" TokenKeyword = "keyword" TokenNumber = "number" )
View Source
const (
Prec = 34 * 8
)
Variables ¶
View Source
var (
ErrParseNumber = errors.New("fail to parse number")
)
View Source
var ErrParseTemporal = errors.New("fail to parse temporal value")
View Source
var Null = &NullValue{}
View Source
var Zero = N(0)
Functions ¶
func CompareValues ¶ added in v0.1.0
func ParseTemporalValue ¶ added in v0.1.0
Types ¶
type ArgSizeError ¶
type ArgSizeError struct {
// contains filtered or unexported fields
}
ArgSizeError
func (ArgSizeError) Error ¶
func (err ArgSizeError) Error() string
type ArgTypeError ¶
type ArgTypeError struct {
// contains filtered or unexported fields
}
arg type error
func (ArgTypeError) Error ¶
func (err ArgTypeError) Error() string
type ArrayNode ¶
type ArrayNode struct { Elements []Node // contains filtered or unexported fields }
array
type EmptyNode ¶ added in v0.1.3
type EmptyNode struct {
// contains filtered or unexported fields
}
Empty node
type EvalError ¶
func NewErrBadOp ¶ added in v0.1.0
func NewErrIndex ¶ added in v0.1.0
func NewErrKeyNotFound ¶ added in v0.1.0
func NewErrKeywordArgument ¶ added in v0.1.0
argument errors
func NewErrTooFewArguments ¶ added in v0.1.0
func NewErrTooManyArguments ¶ added in v0.1.0
func NewErrTooManyArguments() *EvalError
func NewErrTypeMismatch ¶ added in v0.1.0
func NewErrValue ¶ added in v0.1.0
type EveryExpr ¶
type EveryExpr struct { Varname string ListExpr Node FilterExpr Node // contains filtered or unexported fields }
Every expression
type FEELDate ¶ added in v0.1.0
type FEELDate struct {
// contains filtered or unexported fields
}
Date
func (FEELDate) MarshalJSON ¶ added in v0.1.0
type FEELDatetime ¶ added in v0.1.0
type FEELDatetime struct {
// contains filtered or unexported fields
}
Date and Time
func MustParseDatetime ¶ added in v0.1.0
func MustParseDatetime(temporalStr string) *FEELDatetime
func ParseDatetime ¶ added in v0.1.0
func ParseDatetime(temporalStr string) (*FEELDatetime, error)
func (*FEELDatetime) Add ¶ added in v0.1.0
func (sdt *FEELDatetime) Add(dur *FEELDuration) *FEELDatetime
func (FEELDatetime) Compare ¶ added in v0.1.0
func (sdt FEELDatetime) Compare(other FEELDatetime) int
func (FEELDatetime) Date ¶ added in v0.1.0
func (sdt FEELDatetime) Date() time.Time
func (FEELDatetime) Equal ¶ added in v0.1.0
func (sdt FEELDatetime) Equal(other FEELDatetime) bool
func (FEELDatetime) GetAttr ¶ added in v0.1.0
func (sdt FEELDatetime) GetAttr(name string) (interface{}, bool)
func (FEELDatetime) MarshalJSON ¶ added in v0.1.0
func (sdt FEELDatetime) MarshalJSON() ([]byte, error)
func (FEELDatetime) String ¶ added in v0.1.0
func (sdt FEELDatetime) String() string
func (*FEELDatetime) Sub ¶ added in v0.1.0
func (sdt *FEELDatetime) Sub(v HasTime) *FEELDuration
func (FEELDatetime) Time ¶ added in v0.1.0
func (sdt FEELDatetime) Time() time.Time
type FEELDuration ¶ added in v0.1.0
type FEELDuration struct { Neg bool Years int Months int Days int Hours int Minutes int Seconds int }
func NewFEELDuration ¶ added in v0.1.0
func NewFEELDuration(dur time.Duration) *FEELDuration
func ParseDuration ¶ added in v0.1.0
func ParseDuration(temporalStr string) (*FEELDuration, error)
func (FEELDuration) Duration ¶ added in v0.1.0
func (dur FEELDuration) Duration() time.Duration
func (FEELDuration) GetAttr ¶ added in v0.1.0
func (dur FEELDuration) GetAttr(name string) (interface{}, bool)
func (FEELDuration) MarshalJSON ¶ added in v0.1.0
func (dur FEELDuration) MarshalJSON() ([]byte, error)
func (*FEELDuration) Negative ¶ added in v0.1.0
func (dur *FEELDuration) Negative() *FEELDuration
func (FEELDuration) String ¶ added in v0.1.0
func (dur FEELDuration) String() string
type FEELTime ¶ added in v0.1.0
type FEELTime struct {
// contains filtered or unexported fields
}
time
func (FEELTime) MarshalJSON ¶ added in v0.1.0
type ForExpr ¶
type ForExpr struct { Varname string ListExpr Node ReturnExpr Node // contains filtered or unexported fields }
For expression
type FunCall ¶
type FunCall struct { FunRef Node Args []funcallArg // contains filtered or unexported fields }
func (FunCall) EvalFunDef ¶
func (node FunCall) EvalFunDef(intp *Interpreter, funDef *FunDef) (any, error)
func (FunCall) EvalMacro ¶ added in v0.1.0
func (node FunCall) EvalMacro(intp *Interpreter, macro *Macro) (any, error)
func (FunCall) EvalNativeFun ¶
func (node FunCall) EvalNativeFun(intp *Interpreter, funDef *NativeFun) (any, error)
type FunDef ¶
function definition
type IfExpr ¶
type IfExpr struct { Cond Node ThenBranch Node ElseBranch Node // contains filtered or unexported fields }
if expression
type Interpreter ¶
type Interpreter struct {
ScopeStack []Scope
}
func (*Interpreter) Bind ¶
func (intp *Interpreter) Bind(name string, value any)
bind the value to the name of current scope
func (Interpreter) Len ¶
func (intp Interpreter) Len() int
func (*Interpreter) Pop ¶
func (intp *Interpreter) Pop() Scope
func (*Interpreter) Push ¶
func (intp *Interpreter) Push(scp Scope)
func (*Interpreter) PushEmpty ¶
func (intp *Interpreter) PushEmpty()
func (Interpreter) Resolve ¶
func (intp Interpreter) Resolve(name string) (any, bool)
resolve a name from the top of scopestack to bottom
func (Interpreter) Set ¶ added in v0.1.0
func (intp Interpreter) Set(name string, value any) bool
resolve the name and set to new value
func (Interpreter) String ¶
func (intp Interpreter) String() string
type MacroDef ¶ added in v0.1.0
type MacroDef func(intp *Interpreter, args map[string]Node, varArgs []Node) (interface{}, error)
macro
type MultiTests ¶
type MultiTests struct { Elements []Node // contains filtered or unexported fields }
MultiTests
func (MultiTests) Eval ¶
func (node MultiTests) Eval(intp *Interpreter) (any, error)
func (MultiTests) Repr ¶
func (node MultiTests) Repr() string
func (MultiTests) TextRange ¶ added in v0.1.0
func (node MultiTests) TextRange() TextRange
type NativeFun ¶
type NativeFun struct {
// contains filtered or unexported fields
}
func NewNativeFunc ¶
func NewNativeFunc(fn NativeFunDef) *NativeFun
func (*NativeFun) Call ¶
func (nfun *NativeFun) Call(intp *Interpreter, args map[string]interface{}) (interface{}, error)
type NativeFunDef ¶
native function
type Node ¶ added in v0.1.0
type Node interface { Repr() string Eval(*Interpreter) (any, error) TextRange() TextRange }
func ParseString ¶
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
func NewNumberFromFloat ¶
func NewNumberFromInt64 ¶
func ParseNumberWithErr ¶ added in v0.1.0
func (Number) MarshalJSON ¶
type NumberNode ¶
type NumberNode struct { Value string // contains filtered or unexported fields }
number
func (NumberNode) Eval ¶
func (n NumberNode) Eval(intp *Interpreter) (any, error)
Evaluate Number node
func (NumberNode) Repr ¶
func (node NumberNode) Repr() string
func (NumberNode) TextRange ¶ added in v0.1.0
func (node NumberNode) TextRange() TextRange
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (Parser) CurrentToken ¶
func (p Parser) CurrentToken() ScannerToken
func (Parser) Unexpected ¶
func (p Parser) Unexpected(expects ...string) *UnexpectedToken
type Prelude ¶
type Prelude struct {
// contains filtered or unexported fields
}
Prelude
func GetPrelude ¶
func GetPrelude() *Prelude
type RangeNode ¶
type RangeNode struct { StartOpen bool Start Node EndOpen bool End Node // contains filtered or unexported fields }
range
type RangeValue ¶
func (RangeValue) AfterPoint ¶ added in v0.1.0
func (rv RangeValue) AfterPoint(p any) (bool, error)
func (RangeValue) AfterRange ¶ added in v0.1.0
func (rv RangeValue) AfterRange(other RangeValue) (bool, error)
func (RangeValue) BeforePoint ¶ added in v0.1.0
func (rv RangeValue) BeforePoint(p any) (bool, error)
func (RangeValue) BeforeRange ¶ added in v0.1.0
func (rv RangeValue) BeforeRange(other RangeValue) (bool, error)
func (RangeValue) Contains ¶
func (rv RangeValue) Contains(p any) bool
func (RangeValue) Includes ¶ added in v0.1.0
func (rv RangeValue) Includes(other RangeValue) (bool, error)
type ScanPosition ¶
type Scanner ¶
type Scanner struct { Pos ScanPosition Eaten int // contains filtered or unexported fields }
func NewScanner ¶
func (Scanner) Current ¶
func (scanner Scanner) Current() ScannerToken
func (*Scanner) Tokens ¶
func (scanner *Scanner) Tokens() ([]ScannerToken, error)
* * Find all tokens
type ScannerToken ¶
type ScannerToken struct { Kind string Value string Pos ScanPosition }
func (ScannerToken) Expect ¶
func (token ScannerToken) Expect(tokenKinds ...string) bool
func (ScannerToken) ExpectKeywords ¶
func (token ScannerToken) ExpectKeywords(words ...string) bool
func (ScannerToken) IsOp ¶
func (token ScannerToken) IsOp() bool
type SomeExpr ¶
type SomeExpr struct { Varname string ListExpr Node FilterExpr Node // contains filtered or unexported fields }
Some expression
type StringNode ¶
type StringNode struct { Value string // contains filtered or unexported fields }
string
func (StringNode) Content ¶
func (node StringNode) Content() string
func (StringNode) Eval ¶
func (node StringNode) Eval(intp *Interpreter) (any, error)
func (StringNode) Repr ¶
func (node StringNode) Repr() string
func (StringNode) TextRange ¶ added in v0.1.0
func (node StringNode) TextRange() TextRange
type TemporalNode ¶ added in v0.1.0
type TemporalNode struct { Value string // contains filtered or unexported fields }
temporal
func (TemporalNode) Content ¶ added in v0.1.0
func (node TemporalNode) Content() string
func (TemporalNode) Eval ¶ added in v0.1.0
func (node TemporalNode) Eval(intp *Interpreter) (any, error)
func (TemporalNode) Repr ¶ added in v0.1.0
func (node TemporalNode) Repr() string
func (TemporalNode) TextRange ¶ added in v0.1.0
func (node TemporalNode) TextRange() TextRange
type TextRange ¶ added in v0.1.0
type TextRange struct { Start ScanPosition End ScanPosition }
type UnexpectedToken ¶
type UnexpectedToken struct {
// contains filtered or unexported fields
}
func NewUnexpectedToken ¶
func NewUnexpectedToken(token ScannerToken, callers []string, expects []string) *UnexpectedToken
func (UnexpectedToken) Error ¶
func (err UnexpectedToken) Error() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.