From 1b6ef1e43e1ec1107ce29a6438b399352d09fbc2 Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 11 Jul 2022 00:35:59 +0200 Subject: Rebuild compiler and code builder with markers --- pkg/lang/compiler/symbol.go | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'pkg/lang/compiler/symbol.go') diff --git a/pkg/lang/compiler/symbol.go b/pkg/lang/compiler/symbol.go index 03838da..d22cdc0 100644 --- a/pkg/lang/compiler/symbol.go +++ b/pkg/lang/compiler/symbol.go @@ -1,13 +1,38 @@ package compiler +import "jinx/pkg/lang/vm/code" + type SymbolKind int const ( SymbolKindVariable SymbolKind = iota + SymbolKindFunction ) -type Symbol struct { - kind SymbolKind - name string +func (s SymbolKind) String() string { + switch s { + case SymbolKindVariable: + return "variable" + case SymbolKindFunction: + return "function" + default: + panic("unknown symbol kind") + } +} + +type Symbol[D SymbolData] struct { + name string + data D +} + +type SymbolData interface { + SymbolVariable | SymbolFunction +} + +type SymbolVariable struct { localIndex int } + +type SymbolFunction struct { + marker code.Marker +} -- cgit 1.4.1