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