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