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