interpreter

package
v0.2.1-beta Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: GPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	Exit(code int)
	Print(args ...string)
	SwitchOn(name string) (bool, error)
	Switch(name string, on bool) error
	Play(server string, mode string) error
	Notify(title string, description string, level LogLevel) error
	Log(title string, description string, level LogLevel) error

	// Builtin variables
	GetUser() string
	GetWeather() (string, error)
	GetTemperature() (int, error)
	GetDate() (int, int, int, int, int, int)
}

type LogLevel

type LogLevel uint8
const (
	LevelTrace LogLevel = iota
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

type Value

type Value interface {
	Type() ValueType
	TypeName() string
	ToString(executor Executor) (string, error)
	IsTrue(executor Executor) (bool, error)
	IsEqual(executor Executor, other Value) (bool, error)
}

func Exit

func Exit(executor Executor, args ...Value) (Value, error)

func GetCurrentDay

func GetCurrentDay(executor Executor) (Value, error)

func GetCurrentHour

func GetCurrentHour(executor Executor) (Value, error)

func GetCurrentMinute

func GetCurrentMinute(executor Executor) (Value, error)

func GetCurrentMonth

func GetCurrentMonth(executor Executor) (Value, error)

func GetCurrentSecond

func GetCurrentSecond(executor Executor) (Value, error)

func GetCurrentYear

func GetCurrentYear(executor Executor) (Value, error)

func GetTemperature

func GetTemperature(executor Executor) (Value, error)

func GetUser

func GetUser(executor Executor) (Value, error)

//////////// Variables //////////////

func GetWeather

func GetWeather(executor Executor) (Value, error)

func Log

func Log(executor Executor, args ...Value) (Value, error)

func Notify

func Notify(executor Executor, args ...Value) (Value, error)

func Play

func Play(executor Executor, args ...Value) (Value, error)

func Print

func Print(executor Executor, args ...Value) (Value, error)

func Sleep

func Sleep(_ Executor, args ...Value) (Value, error)

func Switch

func Switch(executor Executor, args ...Value) (Value, error)

func SwitchOn

func SwitchOn(executor Executor, args ...Value) (Value, error)

type ValueBoolean

type ValueBoolean struct{ Value bool }

func (ValueBoolean) IsEqual

func (self ValueBoolean) IsEqual(_ Executor, other Value) (bool, error)

func (ValueBoolean) IsTrue

func (self ValueBoolean) IsTrue(_ Executor) (bool, error)

func (ValueBoolean) ToString

func (self ValueBoolean) ToString(_ Executor) (string, error)

func (ValueBoolean) Type

func (self ValueBoolean) Type() ValueType

func (ValueBoolean) TypeName

func (self ValueBoolean) TypeName() string

type ValueFunction

type ValueFunction struct {
	Callback func(executor Executor, args ...Value) (Value, error)
}

func (ValueFunction) IsEqual

func (self ValueFunction) IsEqual(_ Executor, other Value) (bool, error)

func (ValueFunction) IsTrue

func (self ValueFunction) IsTrue(_ Executor) (bool, error)

func (ValueFunction) ToString

func (self ValueFunction) ToString(_ Executor) (string, error)

func (ValueFunction) Type

func (self ValueFunction) Type() ValueType

func (ValueFunction) TypeName

func (self ValueFunction) TypeName() string

type ValueNumber

type ValueNumber struct{ Value int }

func (ValueNumber) IsEqual

func (self ValueNumber) IsEqual(_ Executor, other Value) (bool, error)

func (ValueNumber) IsGreaterThan

func (self ValueNumber) IsGreaterThan(executor Executor, other Value) (bool, error)

func (ValueNumber) IsGreaterThanOrEqual

func (self ValueNumber) IsGreaterThanOrEqual(executor Executor, other Value) (bool, error)

func (ValueNumber) IsLessThan

func (self ValueNumber) IsLessThan(executor Executor, other Value) (bool, error)

func (ValueNumber) IsLessThanOrEqual

func (self ValueNumber) IsLessThanOrEqual(executor Executor, other Value) (bool, error)

func (ValueNumber) IsTrue

func (self ValueNumber) IsTrue(_ Executor) (bool, error)

func (ValueNumber) ToString

func (self ValueNumber) ToString(_ Executor) (string, error)

func (ValueNumber) Type

func (self ValueNumber) Type() ValueType

func (ValueNumber) TypeName

func (self ValueNumber) TypeName() string

type ValueRelational

type ValueRelational interface {
	IsLessThan(executor Executor, other Value) (bool, error)
	IsLessThanOrEqual(executor Executor, other Value) (bool, error)
	IsGreaterThan(executor Executor, other Value) (bool, error)
	IsGreaterThanOrEqual(executor Executor, other Value) (bool, error)
}

type ValueString

type ValueString struct{ Value string }

func (ValueString) IsEqual

func (self ValueString) IsEqual(_ Executor, other Value) (bool, error)

func (ValueString) IsTrue

func (self ValueString) IsTrue(_ Executor) (bool, error)

func (ValueString) ToString

func (self ValueString) ToString(_ Executor) (string, error)

func (ValueString) Type

func (self ValueString) Type() ValueType

func (ValueString) TypeName

func (self ValueString) TypeName() string

type ValueType

type ValueType uint8
const (
	Void ValueType = iota
	Number
	String
	Boolean
	Function
	Variable
)

type ValueVariable

type ValueVariable struct {
	Callback func(executor Executor) (Value, error)
}

func (ValueVariable) IsEqual

func (self ValueVariable) IsEqual(executor Executor, other Value) (bool, error)

func (ValueVariable) IsGreaterThan

func (self ValueVariable) IsGreaterThan(executor Executor, other Value) (bool, error)

func (ValueVariable) IsGreaterThanOrEqual

func (self ValueVariable) IsGreaterThanOrEqual(executor Executor, other Value) (bool, error)

func (ValueVariable) IsLessThan

func (self ValueVariable) IsLessThan(executor Executor, other Value) (bool, error)

func (ValueVariable) IsLessThanOrEqual

func (self ValueVariable) IsLessThanOrEqual(executor Executor, other Value) (bool, error)

func (ValueVariable) IsTrue

func (self ValueVariable) IsTrue(executor Executor) (bool, error)

func (ValueVariable) ToString

func (self ValueVariable) ToString(executor Executor) (string, error)

func (ValueVariable) Type

func (self ValueVariable) Type() ValueType

func (ValueVariable) TypeName

func (self ValueVariable) TypeName() string

type ValueVoid

type ValueVoid struct{}

func (ValueVoid) IsEqual

func (self ValueVoid) IsEqual(_ Executor, other Value) (bool, error)

func (ValueVoid) IsTrue

func (self ValueVoid) IsTrue(_ Executor) (bool, error)

func (ValueVoid) ToString

func (self ValueVoid) ToString(_ Executor) (string, error)

func (ValueVoid) Type

func (self ValueVoid) Type() ValueType

func (ValueVoid) TypeName

func (self ValueVoid) TypeName() string

Jump to

Keyboard shortcuts

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