Documentation
¶
Index ¶
- Constants
- Variables
- func CompareValues(leftVal, rightVal any) int
- func EvalString(input 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 EvalError
- func NewErrBadInput(row int, column int, inputText string) *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 NewEvalError(code int, short string, msgs ...string) *EvalError
- type EveryExpr
- type ExprList
- type FEELDate
- type FEELDatetime
- func (dt *FEELDatetime) Add(dur *FEELDuration) *FEELDatetime
- func (dt FEELDatetime) Compare(other FEELDatetime) int
- func (dt FEELDatetime) Date() time.Time
- func (dt FEELDatetime) Equal(other FEELDatetime) bool
- func (dt FEELDatetime) GetAttr(name string) (interface{}, bool)
- func (dt FEELDatetime) MarshalJSON() ([]byte, error)
- func (dt FEELDatetime) String() string
- func (dt *FEELDatetime) Sub(v HasTime) *FEELDuration
- func (dt FEELDatetime) Time() time.Time
- type FEELDuration
- type FEELTime
- type ForExpr
- type FunCall
- func (fc FunCall) Eval(intp *Interpreter) (any, error)
- func (fc FunCall) EvalFunDef(intp *Interpreter, funDef *FunDef) (any, error)
- func (fc FunCall) EvalMacro(intp *Interpreter, macro *Macro) (any, error)
- func (fc 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 (i *Interpreter) Bind(name string, value any)
- func (i Interpreter) Len() int
- func (i *Interpreter) Pop() Scope
- func (i *Interpreter) Push(scp Scope)
- func (i *Interpreter) PushEmpty()
- func (i Interpreter) Resolve(name string) (any, bool)
- func (i Interpreter) Set(name string, value any) bool
- func (i Interpreter) String() string
- type Macro
- type MacroDef
- type MapNode
- type MultiTests
- type NativeFun
- func (nativeFun NativeFun) ArgNameAt(at int) (string, bool)
- func (nativeFun *NativeFun) Call(intp *Interpreter, args map[string]interface{}) (interface{}, error)
- func (nativeFun *NativeFun) Help(help string) *NativeFun
- func (nativeFun *NativeFun) Optional(argNames ...string) *NativeFun
- func (nativeFun *NativeFun) Required(argNames ...string) *NativeFun
- func (nativeFun *NativeFun) Vararg(argName string) *NativeFun
- type NativeFunDef
- type Node
- type NullNode
- type NullValue
- type Number
- func (n *Number) Add(other *Number) *Number
- func (n *Number) Cmp(other *Number) int
- func (n Number) Compare(other Number) int
- func (n Number) Equal(other Number) bool
- func (n Number) Float64() float64
- func (n *Number) FloatDiv(other *Number) *Number
- func (n Number) Int() int
- func (n Number) Int64() int64
- func (n *Number) IntDiv(other *Number) *Number
- func (n *Number) IntMod(other *Number) *Number
- func (n Number) MarshalJSON() ([]byte, error)
- func (n *Number) Mul(other *Number) *Number
- func (n Number) String() string
- func (n *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 Zero = N(0)
Functions ¶
func CompareValues ¶
func EvalString ¶
func ParseTemporalValue ¶
Types ¶
type ArgSizeError ¶
type ArgSizeError struct {
// contains filtered or unexported fields
}
func (ArgSizeError) Error ¶
func (self ArgSizeError) Error() string
type ArgTypeError ¶
type ArgTypeError struct {
// contains filtered or unexported fields
}
func (ArgTypeError) Error ¶
func (self ArgTypeError) Error() string
type ArrayNode ¶
type ArrayNode struct {
Elements []Node
// contains filtered or unexported fields
}
type BoolNode ¶
type BoolNode struct {
Value bool
// contains filtered or unexported fields
}
type EvalError ¶
func NewErrBadInput ¶ added in v0.1.5
func NewErrBadOp ¶
func NewErrIndex ¶
func NewErrKeyNotFound ¶
func NewErrKeywordArgument ¶
NewErrKeywordArgument argument errors
func NewErrTooFewArguments ¶
func NewErrTooManyArguments ¶
func NewErrTooManyArguments() *EvalError
func NewErrTypeMismatch ¶
type EveryExpr ¶
type EveryExpr struct {
Varname string
ListExpr Node
FilterExpr Node
// contains filtered or unexported fields
}
EveryExpr Every expression
type ExprList ¶
type ExprList struct {
Elements []Node
// contains filtered or unexported fields
}
ExprList Expression List
type FEELDate ¶
type FEELDate struct {
// contains filtered or unexported fields
}
func (FEELDate) MarshalJSON ¶
type FEELDatetime ¶
type FEELDatetime struct {
// contains filtered or unexported fields
}
func MustParseDatetime ¶
func MustParseDatetime(temporalStr string) *FEELDatetime
func ParseDatetime ¶
func ParseDatetime(temporalStr string) (*FEELDatetime, error)
func (*FEELDatetime) Add ¶
func (dt *FEELDatetime) Add(dur *FEELDuration) *FEELDatetime
func (FEELDatetime) Compare ¶
func (dt FEELDatetime) Compare(other FEELDatetime) int
func (FEELDatetime) Date ¶
func (dt FEELDatetime) Date() time.Time
func (FEELDatetime) Equal ¶
func (dt FEELDatetime) Equal(other FEELDatetime) bool
func (FEELDatetime) GetAttr ¶
func (dt FEELDatetime) GetAttr(name string) (interface{}, bool)
func (FEELDatetime) MarshalJSON ¶
func (dt FEELDatetime) MarshalJSON() ([]byte, error)
func (FEELDatetime) String ¶
func (dt FEELDatetime) String() string
func (*FEELDatetime) Sub ¶
func (dt *FEELDatetime) Sub(v HasTime) *FEELDuration
func (FEELDatetime) Time ¶
func (dt FEELDatetime) Time() time.Time
type FEELDuration ¶
type FEELDuration struct {
Neg bool
Years int
Months int
Days int
Hours int
Minutes int
Seconds int
}
func NewFEELDuration ¶
func NewFEELDuration(dur time.Duration) *FEELDuration
func ParseDuration ¶
func ParseDuration(temporalStr string) (*FEELDuration, error)
func (FEELDuration) Duration ¶
func (duration FEELDuration) Duration() time.Duration
func (FEELDuration) GetAttr ¶
func (duration FEELDuration) GetAttr(name string) (interface{}, bool)
func (FEELDuration) MarshalJSON ¶
func (duration FEELDuration) MarshalJSON() ([]byte, error)
func (FEELDuration) Negative ¶
func (duration FEELDuration) Negative() *FEELDuration
func (FEELDuration) String ¶
func (duration FEELDuration) String() string
type FEELTime ¶
type FEELTime struct {
// contains filtered or unexported fields
}
func (FEELTime) MarshalJSON ¶
type ForExpr ¶
type ForExpr struct {
Varname string
ListExpr Node
ReturnExpr Node
// contains filtered or unexported fields
}
ForExpr FOR expression
type FunCall ¶
type FunCall struct {
FunRef Node
Args []funcallArg
// contains filtered or unexported fields
}
func (FunCall) EvalFunDef ¶
func (fc FunCall) EvalFunDef(intp *Interpreter, funDef *FunDef) (any, error)
func (FunCall) EvalMacro ¶
func (fc FunCall) EvalMacro(intp *Interpreter, macro *Macro) (any, error)
func (FunCall) EvalNativeFun ¶
func (fc FunCall) EvalNativeFun(intp *Interpreter, funDef *NativeFun) (any, error)
type IfExpr ¶
type Interpreter ¶
type Interpreter struct {
ScopeStack []Scope
}
func NewIntepreter ¶
func NewIntepreter() *Interpreter
func (*Interpreter) Bind ¶
func (i *Interpreter) Bind(name string, value any)
Bind the value to the name of current scope
func (Interpreter) Len ¶
func (i Interpreter) Len() int
func (*Interpreter) Pop ¶
func (i *Interpreter) Pop() Scope
func (*Interpreter) Push ¶
func (i *Interpreter) Push(scp Scope)
func (*Interpreter) PushEmpty ¶
func (i *Interpreter) PushEmpty()
func (Interpreter) Resolve ¶
func (i Interpreter) Resolve(name string) (any, bool)
Resolve a name from the top of scopestack to bottom
func (Interpreter) Set ¶
func (i Interpreter) Set(name string, value any) bool
Set the name and set to new value
func (Interpreter) String ¶
func (i Interpreter) String() string
type MacroDef ¶
type MacroDef func(intp *Interpreter, args map[string]Node, varArgs []Node) (interface{}, error)
type MultiTests ¶
type MultiTests struct {
Elements []Node
// contains filtered or unexported fields
}
func (MultiTests) Eval ¶
func (mt MultiTests) Eval(intp *Interpreter) (any, error)
func (MultiTests) Repr ¶
func (mt MultiTests) Repr() string
func (MultiTests) TextRange ¶
func (mt MultiTests) TextRange() TextRange
type NativeFun ¶
type NativeFun struct {
// contains filtered or unexported fields
}
func NewNativeFunc ¶
func NewNativeFunc(fn NativeFunDef) *NativeFun
type NativeFunDef ¶
NativeFunDef native function
type Node ¶
type Node interface {
Repr() string
Eval(*Interpreter) (interface{}, error)
TextRange() TextRange
}
func ParseString ¶
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
func NewNumberFromFloat ¶
func NewNumberFromInt64 ¶
func ParseNumberWithErr ¶
func (Number) MarshalJSON ¶
type NumberNode ¶
type NumberNode struct {
Value string
// contains filtered or unexported fields
}
func (NumberNode) Eval ¶
func (numberNode NumberNode) Eval(intp *Interpreter) (any, error)
Eval Evaluate Number node
func (NumberNode) Repr ¶
func (numberNode NumberNode) Repr() string
func (NumberNode) TextRange ¶
func (numberNode 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
}
func GetPrelude ¶
func GetPrelude() *Prelude
type RangeNode ¶
type RangeValue ¶
func (RangeValue) AfterPoint ¶
func (rv RangeValue) AfterPoint(p any) (bool, error)
func (RangeValue) AfterRange ¶
func (rv RangeValue) AfterRange(other RangeValue) (bool, error)
func (RangeValue) BeforePoint ¶
func (rv RangeValue) BeforePoint(p any) (bool, error)
func (RangeValue) BeforeRange ¶
func (rv RangeValue) BeforeRange(other RangeValue) (bool, error)
func (RangeValue) Contains ¶
func (rv RangeValue) Contains(p any) bool
func (RangeValue) Includes ¶
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)
Tokens 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
}
SomeExpr some expression
type StringNode ¶
type StringNode struct {
Value string
// contains filtered or unexported fields
}
func (StringNode) Content ¶
func (stringNode StringNode) Content() string
func (StringNode) Eval ¶
func (stringNode StringNode) Eval(intp *Interpreter) (any, error)
func (StringNode) Repr ¶
func (stringNode StringNode) Repr() string
func (StringNode) TextRange ¶
func (stringNode StringNode) TextRange() TextRange
type TemporalNode ¶
type TemporalNode struct {
Value string
// contains filtered or unexported fields
}
func (TemporalNode) Content ¶
func (tempNode TemporalNode) Content() string
func (TemporalNode) Eval ¶
func (tempNode TemporalNode) Eval(intp *Interpreter) (any, error)
func (TemporalNode) Repr ¶
func (tempNode TemporalNode) Repr() string
func (TemporalNode) TextRange ¶
func (tempNode TemporalNode) TextRange() TextRange
type TextRange ¶
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 (self UnexpectedToken) Error() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.
