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