github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/not_tail_called_attr.go (about) 1 package ast 2 3 // NotTailCalledAttr is a type of attribute that is optionally attached to function 4 // declaration. 5 type NotTailCalledAttr struct { 6 Addr Address 7 Pos Position 8 ChildNodes []Node 9 } 10 11 func parseNotTailCalledAttr(line string) *NotTailCalledAttr { 12 groups := groupsFromRegex( 13 "<(?P<position>.*)>", 14 line, 15 ) 16 17 return &NotTailCalledAttr{ 18 Addr: ParseAddress(groups["address"]), 19 Pos: NewPositionFromString(groups["position"]), 20 ChildNodes: []Node{}, 21 } 22 } 23 24 // AddChild adds a new child node. Child nodes can then be accessed with the 25 // Children attribute. 26 func (n *NotTailCalledAttr) AddChild(node Node) { 27 n.ChildNodes = append(n.ChildNodes, node) 28 } 29 30 // Address returns the numeric address of the node. See the documentation for 31 // the Address type for more information. 32 func (n *NotTailCalledAttr) Address() Address { 33 return n.Addr 34 } 35 36 // Children returns the child nodes. If this node does not have any children or 37 // this node does not support children it will always return an empty slice. 38 func (n *NotTailCalledAttr) Children() []Node { 39 return n.ChildNodes 40 } 41 42 // Position returns the position in the original source code. 43 func (n *NotTailCalledAttr) Position() Position { 44 return n.Pos 45 }