github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/ast/binary_conditional_operator.go (about)

     1  package ast
     2  
     3  // BinaryConditionalOperator is type of binary operator
     4  type BinaryConditionalOperator struct {
     5  	Addr       Address
     6  	Pos        Position
     7  	Type       string
     8  	ChildNodes []Node
     9  }
    10  
    11  func parseBinaryConditionalOperator(line string) *BinaryConditionalOperator {
    12  	groups := groupsFromRegex(
    13  		`<(?P<position>.*)>
    14  		 '(?P<type1>.*?)'`,
    15  		line,
    16  	)
    17  
    18  	return &BinaryConditionalOperator{
    19  		Addr:       ParseAddress(groups["address"]),
    20  		Pos:        NewPositionFromString(groups["position"]),
    21  		Type:       groups["type1"],
    22  		ChildNodes: []Node{},
    23  	}
    24  }
    25  
    26  // AddChild adds a new child node. Child nodes can then be accessed with the
    27  // Children attribute.
    28  func (n *BinaryConditionalOperator) AddChild(node Node) {
    29  	n.ChildNodes = append(n.ChildNodes, node)
    30  }
    31  
    32  // Address returns the numeric address of the node. See the documentation for
    33  // the Address type for more information.
    34  func (n *BinaryConditionalOperator) Address() Address {
    35  	return n.Addr
    36  }
    37  
    38  // Children returns the child nodes. If this node does not have any children or
    39  // this node does not support children it will always return an empty slice.
    40  func (n *BinaryConditionalOperator) Children() []Node {
    41  	return n.ChildNodes
    42  }
    43  
    44  // Position returns the position in the original source code.
    45  func (n *BinaryConditionalOperator) Position() Position {
    46  	return n.Pos
    47  }