homescript

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: GPL-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SymbolTypeUnknown         symbolType = "unknown"
	SymbolTypeNull            symbolType = "null"
	SymbolTypeNumber          symbolType = "number"
	SymbolTypeBoolean         symbolType = "boolean"
	SymbolTypeString          symbolType = "string"
	SymbolTypeList            symbolType = "list"
	SymbolTypePair            symbolType = "pair"
	SymbolTypeObject          symbolType = "object"
	SymbolTypeRange           symbolType = "range"
	SymbolDynamicMember       symbolType = "dynamic member"
	SymbolTypeFunction        symbolType = "function"
	SymbolTypeBuiltinFunction symbolType = "builtin function"
	SymbolTypeBuiltinVariable symbolType = "builtin variable"
	SymbolTypeEnum            symbolType = "enum"
	SymbolTypeEnumVariant     symbolType = "enum variant"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddExpression

type AddExpression struct {
	Base      MulExpression
	Following []struct {
		AddOperator AddOperator
		Other       MulExpression
		Span        errors.Span
	}
	Span errors.Span
}

Add expression

type AddOperator

type AddOperator uint8
const (
	AddOpPlus AddOperator = iota
	AddOpMinus
)

type Analyzer

type Analyzer struct {
	// contains filtered or unexported fields
}

func NewAnalyzer

func NewAnalyzer(
	program []StatementOrExpr,
	executor Executor,
	scopeAdditions map[string]Value,
	moduleStack []string,
	filename string,
) Analyzer

type AnalyzerDummyExecutor added in v2.3.0

type AnalyzerDummyExecutor struct{}

func (AnalyzerDummyExecutor) Exec added in v2.3.0

func (self AnalyzerDummyExecutor) Exec(id string, args map[string]string) (ExecResponse, error)

func (AnalyzerDummyExecutor) Get added in v2.3.0

func (AnalyzerDummyExecutor) GetStorage added in v2.3.0

func (self AnalyzerDummyExecutor) GetStorage(_ string) (*string, error)

func (AnalyzerDummyExecutor) GetSwitch added in v2.3.0

func (self AnalyzerDummyExecutor) GetSwitch(id string) (SwitchResponse, error)

func (AnalyzerDummyExecutor) GetUser added in v2.3.0

func (self AnalyzerDummyExecutor) GetUser() string

func (AnalyzerDummyExecutor) GetWeather added in v2.3.0

func (self AnalyzerDummyExecutor) GetWeather() (Weather, error)

func (AnalyzerDummyExecutor) Http added in v2.3.0

func (self AnalyzerDummyExecutor) Http(url string, method string, body string, headers map[string]string, cookies map[string]string) (HttpResponse, error)

func (AnalyzerDummyExecutor) IsAnalyzer added in v2.3.0

func (self AnalyzerDummyExecutor) IsAnalyzer() bool

func (AnalyzerDummyExecutor) Log added in v2.3.0

func (self AnalyzerDummyExecutor) Log(title string, description string, level LogLevel) error

func (AnalyzerDummyExecutor) Notify added in v2.3.0

func (self AnalyzerDummyExecutor) Notify(title string, description string, level NotificationLevel) error

func (AnalyzerDummyExecutor) Ping added in v2.3.0

func (self AnalyzerDummyExecutor) Ping(ip string, timeout float64) (bool, error)

func (AnalyzerDummyExecutor) Print added in v2.3.0

func (self AnalyzerDummyExecutor) Print(args ...string) error

func (AnalyzerDummyExecutor) Println added in v2.3.0

func (self AnalyzerDummyExecutor) Println(args ...string) error

func (AnalyzerDummyExecutor) ReadFile added in v2.4.0

func (self AnalyzerDummyExecutor) ReadFile(path string) (string, error)

func (AnalyzerDummyExecutor) Remind added in v2.3.0

func (self AnalyzerDummyExecutor) Remind(title string, description string, urgency ReminderUrgency, dueDate time.Time) (uint, error)

func (AnalyzerDummyExecutor) ResolveModule added in v2.3.0

func (self AnalyzerDummyExecutor) ResolveModule(id string) (string, string, bool, bool, error)

func (AnalyzerDummyExecutor) SetStorage added in v2.3.0

func (self AnalyzerDummyExecutor) SetStorage(key string, value string) error

func (AnalyzerDummyExecutor) Sleep added in v2.3.0

func (self AnalyzerDummyExecutor) Sleep(sleepTime float64)

func (AnalyzerDummyExecutor) Switch added in v2.3.0

func (self AnalyzerDummyExecutor) Switch(name string, power bool) error

type AndExpression

type AndExpression struct {
	Base      EqExpression
	Following []EqExpression
	Span      errors.Span
}

And expression

type AssignExpression

type AssignExpression struct {
	Base  CallExpression
	Other *struct {
		Operator   AssignOperator
		Expression Expression
	}
	Span errors.Span
}

Assign expression

type AssignOperator

type AssignOperator uint8
const (
	OpAssign AssignOperator = iota
	OpPlusAssign
	OpMinusAssign
	OpMulAssign
	OpDivAssign
	OpIntDivAssign
	OpReminderAssign
	OpPowerAssign
)

type Atom

type Atom interface {
	Kind() AtomKind
	Span() errors.Span
}

type AtomBoolean

type AtomBoolean struct {
	Value bool
	Range errors.Span
}

Boolean

func (AtomBoolean) Kind

func (self AtomBoolean) Kind() AtomKind

func (AtomBoolean) Span

func (self AtomBoolean) Span() errors.Span

type AtomEnum added in v2.4.0

type AtomEnum struct {
	Name     string
	Variants []EnumVariant
	Range    errors.Span
}

Enum

func (AtomEnum) Kind added in v2.4.0

