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