eval

package
v0.0.0-...-609d484 Latest Latest
Warning

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

Go to latest
Published: May 23, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PREFIXOP int
	INFIXOP
	UNKNOWNIDENT
	NOMETHODERROR
	NOINDEXERROR
	KEYERROR
	INDEXERROR
	SLICEERROR
	ARGUMENTERROR
	INPUTERROR
	RTERROR
	CONSTRUCTERR
	INLENERR
)

constants for error types

View Source
const (
	INTEGER_OBJ      = "INTEGER"
	BOOLEAN_OBJ      = "BOOLEAN"
	NULL_OBJ         = "NULL"
	RETURN_VALUE_OBJ = "RETURN_VALUE"
	BREAK_OBJ        = "BREAK"
	ERROR_OBJ        = "ERROR"
	FUNCTION_OBJ     = "FUNCTION"
	STRING_OBJ       = "STRING"
	BUILTIN_OBJ      = "BUILTIN"
	ARRAY_OBJ        = "ARRAY"
	HASH_OBJ         = "HASH"
	INCLUDED_OBJ     = "INCLUDE"
	STRUCT_OBJ       = "STRUCT"
	FILE_OBJ         = "FILE"
)

INTEGER_OBJ/*_OBJ = object types

Variables

View Source
var (
	TRUE  = &Boolean{Value: true}
	FALSE = &Boolean{Value: false}
	NULL  = &Null{}
	BREAK = &Break{}
)

Functions

This section is empty.

Types

type Array

type Array struct {
	Members []Object
}

func (*Array) CallMethod

func (a *Array) CallMethod(method string, args ...Object) Object

func (*Array) Count

func (a *Array) Count(args ...Object) Object

func (*Array) Filter

func (a *Array) Filter(args ...Object) Object

func (*Array) Index

func (a *Array) Index(args ...Object) Object

func (*Array) Inspect

func (a *Array) Inspect() string

func (*Array) Map

func (a *Array) Map(args ...Object) Object

func (*Array) Merge

func (a *Array) Merge(args ...Object) Object

func (*Array) Pop

func (a *Array) Pop(args ...Object) Object

func (*Array) Push

func (a *Array) Push(args ...Object) Object

func (*Array) Reduce

func (a *Array) Reduce(args ...Object) Object

func (*Array) Type

func (a *Array) Type() ObjectType

type Boolean

type Boolean struct{ Value bool }

func (*Boolean) CallMethod

func (b *Boolean) CallMethod(method string, args ...Object) Object

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

func (*Boolean) Type

func (b *Boolean) Type() ObjectType

type Break

type Break struct{}

func (*Break) CallMethod

func (b *Break) CallMethod(method string, args ...Object) Object

func (*Break) Inspect

func (b *Break) Inspect() string

func (*Break) Type

func (b *Break) Type() ObjectType

type Builtin

type Builtin struct {
	Fn BuiltinFunc
}

func (*Builtin) CallMethod

func (b *Builtin) CallMethod(method string, args ...Object) Object

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

type BuiltinFunc

type BuiltinFunc func(args ...Object) Object

type Error

type Error struct{ Message string }

func (*Error) CallMethod

func (e *Error) CallMethod(method string, args ...Object) Object

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() ObjectType

type FileObject

type FileObject struct {
	File    *os.File
	Name    string
	Scanner *bufio.Scanner
}

func (*FileObject) CallMethod

func (f *FileObject) CallMethod(method string, args ...Object) Object

func (*FileObject) Close

func (f *FileObject) Close(args ...Object) Object

func (*FileObject) Inspect

func (f *FileObject) Inspect() string

func (*FileObject) Read

func (f *FileObject) Read(args ...Object) Object

func (*FileObject) ReadLine

func (f *FileObject) ReadLine(args ...Object) Object

func (*FileObject) Type

func (f *FileObject) Type() ObjectType

type Function

type Function struct {
	Literal *ast.FunctionLiteral
	Scope   *Scope
}

func (*Function) CallMethod

func (f *Function) CallMethod(method string, args ...Object) Object

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (r *Function) Type() ObjectType

type Hash

type Hash struct {
	Pairs map[HashKey]HashPair
}

func (*Hash) CallMethod

func (h *Hash) CallMethod(method string, args ...Object) Object

func (*Hash) Filter

func (h *Hash) Filter(args ...Object) Object

func (*Hash) Inspect

func (h *Hash) Inspect() string

func (*Hash) Keys

func (h *Hash) Keys(args ...Object) Object

func (*Hash) Map

func (h *Hash) Map(args ...Object) Object

func (*Hash) Merge

func (h *Hash) Merge(args ...Object) Object

func (*Hash) Pop

func (h *Hash) Pop(args ...Object) Object

func (*Hash) Push

func (h *Hash) Push(args ...Object) Object

func (*Hash) Type

func (h *Hash) Type() ObjectType

func (*Hash) Values

func (h *Hash) Values(args ...Object) Object

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

type HashPair

type HashPair struct {
	Key   Object
	Value Object
}

type Hashable

type Hashable interface {
	HashKey() HashKey
}

type IncludedObject

type IncludedObject struct {
	Name  string
	Scope *Scope
}

func (*IncludedObject) CallMethod

func (io *IncludedObject) CallMethod(method string, args ...Object) Object

func (*IncludedObject) Inspect

func (io *IncludedObject) Inspect() string

func (*IncludedObject) Type

func (io *IncludedObject) Type() ObjectType

type Integer

type Integer struct{ Value int64 }

func (*Integer) CallMethod

func (i *Integer) CallMethod(method string, args ...Object) Object

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

func (*Integer) Inspect

func (i *Integer) Inspect() string

func (*Integer) Type

func (i *Integer) Type() ObjectType

type Interpolable

type Interpolable interface {
	Interpolate(scope *Scope)
}

type InterpolatedString

type InterpolatedString struct {
	Value       *String
	RawValue    string
	Expressions map[byte]ast.Expression
}

func (*InterpolatedString) CallMethod

func (is *InterpolatedString) CallMethod(method string, args ...Object) Object

func (*InterpolatedString) Inspect

func (is *InterpolatedString) Inspect() string

func (*InterpolatedString) Interpolate

func (is *InterpolatedString) Interpolate(scope *Scope)

func (*InterpolatedString) Type

func (is *InterpolatedString) Type() ObjectType

type Null

type Null struct{}

func (*Null) CallMethod

func (n *Null) CallMethod(method string, args ...Object) Object

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) Type

func (n *Null) Type() ObjectType

type Object

type Object interface {
	Type() ObjectType
	Inspect() string
	CallMethod(method string, args ...Object) Object
}

func Eval

func Eval(node ast.Node, scope *Scope) Object

type ObjectType

type ObjectType string

type ReturnValue

type ReturnValue struct{ Value Object }

func (*ReturnValue) CallMethod

func (rv *ReturnValue) CallMethod(method string, args ...Object) Object

func (*ReturnValue) Inspect

func (rv *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (rv *ReturnValue) Type() ObjectType

type Scope

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

func NewScope

func NewScope(p *Scope) *Scope

func (*Scope) Get

func (s *Scope) Get(name string) (Object, bool)

func (*Scope) Reset

func (s *Scope) Reset(name string, val Object) (Object, bool)

func (*Scope) Set

func (s *Scope) Set(name string, val Object) Object

type String

type String struct{ Value string }

func (*String) CallMethod

func (s *String) CallMethod(method string, args ...Object) Object

func (*String) Count

func (s *String) Count(args ...Object) Object

func (*String) Find

func (s *String) Find(args ...Object) Object

func (*String) HashKey

func (s *String) HashKey() HashKey

func (*String) Inspect

func (s *String) Inspect() string

func (*String) Join

func (s *String) Join(args ...Object) Object

func (*String) Lower

func (s *String) Lower(args ...Object) Object

func (*String) Lstrip

func (s *String) Lstrip(args ...Object) Object

func (*String) Replace

func (s *String) Replace(args ...Object) Object

func (*String) Reverse

func (s *String) Reverse(args ...Object) Object

func (*String) Rstrip

func (s *String) Rstrip(args ...Object) Object

func (*String) Split

func (s *String) Split(args ...Object) Object

func (*String) Strip

func (s *String) Strip(args ...Object) Object

func (*String) Type

func (s *String) Type() ObjectType

func (*String) Upper

func (s *String) Upper(args ...Object) Object

type Struct

type Struct struct {
	Scope *Scope
	// contains filtered or unexported fields
}

func (*Struct) CallMethod

func (s *Struct) CallMethod(method string, args ...Object) Object

func (*Struct) Inspect

func (s *Struct) Inspect() string

func (*Struct) Type

func (s *Struct) Type() ObjectType

Jump to

Keyboard shortcuts

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