github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/c11_no_return_attr.go (about)

     1  package ast
     2  
     3  // C11NoReturnAttr is a type of attribute that is optionally attached to a function
     4  // with return type void.
     5  type C11NoReturnAttr struct {
     6  	Addr       Address
     7  	Pos        Position
     8  	ChildNodes []Node
     9  }
    10  
    11  func parseC11NoReturnAttr(line string) *C11NoReturnAttr {
    12  	groups := groupsFromRegex(
    13  		"<(?P<position>.*)>",
    14  		line,
    15  	)
    16  
    17  	return &C11NoReturnAttr{
    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 *C11NoReturnAttr) 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 *C11NoReturnAttr) 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 *C11NoReturnAttr) Children() []Node {
    39  	return n.ChildNodes
    40  }
    41  
    42  // Position returns the position in the original source code.
    43  func (n *C11NoReturnAttr) Position() Position {
    44  	return n.Pos
    45  }