github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/predefined_expr.go (about) 1 package ast 2 3 // PredefinedExpr is expression. 4 type PredefinedExpr struct { 5 Addr Address 6 Pos Position 7 Type string 8 Name string 9 IsLvalue bool 10 ChildNodes []Node 11 } 12 13 func parsePredefinedExpr(line string) *PredefinedExpr { 14 groups := groupsFromRegex( 15 "<(?P<position>.*)> '(?P<type>.*)' lvalue (?P<name>.*)", 16 line, 17 ) 18 19 return &PredefinedExpr{ 20 Addr: ParseAddress(groups["address"]), 21 Pos: NewPositionFromString(groups["position"]), 22 Type: groups["type"], 23 Name: groups["name"], 24 IsLvalue: true, 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 *PredefinedExpr) 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 *PredefinedExpr) 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 *PredefinedExpr) Children() []Node { 44 return n.ChildNodes 45 } 46 47 // Position returns the position in the original source code. 48 func (n *PredefinedExpr) Position() Position { 49 return n.Pos 50 }