func (self AtomEnum) Kind() AtomKind

func (AtomEnum) Span added in v2.4.0

func (self AtomEnum) Span() errors.Span

type AtomEnumVariant added in v2.4.0

type AtomEnumVariant struct {
	RefersToEnum string
	Name         string
	Range        errors.Span
}

Enum Variant

func (AtomEnumVariant) Kind added in v2.4.0

func (self AtomEnumVariant) Kind() AtomKind

func (AtomEnumVariant) Span added in v2.4.0

func (self AtomEnumVariant) Span() errors.Span

type AtomExpression

type AtomExpression struct {
	Expression Expression
	Range      errors.Span
}

Atom Expression

func (AtomExpression) Kind

func (self AtomExpression) Kind() AtomKind

func (AtomExpression) Span

func (self AtomExpression) Span() errors.Span

type AtomFor

type AtomFor struct {
	HeadIdentifier struct {
		Identifier string
		Span       errors.Span
	}
	IterExpr      Expression
	IterationCode Block
	Range         errors.Span
}

For loop

func (AtomFor) Kind

func (self AtomFor) Kind() AtomKind

func (AtomFor) Span

func (self AtomFor) Span() errors.Span

type AtomFunction

type AtomFunction struct {
	Ident          *string
	ArgIdentifiers []struct {
		Identifier string
		Span       errors.Span
	}
	Body  Block
	Range errors.Span
}

Function declaration

func (AtomFunction) Kind

func (self AtomFunction) Kind() AtomKind

func (AtomFunction) Span

func (self AtomFunction) Span() errors.Span

type AtomIdentifier

type AtomIdentifier struct {
	Identifier string
	Range      errors.Span
}

Identifier

func (AtomIdentifier) Kind

func (self AtomIdentifier) Kind() AtomKind

func (AtomIdentifier) Span

func (self AtomIdentifier) Span() errors.Span

type AtomKind

type AtomKind uint8

Atom

const (
	AtomKindNumber AtomKind = iota
	AtomKindBoolean
	AtomKindString
	AtomKindListLiteral
	AtomKindObject
	AtomKindPair
	AtomKindNull
	AtomKindIdentifier
	AtomKindRange
	AtomKindEnum
	AtomKindEnumVariant
	AtomKindIfExpr
	AtomKindForExpr
	AtomKindWhileExpr
	AtomKindLoopExpr
	AtomKindFnExpr
	AtomKindTryExpr
	AtomKindExpression
)

type AtomListLiteral

type AtomListLiteral struct {
	Values []Expression
	Range  errors.Span
}

List literals

func (AtomListLiteral) Kind

func (self AtomListLiteral) Kind() AtomKind

func (AtomListLiteral) Span

func (self AtomListLiteral) Span() errors.Span

type AtomLoop

type AtomLoop struct {
	IterationCode Block
	Range         errors.Span
}

Loop expression

func (AtomLoop) Kind

func (self AtomLoop) Kind() AtomKind

func (AtomLoop) Span

func (self AtomLoop) Span() errors.Span

type AtomNull

type AtomNull struct {
	Range errors.Span
}

Null

func (AtomNull) Kind

func (self AtomNull) Kind() AtomKind

func (AtomNull) Span

func (self AtomNull) Span() errors.Span

type AtomNumber

type AtomNumber struct {
	Num   float64
	Range errors.Span
}

Number

func (AtomNumber) Kind

func (self AtomNumber) Kind() AtomKind

func (AtomNumber) Span

func (self AtomNumber) Span() errors.Span

type AtomObject

type AtomObject struct {
	Range  errors.Span
	Fields []AtomObjectField
}

Object

func (AtomObject) Kind

func (self AtomObject) Kind() AtomKind

func (AtomObject) Span

func (self AtomObject) Span() errors.Span

type AtomObjectField

type AtomObjectField struct {
	Span       errors.Span
	Identifier string
	IdentSpan  errors.Span
	Expression Expression
}

type AtomPair

type AtomPair struct {
	Key       string
	ValueExpr Expression
	Range     errors.Span
}

Pair

func (AtomPair) Kind

func (self AtomPair) Kind() AtomKind

func (AtomPair) Span

func (self AtomPair) Span() errors.Span

type AtomRange added in v2.3.0

type AtomRange struct {
	Start int
	End   int
	Range errors.Span
}

Range

func (AtomRange) Kind added in v2.3.0

func (self AtomRange) Kind() AtomKind

func (AtomRange) Span added in v2.3.0

func (self AtomRange) Span() errors.Span

type AtomString

type AtomString struct {
	Content string
	Range   errors.Span
}

String

func (AtomString) Kind

func (self AtomString) Kind() AtomKind

func (AtomString) Span

func (self AtomString) Span() errors.Span

type AtomTry

type AtomTry struct {
	TryBlock        Block
	ErrorIdentifier string
	CatchBlock      Block
	Range           errors.Span
}

Try expression

func (AtomTry) Kind

func (self AtomTry) Kind() AtomKind

func (AtomTry) Span

func (self AtomTry) Span() errors.Span

type AtomWhile

type AtomWhile struct {
	HeadCondition Expression
	IterationCode Block
	Range         errors.Span
}

While loop

func (AtomWhile) Kind

func (self AtomWhile) Kind() AtomKind

func (AtomWhile) Span

func (self AtomWhile) Span() errors.Span

type Block

type Block struct {
	Statements []Statement
	Expr       *Expression
	Span       errors.Span
}

func (Block) IntoItemsList added in v2.3.0

func (self Block) IntoItemsList() []StatementOrExpr

type BreakStmt

type BreakStmt struct {
	Expression *Expression // Can be the return value of the loop
	Range      errors.Span
}

func (BreakStmt) Kind

func (self BreakStmt) Kind() StatementKind

