syms

package
v0.0.0-...-093a1a0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPublic

func IsPublic(name string) bool

IsPublic checks if a symbol name is public.

Types

type Scope

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

Scope is a stack of symbol tables.

func NewScope

func NewScope() *Scope

NewScope creates a new symbole scope with one symbol table at the bottom.

func (*Scope) Declare

func (s *Scope) Declare(sym *Symbol) *Symbol

Declare declares a symbole on the top of the symbol table stack. It returns nil on successful, and returns the conflict symbol when it is already declared.

func (*Scope) Depth

func (s *Scope) Depth() int

Depth returns the number of scopes on the stack.

func (*Scope) Pop

func (s *Scope) Pop() *Table

Pop removes a symbol table from the top of the stack. It panics when the stack is empty after the pop.

func (*Scope) Push

func (s *Scope) Push()

Push adds a new symbol table on the top of the stack.

func (*Scope) PushTable

func (s *Scope) PushTable(tab *Table)

PushTable adds an existing table on the top of the stack.

func (*Scope) Query

func (s *Scope) Query(n string) *Symbol

Query searches for the top visible symbol with a particular name.

type Symbol

type Symbol struct {
	Type    int
	Obj     interface{}
	ObjType interface{}
	Pos     *lexing.Pos
	Used    bool
	// contains filtered or unexported fields
}

Symbol is a data structure for saving a symbol.

func Make

func Make(
	pkg, name string, t int,
	obj, objType interface{},
	pos *lexing.Pos,
) *Symbol

Make creates a new symbol

func (*Symbol) Clone

func (s *Symbol) Clone(item interface{}) *Symbol

Clone returns a clone of the symbol which item is the given one.

func (*Symbol) Name

func (s *Symbol) Name() string

Name returns the symbol name. This name is immutable for its used for indexing in the tables.

func (*Symbol) Pkg

func (s *Symbol) Pkg() string

Pkg returns the package token of the symbol.

type Table

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

Table save the symbol

func NewTable

func NewTable() *Table

NewTable creates an empty symbol table

func (*Table) Declare

func (tab *Table) Declare(s *Symbol) *Symbol

Declare adds a symbol into the table. It returns nil on successful, and returns the conflict symbol when it is already declared. Declare "_" will be ignored.

func (*Table) List

func (tab *Table) List() []*Symbol

List returns a map of the symbols.

func (*Table) Query

func (tab *Table) Query(n string) *Symbol

Query searches for a symbol with a particular name.

Jump to

Keyboard shortcuts

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