diff options
| author | Marc Vertes <mvertes@free.fr> | 2026-01-22 11:33:32 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2026-01-22 11:33:32 +0100 |
| commit | 9bf668e7114bb92a0b072db5d4e092c0b8f964c4 (patch) | |
| tree | 0d35e544715a3f902550af2cb4d249e8fb1e33af /comp/compiler.go | |
| parent | c922c797204069f42a7abf88500c5708f68a8e43 (diff) | |
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.
Diffstat (limited to 'comp/compiler.go')
| -rw-r--r-- | comp/compiler.go | 3 |
1 files changed, 1 insertions, 2 deletions
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}) |
