picol

package
v0.0.0-...-1a04551 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 7 Imported by: 0

README

picol.go

Original http://oldblog.antirez.com/post/picol.html

Sample use:

func CommandPuts(i *picol.Interp, argv []string, pd interface{}) (string, error) {
	if len(argv) != 2 {
		return "", fmt.Errorf("Wrong number of args for %s %s", argv[0], argv)
	}
	fmt.Println(argv[1])
	return "", nil
}
...
	interp := picol.InitInterp()
	// add core functions
	interp.RegisterCoreCommands()
	// add user function
	interp.RegisterCommand("puts", CommandPuts, nil)
	// eval
	result, err := interp.Eval(string(buf))
	if err != nil {
		fmt.Println("ERROR", err, result)
	} else {
		fmt.Println(result)
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandCallProc

func CommandCallProc(i *Interp, argv []string, pd interface{}) (string, error)

CommandCallProc is a function to call proc commands for TCL

func CommandError

func CommandError(i *Interp, argv []string, pd interface{}) (string, error)

CommandError is a function to return error codes for commands for TCL

func CommandIf

func CommandIf(i *Interp, argv []string, pd interface{}) (string, error)

CommandIf is the if command for TCL

func CommandMath

func CommandMath(i *Interp, argv []string, pd interface{}) (string, error)

CommandMath is the math command for TCL

func CommandProc

func CommandProc(i *Interp, argv []string, pd interface{}) (string, error)

CommandProc is a function to register proc commands for TCL

func CommandPuts

func CommandPuts(i *Interp, argv []string, pd interface{}) (string, error)

CommandPuts is a function to print strings for TCL

func CommandRetCodes

func CommandRetCodes(i *Interp, argv []string, pd interface{}) (string, error)

CommandRetCodes is a function to get the return codes for TCL

func CommandReturn

func CommandReturn(i *Interp, argv []string, pd interface{}) (string, error)

CommandReturn is a function to register return codes for commands for TCL

func CommandSet

func CommandSet(i *Interp, argv []string, pd interface{}) (string, error)

CommandSet is the set command for TCL

func CommandUnset

func CommandUnset(i *Interp, argv []string, pd interface{}) (string, error)

CommandUnset is the unset command for TCL

func CommandWhile

func CommandWhile(i *Interp, argv []string, pd interface{}) (string, error)

CommandWhile is the while command for TCL

func TestneedleInHaystack

func TestneedleInHaystack(t *testing.T)

TestneedleInHaystack tests the return value of needleInHaystack

Types

type CallFrame

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

type Cmd

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

type CmdFunc

type CmdFunc func(i *Interp, argv []string, privdata interface{}) (string, error)

type Interp

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

func InitInterp

func InitInterp() *Interp

func (*Interp) Command

func (i *Interp) Command(name string) *Cmd

func (*Interp) Eval

func (i *Interp) Eval(t string) (string, error)

EVAL!

func (*Interp) RegisterCommand

func (i *Interp) RegisterCommand(name string, fn CmdFunc, privdata interface{}) error

func (*Interp) RegisterCoreCommands

func (i *Interp) RegisterCoreCommands()

RegisterCoreCommands is a callable to register TCL commands.

func (*Interp) SetVar

func (i *Interp) SetVar(name, val string)

func (*Interp) UnsetVar

func (i *Interp) UnsetVar(name string)

func (*Interp) Var

func (i *Interp) Var(name string) (Var, bool)

type Var

type Var string

Jump to

Keyboard shortcuts

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