1 Star 0 Fork 0

ThinCats/tree-sitter-nodegen

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
ThinCats 提交于 2021-04-20 20:55 +08:00 . feat: add sema type support
package main
import (
"io/ioutil"
"os"
"gitee.com/thincats/codegen-tool"
"gitee.com/thincats/conftool"
"gitee.com/thincats/tree-sitter-nodegen/pkg/config"
"gitee.com/thincats/tree-sitter-nodegen/pkg/parse"
"gitee.com/thincats/tree-sitter-nodegen/pkg/types"
)
func panicIfErr(err error) {
if err != nil {
panic(err)
}
}
func main() {
conf := config.NodeGenConfig{}
ctool := conftool.New(
conftool.WithPathFlagMode(os.Args[1:]),
)
ctool.MustParse(&conf,
ctool.WithDefaultValueSupport(),
ctool.WithCommandLineSupportPathFlag(),
ctool.WithConfigFileSupportPathFlag("conf"),
ctool.WithValidateSupport(),
)
nodeTypesData, err := ioutil.ReadFile(conf.Input)
panicIfErr(err)
nodes, err := parse.Parse(nodeTypesData)
panicIfErr(err)
err = types.NewNodesValidChecker().Validate(nodes)
panicIfErr(err)
sema, err := types.NewNodeSemaAnalysis().Analysis(nodes)
panicIfErr(err)
sfLoader := types.NewStoreFuncsLoader(nodes, sema)
builder := codegen.NewToolBuilder()
tool, err := builder.
WithConfig(conf.Codegen).
WithFuncsLoader(sfLoader).
WithStoreLoader(sfLoader).
Build()
panicIfErr(err)
err = tool.Run()
panicIfErr(err)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/thincats/tree-sitter-nodegen.git
git@gitee.com:thincats/tree-sitter-nodegen.git
thincats
tree-sitter-nodegen
tree-sitter-nodegen
606d0162f6c8

搜索帮助