chore: implement gomark skeleton

This commit is contained in:
Steven
2023-12-12 23:24:02 +08:00
parent 7f1f6f77a0
commit aa3632e2ac
15 changed files with 393 additions and 172 deletions

View File

@ -1,12 +1,20 @@
package ast
func NewNode(tp, text string) *Node {
return &Node{
Type: tp,
Text: text,
}
type Node interface {
Type() NodeType
}
func (n *Node) AddChild(child *Node) {
n.Children = append(n.Children, child)
type NodeType int
func (t NodeType) String() string {
return nodeTypeNames[t]
}
var nodeTypeIndex NodeType
var nodeTypeNames = []string{""}
func NewNodeType(name string) NodeType {
nodeTypeNames = append(nodeTypeNames, name)
nodeTypeIndex++
return nodeTypeIndex
}