throfflib

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

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

Go to latest
Published: Sep 20, 2021 License: Artistic-2.0 Imports: 21 Imported by: 3

README

Build Status GoDoc

throfflib

Engine and libraries for Throff

Documentation

Overview

commands.go All the basic commands supported by throff. They are all cross platform, and usually are in caps

They all need more error checking

Index

Constants

This section is empty.

Variables

View Source
var BraceMode = "throff"
View Source
var PrintWarnings = false
View Source
var USE_FUNCTION_CACHE = false

Functions

func BootStrapString

func BootStrapString() string

func DetectJapanese

func DetectJapanese(text string) bool

func PopData

func PopData(e *Engine) (*Thingy, *Engine)

func SlurpFile

func SlurpFile(fname string) string

func String2Big

func String2Big(in string, precision uint) *big.Float

Types

type Engine

type Engine struct {
	LastFunction *Thingy
	// contains filtered or unexported fields
}

func Add

func Add(e *Engine, s string, t *Thingy) *Engine

func MakeEngine

func MakeEngine() *Engine

Creates a new engine and populates it with the core functions

func NewEngine

func NewEngine() *Engine

func NullStep

func NullStep(e *Engine) *Engine

Sometimes, we just don't want to do anything

func PushData

func PushData(e *Engine, t *Thingy) *Engine

func Repl

func Repl(e *Engine, japanese bool) *Engine

func Shell

func Shell(e *Engine, japanese bool) *Engine

func (*Engine) CallArgs

func (e *Engine) CallArgs(s string, args ...string) (string, *Engine)

func (*Engine) CallArgs1

func (e *Engine) CallArgs1(s string, args ...interface{}) (string, *Engine)

func (*Engine) CallArray

func (e *Engine) CallArray(s string, args []string) ([]string, *Engine)

func (*Engine) CurrentEndBrace

func (e *Engine) CurrentEndBrace() string

func (*Engine) DataStackTop

func (e *Engine) DataStackTop() *Thingy

func (*Engine) LoadTokens

func (e *Engine) LoadTokens(s Stack)

func (*Engine) Run

func (e *Engine) Run() *Engine

func (*Engine) RunFile

func (e *Engine) RunFile(s string) *Engine

func (*Engine) RunString

func (e *Engine) RunString(s string, source string) *Engine

type Stack

type Stack []*Thingy

func PushStack

func PushStack(s Stack, v *Thingy) Stack

func StringsToTokens

func StringsToTokens(stringBits []string) Stack

type StepFunc

type StepFunc func(*Engine, *Thingy) *Engine

type Thingy

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

The fundamental unit of data. In this engine, arrays, hashes, strings and numbers are all "Thingy"s

func Environment

func Environment(e *Engine) *Thingy

Exported funcs

func NewArray

func NewArray(a Stack) *Thingy

func NewBool

func NewBool(a int) *Thingy

func NewBytes

func NewBytes(bytes []byte, env *Thingy) *Thingy

Raw byte representated.

func NewCode

func NewCode(aName string, arity, arityIn, arityOut int, aFunc StepFunc) *Thingy

Wraps a native go function

func NewContinuation

func NewContinuation(e *Engine) *Thingy

Stores a reference to the engine at the point where it was called. When activated, execution continues at that point

func NewHash

func NewHash() *Thingy

func NewString

func NewString(aString string, env *Thingy) *Thingy

Unicode strings. Length etc might not be the same as its byte representation

func NewToken

func NewToken(aString string, env *Thingy) *Thingy

Tokens cause a namespace lookup on their string value Whatever gets returned is pushed onto the code stack Then on the next step, that Thing gets activated, usually moving itself to the data stack, or running some code This can cause infinite loops if the token resolves to itself So we should probably detect that and move it to the data stack, since that is probably what the user wanted?

func NewWrapper

func NewWrapper(s interface{}) *Thingy

Holds any go structure, like a filehandle, network socket or database handle

func StringsToArray

func StringsToArray(stringBits []string) *Thingy

func (*Thingy) GetString

func (t *Thingy) GetString() string

Builds a string for display to the user. Probably can't be used to re-create the original data structure

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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