func (BreakStmt) Span

func (self BreakStmt) Span() errors.Span

type CallExprPart

type CallExprPart struct {
	MemberExpressionPart *string       // Optional: .identifier as a member
	Args                 *[]Expression // Optional: (arg1, arg2) to call the function
	Index                *Expression   // Optional: [42] to index a value
	Span                 errors.Span
}

If member expr part is nil, args is used if args is nil, member expr part is used

type CallExpression

type CallExpression struct {
	Base  MemberExpression
	Parts []CallExprPart // Allows chaining of function calls ( like foo()()() )
	Span  errors.Span
}

Call expression

type CastExpression

type CastExpression struct {
	Base  UnaryExpression
	Other *ValueType // Casting is optional, otherwise, just the base is used
	Span  errors.Span
}

Cast expression

type ContinueStmt

type ContinueStmt struct {
	Range errors.Span
}

func (ContinueStmt) Kind

func (self ContinueStmt) Kind() StatementKind

func (ContinueStmt) Span

func (self ContinueStmt) Span() errors.Span

type Diagnostic

type Diagnostic struct {
	Severity DiagnosticSeverity
	Kind     errors.ErrorKind
	Message  string
	Span     errors.Span
}

func Analyze

func Analyze(
	executor Executor,
	program string,
	scopeAdditions map[string]Value,
	moduleStack []string,
	moduleName string,
	filename string,
) (
	diagnostics []Diagnostic,
	symbols []symbol,
	rootScope map[string]*Value,
)

Analyzes the given Homescript code

func (Diagnostic) Display

func (self Diagnostic) Display(program string) string

type DiagnosticSeverity

type DiagnosticSeverity uint8
const (
	Info DiagnosticSeverity = iota
	Warning
	Error
)

type DummyExecutor added in v2.3.0

type DummyExecutor struct{}

func (DummyExecutor) Exec added in v2.3.0

func (self DummyExecutor) Exec(id string, args map[string]string) (ExecResponse, error)

func (DummyExecutor) Get added in v2.3.0

func (self DummyExecutor) Get(url string) (HttpResponse, error)

func (DummyExecutor) GetStorage added in v2.3.0

func (self DummyExecutor) GetStorage(_ string) (*string, error)

func (DummyExecutor) GetSwitch added in v2.3.0

func (self DummyExecutor) GetSwitch(id string) (SwitchResponse, error)

func (DummyExecutor) GetUser added in v2.3.0

func (self DummyExecutor) GetUser() string

func (DummyExecutor) GetWeather added in v2.3.0

func (self DummyExecutor) GetWeather() (Weather, error)

func (DummyExecutor) Http added in v2.3.0

func (self DummyExecutor) Http(url string, method string, body string, headers map[string]string, cookies map[string]string) (HttpResponse, error)

func (DummyExecutor) IsAnalyzer added in v2.3.0

func (self DummyExecutor) IsAnalyzer() bool

func (DummyExecutor) Log added in v2.3.0

func (self DummyExecutor) Log(title string, description string, level LogLevel) error

func (DummyExecutor) Notify added in v2.3.0

func (self DummyExecutor) Notify(title string, description string, level NotificationLevel) error

func (DummyExecutor) Ping added in v2.3.0

func (self DummyExecutor) Ping(ip string, timeout float64) (bool, error)

func (DummyExecutor) Print added in v2.3.0

func (self DummyExecutor) Print(args ...string) error

func (DummyExecutor) Println added in v2.3.0

func (self DummyExecutor) Println(args ...string) error

func (DummyExecutor) ReadFile added in v2.4.0

func (self DummyExecutor) ReadFile(path string) (string, error)

func (DummyExecutor) Remind added in v2.3.0

func (self DummyExecutor) Remind(title string, description string, urgency ReminderUrgency, dueDate time.Time) (uint, error)

func (DummyExecutor) ResolveModule added in v2.3.0

func (self DummyExecutor) ResolveModule(id string) (string, string, bool, bool, error)

func (DummyExecutor) SetStorage added in v2.3.0

func (self DummyExecutor) SetStorage(key string, value string) error

func (DummyExecutor) Sleep added in v2.3.0

func (self DummyExecutor) Sleep(sleepTime float64)

func (DummyExecutor) Switch added in v2.3.0

func (self DummyExecutor) Switch(name string, power bool) error

type EnumVariant added in v2.4.0

type EnumVariant struct {
	Value string
	Span  errors.Span
}

type EqExpression

type EqExpression struct {
	Base  RelExpression
	Other *struct {
		// True corresponds to `!=` and false corresponds to `==`
		Inverted bool
		Node     RelExpression
	}
	Span errors.Span
}

Equality expression

type ExecResponse

type ExecResponse struct {
	RuntimeSecs float64
	ReturnValue Value
	RootScope   map[string]*Value
}

type Executor

type Executor interface {
	Sleep(float64)
	Print(args ...string) error
	Println(args ...string) error
	GetSwitch(id string) (SwitchResponse, error)
	Switch(name string, on bool) error
	Ping(ip string, timeout float64) (bool, error)
	Notify(title string, description string, level NotificationLevel) error
	Remind(title string, description string, urgency ReminderUrgency, dueDate time.Time) (uint, error)
	Log(title string, description string, level LogLevel) error
	Exec(homescriptId string, args map[string]string) (ExecResponse, error)
	ResolveModule(homescriptId string) (code string, filename string, found bool, shouldProceed bool, err error)
	ReadFile(path string) (code string, err error)
	Get(url string) (HttpResponse, error)
	Http(url string, method string, body string, headers map[string]string, cookies map[string]string) (HttpResponse, error)
	GetStorage(key string) (*string, error)
	SetStorage(key string, value string) error
	IsAnalyzer() bool

	// Builtin variables
	GetUser() string
	GetWeather() (Weather, error)
}

