homescript

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(executor interpreter.Executor, filename string, code string) (int, []customError.Error)

Runs a provided homescript file given the source code Returns an error slice

Types

type AndExpr

type AndExpr struct {
	Base      EqExpr
	Following []EqExpr
}

type Atom

type Atom interface {
	Kind() AtomKind
}

type AtomBoolean

type AtomBoolean struct{ Value bool }

Boolean

func (AtomBoolean) Kind

func (self AtomBoolean) Kind() AtomKind

type AtomCall

type AtomCall struct {
	CallExpr CallExpr
}

Call

func (AtomCall) Kind

func (self AtomCall) Kind() AtomKind

type AtomExpr

type AtomExpr struct{ Expr Expression }

Expression

func (AtomExpr) Kind

func (self AtomExpr) Kind() AtomKind

type AtomIdentifier

type AtomIdentifier struct {
	Name     string
	Location error.Location
}

Identifier

func (AtomIdentifier) Kind

func (self AtomIdentifier) Kind() AtomKind

type AtomIf

type AtomIf struct{ IfExpr IfExpr }

If

func (AtomIf) Kind

func (self AtomIf) Kind() AtomKind

type AtomKind

type AtomKind uint8
const (
	AtomNumberKind AtomKind = iota
	AtomStringKind
	AtomBooleanKind
	AtomIdentifierKind
	AtomIfKind
	AtomCallKind
	AtomExpressionKind
)

type AtomNumber

type AtomNumber struct{ Num float64 }

Number

func (AtomNumber) Kind

func (self AtomNumber) Kind() AtomKind

type AtomString

type AtomString struct{ Content string }

String

func (AtomString) Kind

func (self AtomString) Kind() AtomKind

type CallExpr

type CallExpr struct {
	Name      string
	Arguments []Expression
	Location  error.Location
}

type DummyExecutor

type DummyExecutor struct{}

func (DummyExecutor) AddPerm

func (self DummyExecutor) AddPerm(username string, permission string) error

func (DummyExecutor) AddUser

func (self DummyExecutor) AddUser(username string, password string, forename string, surname string) error

func (DummyExecutor) DelPerm

func (self DummyExecutor) DelPerm(username string, permission string) error

func (DummyExecutor) DelUser

func (self DummyExecutor) DelUser(username string) error

func (DummyExecutor) Exec

func (self DummyExecutor) Exec(homescriptId string) (string, error)

func (DummyExecutor) GetDate

func (self DummyExecutor) GetDate() (int, int, int, int, int, int)

func (DummyExecutor) GetDebugInfo

func (self DummyExecutor) GetDebugInfo() (string, error)

func (DummyExecutor) GetTemperature

func (self DummyExecutor) GetTemperature() (int, error)

func (DummyExecutor) GetUser

func (self DummyExecutor) GetUser() string

func (DummyExecutor) GetWeather

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

func (DummyExecutor) Log

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

func (DummyExecutor) Notify

func (self DummyExecutor) Notify(
	title string,
	description string,
	level interpreter.LogLevel,
) error

func (DummyExecutor) Play

func (self DummyExecutor) Play(server string, mode string) error

func (DummyExecutor) Print

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

func (DummyExecutor) Switch

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

func (DummyExecutor) SwitchOn

func (self DummyExecutor) SwitchOn(name string) (bool, error)

type EqExpr

type EqExpr struct {
	Base  RelExpr
	Other *struct {
		TokenType
		RelExpr
	}
}

type Expression

type Expression struct {
	Base      AndExpr
	Following []AndExpr
}

type Expressions

type Expressions []Expression

type IfExpr

type IfExpr struct {
	Condition Expression
	Body      Expressions
	ElseBody  Expressions
	Location  error.Location
}

type Interpreter

type Interpreter struct {
	StartNode Expressions
	Executor  interpreter.Executor
	Scope     map[string]interpreter.Value
}

func NewInterpreter

func NewInterpreter(startNode Expressions, executor interpreter.Executor) Interpreter

func (*Interpreter) Run

func (self *Interpreter) Run() (int, *error.Error)

type Lexer

type Lexer struct {
	CurrentChar  *rune
	CurrentIndex uint
	Input        []rune
	Location     error.Location
}

func NewLexer

func NewLexer(filename string, input string) Lexer

func (*Lexer) Scan

func (self *Lexer) Scan() (Token, *error.Error)

type NotExpr

type NotExpr struct {
	Base     Atom
	Negated  bool
	Location error.Location
}

type Parser

type Parser struct {
	Lexer        Lexer
	CurrentToken Token
	Errors       []error.Error
}

func NewParser

func NewParser(lexer Lexer) Parser

func (*Parser) Parse

func (self *Parser) Parse() (Expressions, []error.Error)

type RelExpr

type RelExpr struct {
	Base  NotExpr
	Other *struct {
		TokenType
		NotExpr
	}
}

type Token

type Token struct {
	TokenType TokenType
	Value     string
	Location  error.Location
}

func UnknownToken

func UnknownToken(location error.Location) Token

type TokenType

type TokenType uint8
const (
	Unknown TokenType = iota
	EOF
	EOL        // \n
	Number     // int
	String     // " "
	Identifier // temperature, sleep

	// Terminal symbols
	Or                 // ||
	And                // &&
	Equal              // ==
	NotEqual           // !=
	LessThan           // <
	LessThanOrEqual    // <=
	GreaterThan        // >
	GreaterThanOrEqual // >=
	Not                // !
	LeftParenthesis    // (
	RightParenthesis   // )
	LeftCurlyBrace     // {
	RightCurlyBrace    // }
	Comma              // ,
	If                 // if
	Else               // else
	True               // true | on
	False              // false | off
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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