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