symbol

package
v3.0.0-rc20+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scope

type Scope struct {
	Parent  *Scope
	Symbols map[string]*Symbol
}

Scope maintains a record of the identifiers declared in the current program scope, and a link to the parent scope.

func NewScope

func NewScope(parent *Scope) *Scope

NewScope creates a new scope within the parent scope

func (*Scope) CopyFrom

func (s *Scope) CopyFrom(o *Scope)

CopyFrom copies all the symbols from another scope object into this one. It recurses up the input scope copying all visible symbols into one.

func (*Scope) Insert

func (s *Scope) Insert(sym *Symbol) (alt *Symbol)

Insert attempts to insert a symbol into the scope. If the scope already contains an object alt with the same name, the scope is unchanged and the function returns alt. Otherwise the symbol is inserted, and returns nil.

func (*Scope) InsertAlias

func (s *Scope) InsertAlias(sym *Symbol, alias string) (alt *Symbol)

InsertAlias attempts to insert a duplicate name for an existing symbol into the scope. If the scope already contains an object alt with the alias, the scope is unchanged and the function returns alt. Otherwise, the symbol is inserted and the function returns nil.

func (*Scope) Lookup

func (s *Scope) Lookup(name string, kind SymbolKind) *Symbol

Lookup returns the symbol with the given name if it is found in this or any parent scope, otherwise nil.

func (*Scope) String

func (s *Scope) String() string

String prints the current scope and all parents to a string, recursing up to the root scope. This method is only used for debugging.

type Symbol

type Symbol struct {
	Name    string             // identifier name
	Kind    SymbolKind         // kind of program object
	Type    types.Type         // object's type
	Pos     *position.Position // Source file position of definition
	Binding interface{}        // binding to storage allocated in runtime
	Addr    int                // Address offset in another structure, object specific
	Used    bool               // Optional marker that this symbol is used after declaration.
}

Symbol describes a named program object.

func NewSymbol

func NewSymbol(name string, kind SymbolKind, pos *position.Position) (sym *Symbol)

NewSymbol creates a record of a given symbol kind, named name, found at loc

type SymbolKind

type SymbolKind int

SymbolKind enumerates the kind of a Symbol.

const (
	VarSymbol     SymbolKind = iota // Variables
	CaprefSymbol                    // Capture group references
	DecoSymbol                      // Decorators
	PatternSymbol                   // Named pattern constants

)

SymbolKind enumerates the kinds of symbols found in the program text.

func (SymbolKind) String

func (k SymbolKind) String() string

Jump to

Keyboard shortcuts

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