dsl

package
v0.58.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const SyntaxVersion = "0.37" // major,minor

SyntaxVersion tells what language version this package is supporting.

Variables

This section is empty.

Functions

func EvalFunctions

func EvalFunctions(ctx core.Context) map[string]Function

func ImportProgram added in v0.9.2

func ImportProgram(ctx core.Context, filename string) error

ImportProgram runs a script from a file

func IsAssignment

func IsAssignment(entry string) (varname string, expression string, ok bool)

[ ]a[]=[]note('c')

func IsCompatibleSyntax added in v0.7.0

func IsCompatibleSyntax(s string) bool

func ListVariables added in v0.9.2

func ListVariables(storage core.VariableStorage, args []string) notify.Message

ListVariables prints a list of sorted key=value pairs.

func StopAllPlayables added in v0.9.2

func StopAllPlayables(context core.Context)

Types

type Evaluator added in v0.9.2

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

func NewEvaluator added in v0.9.2

func NewEvaluator(ctx core.Context) *Evaluator

func (*Evaluator) EvaluateExpression added in v0.9.2

func (e *Evaluator) EvaluateExpression(entry string) (any, error)

EvaluateExpression returns the result of an expression (entry) using a given store of variables. The result is either FunctionResult or a "raw" Go object.

func (*Evaluator) EvaluateProgram added in v0.9.2

func (e *Evaluator) EvaluateProgram(source string) (any, error)

Statements are separated by newlines and semicolons. If a line is prefixed by one or more TABs then that line is appended to the previous. If a line is prefixed by 4 SPACES then that line is appended to the previous. Return the result of the last expression or statement.

func (*Evaluator) LookupFunction added in v0.9.2

func (e *Evaluator) LookupFunction(fn string) (Function, bool)

func (*Evaluator) RecoveringEvaluateProgram added in v0.58.0

func (e *Evaluator) RecoveringEvaluateProgram(entry string) (any, error)

type Function

type Function struct {
	Keyword       string
	Title         string
	Description   string
	Prefix        string // for autocomplete
	Alias         string // short notation
	Template      string // for autocomplete in VSC
	Samples       string // for doc generation
	ControlsAudio bool
	Tags          string // space separated
	IsCore        bool   // creates a core musical object
	IsComposer    bool   // can decorate a musical object or other decorations
	Func          any
}

func (Function) Declaration added in v0.50.0

func (f Function) Declaration() string

func (Function) HumanizedTemplate added in v0.9.2

func (f Function) HumanizedTemplate() string

func (Function) Markdown added in v0.9.2

func (f Function) Markdown() string

type VariableStore

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

VariableStore is an in-memory storage of values by name. Access to this store is go-routine safe.

func NewVariableStore

func NewVariableStore() *VariableStore

NewVariableStore returns a new

func (*VariableStore) Delete

func (v *VariableStore) Delete(key string)

Delete removes a stored value by the key. Ignores if the key is not found.

func (*VariableStore) Get

func (v *VariableStore) Get(key string) (any, bool)

Get returns a value found by the key. Inspect the second return value of presence.

func (*VariableStore) NameFor

func (v *VariableStore) NameFor(value any) string

NameFor finds the entry for a value and returns its (first) associated name

func (*VariableStore) Put

func (v *VariableStore) Put(key string, value any)

Put stores a value by the key. Overwrites any existing value.

func (*VariableStore) Variables

func (v *VariableStore) Variables() map[string]any

Variables returns a copy of all stores variables.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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