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