dsl

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 21 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

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 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)

func Validate added in v1.0.0

func Validate(source string) error

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) EvaluateProgramReportEvaluated added in v1.0.0

func (e *Evaluator) EvaluateProgramReportEvaluated(source string) (result any, evaluated bool, err error)

EvaluateProgramReportEvaluated is like EvaluateProgram. It also reports whether the result was already evaluated (e.g. a play expression played), in which case evaluating it again would repeat its effect.

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