github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/static_assert_decl.go (about) 1 package ast 2 3 import "strings" 4 5 // StaticAssertDecl 6 type StaticAssertDecl struct { 7 Addr Address 8 Pos Position 9 Position2 string 10 ChildNodes []Node 11 } 12 13 func parseStaticAssertDecl(line string) *StaticAssertDecl { 14 groups := groupsFromRegex( 15 `<(?P<position>.*)> 16 (?P<position2> col:\d+| line:\d+:\d+)? 17 `, 18 line, 19 ) 20 21 return &StaticAssertDecl{ 22 Addr: ParseAddress(groups["address"]), 23 Pos: NewPositionFromString(groups["position"]), 24 Position2: strings.TrimSpace(groups["position2"]), 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 *StaticAssertDecl) 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 *StaticAssertDecl) 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 *StaticAssertDecl) Children() []Node { 44 return n.ChildNodes 45 } 46 47 // Position returns the position in the original source code. 48 func (n *StaticAssertDecl) Position() Position { 49 return n.Pos 50 }