stack

package
v0.0.0-...-d69f115 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

type Stack struct {
	Tables  []*tables.Table               `json:"tables"`
	Size    int                           `json:"size"`
	Imports map[string]*symbols.SymbolDef `json:"imports"`
}

Stack is a multi-level symbol table for parsing blocks of code

func New

func New() *Stack

NewStack creates an empty stack with no symbol table

func (*Stack) AddDataType

func (s *Stack) AddDataType(sym *symbols.SymbolDef) error

func (*Stack) AddFunction

func (s *Stack) AddFunction(sym *symbols.SymbolDef) error

func (*Stack) AddImport

func (s *Stack) AddImport(sym *symbols.SymbolDef) error

func (*Stack) AddVariable

func (s *Stack) AddVariable(sym *symbols.SymbolDef) error

func (*Stack) AddVirtualDataType

func (s *Stack) AddVirtualDataType(sym *symbols.SymbolDef) error

func (*Stack) CurrentLevel

func (s *Stack) CurrentLevel() int

func (*Stack) Exists

func (s *Stack) Exists(name string) bool

func (*Stack) Json

func (s *Stack) Json()

func (*Stack) Lookup

func (s *Stack) Lookup(name string) (*symbols.SymbolDef, symbols.SymbolType, error)

Lookup looks for the first occurrence of a symbol with the given name

func (*Stack) LookupAllMethods

func (s *Stack) LookupAllMethods(datatype string) (map[string]*symbols.SymbolDef, error)

func (*Stack) LookupDataType

func (s *Stack) LookupDataType(name string) (*symbols.SymbolDef, error)

func (*Stack) LookupFromBlock

func (s *Stack) LookupFromBlock(name string, idx int) (*symbols.SymbolDef, symbols.SymbolType, error)

Lookup looks for the first occurrence of a symbol with the given name starting from a block idx

func (*Stack) LookupFunction

func (s *Stack) LookupFunction(name string) (*symbols.SymbolDef, error)

func (*Stack) LookupMethod

func (s *Stack) LookupMethod(datatype, methodName string) (*symbols.SymbolDef, error)

func (*Stack) LookupVariable

func (s *Stack) LookupVariable(name string) (*symbols.SymbolDef, error)

func (*Stack) LookupVariableLikeSymbol

func (s *Stack) LookupVariableLikeSymbol(name string) (*symbols.SymbolDef, symbols.SymbolType, error)

func (*Stack) Pop

func (s *Stack) Pop()

Pop pops the top most symbol table from the stack

func (*Stack) Print

func (s *Stack) Print()

func (*Stack) PrintTop

func (s *Stack) PrintTop()

func (*Stack) Push

func (s *Stack) Push()

Push pushes a new symbol table at the top of the stack

func (*Stack) Reset

func (s *Stack) Reset() error

func (*Stack) Table

func (s *Stack) Table(level int) (*tables.Table, error)

Table gets a symbol table at given level Level 0 corresponds to the file level symbol table (the top most block)

Jump to

Keyboard shortcuts

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