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

     1  package ast
     2  
     3  // CompoundAssignOperator is type of compound assign operator
     4  type CompoundAssignOperator struct {
     5  	Addr                   Address
     6  	Pos                    Position
     7  	Type                   string
     8  	Type2                  string
     9  	Opcode                 string
    10  	ComputationLHSType     string
    11  	ComputationLHSType2    string
    12  	ComputationResultType  string
    13  	ComputationResultType2 string
    14  	ChildNodes             []Node
    15  }
    16  
    17  func parseCompoundAssignOperator(line string) *CompoundAssignOperator {
    18  	groups := groupsFromRegex(
    19  		`<(?P<position>.*)>
    20  		 '(?P<type>.+?)'(:'(?P<type2>.*)')?
    21  		 '(?P<opcode>.+?)'
    22  		 ComputeLHSTy='(?P<clhstype>.+?)'(:'(?P<clhstype2>.*)')?
    23  		 ComputeResultTy='(?P<crestype>.+?)'(:'(?P<crestype2>.*)')?`,
    24  		line,
    25  	)
    26  
    27  	return &CompoundAssignOperator{
    28  		Addr:                   ParseAddress(groups["address"]),
    29  		Pos:                    NewPositionFromString(groups["position"]),
    30  		Type:                   groups["type"],
    31  		Type2:                  groups["type2"],
    32  		Opcode:                 groups["opcode"],
    33  		ComputationLHSType:     groups["clhstype"],
    34  		ComputationLHSType2:    groups["clhstype2"],
    35  		ComputationResultType:  groups["crestype"],
    36  		ComputationResultType2: groups["crestype2"],
    37  		ChildNodes:             []Node{},
    38  	}
    39  }
    40  
    41  // AddChild adds a new child node. Child nodes can then be accessed with the
    42  // Children attribute.
    43  func (n *CompoundAssignOperator) AddChild(node Node) {
    44  	n.ChildNodes = append(n.ChildNodes, node)
    45  }
    46  
    47  // Address returns the numeric address of the node. See the documentation for
    48  // the Address type for more information.
    49  func (n *CompoundAssignOperator) Address() Address {
    50  	return n.Addr
    51  }
    52  
    53  // Children returns the child nodes. If this node does not have any children or
    54  // this node does not support children it will always return an empty slice.
    55  func (n *CompoundAssignOperator) Children() []Node {
    56  	return n.ChildNodes
    57  }
    58  
    59  // Position returns the position in the original source code.
    60  func (n *CompoundAssignOperator) Position() Position {
    61  	return n.Pos
    62  }