1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-19 09:00:28 +08:00

feat(gen): add symbol table

This commit is contained in:
源文雨
2026-03-14 00:36:07 +08:00
parent 9ec7cdb4aa
commit e852e0e4d5
2 changed files with 102 additions and 0 deletions

38
gen/symb.go Normal file
View File

@@ -0,0 +1,38 @@
package main
import (
"errors"
"strconv"
"strings"
)
type symbolType uintptr
const (
// symbolTypeConst fields
//
// 0: const eval
symbolTypeConst symbolType = iota
// symbolTypeFunc fields
//
// 0: _para1_name, _para2_name, ...
// 1: replaceable eval
symbolTypeFunc
)
type symbol struct {
stype symbolType
name string
fields []string
}
func (s *symbol) replace(txt string, args ...string) (string, error) {
switch s.stype {
case symbolTypeConst:
return strings.ReplaceAll(txt, s.name, s.fields[0]), nil
case symbolTypeFunc:
//TODO: finish
return "", nil
}
return "", errors.New("unsupported symbol type " + strconv.Itoa(int(s.stype)))
}