amath  1.8.5
Simple command line calculator
AdditionNode Class Reference

#include <operators.h>

Inheritance diagram for AdditionNode:
Collaboration diagram for AdditionNode:

Public Member Functions

 AdditionNode (ExpressionNode *left, ExpressionNode *right)
 
ReductionType GetReductionType ()
 
int GetPrecedence ()
 
NumberEvaluate ()
 
- Public Member Functions inherited from NumericOperator
 NumericOperator (ExpressionNode *left, ExpressionNode *right)
 
 ~NumericOperator ()
 
SyntaxNodeGetNext ()
 
char * GetText ()
 
void Attach (SyntaxNode *node)
 
void Detach (SyntaxNode *node)
 
void Replace (SyntaxNode *n, SyntaxNode *x)
 
- Public Member Functions inherited from ExpressionNode
 ExpressionNode ()
 
 ExpressionNode (Number *value)
 
virtual ~ExpressionNode ()
 
NodeType GetNodeType ()
 
virtual bool IsSilent ()
 
char * GetTextCode ()
 
char * Execute ()
 
- Public Member Functions inherited from SyntaxNode
 SyntaxNode ()
 
virtual ~SyntaxNode ()
 
void SetFirstNode ()
 
bool GetFirstNode () const
 
SyntaxNodeGetParent () const
 
void SetParent (SyntaxNode *node)
 
virtual void ResetIterator ()
 

Protected Member Functions

char * GetNodeText ()
 

Additional Inherited Members

- Protected Attributes inherited from NumericOperator
ExpressionNodeleft
 
ExpressionNoderight
 
- Protected Attributes inherited from ExpressionNode
Numberresult
 
- Protected Attributes inherited from SyntaxNode
CharBufferoutput
 
SyntaxNodeparent
 
SyntaxNodeiterator
 
bool leftBottom
 

Detailed Description

Definition at line 123 of file operators.h.

Constructor & Destructor Documentation

◆ AdditionNode()

AdditionNode::AdditionNode ( ExpressionNode left,
ExpressionNode right 
)

Definition at line 431 of file operators.cpp.

References NumericOperator::NumericOperator().

Referenced by Parser::ParseAddSubstract().

431  :
432  NumericOperator(left, right)
433 {
434 }
NumericOperator(ExpressionNode *left, ExpressionNode *right)
Definition: operators.cpp:308
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ Evaluate()

Number * AdditionNode::Evaluate ( )
virtual

Implements ExpressionNode.

Definition at line 446 of file operators.cpp.

References Number::Add(), ExpressionNode::Evaluate(), NumericOperator::left, ExpressionNode::result, and NumericOperator::right.

447 {
448  result = left->Evaluate()->Add(right->Evaluate());
449  return result;
450 }
ExpressionNode * left
Definition: operators.h:119
virtual Number * Evaluate()=0
ExpressionNode * right
Definition: operators.h:120
Number * result
Definition: nodes.h:116
virtual Number * Add(Number *other)=0
Here is the call graph for this function:

◆ GetNodeText()

char * AdditionNode::GetNodeText ( )
protectedvirtual

Implements ExpressionNode.

Definition at line 452 of file operators.cpp.

453 {
454  static char* ret = (char*)"+";
455  return ret;
456 }

◆ GetPrecedence()

int AdditionNode::GetPrecedence ( )
virtual

Implements ExpressionNode.

Definition at line 441 of file operators.cpp.

442 {
443  return 2;
444 }

◆ GetReductionType()

ReductionType AdditionNode::GetReductionType ( )
virtual

Reimplemented from SyntaxNode.

Definition at line 436 of file operators.cpp.

References compladdreduc.

437 {
438  return compladdreduc;
439 }

The documentation for this class was generated from the following files: