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