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