parser

package
v2.6.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: GPL-3.0 Imports: 11 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       = ']'
	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 ArgExprEnv

type ArgExprEnv struct {
	ActiveMedia  ExprEnvActiveMedia `expr:"active_media"`
	Device       ExprEnvDevice      `expr:"device"`
	LastScanned  ExprEnvLastScanned `expr:"last_scanned"`
	Platform     string             `expr:"platform"`
	Version      string             `expr:"version"`
	ScanMode     string             `expr:"scan_mode"`
	MediaPlaying bool               `expr:"media_playing"`
}

type Command

type Command struct {
	AdvArgs map[string]string
	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"`
	SystemID   string `expr:"system_id"`
	SystemName string `expr:"system_name"`
	Path       string `expr:"path"`
	Name       string `expr:"name"`
}

type ExprEnvDevice

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

type ExprEnvLastScanned

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

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