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