Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
RootScope *Scope
CurrentScope *Scope
// contains filtered or unexported fields
}
func CreateBuilder ¶
func CreateBuilder() *Builder
type Scope ¶
type Scope struct {
// ParentScope is the scope above this, if any (may be nil)
ParentScope *Scope
// ChildScopes are the scopes contained within this, in the order they're declared
ChildScopes map[ast.Node]*Scope
// SymbolTable is the table of symbols defined within the scope
SymbolTable *SymbolTable
HasSeenReturn bool
HasSeenBreak bool
}
Scope is a scope within a program
func CreateScope ¶
func (*Scope) LookupByName ¶
LookupByName checks for a symbol by name up the scope tree
type Symbol ¶
type Symbol struct {
// Name is the name of the symbol, such as the identifier of a declared variable
Name string
// Trait is the behavior of a symbol
Trait Trait
// ArgumentCount is the number of arguments the symbol may take if called. If < 0, assume infinite (or runtime specified) arguments
ArgumentCount int
// Node is the AST node the symbol corresponds to
Node ast.Node
// contains filtered or unexported fields
}
Symbol is a semantic unit
func (*Symbol) AddReference ¶
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
SymbolTable keeps track of symbols within a scope
func CreateSymbolTable ¶
func CreateSymbolTable() *SymbolTable
func (*SymbolTable) Insert ¶
func (table *SymbolTable) Insert(symbol *Symbol)
Insert directly inserts a symbol
func (*SymbolTable) LookupByName ¶
func (table *SymbolTable) LookupByName(name string) (*Symbol, bool)
LookupByName checks for a symbol by name
func (*SymbolTable) LookupNode ¶
func (table *SymbolTable) LookupNode(node ast.Node) (*Symbol, bool)
LookupNode checks for a symbol for the node
func (*SymbolTable) Symbols ¶
func (table *SymbolTable) Symbols() []*Symbol
Symbols returns all of the symbols in the order they were inserted
type Trait ¶
type Trait uint64
Trait describes the behavior of a symbol
const ( // TraitNumeric indicates that the symbol may be used for numeric operations TraitNumeric Trait = 1 << iota // TraitCallable indicates that the symbol may be called TraitCallable // TraitAny indicates that the symbol behaves like any trait (likely determined at runtime for non-typed variables) TraitAny // TraitAlias indicates that the symbol is an alias for other rules, aliases or functions TraitAlias // TraitImport indicates that the symbol is the root of an import package TraitImport // TraitString indicates that the symbol may be treated as a string TraitString // TraitObject indiciates that the symbol may be treated as a string TraitObject )
const TraitNone Trait = 0
TraitNone indiciates an empty trait
Click to show internal directories.
Click to hide internal directories.