From fbc73922e9853d7e344e388f3fdfedb8fa323682 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 28 Nov 2025 16:34:28 +0100 Subject: doc: improve comments, pass lint Also improve the setup of golangci-lint. --- parser/symbol.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'parser/symbol.go') 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} -- cgit v1.2.3