diff options
| author | Marc Vertes <mvertes@free.fr> | 2025-11-28 16:34:28 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2025-11-28 16:34:28 +0100 |
| commit | fbc73922e9853d7e344e388f3fdfedb8fa323682 (patch) | |
| tree | 17cab9c49babad09906a34f3c16ebb0558c4e948 /parser/symbol.go | |
| parent | 22b020225ae77ca1cf9f9984817df9b7fd1aaa12 (diff) | |
doc: improve comments, pass lint
Also improve the setup of golangci-lint.
Diffstat (limited to 'parser/symbol.go')
| -rw-r--r-- | parser/symbol.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/parser/symbol.go b/parser/symbol.go index 3aba4e5..3ad8fda 100644 --- a/parser/symbol.go +++ b/parser/symbol.go @@ -8,8 +8,10 @@ import ( "github.com/mvertes/parscan/vm" ) +// SymKind represents the symbol kind. type SymKind int +// Symbol kinds. const ( SymValue SymKind = iota // a value defined in the runtime SymType // a type @@ -22,8 +24,10 @@ const ( //go:generate stringer -type=SymKind +// UnsetAddr denotes an unset symbol index (vs 0). const UnsetAddr = -65535 +// Symbol structure used in parser and compiler. type Symbol struct { Kind SymKind Index int // address of symbol in frame @@ -35,6 +39,7 @@ type Symbol struct { Used bool // } +// SymbolType returns the VM type of a symbol. func SymbolType(s *Symbol) *vm.Type { if s.Type != nil { return s.Type @@ -42,11 +47,7 @@ func SymbolType(s *Symbol) *vm.Type { return vm.TypeOf(s.Value) } -// AddSym add a new named value at memory position i in the parser symbol table. -// func (p *Parser) AddSym(i int, name string, v vm.Value) { -// p.addSym(i, name, v, SymValue, nil, false) -// } - +// AddSymbol adds a new named value at memory position i in the parser symbol table. func (p *Parser) AddSymbol(i int, name string, v vm.Value, k SymKind, t *vm.Type, local bool) { name = strings.TrimPrefix(name, "/") p.Symbols[name] = &Symbol{Kind: k, Index: i, Local: local, Value: v, Type: t} |
