eval

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxType_NULL     = 0
	CtxType_Int      = 1
	CtxType_Str      = 2
	CtxType_Bool     = 3
	CtxType_Float    = 4
	CtxType_ArrayOf  = 5
	CtxType_MapOf    = 6
	CtxType_SMapOf   = 7
	CtxType_KMapOf   = 8
	CtxType_Error    = 9
	CtxType_ID       = 10
	CtxType_Func     = 11
	CtxType_TypeCast = 12
	CtxType_Token    = 13 // Id is equvilant token (and, or, xor etc)
)

Variables

View Source
var (
	ErrParamsNotAdapted = errors.New("The number of params is not adapted.")
)

Functions

func BoundArrayIndex

func BoundArrayIndex(i, min, max int) int

func MapIsEmpty

func MapIsEmpty(t map[string]tok.Token) bool

-------------------------------------------------------------------------------------------------------------------------------------------------------

func MapLength

func MapLength(t map[string]tok.Token) (l int)

-------------------------------------------------------------------------------------------------------------------------------------------------------

rv.CurValue = mapLength(x.CurValue.(map[string]tok.Token))

Types

type BobType

type BobType struct {
	Ooops  int
	Ooopsy int
}

type ContextType

type ContextType struct {
	Store map[string]*ContextValueType
	// contains filtered or unexported fields
}

func NewContextType

func NewContextType() (rv *ContextType)

func (*ContextType) Call

func (ctx *ContextType) Call(name string, params ...interface{}) (result []reflect.Value, err error)

Call a function that has been placed in the table

func (*ContextType) DumpContext

func (ctx *ContextType) DumpContext()

func (*ContextType) GetFromContext

func (ctx *ContextType) GetFromContext(id string) (v interface{}, t int, f bool)

func (*ContextType) IsDefinedContext

func (ctx *ContextType) IsDefinedContext(id string) (f bool)

func (*ContextType) NameOfType

func (ctx *ContextType) NameOfType(t int) (rv string)

fmt.Printf(" Found, Type=%d\n", t, eval.Ctx.NameOfType(t))

func (*ContextType) PopFromContext

func (ctx *ContextType) PopFromContext(id string)

func (*ContextType) PushInContext

func (ctx *ContextType) PushInContext(id string, ty int, val interface{})

func (*ContextType) SetInContext

func (ctx *ContextType) SetInContext(id string, ty int, val interface{}) (err error)

type ContextValueType

type ContextValueType struct {
	TypeOf int
	Val    interface{}
	Func   reflect.Value
	Prev   *ContextValueType
}

type EvalType

type EvalType struct {
	Pos     int          //
	Ctx     *ContextType //
	Mm      []tok.Token  //
	Lax_DCL bool         // If true, then auto declare on all assignments
	// Lax_ArrayHash bool         // If true, then [a] == a, { "x":a } == a
	// FloatEQThrUse bool    // If true then compare floats using threshold
	// FloatEQThr    float64 //
	PrintErrorMsg bool
	TestCase      string
}

func (*EvalType) CallFunction

func (eval *EvalType) CallFunction(match string, plist []tok.Token) (rv tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) DclFunction

func (eval *EvalType) DclFunction(id string, fx interface{})

------------------------------------------------------------------------------------------------------------------------------------------------------- Create the function with Fx ptr in the symbol table.

func (*EvalType) InitFunctions

func (eval *EvalType) InitFunctions()

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) ListTokens

func (eval *EvalType) ListTokens() string

------------------------------------------------------------------------------------------------------------------------------------------------------- This is called form PresG (pipe) during error conditions.

func (*EvalType) ParseArrayRef

func (eval *EvalType) ParseArrayRef() (rv tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) ParseJSON

func (eval *EvalType) ParseJSON() (rv tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) ParsePlist

func (eval *EvalType) ParsePlist() (rv []tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) Pres0

func (eval *EvalType) Pres0() (rv tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) Pres1

func (eval *EvalType) Pres1() (TkL tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

Array Slice Ops

Expr [ : Expr ]
Expr [ Expr : ]
Expr [ : ]
Expr [ ExprID ]							-- 			-- Map Ref
Expr . Name								-- 			-- Map Ref xyzzy

ArrayId(expr) [ ... ] MapId(expr) . Name List

xyzzy1857 - not working

Array is just a postfix '[' or '.' operator (Could have been -> too) -->> search for occurrence of "name" in hash

func (*EvalType) Pres2

func (eval *EvalType) Pres2() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- Unary !

func (*EvalType) Pres3

func (eval *EvalType) Pres3() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- Unary +, -

func (*EvalType) Pres4

func (eval *EvalType) Pres4() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- Parse multiplication and division, *, /, %

func (*EvalType) Pres5

func (eval *EvalType) Pres5() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- Parse addition and subtraction, -, + (binary)

func (*EvalType) Pres5a

func (eval *EvalType) Pres5a() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- Parse addition and subtraction, <<, >> (binary)

func (*EvalType) Pres6

func (eval *EvalType) Pres6() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- Parse Compare OPS, <, <=, >, >=

func (*EvalType) Pres7

func (eval *EvalType) Pres7() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- !=, ==, <>

func (*EvalType) Pres8

func (eval *EvalType) Pres8() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- &

func (*EvalType) Pres9

func (eval *EvalType) Pres9() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- | -- Change to "bor" token/ID

func (*EvalType) PresA

func (eval *EvalType) PresA() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- ^

func (*EvalType) PresB

func (eval *EvalType) PresB() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- &&

func (*EvalType) PresC

func (eval *EvalType) PresC() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- ||

func (*EvalType) PresD

func (eval *EvalType) PresD() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- Not Used Uet

func (*EvalType) PresE

func (eval *EvalType) PresE() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- = (assignment), += etc. :=?? Right To Left - how, Recursion?? array and append?? xyzzy R->L not implemented - just one assignemtn at the moment

func (*EvalType) PresF

func (eval *EvalType) PresF() (TkL tok.Token)

------------------------------------------------------------------------------------------------------------------------------------------------------- Computational IF ?:

func (*EvalType) PresG

func (eval *EvalType) PresG() (TkL tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

expr | function-name ( values, ... ) | function-name ( values, ... )

x | Fx | Fy ( w, v ) | Fy ( m, n )

a, b := Fx ( x ) c, err := Fy ( a, b, w, v ) d := Fy ( c, m, n )

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) PresTop

func (eval *EvalType) PresTop() (TkL tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) SetErrorInfo

func (eval *EvalType) SetErrorInfo(rv *tok.Token, format string, args ...interface{})

-------------------------------------------------------------------------------------------------------------------------------------------------------

func (*EvalType) TypeConvertToNumber

func (eval *EvalType) TypeConvertToNumber(TkL tok.Token) (rv tok.Token)

-------------------------------------------------------------------------------------------------------------------------------------------------------

Jump to

Keyboard shortcuts

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