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