github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/weak_attr.go (about) 1 package ast 2 3 // WeakAttr for the WeakAttr node 4 type WeakAttr struct { 5 Addr Address 6 Pos Position 7 IsInherited bool 8 ChildNodes []Node 9 } 10 11 func parseWeakAttr(line string) *WeakAttr { 12 groups := groupsFromRegex( 13 `<(?P<position>.*)>(?P<inherited> Inherited)?`, 14 line, 15 ) 16 17 return &WeakAttr{ 18 Addr: ParseAddress(groups["address"]), 19 Pos: NewPositionFromString(groups["position"]), 20 IsInherited: len(groups["inherited"]) > 0, 21 ChildNodes: []Node{}, 22 } 23 } 24 25 // AddChild method to implements Node interface 26 func (n *WeakAttr) 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 *WeakAttr) 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 *WeakAttr) Children() []Node { 39 return n.ChildNodes 40 } 41 42 // Position returns the position in the original source code. 43 func (n *WeakAttr) Position() Position { 44 return n.Pos 45 }