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