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