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