type ExpExpression

type ExpExpression struct {
	Base  AssignExpression
	Other *UnaryExpression
	Span  errors.Span
}

Exp expression

type Expression

type Expression OrExpression

Expression

type ExpressionStmt

type ExpressionStmt struct {
	Expression Expression
}

func (ExpressionStmt) Kind

func (self ExpressionStmt) Kind() StatementKind

func (ExpressionStmt) Span

func (self ExpressionStmt) Span() errors.Span

type HttpResponse

type HttpResponse struct {
	Status     string
	StatusCode uint16
	Body       string
	Cookies    []http.Cookie
}

type IfExpr

type IfExpr struct {
	Condition  Expression
	Block      Block   // To be executed if condition is true
	ElseBlock  *Block  // Optional (else {...})
	ElseIfExpr *IfExpr // Optional (else if ... {...})
	Range      errors.Span
}

func (IfExpr) Kind

func (self IfExpr) Kind() AtomKind

func (IfExpr) Span

func (self IfExpr) Span() errors.Span

type ImportStmt

type ImportStmt struct {
	Functions  []string // import `foo`
	FromModule string   // from `baz`
	Range      errors.Span
}

func (ImportStmt) Kind

func (self ImportStmt) Kind() StatementKind

func (ImportStmt) Span

func (self ImportStmt) Span() errors.Span

type Interpreter

type Interpreter struct {
	// contains filtered or unexported fields
}

func NewInterpreter

func NewInterpreter(
	program []StatementOrExpr,
	executor Executor,
	sigTerm *chan int,
	stackLimit uint,
	scopeAdditions map[string]Value,
	args map[string]*Value,
	debug bool,
	moduleStack []string,
	moduleName string,
	filename string,
) Interpreter

func (Interpreter) ResolveModule

func (self Interpreter) ResolveModule(span errors.Span, module string, functions []string) ([]*Value, map[string]*Value, *errors.Error)

Resolves functions imported by an 'import' statement The builtin just has the task of providing the target module code This function then runs the target module code and returns the values of the target functionsj (analyzes the root scope) If the target module contains top level code, it is also executed

type LetStmt

type LetStmt struct {
	Left struct {
		Identifier string
		Span       errors.Span
	}
	Right Expression
	Range errors.Span
}

func (LetStmt) Kind

func (self LetStmt) Kind() StatementKind

func (LetStmt) Span

func (self LetStmt) Span() errors.Span

type LogLevel

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

type MemberExpression

type MemberExpression struct {
	Base Atom
	// Each member is either an identifier 'foo.bar.baz' where `foo` is the base and `bar` and `baz` are the members
	// However, each member can also be an index access: `[1]`, where 1 is an expression
	Members []struct {
		// Normal member identifier with a dot
		Identifier *string
		// List index access
		Index *Expression
		// Span is used in order to deliver better error messages
		Span errors.Span
	}
	Span errors.Span
}

Member expression

type MulExpression

type MulExpression struct {
	Base      CastExpression
	Following []struct {
		MulOperator MulOperator
		Other       CastExpression
		Span        errors.Span
	}
	Span errors.Span
}

Mul expression

type MulOperator

type MulOperator uint8
const (
	MulOpMul MulOperator = iota
	MulOpDiv
	MulOpIntDiv
	MulOpReminder
)

type NotificationLevel

type NotificationLevel uint8
const (
	NotiInfo NotificationLevel = iota
	NotiWarning
	NotiCritical
)

type OrExpression

type OrExpression struct {
	Base      AndExpression
	Following []AndExpression
	Span      errors.Span
}

Or expression

type RelExpression

type RelExpression struct {
	Base  AddExpression
	Other *struct {
		RelOperator RelOperator
		Node        AddExpression
	}
	Span errors.Span
}

Relational expression

type RelOperator

type RelOperator uint8
const (
	RelLessThan RelOperator = iota
	RelLessOrEqual
	RelGreaterThan
	RelGreaterOrEqual
)

type ReminderUrgency added in v2.1.0

type ReminderUrgency uint8
const (
	UrgencyLow ReminderUrgency = iota
	UrgencyNormal
	UrgencyMedium
	UrgencyHigh
	UrgencyUrgent
)

type Result

type Result struct {
	ShouldContinue bool
	ReturnValue    *Value
	BreakValue     *Value
	Value          *Value
}

type ReturnStmt

type ReturnStmt struct {
	Expression *Expression // Can be the return value of the function
	Range      errors.Span
}

func (ReturnStmt) Kind

func (self ReturnStmt) Kind() StatementKind

func (ReturnStmt) Span

func (self ReturnStmt) Span() errors.Span

type Statement

type Statement interface {
	Kind() StatementKind
	Span() errors.Span
}

type StatementKind

type StatementKind uint8

///// Statements ///////

const (
	LetStmtKind StatementKind = iota
	ImportStmtKind
	BreakStmtKind
	ContinueStmtKind
	ReturnStmtKind
	ExpressionStmtKind
)

func (StatementKind) String

func (self StatementKind) String() string

type StatementOrExpr added in v2.3.0

type StatementOrExpr struct {
	Statement  Statement
	Expression *Expression
}

func (StatementOrExpr) IsStatement added in v2.3.0

func (self StatementOrExpr) IsStatement() bool

func (StatementOrExpr) Span added in v2.3.0

func (self StatementOrExpr) Span() errors.Span

type SwitchResponse

type SwitchResponse struct {
	Name  string
	Power bool
	Watts uint
}

type Token

type Token struct {
	Kind          TokenKind
	Value         string
	StartLocation errors.Location
	EndLocation   errors.Location
}

type TokenKind

