symbol

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IntegerSymbol  = "INTEGER"
	BooleanSymbol  = "BOOLEAN"
	StringSymbol   = "STRING"
	FunctionSymbol = "FUNCTION"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean struct {
	Name *ast.Identifier
}

Represent Boolean Object

func (*Boolean) String

func (b *Boolean) String() string

func (*Boolean) Type

func (b *Boolean) Type() SymbolType

type Function

type Function struct {
	Name  string
	Scope *Scope
}

Represent Function symbol Name represents function's name. Scope represents function value's scope.

func (*Function) String

func (f *Function) String() string

func (*Function) Type

func (f *Function) Type() SymbolType

type Integer

type Integer struct {
	Name *ast.Identifier
}

Represent Integer symbol

func (*Integer) String

func (i *Integer) String() string

String() returns symbol's name

func (*Integer) Type

func (i *Integer) Type() SymbolType

type Scope

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

Scope represent a variable's scope.

func NewEnclosedScope

func NewEnclosedScope(outer *Scope) *Scope

NewEnclosedScope makes a new scope which has outer scope.

func NewScope

func NewScope() *Scope

NewScope() makes a new scope.

func (*Scope) AppendInner

func (s *Scope) AppendInner(in *Scope)

func (*Scope) Get

func (s *Scope) Get(name string) Symbol

Getter return's variable's scope. If a scope doesn't have a variable, Program will search in outer scope.

func (*Scope) GetInner

func (s *Scope) GetInner() []*Scope

func (*Scope) GetOuter

func (s *Scope) GetOuter() *Scope

func (*Scope) Set

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

Setter set a variable to target scope's map

func (*Scope) SetOuter

func (s *Scope) SetOuter(outer *Scope)

func (*Scope) String

func (s *Scope) String() string

type String

type String struct {
	Name *ast.Identifier
}

Represent String Object

func (*String) String

func (s *String) String() string

func (*String) Type

func (s *String) Type() SymbolType

type Symbol

type Symbol interface {
	Type() SymbolType
	String() string
}

type SymbolType

type SymbolType string

Jump to

Keyboard shortcuts

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