parser

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SymCmdStart            = '*'
	SymCmdSep              = '|'
	SymEscapeSeq           = '^'
	SymArgStart            = ':'
	SymArgSep              = ','
	SymArgDoubleQuote      = '"'
	SymArgSingleQuote      = '\''
	SymAdvArgStart         = '?'
	SymAdvArgSep           = '&'
	SymAdvArgEq            = '='
	SymJSONStart           = '{'
	SymJSONEnd             = '}'
	SymJSONEscapeSeq       = '\\'
	SymJSONString          = '"'
	SymInputMacroEscapeSeq = '\\'
	SymInputMacroExtStart  = '{'
	SymInputMacroExtEnd    = '}'
	SymExpressionStart     = '['
	SymExpressionEnd       = ']'
	SymMediaTitleStart     = '@'
	SymMediaTitleSep       = '/'
	SymTagAnd              = '+'
	SymTagNot              = '-'
	SymTagOr               = '~'
	TokExpStart            = "\uE000"
	TokExprEnd             = "\uE001"
)

Variables

View Source
var (
	ErrUnexpectedEOF          = errors.New("unexpected end of file")
	ErrInvalidCmdName         = errors.New("invalid characters in command name")
	ErrInvalidAdvArgName      = errors.New("invalid characters in advanced arg name")
	ErrEmptyCmdName           = errors.New("command name is empty")
	ErrEmptyZapScript         = errors.New("script is empty")
	ErrUnmatchedQuote         = errors.New("unmatched quote")
	ErrInvalidJSON            = errors.New("invalid JSON argument")
	ErrUnmatchedInputMacroExt = errors.New("unmatched input macro extension")
	ErrUnmatchedExpression    = errors.New("unmatched expression")
	ErrBadExpressionReturn    = errors.New("expression return type not supported")
)

Functions

This section is empty.

Types

type AdvArgs added in v2.8.0

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

AdvArgs is a wrapper around raw advanced arguments that enforces type-safe access. Direct map access is not allowed; use the advargs.Parse() function to get typed structs, or the getter/setter methods for pre-parse operations.

func NewAdvArgs added in v2.8.0

func NewAdvArgs(m map[string]string) AdvArgs

func (AdvArgs) Get added in v2.8.0

func (a AdvArgs) Get(key advargtypes.Key) string

func (AdvArgs) GetWhen added in v2.8.0

func (a AdvArgs) GetWhen() (string, bool)

func (AdvArgs) IsEmpty added in v2.8.0

func (a AdvArgs) IsEmpty() bool

func (AdvArgs) MarshalJSON added in v2.8.0

func (a AdvArgs) MarshalJSON() ([]byte, error)

func (AdvArgs) Range added in v2.8.0

func (a AdvArgs) Range(fn func(key advargtypes.Key, value string) bool)

func (AdvArgs) Raw added in v2.8.0

func (a AdvArgs) Raw() map[string]string

func (*AdvArgs) UnmarshalJSON added in v2.8.0

func (a *AdvArgs) UnmarshalJSON(data []byte) error

func (AdvArgs) With added in v2.8.0

func (a AdvArgs) With(key advargtypes.Key, value string) AdvArgs

With returns a new AdvArgs with the key set to value. Does not mutate the receiver.

type ArgExprEnv

type ArgExprEnv struct {
	ActiveMedia  ExprEnvActiveMedia `expr:"active_media" json:"active_media"`
	Device       ExprEnvDevice      `expr:"device" json:"device"`
	LastScanned  ExprEnvLastScanned `expr:"last_scanned" json:"last_scanned"`
	Scanned      ExprEnvScanned     `expr:"scanned" json:"scanned,omitempty"`
	Launching    ExprEnvLaunching   `expr:"launching" json:"launching,omitempty"`
	Platform     string             `expr:"platform" json:"platform"`
	Version      string             `expr:"version" json:"version"`
	ScanMode     string             `expr:"scan_mode" json:"scan_mode"`
	MediaPlaying bool               `expr:"media_playing" json:"media_playing"`
}

type Command

type Command struct {
	AdvArgs AdvArgs
	Name    string
	Args    []string
}

type CustomLauncherExprEnv

type CustomLauncherExprEnv struct {
	Platform  string        `expr:"platform"`
	Version   string        `expr:"version"`
	Device    ExprEnvDevice `expr:"device"`
	MediaPath string        `expr:"media_path"`
}

type ExprEnvActiveMedia

type ExprEnvActiveMedia struct {
	LauncherID string `expr:"launcher_id" json:"launcher_id"`
	SystemID   string `expr:"system_id" json:"system_id"`
	SystemName string `expr:"system_name" json:"system_name"`
	Path       string `expr:"path" json:"path"`
	Name       string `expr:"name" json:"name"`
}

type ExprEnvDevice

type ExprEnvDevice struct {
	Hostname string `expr:"hostname" json:"hostname"`
	OS       string `expr:"os" json:"os"`
	Arch     string `expr:"arch" json:"arch"`
}

type ExprEnvLastScanned

type ExprEnvLastScanned struct {
	ID    string `expr:"id" json:"id"`
	Value string `expr:"value" json:"value"`
	Data  string `expr:"data" json:"data"`
}

type ExprEnvLaunching added in v2.8.0

type ExprEnvLaunching struct {
	Path       string `expr:"path" json:"path"`
	SystemID   string `expr:"system_id" json:"system_id"`
	LauncherID string `expr:"launcher_id" json:"launcher_id"`
}

ExprEnvLaunching represents the media about to launch.

type ExprEnvScanned added in v2.8.0

type ExprEnvScanned struct {
	ID    string `expr:"id" json:"id"`
	Value string `expr:"value" json:"value"`
	Data  string `expr:"data" json:"data"`
}

ExprEnvScanned represents the token currently being processed.

type PostArgPart

type PostArgPart struct {
	Value string
	Type  PostArgPartType
}

type PostArgPartType

type PostArgPartType int
const (
	ArgPartTypeUnknown PostArgPartType = iota
	ArgPartTypeString
	ArgPartTypeExpression
)

type Script

type Script struct {
	Cmds []Command
}

type ScriptReader

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

func NewParser

func NewParser(value string) *ScriptReader

func (*ScriptReader) EvalExpressions

func (sr *ScriptReader) EvalExpressions(exprEnv any) (string, error)

func (*ScriptReader) ParseExpressions

func (sr *ScriptReader) ParseExpressions() (string, error)

ParseExpressions parses and converts expressions in the input string from [[...]] formatted expression fields to internal expression token delimiters, to be evaluated by the EvalExpressions function. This function ONLY parses expression symbols and escape sequences, no other ZapScript syntax.

func (*ScriptReader) ParseScript

func (sr *ScriptReader) ParseScript() (Script, error)

Jump to

Keyboard shortcuts

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