type TokenKind uint8
const (
	Unknown TokenKind = iota
	EOF

	Semicolon // ;
	Comma     // ,
	Colon     // :
	Dot       // .
	Range     // ..
	Arrow     // =>

	LParen   // (
	RParen   // )
	LCurly   // {
	RCurly   // }
	LBracket // [
	RBracket // ]

	Or               // ||
	And              // &&
	Equal            // ==
	NotEqual         // !=
	LessThan         // <
	LessThanEqual    // <=
	GreaterThan      // >
	GreaterThanEqual // >=
	Not              // !

	Plus      // +
	Minus     // -
	Multiply  // *
	Divide    // /
	IntDivide // /
	Reminder  // %
	Power     // **

	Assign          // =
	PlusAssign      // +=
	MinusAssign     // -=
	MultiplyAssign  // *=
	DivideAssign    // /=
	IntDivideAssign // \=
	PowerAssign     // **=
	ReminderAssign  // %=

	Import   // import
	As       // as
	From     // from
	In       // in
	Let      // let
	Fn       // fn
	If       // if
	Else     // else
	Try      // try
	Catch    // catch
	For      // for
	While    // while
	Loop     // loop
	Break    // break
	Continue // continue
	Return   // return
	Enum     // enum

	StringType  // str
	NumberType  // num
	BooleanType // bool
	NullType    // null

	True  // true
	False // false

	String     // "foo" (token includes quotes whilst content excludes quotes)
	Number     // 42
	Identifier // foobar
)

func (TokenKind) String

func (self TokenKind) String() string

type UnaryExpression

type UnaryExpression struct {
	UnaryExpression *struct {
		UnaryOp         UnaryOp
		UnaryExpression UnaryExpression
	}
	ExpExpression *ExpExpression
	Span          errors.Span
}

Unary expression Is either unary or exp expression if unary = nil, then exp is not nil if exp is nil, then unary is not nil

type UnaryOp

type UnaryOp uint8
const (
	UnaryOpPlus UnaryOp = iota
	UnaryOpMinus
	UnaryOpNot
)

type Value

type Value interface {
	Type() ValueType
	Protected() bool
	Span() errors.Span
	Fields() map[string]*Value
	Index(executor Executor, index Value, span errors.Span) (*Value, bool, *errors.Error)
	// Is also used for `as str` and printing
	Display(executor Executor, span errors.Span) (string, *errors.Error)
	Debug(executor Executor, span errors.Span) (string, *errors.Error)
	IsTrue(executor Executor, span errors.Span) (bool, *errors.Error)
	IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)
}

Value interfaces

func AnalyzerAssert added in v2.3.0

