ast

package
v0.0.0-...-d17e975 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SyncTablesWithOSEnviron = false

Trigger this if you are using this for a shell

Functions

func DeleteVarTable

func DeleteVarTable(table VarTable)

Dont do this on var tables youve already called InitVarTable on.... please.... This will pull currently contained variables OUT of the operating env

func FmtToken

func FmtToken(arg *Token) string

func GetTagAsStr

func GetTagAsStr(tag Token_t) string

func InitVarTable

func InitVarTable(table VarTable)

func PrintSExprsIndividually

func PrintSExprsIndividually(arg *Token)

Print function which breaks each embedded list out on individual lines. * Used in the print_ast debug tool. not too useful for repl applications. * Very useful for debugging syntax though. * TODO: Add numbers to denote embedded scope?

func SetVar

func SetVar(variable string, value *Token, vt VarTable)

TODO: this could be much more optimal

func StrIsNumber

func StrIsNumber(arg string) bool

Types

type FuncTable

type FuncTable *map[string]*Function

type Function

type Function struct {
	Function    Operation
	Name        string
	TimesCalled int
	Args        int // TODO: Make this a list of expected types (TAGs)
}

func GetFunction

func GetFunction(arg string, table FuncTable) *Function

func (Function) CallFunction

func (f Function) CallFunction(args *Token, vt VarTable, ft FuncTable) *Token

func (Function) ParseFunction

func (f Function) ParseFunction(args *Token) bool

TODO: Currently only checks arg list length

type Operation

type Operation func(*Token, VarTable, FuncTable) *Token

type Token

type Token struct {
	Next     *Token
	Tag      Token_t
	Position int
	Inner    interface{}
}

func GetVar

func GetVar(arg string, vt VarTable) *Token

func GetVarFromTables

func GetVarFromTables(arg string, library []VarTable) *Token

Library represents variables defined in inner scope It is assumed library is ordered from innermost scope to outermost scope

func Lex

func Lex(input string) *Token

func (*Token) Eval

func (t *Token) Eval(funcs FuncTable, vars VarTable) (*Token, bool)

func (*Token) String

func (t *Token) String() string

Print function which is better suited for repl. * This one prints the SEXPRs as one would write them.

type TokenStack

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

func (*TokenStack) Pop

func (s *TokenStack) Pop() *Token

func (*TokenStack) Push

func (s *TokenStack) Push(v *Token)

type Token_t

type Token_t int
const (
	LIST   Token_t = iota
	STRING Token_t = iota
	NUMBER Token_t = iota
	SYMBOL Token_t = iota
)

type VarTable

type VarTable *map[string]*Token

Jump to

Keyboard shortcuts

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