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