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

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