From 9bf668e7114bb92a0b072db5d4e092c0b8f964c4 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 22 Jan 2026 11:33:32 +0100 Subject: chore: refactor token types to avoid mutate scanner tokens Mutating scanner tokens or reusing scanner token attributes to store other metadata is a hack. Introduce a new parser token type with arbitrary args. The next step will be to use the arg field instead of scanner token fields. --- comp/compiler.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'comp/compiler.go') diff --git a/comp/compiler.go b/comp/compiler.go index 55a3166..4fa34de 100644 --- a/comp/compiler.go +++ b/comp/compiler.go @@ -13,7 +13,6 @@ import ( "github.com/mvertes/parscan/lang" "github.com/mvertes/parscan/parser" - "github.com/mvertes/parscan/scanner" "github.com/mvertes/parscan/symbol" "github.com/mvertes/parscan/vm" ) @@ -66,7 +65,7 @@ func (c *Compiler) Generate(tokens parser.Tokens) (err error) { stack := []*symbol.Symbol{} // for symbolic evaluation and type checking flen := []int{} // stack length according to function scopes - emit := func(t scanner.Token, op vm.Op, arg ...int) { + emit := func(t parser.Token, op vm.Op, arg ...int) { _, file, line, _ := runtime.Caller(1) fmt.Fprintf(os.Stderr, "%s:%d: %v emit %v %v\n", path.Base(file), line, t, op, arg) c.Code = append(c.Code, vm.Instruction{Pos: vm.Pos(t.Pos), Op: op, Arg: arg}) -- cgit v1.2.3