cgam

package
v0.0.0-...-c991dcf Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: GPL-3.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DUMP_VERTICAL = iota
	DUMP_HORIZONTAL
	DUMP_STRING
)
View Source
const (
	RESET_STACK = 1 << (iota + 1)
	RESET_VARS
	RESET_LONGVARS
	RESET_NAMESPACE
)
View Source
const SIGNAL string = "!#\ufdd0"

Variables

View Source
var OPS map[string]*Op = make(map[string]*Op)

Functions

func I

func I(a interface{}) interface{}

func InitFuncs

func InitFuncs()

Functions

func MatchSign

func MatchSign(tf TypedFunc, x *Stack) int

func Range

func Range(n int) []interface{}

Types

type Block

type Block struct {
	Ops     []*Op
	Offsets [][2]int // LineNum & Offset
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(ops []*Op, offsets [][2]int, wb bool, parser *Parser) *Block

func Parse

func Parse(code *Parser, withbrace bool) *Block

func (*Block) Run

func (b *Block) Run(env *Environ)

func (*Block) String

func (b *Block) String() string

type Environ

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

The environment

func NewEnviron

func NewEnviron(args []string) *Environ

func (*Environ) Clear

func (env *Environ) Clear(opts int)

func (*Environ) Dump

func (env *Environ) Dump(opt int)

func (*Environ) Get

func (env *Environ) Get(ind int) interface{}

func (*Environ) GetMemo

func (env *Environ) GetMemo() *Memo

func (*Environ) GetRand

func (env *Environ) GetRand() *rand.Rand

func (*Environ) GetVar

func (env *Environ) GetVar(s string) interface{}

Variables

func (*Environ) InitVars

func (env *Environ) InitVars()

func (*Environ) Mark

func (env *Environ) Mark()

func (*Environ) Pop

func (env *Environ) Pop() (a interface{})

func (*Environ) PopMark

func (env *Environ) PopMark()

func (*Environ) Push

func (env *Environ) Push(a interface{})

func (*Environ) Pusha

func (env *Environ) Pusha(as *Stack)

func (*Environ) SetMemo

func (env *Environ) SetMemo(m *Memo)

func (*Environ) SetVar

func (env *Environ) SetVar(s string, a interface{})

func (*Environ) Size

func (env *Environ) Size() int

type Memo

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

The memo for recursive functions (`y`)

func NewMemo

func NewMemo(b *Block, n int) *Memo

func (*Memo) Get

func (m *Memo) Get(entry []interface{}) (interface{}, bool)

func (*Memo) Run

func (m *Memo) Run(env *Environ)

func (*Memo) Set

func (m *Memo) Set(entry []interface{}, val interface{})

type Op

type Op struct {
	Name  string
	Funcs []TypedFunc
}

func (*Op) HasArity

func (op *Op) HasArity(arity int) bool

A work around for the Op, Op1, Op2 and Op3 classes

func (*Op) Run

func (op *Op) Run(env *Environ)

func (*Op) String

func (op *Op) String() string

type Parser

type Parser struct {
	LnNum  int
	Offset int
	// contains filtered or unexported fields
}

Parsing//

func NewParser

func NewParser(src, code string) *Parser

func (*Parser) GetOffset

func (p *Parser) GetOffset() [2]int

func (*Parser) GetSrc

func (p *Parser) GetSrc() string

func (*Parser) Read

func (p *Parser) Read() (c rune, e error)

func (*Parser) Unread

func (p *Parser) Unread() error

type Runner

type Runner interface {
	Run(*Environ)
	String() string
}

type Sorter

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

func NewSorter

func NewSorter(arr []interface{}, key func(a interface{}) interface{}) *Sorter

func (*Sorter) Len

func (s *Sorter) Len() int

func (*Sorter) Less

func (s *Sorter) Less(i, j int) bool

func (*Sorter) Swap

func (s *Sorter) Swap(i, j int)

type Stack

type Stack []interface{} // A wrapper for []interface{}, also acts as the main stack

func NewStack

func NewStack(x []interface{}) *Stack

func (*Stack) Clear

func (x *Stack) Clear()

func (*Stack) Contents

func (x *Stack) Contents() []interface{}

func (*Stack) Get

func (x *Stack) Get(ind int) interface{}

func (*Stack) Get1

func (x *Stack) Get1() interface{}

The unpacking methods for usage in operators' parameter passing

func (*Stack) Get2

func (x *Stack) Get2() (interface{}, interface{})

func (*Stack) Get3

func (x *Stack) Get3() (interface{}, interface{}, interface{})

func (*Stack) Get4

func (x *Stack) Get4() (interface{}, interface{}, interface{}, interface{})

func (*Stack) Pop

func (x *Stack) Pop() (a interface{})

func (*Stack) Push

func (x *Stack) Push(a interface{})

func (*Stack) Pusha

func (x *Stack) Pusha(as *Stack)

func (*Stack) Reverse

func (x *Stack) Reverse()

func (*Stack) Size

func (x *Stack) Size() int

func (*Stack) Switch

func (x *Stack) Switch(a, b int)

type TypedFunc

type TypedFunc struct {
	Sign   string // Signature
	Option byte   // * * * * | Switch_start Switch_end
	Func   func(env *Environ, x *Stack) *Stack
}

Operator//

Jump to

Keyboard shortcuts

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