func AnalyzerAssert(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Asserts that a statement is true, otherwise an error is returned

func Assert

func Assert(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Asserts that a statement is true, otherwise an error is returned

func CreateDateObj added in v2.3.0

func CreateDateObj(tm time.Time) Value

func Debug

func Debug(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Displays the given arguments as debug output

func Exec

func Exec(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.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 Exit

func Exit(_ Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

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

func Fmt added in v2.2.0

func Fmt(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

func Get

func Get(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Makes a get-request to an arbitrary url and returns the result HTTP response

func GetSwitch

func GetSwitch(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Retrieves data about a Smarthome switch

func GetUser

func GetUser(executor Executor, _ errors.Span) (Value, *errors.Error)

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

func GetWeather

func GetWeather(executor Executor, span errors.Span) (Value, *errors.Error)

func Http

func Http(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Makes a network request using an arbitrary URL, method , body (as plaintext), (and optionally headers)

func Log

func Log(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Adds a event to the logging system

func Notify

func Notify(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

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

func Ping added in v2.0.6

func Ping(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Performs a ping given the target-ip and a maximum timeout

func Print

func Print(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Outputs a string

func Println

func Println(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Outputs a string with a newline at the end

func Remind added in v2.1.0

func Remind(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Adds a new reminder to the current user's reminders.

func Run

func Run(
	executor Executor,
	sigTerm *chan int,
	program string,
	scopeAdditions map[string]Value,
	args map[string]Value,
	debug bool,
	stackSize uint,
	moduleStack []string,
	moduleName string,
	filename string,
) (
	returnValue Value,
	exitCode int,
	rootScope map[string]*Value,
	hmsErrors []hmsError.Error,
)

Executes the given Homescript code The `sigTerm` variable is used to terminate the script at any point in time The value passed into the channel is used as an exit-code to terminate the script

func Sleep

func Sleep(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

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

func Storage added in v2.2.0

func Storage(executor Executor, _ errors.Span) (Value, *errors.Error)

func Switch

func Switch(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Used to interact with switches and change power states

func Throw

func Throw(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)

Returns an intentional error

func Time added in v2.0.6

func Time(executor Executor, _ errors.Span) (Value, *errors.Error)

type ValueAlg

type ValueAlg interface {
	Add(executor Executor, span errors.Span, other Value) (Value, *errors.Error)
	Sub(executor Executor, span errors.Span, other Value) (Value, *errors.Error)
	Mul(executor Executor, span errors.Span, other Value) (Value, *errors.Error)
	Div(executor Executor, span errors.Span, other Value) (Value, *errors.Error)
	IntDiv(executor Executor, span errors.Span, other Value) (Value, *errors.Error)
	Rem(executor Executor, span errors.Span, other Value) (Value, *errors.Error)
	Pow(executor Executor, span errors.Span, other Value) (Value, *errors.Error)
}

type ValueBool

type ValueBool struct {
	Value       bool
	Range       errors.Span
	IsProtected bool
}

Boolean value

func (ValueBool) Add

func (self ValueBool) Add(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBool) Debug

func (self ValueBool) Debug(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueBool) Display

func (self ValueBool) Display(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueBool) Div

func (self ValueBool) Div(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBool) Fields

func (self ValueBool) Fields() map[string]*Value

Fields also return a pointer so that member assignments are possible

func (ValueBool) Index

func (self ValueBool) Index(_ Executor, _ Value, span errors.Span) (*Value, bool, *errors.Error)

Index returns a pointer so that index assignments are possible

func (ValueBool) IntDiv

func (self ValueBool) IntDiv(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBool) IsEqual

func (self ValueBool) IsEqual(_ Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueBool) IsTrue

func (self ValueBool) IsTrue(_ Executor, _ errors.Span) (bool, *errors.Error)

func (ValueBool) Mul

func (self ValueBool) Mul(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBool) Pow

func (self ValueBool) Pow(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBool) Protected

func (self ValueBool) Protected() bool

func (ValueBool) Rem

func (self ValueBool) Rem(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBool) Span

func (self ValueBool) Span() errors.Span

func (ValueBool) Sub

func (self ValueBool) Sub(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBool) Type

func (self ValueBool) Type() ValueType

type ValueBuiltinFunction

type ValueBuiltinFunction struct {
	Callback func(executor Executor, span errors.Span, args ...Value) (Value, *int, *errors.Error)
}

Builtin function value

func (ValueBuiltinFunction) Debug

func (ValueBuiltinFunction) Display

func (self ValueBuiltinFunction) Display(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueBuiltinFunction) Fields

func (self ValueBuiltinFunction) Fields() map[string]*Value

func (ValueBuiltinFunction) Index

func (self ValueBuiltinFunction) Index(_ Executor, _ Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueBuiltinFunction) IsEqual

func (self ValueBuiltinFunction) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueBuiltinFunction) IsTrue

func (self ValueBuiltinFunction) IsTrue(_ Executor, _ errors.Span) (bool, *errors.Error)

func (ValueBuiltinFunction) Protected

func (self ValueBuiltinFunction) Protected() bool

func (ValueBuiltinFunction) Span

func (self ValueBuiltinFunction) Span() errors.Span

func (ValueBuiltinFunction) Type

func (self ValueBuiltinFunction) Type() ValueType

type ValueBuiltinVariable

type ValueBuiltinVariable struct {
	Callback func(executor Executor, span errors.Span) (Value, *errors.Error)
}

Builtin variable value

func (ValueBuiltinVariable) Add

func (self ValueBuiltinVariable) Add(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBuiltinVariable) Debug

func (self ValueBuiltinVariable) Debug(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueBuiltinVariable) Display

func (self ValueBuiltinVariable) Display(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueBuiltinVariable) Div

func (self ValueBuiltinVariable) Div(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBuiltinVariable) Fields

func (self ValueBuiltinVariable) Fields() map[string]*Value

func (ValueBuiltinVariable) Index

func (self ValueBuiltinVariable) Index(_ Executor, _ Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueBuiltinVariable) IntDiv

func (self ValueBuiltinVariable) IntDiv(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBuiltinVariable) IsEqual

func (self ValueBuiltinVariable) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueBuiltinVariable) IsGreaterThan

func (self ValueBuiltinVariable) IsGreaterThan(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueBuiltinVariable) IsGreaterThanOrEqual

func (self ValueBuiltinVariable) IsGreaterThanOrEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueBuiltinVariable) IsLessThan

func (self ValueBuiltinVariable) IsLessThan(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueBuiltinVariable) IsLessThanOrEqual

func (self ValueBuiltinVariable) IsLessThanOrEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueBuiltinVariable) IsTrue

func (self ValueBuiltinVariable) IsTrue(executor Executor, span errors.Span) (bool, *errors.Error)

func (ValueBuiltinVariable) Mul

func (self ValueBuiltinVariable) Mul(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBuiltinVariable) Pow

func (self ValueBuiltinVariable) Pow(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBuiltinVariable) Protected

func (self ValueBuiltinVariable) Protected() bool

func (ValueBuiltinVariable) Rem

func (self ValueBuiltinVariable) Rem(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBuiltinVariable) Span

func (self ValueBuiltinVariable) Span() errors.Span

func (ValueBuiltinVariable) Sub

func (self ValueBuiltinVariable) Sub(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueBuiltinVariable) Type

func (self ValueBuiltinVariable) Type() ValueType

type ValueEnum added in v2.4.0

type ValueEnum struct {
	Variants         []ValueEnumVariant
	CurrentIterIndex *int
	Range            errors.Span
	IsProtected      bool
}

Enum value

func (ValueEnum) Debug added in v2.4.0

func (self ValueEnum) Debug(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueEnum) Display added in v2.4.0

func (self ValueEnum) Display(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueEnum) Fields added in v2.4.0

func (self ValueEnum) Fields() map[string]*Value

func (ValueEnum) HasVariant added in v2.4.0

func (self ValueEnum) HasVariant(toCheck string) bool

func (ValueEnum) Index added in v2.4.0

func (self ValueEnum) Index(_ Executor, indexValue Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueEnum) IsEqual added in v2.4.0

func (self ValueEnum) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueEnum) IsTrue added in v2.4.0

func (self ValueEnum) IsTrue(executor Executor, span errors.Span) (bool, *errors.Error)

func (ValueEnum) Protected added in v2.4.0

func (self ValueEnum) Protected() bool

func (ValueEnum) Span added in v2.4.0

func (self ValueEnum) Span() errors.Span

func (ValueEnum) Type added in v2.4.0

func (self ValueEnum) Type() ValueType

type ValueEnumVariant added in v2.4.0

type ValueEnumVariant struct {
	Name  string
	Range errors.Span
}

EnumVariant value

func (ValueEnumVariant) Debug added in v2.4.0

func (self ValueEnumVariant) Debug(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueEnumVariant) Display added in v2.4.0

func (self ValueEnumVariant) Display(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueEnumVariant) Fields added in v2.4.0

func (self ValueEnumVariant) Fields() map[string]*Value

func (ValueEnumVariant) Index added in v2.4.0

func (self ValueEnumVariant) Index(_ Executor, indexValue Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueEnumVariant) IsEqual added in v2.4.0

func (self ValueEnumVariant) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueEnumVariant) IsTrue added in v2.4.0

func (self ValueEnumVariant) IsTrue(executor Executor, span errors.Span) (bool, *errors.Error)

func (ValueEnumVariant) Protected added in v2.4.0

func (self ValueEnumVariant) Protected() bool

func (ValueEnumVariant) Span added in v2.4.0

func (self ValueEnumVariant) Span() errors.Span

func (ValueEnumVariant) Type added in v2.4.0

func (self ValueEnumVariant) Type() ValueType

type ValueFunction

type ValueFunction struct {
	Identifier *string
	Args       []struct {
		Identifier string
		Span       errors.Span
	}
	Body        Block
	Range       errors.Span
	IsProtected bool
}

Function value

func (ValueFunction) Debug

func (self ValueFunction) Debug(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueFunction) Display

func (self ValueFunction) Display(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueFunction) Fields

func (self ValueFunction) Fields() map[string]*Value

func (ValueFunction) Index

func (self ValueFunction) Index(_ Executor, _ Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueFunction) IsEqual

func (self ValueFunction) IsEqual(_ Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueFunction) IsTrue

func (self ValueFunction) IsTrue(_ Executor, _ errors.Span) (bool, *errors.Error)

func (ValueFunction) Protected

func (self ValueFunction) Protected() bool

func (ValueFunction) Span

func (self ValueFunction) Span() errors.Span

func (ValueFunction) Type

func (self ValueFunction) Type() ValueType

type ValueList

type ValueList struct {
	Values *[]*Value
	// Is set to a value type the first time the list contains at least 1 element
	ValueType        *ValueType
	Range            errors.Span
	IsProtected      bool
	CurrentIterIndex *int
}

List value

func (ValueList) Debug

func (self ValueList) Debug(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueList) Display

func (self ValueList) Display(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueList) Fields

func (self ValueList) Fields() map[string]*Value

func (ValueList) Index

func (self ValueList) Index(executor Executor, indexValue Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueList) IsEqual

func (self ValueList) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueList) IsTrue

func (self ValueList) IsTrue(_ Executor, _ errors.Span) (bool, *errors.Error)

func (*ValueList) IterReset added in v2.3.0

func (self *ValueList) IterReset()

func (*ValueList) Next added in v2.3.0

func (self *ValueList) Next(val *Value, span errors.Span) bool

func (ValueList) Protected

func (self ValueList) Protected() bool

func (ValueList) Span

func (self ValueList) Span() errors.Span

func (ValueList) Type

func (self ValueList) Type() ValueType

type ValueNull

type ValueNull struct {
	Range       errors.Span
	IsProtected bool
}

Null value

func (ValueNull) Debug

func (self ValueNull) Debug(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueNull) Display

func (self ValueNull) Display(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueNull) Fields

func (self ValueNull) Fields() map[string]*Value

func (ValueNull) Index

func (self ValueNull) Index(_ Executor, _ Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueNull) IsEqual

func (self ValueNull) IsEqual(_ Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueNull) IsTrue

func (self ValueNull) IsTrue(_ Executor, _ errors.Span) (bool, *errors.Error)

func (ValueNull) Protected

func (self ValueNull) Protected() bool

func (ValueNull) Span

func (self ValueNull) Span() errors.Span

func (ValueNull) Type

func (self ValueNull) Type() ValueType

type ValueNumber

type ValueNumber struct {
	Value       float64
	Range       errors.Span
	IsProtected bool
}

Number value

func (ValueNumber) Add

func (self ValueNumber) Add(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueNumber) Debug

func (self ValueNumber) Debug(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueNumber) Display

func (self ValueNumber) Display(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueNumber) Div

func (self ValueNumber) Div(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueNumber) Fields

func (self ValueNumber) Fields() map[string]*Value

func (ValueNumber) Index

func (self ValueNumber) Index(_ Executor, _ Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueNumber) IntDiv

func (self ValueNumber) IntDiv(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueNumber) IsEqual

func (self ValueNumber) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueNumber) IsGreaterThan

func (self ValueNumber) IsGreaterThan(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueNumber) IsGreaterThanOrEqual

func (self ValueNumber) IsGreaterThanOrEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueNumber) IsLessThan

func (self ValueNumber) IsLessThan(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueNumber) IsLessThanOrEqual

func (self ValueNumber) IsLessThanOrEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueNumber) IsTrue

func (self ValueNumber) IsTrue(executor Executor, span errors.Span) (bool, *errors.Error)

func (ValueNumber) Mul

func (self ValueNumber) Mul(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueNumber) Pow

func (self ValueNumber) Pow(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueNumber) Protected

func (self ValueNumber) Protected() bool

func (ValueNumber) Rem

func (self ValueNumber) Rem(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueNumber) Span

func (self ValueNumber) Span() errors.Span

func (ValueNumber) Sub

func (self ValueNumber) Sub(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueNumber) Type

func (self ValueNumber) Type() ValueType

type ValueObject

type ValueObject struct {
	// Can be used if a builtin function only accepts objects of a certain type
	DataType string
	// Specifies whether this object is dynamic
	// If it is dynamic, the analyzer will not run its field checks
	// Such a dynamic object could be the global `ARGS` object
	IsDynamic bool
	// The fields of the object
	ObjFields        map[string]*Value
	CurrentIterIndex *int
	Range            errors.Span
	IsProtected      bool
}

Object value

func (ValueObject) Debug

func (self ValueObject) Debug(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueObject) Display

func (self ValueObject) Display(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueObject) Fields

func (self ValueObject) Fields() map[string]*Value

func (ValueObject) Index

func (self ValueObject) Index(_ Executor, indexValue Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueObject) IsEqual

func (self ValueObject) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueObject) IsTrue

func (self ValueObject) IsTrue(executor Executor, span errors.Span) (bool, *errors.Error)

func (*ValueObject) IterReset added in v2.3.0

func (self *ValueObject) IterReset()

func (*ValueObject) Next added in v2.3.0

func (self *ValueObject) Next(val *Value, span errors.Span) bool

func (ValueObject) Protected

func (self ValueObject) Protected() bool

func (ValueObject) Span

func (self ValueObject) Span() errors.Span

func (ValueObject) Type

func (self ValueObject) Type() ValueType

type ValuePair

type ValuePair struct {
	Key         *Value
	Value       *Value
	Range       errors.Span
	IsProtected bool
}

Pair value

func (ValuePair) Debug

func (self ValuePair) Debug(executor Executor, span errors.Span) (string, *errors.Error)

func (ValuePair) Display

func (self ValuePair) Display(executor Executor, span errors.Span) (string, *errors.Error)

func (ValuePair) Fields

func (self ValuePair) Fields() map[string]*Value

func (ValuePair) Index

func (self ValuePair) Index(_ Executor, _ Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValuePair) IsEqual

func (self ValuePair) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValuePair) IsTrue

func (self ValuePair) IsTrue(executor Executor, span errors.Span) (bool, *errors.Error)

func (ValuePair) Protected

func (self ValuePair) Protected() bool

func (ValuePair) Span

func (self ValuePair) Span() errors.Span

func (ValuePair) Type

func (self ValuePair) Type() ValueType

type ValueRange added in v2.3.0

type ValueRange struct {
	Start       *Value
	End         *Value
	Current     *float64
	Range       errors.Span
	IsProtected bool
}

Range value

func (ValueRange) Debug added in v2.3.0

func (self ValueRange) Debug(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueRange) Display added in v2.3.0

func (self ValueRange) Display(executor Executor, span errors.Span) (string, *errors.Error)

func (ValueRange) Fields added in v2.3.0

func (self ValueRange) Fields() map[string]*Value

func (ValueRange) Index added in v2.3.0

func (self ValueRange) Index(_ Executor, _ Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueRange) IsEqual added in v2.3.0

func (self ValueRange) IsEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueRange) IsTrue added in v2.3.0

func (self ValueRange) IsTrue(_ Executor, _ errors.Span) (bool, *errors.Error)

func (*ValueRange) IterReset added in v2.3.0

func (self *ValueRange) IterReset()

func (*ValueRange) Next added in v2.3.0

func (self *ValueRange) Next(val *Value, span errors.Span) bool

func (ValueRange) Protected added in v2.3.0

func (self ValueRange) Protected() bool

func (ValueRange) Span added in v2.3.0

func (self ValueRange) Span() errors.Span

func (ValueRange) Type added in v2.3.0

func (self ValueRange) Type() ValueType

type ValueRelational

type ValueRelational interface {
	IsLessThan(executor Executor, span errors.Span, other Value) (bool, *errors.Error)
	IsLessThanOrEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)
	IsGreaterThan(executor Executor, span errors.Span, other Value) (bool, *errors.Error)
	IsGreaterThanOrEqual(executor Executor, span errors.Span, other Value) (bool, *errors.Error)
}

type ValueString

type ValueString struct {
	Value            string
	Range            errors.Span
	CurrentIterIndex *int
	IsProtected      bool
}

String value

func (ValueString) Add

func (self ValueString) Add(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueString) Debug

func (self ValueString) Debug(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueString) Display

func (self ValueString) Display(_ Executor, _ errors.Span) (string, *errors.Error)

func (ValueString) Div

func (self ValueString) Div(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueString) Fields

func (self ValueString) Fields() map[string]*Value

func (ValueString) Index

func (self ValueString) Index(_ Executor, indexValue Value, span errors.Span) (*Value, bool, *errors.Error)

func (ValueString) IntDiv

func (self ValueString) IntDiv(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueString) IsEqual

func (self ValueString) IsEqual(_ Executor, span errors.Span, other Value) (bool, *errors.Error)

func (ValueString) IsTrue

func (self ValueString) IsTrue(_ Executor, span errors.Span) (bool, *errors.Error)

func (*ValueString) IterReset added in v2.3.0

func (self *ValueString) IterReset()

func (ValueString) Mul

func (self ValueString) Mul(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (*ValueString) Next added in v2.3.0

func (self *ValueString) Next(val *Value, span errors.Span) bool

func (ValueString) Pow

func (self ValueString) Pow(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueString) Protected

func (self ValueString) Protected() bool

func (ValueString) Rem

func (self ValueString) Rem(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueString) Span

func (self ValueString) Span() errors.Span

func (ValueString) Sub

func (self ValueString) Sub(executor Executor, span errors.Span, other Value) (Value, *errors.Error)

func (ValueString) Type

func (self ValueString) Type() ValueType

type ValueType

type ValueType uint8
const (
	TypeUnknown ValueType = iota
	TypeNull
	TypeNumber
	TypeBoolean
	TypeString
	TypePair
	TypeObject
	TypeList
	TypeRange
	TypeEnum
	TypeEnumVariant
	TypeFunction
	TypeBuiltinFunction
	TypeBuiltinVariable
)

func (ValueType) String

func (self ValueType) String() string

type Weather

type Weather struct {
	WeatherTitle       string
	WeatherDescription string
	Temperature        float64
	FeelsLike          float64
	Humidity           uint8
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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