script

package
v0.0.0-...-377d37b Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATE  = "create"
	DELETE  = "delete"
	UPDATE  = "update"
	ADD     = "add"
	PRINT   = "print"
	SUB     = "subtract"
	MUL     = "multiply"
	DIV     = "divide"
	VALUE   = "value"
	OPERAND = "operand"
)

Operations constants

View Source
const (
	UNARY = iota
	BINARY
)

operation type either unary or binary

View Source
const (
	DOLLAR = "$"
	HASH   = "#"
)

tokens constants

View Source
const (
	CMD = "cmd"
	ID  = "id"
)
View Source
const InitFunc = "init"
View Source
const UNDEF = "undefined"

Variables

This section is empty.

Functions

func Parse

func Parse(doc map[string]interface{}, vars *Variables, fns *Script) error

Types

type Command

type Command struct {
	CMD        string
	Params     map[string]interface{}
	ParentVars map[string]interface{}
}

func ProcessFunc

func ProcessFunc(fnName string, rawCmds []interface{}) ([]Command, error)

func (*Command) Do

func (c *Command) Do(out *[]interface{}) error

type Func

type Func struct {
	Name     string
	Commands []Command
}

func NewFunc

func NewFunc(name string) *Func

func (*Func) Add

func (f *Func) Add(commands []Command) *Func

type Script

type Script struct {
	sync.RWMutex
	Funcs map[string]*Func
	Out   *[]interface{}
}
var Body *Script

func NewScript

func NewScript() *Script

A NewScript creates a new script instance it returns the new script instance

func (*Script) Execute

func (sc *Script) Execute(fName string, localVars map[string]interface{}) error

func (*Script) Reset

func (s *Script) Reset()

func (*Script) RestOut

func (s *Script) RestOut()

func (*Script) Run

func (s *Script) Run(r io.Reader) error

func (*Script) WithOutPut

func (s *Script) WithOutPut() *Script

type Value

type Value float64

func (Value) String

func (v Value) String() string

type Variables

type Variables struct {
	sync.RWMutex
	V map[string]Value
}
var Vars *Variables

var Variables map[string]Value

func NewVariables

func NewVariables() *Variables

func (*Variables) GetVars

func (v *Variables) GetVars() map[string]Value

func (*Variables) Reset

func (v *Variables) Reset()

Jump to

Keyboard shortcuts

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