golisp

package module
v0.0.0-...-3c4b291 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 14 Imported by: 0

README

golisp

CI

Lisp Interpreter

Usage

$ golisp < foo.lisp

Installation

$ go get github.com/mattn/golisp/cmd/golisp

Features

Call Go functions.

Print random ints.

(setq time (go:import 'time))
(setq rand (go:import 'math/rand))
(.Seed rand (.UnixNano (.Now time)))
(print (.Int rand))
Use goroutine/channel
(setq time (go:import time))
(let ((ch (go:make-chan string 1)))
  (go
    (.Sleep time 1e9)
    (go:chan-send ch "3")
    (.Sleep time 1e9)
    (go:chan-send ch "2")
    (.Sleep time 1e9)
    (go:chan-send ch "1")
    (.Sleep time 1e9)
    (go:chan-send ch "Fire!")
  )
  (print (car (go:chan-recv ch)))
  (print (car (go:chan-recv ch)))
  (print (car (go:chan-recv ch)))
  (print (car (go:chan-recv ch)))
)

TODO

  • macro

License

MIT

Author

Yasuhiro Matsumoto (a.k.a. mattn)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EOF = errors.New("unexpected end of file")
)

Functions

func LoadLib

func LoadLib(env *Env) error

Types

type Env

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

func NewEnv

func NewEnv(env *Env) *Env

func (*Env) Eval

func (e *Env) Eval(node *Node) (*Node, error)

func (*Env) SetOut

func (e *Env) SetOut(o io.Writer)

type Fn

type Fn func(*Env, *Node) (*Node, error)

type FnInfo

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

type Ft

type Ft int
const (
	FtSpecial Ft = iota
	FtBuiltin
)

type Node

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

func (*Node) CarIsNil

func (n *Node) CarIsNil() bool

func (*Node) CdrIsNil

func (n *Node) CdrIsNil() bool

func (*Node) String

func (n *Node) String() string

type NodeType

type NodeType int
const (
	NodeNil NodeType = iota
	NodeT
	NodeInt
	NodeDouble
	NodeString
	NodeQuote
	NodeBquote
	NodeIdent
	NodeLambda
	NodeSpecial
	NodeBuiltinfunc
	NodeCell
	NodeAref
	NodeEnv
	NodeError
	NodeGoValue
)

func (NodeType) String

func (i NodeType) String() string

type Parser

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

func NewParser

func NewParser(r io.Reader) *Parser

func (*Parser) NewError

func (p *Parser) NewError(err error) *Node

func (*Parser) Parse

func (p *Parser) Parse() (*Node, error)

func (*Parser) ParseAny

func (p *Parser) ParseAny(bq bool) (*Node, error)

func (*Parser) ParseBquote

func (p *Parser) ParseBquote() (*Node, error)

func (*Parser) ParseParen

func (p *Parser) ParseParen(bq bool) (*Node, error)

func (*Parser) ParsePrimitive

func (p *Parser) ParsePrimitive() (*Node, error)

func (*Parser) ParseQuote

func (p *Parser) ParseQuote() (*Node, error)

func (*Parser) ParseString

func (p *Parser) ParseString() (*Node, error)

func (*Parser) Pos

func (p *Parser) Pos() int

func (*Parser) SkipWhite

func (p *Parser) SkipWhite()

Directories

Path Synopsis
cmd
Package statik contains static assets.
Package statik contains static assets.

Jump to

Keyboard shortcuts

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