amath  1.8.5
Simple command line calculator
SyntaxNode Class Referenceabstract

Base class for all nodes in a syntax tree. More...

#include <nodes.h>

Inheritance diagram for SyntaxNode:
Collaboration diagram for SyntaxNode:

Public Member Functions

 SyntaxNode ()
 
virtual ~SyntaxNode ()
 
void SetFirstNode ()
 
bool GetFirstNode () const
 
SyntaxNodeGetParent () const
 
void SetParent (SyntaxNode *node)
 
virtual NodeType GetNodeType ()=0
 
virtual ReductionType GetReductionType ()
 
virtual void ResetIterator ()
 
virtual SyntaxNodeGetNext ()=0
 
virtual char * GetTextCode ()=0
 
virtual char * Execute ()=0
 
virtual void Attach (SyntaxNode *node)=0
 
virtual void Detach (SyntaxNode *node)=0
 
virtual void Replace (SyntaxNode *n, SyntaxNode *x)=0
 

Protected Attributes

CharBufferoutput
 
SyntaxNodeparent
 
SyntaxNodeiterator
 
bool leftBottom
 

Detailed Description

Base class for all nodes in a syntax tree.

More info is available at Wikipedia: https://wikipedia.org/wiki/Abstract_syntax_tree

Definition at line 65 of file nodes.h.

Constructor & Destructor Documentation

◆ SyntaxNode()

SyntaxNode::SyntaxNode ( )

Definition at line 42 of file nodes.cpp.

References CharBuffer::CharBuffer(), iterator, leftBottom, output, and parent.

Referenced by ErrorNode::ErrorNode(), ExpressionNode::ExpressionNode(), StatementBlockNode::StatementBlockNode(), and StatementNode::StatementNode().

43 {
44  output = new CharBuffer();
45  parent = nullptr;
46  iterator = nullptr;
47  leftBottom = false;
48 }
bool leftBottom
Definition: nodes.h:88
SyntaxNode * parent
Definition: nodes.h:86
CharBuffer * output
Definition: nodes.h:85
SyntaxNode * iterator
Definition: nodes.h:87
Encapsulate an character array which can be used as a string.
Definition: charbuf.h:44
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~SyntaxNode()

SyntaxNode::~SyntaxNode ( )
virtual

Definition at line 50 of file nodes.cpp.

References output.

51 {
52  delete output;
53 }
CharBuffer * output
Definition: nodes.h:85

Member Function Documentation

◆ Attach()

virtual void SyntaxNode::Attach ( SyntaxNode node)
pure virtual

◆ Detach()

virtual void SyntaxNode::Detach ( SyntaxNode node)
pure virtual

◆ Execute()

◆ GetFirstNode()

bool SyntaxNode::GetFirstNode ( ) const

Definition at line 60 of file nodes.cpp.

References leftBottom.

61 {
62  return leftBottom;
63 }
bool leftBottom
Definition: nodes.h:88

◆ GetNext()

◆ GetNodeType()

virtual NodeType SyntaxNode::GetNodeType ( )
pure virtual

Implemented in StatementBlockNode, ErrorNode, ExpressionNode, and StatementNode.

Referenced by Optimizer::BalanceTree(), and Optimizer::ReduceValueNodes().

Here is the caller graph for this function:

◆ GetParent()

SyntaxNode * SyntaxNode::GetParent ( ) const

Definition at line 70 of file nodes.cpp.

References parent.

Referenced by Optimizer::BalanceTree(), Optimizer::ReduceUnaryNodes(), and Optimizer::ReduceValueNodes().

71 {
72  return parent;
73 }
SyntaxNode * parent
Definition: nodes.h:86
Here is the caller graph for this function:

◆ GetReductionType()

ReductionType SyntaxNode::GetReductionType ( )
virtual

Reimplemented in ComplexiNode, PiNode, EulersNumberNode, NumericValueNode, SubtractionNode, AdditionNode, and UnaryNode.

Definition at line 55 of file nodes.cpp.

References nonereduc.

Referenced by Optimizer::ReduceUnaryNodes(), and Optimizer::ReduceValueNodes().

56 {
57  return nonereduc;
58 }
Here is the caller graph for this function:

◆ GetTextCode()

virtual char* SyntaxNode::GetTextCode ( )
pure virtual

◆ Replace()

virtual void SyntaxNode::Replace ( SyntaxNode n,
SyntaxNode x 
)
pure virtual

◆ ResetIterator()

void SyntaxNode::ResetIterator ( )
virtual

Definition at line 80 of file nodes.cpp.

References iterator.

Referenced by Optimizer::BalanceTree(), Optimizer::GetTreeDepth(), Optimizer::ReduceUnaryNodes(), Optimizer::ReduceValueNodes(), Optimizer::TagChildren(), and Optimizer::TagStartNode().

81 {
82  iterator = nullptr;
83 }
SyntaxNode * iterator
Definition: nodes.h:87
Here is the caller graph for this function:

◆ SetFirstNode()

void SyntaxNode::SetFirstNode ( )

Definition at line 65 of file nodes.cpp.

References leftBottom.

Referenced by Optimizer::TagStartNode().

66 {
67  leftBottom = true;
68 }
bool leftBottom
Definition: nodes.h:88
Here is the caller graph for this function:

◆ SetParent()

void SyntaxNode::SetParent ( SyntaxNode node)

Definition at line 75 of file nodes.cpp.

References parent.

Referenced by EvalStatement::Attach(), SilentStatement::Attach(), UnaryNode::Attach(), FunctionNode::Attach(), AbsoluteNode::Attach(), FactorialNode::Attach(), NumericOperator::Attach(), and Optimizer::TagChildren().

76 {
77  parent = node;
78 }
SyntaxNode * parent
Definition: nodes.h:86
Here is the caller graph for this function:

Member Data Documentation

◆ iterator

◆ leftBottom

bool SyntaxNode::leftBottom
protected

Definition at line 88 of file nodes.h.

Referenced by GetFirstNode(), NumericValueNode::GetPrecedence(), SetFirstNode(), and SyntaxNode().

◆ output

◆ parent

SyntaxNode* SyntaxNode::parent
protected

Definition at line 86 of file nodes.h.

Referenced by GetParent(), SetParent(), and SyntaxNode().


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