sexp

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReferencedVars

func ReferencedVars(s Sexp) []string

Types

type Context

type Context struct {
	Funcs map[string]func([]interface{}) (Sexp, error)
	Vars  map[string]Sexp
}
var Builtin Context = Context{
	Funcs: map[string]func([]interface{}) (Sexp, error){
		"format": format,
	},
	Vars: map[string]Sexp{
		"xxxx": {"xxx"},
	},
}

type List

type List []Sexp

func (List) String

func (l List) String() string

type QString

type QString string

type Sexp

type Sexp struct {
	I interface{}
}

dynamic types for i are string, qString, int, float64, list, and error.

func Eval

func Eval(ctx *Context, s Sexp) (Sexp, error)

func Parse

func Parse(s string) (Sexp, error)

Parse parses a string into a Go representation of an s-expression.

Quoted strings go from one " to the next. There is no escape character, all characters except " are valid.

Otherwise atoms are any string of characters between any of '(', ')', '"', or white space characters. If the atom parses as a Go int type using strconv.Atoi, it is taken as int; if it parses as a Go float64 type using strconv.ParseFloat, it is taken as float64; otherwise it is taken as an unquoted string.

Unmatched (, ), or " are errors. An empty or all whitespace input string is an error. Left over text after the sexp is an error.

An empty list is a valid sexp, but there is no nil, no cons, no dot.

func (Sexp) Dump

func (s Sexp) Dump(i int)

func (Sexp) String

func (s Sexp) String() string

Jump to

Keyboard shortcuts

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