Documentation ¶
Index ¶
- Constants
- Variables
- func IsEmpty(val Value) bool
- func Prelude() map[string]Cmd
- func Strings[Slice ~[]E, E fmt.Stringer](vals Slice) []string
- func Truthy(val Value) bool
- type Access
- type Block
- type Bool
- type Cmd
- type CmdExprFunc
- type CmdFunc
- type Command
- type Error
- type EvalErrorFunc
- type Expr
- type Func
- type Int
- type Interp
- func (tcl *Interp) Bind(name string, cmd Cmd)
- func (tcl *Interp) BindCmds(cmds map[string]Cmd)
- func (tcl *Interp) Call(name string, args ...Value) (Values, error)
- func (tcl *Interp) Cmd(name string) (Cmd, error)
- func (tcl *Interp) Do(e Expr) (result Values, err error)
- func (tcl *Interp) Eval(e Expr, lookup *Interp, handleErr EvalErrorFunc) (result Values, err error)
- func (tcl *Interp) Fork() *Interp
- func (tcl *Interp) Global(name string) error
- func (tcl *Interp) GlobalScope() *Interp
- func (tcl *Interp) Parent(nth uint) (*Interp, error)
- func (tcl *Interp) Return() (*Interp, error)
- func (tcl *Interp) SetPrelude(cmds map[string]Cmd)
- func (tcl *Interp) SetVar(name string, vals Values)
- func (tcl *Interp) Unset(name string)
- func (tcl *Interp) Upvar(name string) error
- func (tcl *Interp) Var(name string) (Values, error)
- func (tcl *Interp) VarStorage(name string) (*Values, error)
- type Iterable
- type Iterator
- type ListExpr
- type Literal
- type Map
- type OnceIterable
- type Parser
- type QuoteString
- type RawString
- type ReturnCode
- type Seq
- type String
- type TokenReader
- type UnexpectedTokenError
- type Value
- type Values
- func Empty() Values
- func PreludeAnd(tcl *Interp, args []Expr) (last Values, err error)
- func PreludeBind(tcl *Interp, args Values) (Values, error)
- func PreludeBreak(tcl *Interp, args Values) (Values, error)
- func PreludeCatch(tcl *Interp, args []Expr) (last Values, err error)
- func PreludeConcat(tr *Interp, args Values) (Values, error)
- func PreludeContinue(tcl *Interp, args Values) (Values, error)
- func PreludeDict(tcl *Interp, args Values) (Values, error)
- func PreludeExpand(tcl *Interp, args Values) (Values, error)
- func PreludeFalse(tcl *Interp, args Values) (Values, error)
- func PreludeFn(tcl *Interp, args []Expr) (Values, error)
- func PreludeForeach(tcl *Interp, args []Expr) (Values, error)
- func PreludeIf(tcl *Interp, args []Expr) (results Values, err error)
- func PreludeIndex(tr *Interp, args Values) (Values, error)
- func PreludeInt(tcl *Interp, args Values) (Values, error)
- func PreludeIsEmpty(tcl *Interp, args Values) (Values, error)
- func PreludeIsError(tcl *Interp, args Values) (Values, error)
- func PreludeIsTrue(tcl *Interp, args Values) (Values, error)
- func PreludeLen(tcl *Interp, args Values) (Values, error)
- func PreludeList(tcl *Interp, args Values) (Values, error)
- func PreludeNot(tcl *Interp, args Values) (Values, error)
- func PreludeOr(tcl *Interp, args []Expr) (last Values, err error)
- func PreludePuts(tr *Interp, args Values) (Values, error)
- func PreludeReturn(tcl *Interp, args Values) (Values, error)
- func PreludeSeq(tcl *Interp, args Values) (Values, error)
- func PreludeSet(tcl *Interp, args Values) (Values, error)
- func PreludeStr(tcl *Interp, args Values) (Values, error)
- func PreludeTap(tcl *Interp, args Values) (Values, error)
- func PreludeTrue(tcl *Interp, args Values) (Values, error)
- func PreludeType(tcl *Interp, args Values) (Values, error)
- func PreludeUplevel(tcl *Interp, args []Expr) (results Values, err error)
- func PreludeUpvar(tcl *Interp, args Values) (Values, error)
- func PreludeWhile(tcl *Interp, args []Expr) (results Values, err error)
- type Word
Constants ¶
View Source
const UnknownCmd = `*unknown*`
Variables ¶
View Source
var ( ErrNotFound = errors.New("not found") ErrVarNotFound = fmt.Errorf("variable %w", ErrNotFound) ErrCmdNotFound = fmt.Errorf("command %w", ErrNotFound) )
Functions ¶
Types ¶
type Access ¶
type Access struct { Access string `json:"access"` Braced bool `json:"braced,omitempty"` // True if variable name enclosed in curly braces. Tok token.Token `json:"-"` }
Access is a variable access denoted as `$var` or `${var}`.
type Block ¶
type Block struct { Block []*Command `json:"block"` StartTok token.Token `json:"-"` // '[' token EndTok token.Token `json:"-"` // ']' token }
A Block is a set of Commands enclosed in square brackets, such as `[concat a b]`.
type CmdExprFunc ¶
type Expr ¶
type Expr interface { // Token returns the token from the first part of the Expr. The // concrete type of the Expr may contain additional tokens identifying // the remaining tokens making up the Expr. Token() token.Token // String returns the Expr as a string that is equivalent in value // to the source tokens (with differences allowed for comments // and whitespace). String() string }
type Interp ¶
type Interp struct {
// contains filtered or unexported fields
}
func (*Interp) GlobalScope ¶
func (*Interp) SetPrelude ¶
type ListExpr ¶
type ListExpr struct { List []Expr `json:"list"` StartTok token.Token `json:"-"` // '(' token EndTok token.Token `json:"-"` // ')' token }
A ListExpr is a sequence of expressions that results in a list. This is functionally equivalent to calling [list exprs...] in the source script, assuming [list] is provided..
type OnceIterable ¶
type OnceIterable struct {
Value
}
func (OnceIterable) Iterator ¶
func (o OnceIterable) Iterator() Iterator
type Parser ¶
type Parser struct { LogFunc func(...any) // contains filtered or unexported fields }
func NewParser ¶
func NewParser(r TokenReader) *Parser
func (*Parser) ParseCommand ¶
type QuoteString ¶
type QuoteString struct {
QuoteString *Word `json:"quote_string"`
}
A QuoteString is a string starting and ending in double quotes made up of Words, Accesses, and Blocks.
func (*QuoteString) String ¶
func (qs *QuoteString) String() string
func (*QuoteString) Token ¶
func (qs *QuoteString) Token() token.Token
type RawString ¶
type RawString struct { RawString string `json:"raw_string"` Tok token.Token `json:"-"` // Exprs contains parsed commands from the RawString. May be empty if the string cannot be parsed as a set of expressions. Cmds []*Command `json:"cmds"` }
A RawString is a string wrapped in curly braces that has no interpreted value other than itself, minus escaped curly braces.
type ReturnCode ¶
type ReturnCode int
const ( ReturnOK ReturnCode = 0 ReturnError ReturnCode = 1 ReturnOuter ReturnCode = 2 ReturnBreak ReturnCode = 3 ReturnContinue ReturnCode = 4 )
func (ReturnCode) Error ¶
func (rc ReturnCode) Error() string
type TokenReader ¶
type UnexpectedTokenError ¶
func (*UnexpectedTokenError) Error ¶
func (e *UnexpectedTokenError) Error() string
func (*UnexpectedTokenError) Unwrap ¶
func (e *UnexpectedTokenError) Unwrap() error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.