1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-08 18:10:26 +08:00

feat(gen): add symbolTable

This commit is contained in:
源文雨
2026-03-15 00:34:33 +08:00
parent e852e0e4d5
commit bddf993ebf
3 changed files with 139 additions and 17 deletions

46
gen/skip.go Normal file
View File

@@ -0,0 +1,46 @@
package main
import (
"bufio"
"errors"
"strings"
)
func skip2endif(scan *bufio.Scanner, ln int) int {
depth := 1
for scan.Scan() {
ln++
t := scan.Text()
switch {
case strings.HasPrefix(t, "#endif"):
depth--
case strings.HasPrefix(t, "#if"):
depth++
default:
}
if depth <= 0 {
break
}
}
return ln
}
func getinside0brakets(txt string) (string, int, error) {
depth := 0
a := 0
for i, t := range txt {
switch t {
case '(':
if depth == 0 {
a = i + 1
}
depth++
case ')':
depth--
if depth <= 0 {
return txt[a:i], i, nil
}
}
}
return "", 0, errors.New("no round brakets pair in " + txt)
}