interpreter

package
v0.5.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit(location error.Location, args ...Value) (*error.Error, *int)

Terminates the execution of the current Homescript Exit code `0` indicates success, other can be used for different purposes

Types

type Executor

type Executor interface {
	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
	Exec(homescriptId string) (string, error)
	AddUser(username string, password string, forename string, surname string) error
	DelUser(username string) error
	AddPerm(username string, permission string) error
	DelPerm(username string, permission string) 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
	ToString(executor Executor, location error.Location) (string, *error.Error)
	IsTrue(executor Executor, location error.Location) (bool, *error.Error)
	IsEqual(executor Executor, location error.Location, other Value) (bool, *error.Error)
}

func AddPerm

func AddPerm(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Adds a permission to an arbitrary user

func AddUser

func AddUser(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Creates a new user unless the username is already taken

func DelPerm

func DelPerm(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Deletes an existing permission from arbitrary user

func DelUser

func DelUser(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Deletes an arbitrary user

func Exec

func Exec(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Launches a Homescript based on the provided script Id If no valid script could be found or the user lacks permission to execute it, an error is returned

func GetCurrentDay

func GetCurrentDay(executor Executor, _ error.Location) (Value, *error.Error)

func GetCurrentHour

func GetCurrentHour(executor Executor, _ error.Location) (Value, *error.Error)

func GetCurrentMinute

func GetCurrentMinute(executor Executor, _ error.Location) (Value, *error.Error)

func GetCurrentMonth

func GetCurrentMonth(executor Executor, _ error.Location) (Value, *error.Error)

func GetCurrentSecond

func GetCurrentSecond(executor Executor, _ error.Location) (Value, *error.Error)

func GetCurrentYear

func GetCurrentYear(executor Executor, _ error.Location) (Value, *error.Error)

func GetTemperature

func GetTemperature(executor Executor, location error.Location) (Value, *error.Error)

func GetUser

func GetUser(executor Executor, _ error.Location) (Value, *error.Error)

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

func GetWeather

func GetWeather(executor Executor, location error.Location) (Value, *error.Error)

func Log

func Log(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Adds a event to the logging system

func Notify

func Notify(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

If a notification system is provided in the runtime environment a notification is sent to the current user

func Play

func Play(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Sends a mode request to a given radigo server via its url

func Print

func Print(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Outputs a string

func Sleep

func Sleep(_ Executor, location error.Location, args ...Value) (Value, *error.Error)

Pauses the execution of the current script for a given amount of seconds

func Switch

func Switch(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Used to interact with switches and change power states

func SwitchOn

func SwitchOn(executor Executor, location error.Location, args ...Value) (Value, *error.Error)

Retrieves the current power state of the provided switch

type ValueBoolean

type ValueBoolean struct{ Value bool }

func (ValueBoolean) IsEqual

func (self ValueBoolean) IsEqual(_ Executor, _ error.Location, other Value) (bool, *error.Error)

func (ValueBoolean) IsTrue

func (self ValueBoolean) IsTrue(_ Executor, _ error.Location) (bool, *error.Error)

func (ValueBoolean) ToString

func (self ValueBoolean) ToString(_ Executor, _ error.Location) (string, *error.Error)

func (ValueBoolean) Type

func (self ValueBoolean) Type() ValueType

type ValueFunction

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

func (ValueFunction) IsEqual

func (self ValueFunction) IsEqual(_ Executor, _ error.Location, other Value) (bool, *error.Error)

func (ValueFunction) IsTrue

func (self ValueFunction) IsTrue(_ Executor, _ error.Location) (bool, *error.Error)

func (ValueFunction) ToString

func (self ValueFunction) ToString(_ Executor, _ error.Location) (string, *error.Error)

func (ValueFunction) Type

func (self ValueFunction) Type() ValueType

type ValueNumber

type ValueNumber struct{ Value float64 }

func (ValueNumber) IsEqual

func (self ValueNumber) IsEqual(_ Executor, _ error.Location, other Value) (bool, *error.Error)

func (ValueNumber) IsGreaterThan

func (self ValueNumber) IsGreaterThan(executor Executor, other Value, location error.Location) (bool, *error.Error)

func (ValueNumber) IsGreaterThanOrEqual

func (self ValueNumber) IsGreaterThanOrEqual(executor Executor, other Value, location error.Location) (bool, *error.Error)

func (ValueNumber) IsLessThan

func (self ValueNumber) IsLessThan(executor Executor, other Value, location error.Location) (bool, *error.Error)

func (ValueNumber) IsLessThanOrEqual

func (self ValueNumber) IsLessThanOrEqual(executor Executor, other Value, location error.Location) (bool, *error.Error)

func (ValueNumber) IsTrue

func (self ValueNumber) IsTrue(_ Executor, _ error.Location) (bool, *error.Error)

func (ValueNumber) ToString

func (self ValueNumber) ToString(_ Executor, _ error.Location) (string, *error.Error)

func (ValueNumber) Type

func (self ValueNumber) Type() ValueType

type ValueRelational

type ValueRelational interface {
	IsLessThan(executor Executor, other Value, location error.Location) (bool, *error.Error)
	IsLessThanOrEqual(executor Executor, other Value, location error.Location) (bool, *error.Error)
	IsGreaterThan(executor Executor, other Value, location error.Location) (bool, *error.Error)
	IsGreaterThanOrEqual(executor Executor, other Value, location error.Location) (bool, *error.Error)
}

type ValueString

type ValueString struct{ Value string }

func (ValueString) IsEqual

func (self ValueString) IsEqual(_ Executor, _ error.Location, other Value) (bool, *error.Error)

func (ValueString) IsTrue

func (self ValueString) IsTrue(_ Executor, _ error.Location) (bool, *error.Error)

func (ValueString) ToString

func (self ValueString) ToString(_ Executor, _ error.Location) (string, *error.Error)

func (ValueString) Type

func (self ValueString) Type() ValueType

type ValueType

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

func (ValueType) Name

func (self ValueType) Name() string

type ValueVariable

type ValueVariable struct {
	Callback func(executor Executor, location error.Location) (Value, *error.Error)
}

func (ValueVariable) IsEqual

func (self ValueVariable) IsEqual(executor Executor, location error.Location, other Value) (bool, *error.Error)

func (ValueVariable) IsGreaterThan

func (self ValueVariable) IsGreaterThan(executor Executor, other Value, location error.Location) (bool, *error.Error)

func (ValueVariable) IsGreaterThanOrEqual

func (self ValueVariable) IsGreaterThanOrEqual(executor Executor, other Value, location error.Location) (bool, *error.Error)

func (ValueVariable) IsLessThan

func (self ValueVariable) IsLessThan(executor Executor, other Value, location error.Location) (bool, *error.Error)

func (ValueVariable) IsLessThanOrEqual

func (self ValueVariable) IsLessThanOrEqual(executor Executor, other Value, location error.Location) (bool, *error.Error)

func (ValueVariable) IsTrue

func (self ValueVariable) IsTrue(executor Executor, location error.Location) (bool, *error.Error)

func (ValueVariable) ToString

func (self ValueVariable) ToString(executor Executor, location error.Location) (string, *error.Error)

func (ValueVariable) Type

func (self ValueVariable) Type() ValueType

type ValueVoid

type ValueVoid struct{}

func (ValueVoid) IsEqual

func (self ValueVoid) IsEqual(_ Executor, _ error.Location, other Value) (bool, *error.Error)

func (ValueVoid) IsTrue

func (self ValueVoid) IsTrue(_ Executor, _ error.Location) (bool, *error.Error)

func (ValueVoid) ToString

func (self ValueVoid) ToString(_ Executor, _ error.Location) (string, *error.Error)

func (ValueVoid) Type

func (self ValueVoid) Type() ValueType

Jump to

Keyboard shortcuts

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