Loading...
Searching...
No Matches
PLMD::lepton::ExpressionTreeNode Class Reference

This class represents a node in the abstract syntax tree representation of an expression. More...

#include <ExpressionTreeNode.h>

Public Member Functions

 ExpressionTreeNode ()
 ExpressionTreeNode (const ExpressionTreeNode &node)
 ExpressionTreeNode (ExpressionTreeNode &&node)
 ExpressionTreeNode (Operation *operation)
 Create a new ExpressionTreeNode with no children.
 ExpressionTreeNode (Operation *operation, const ExpressionTreeNode &child)
 Create a new ExpressionTreeNode with one child.
 ExpressionTreeNode (Operation *operation, const ExpressionTreeNode &child1, const ExpressionTreeNode &child2)
 Create a new ExpressionTreeNode with two children.
 ExpressionTreeNode (Operation *operation, const std::vector< ExpressionTreeNode > &children)
 Create a new ExpressionTreeNode.
 ~ExpressionTreeNode ()
const std::vector< ExpressionTreeNode > & getChildren () const
 Get this node's child nodes.
const OperationgetOperation () const
 Get the Operation performed by this node.
bool operator!= (const ExpressionTreeNode &node) const
ExpressionTreeNodeoperator= (const ExpressionTreeNode &node)
ExpressionTreeNodeoperator= (ExpressionTreeNode &&node)
bool operator== (const ExpressionTreeNode &node) const

Private Member Functions

void assignTags (std::vector< const ExpressionTreeNode * > &examples) const

Private Attributes

std::vector< ExpressionTreeNodechildren
Operationoperation
int tag

Friends

class ParsedExpression

Detailed Description

This class represents a node in the abstract syntax tree representation of an expression.

Each node is defined by an Operation and a set of children. When the expression is evaluated, each child is first evaluated in order, then the resulting values are passed as the arguments to the Operation's evaluate() method.

Constructor & Destructor Documentation

◆ ExpressionTreeNode() [1/7]

PLMD::ExpressionTreeNode::ExpressionTreeNode ( Operation * operation,
const std::vector< ExpressionTreeNode > & children )

Create a new ExpressionTreeNode.

Parameters
operationthe operation for this node. The ExpressionTreeNode takes over ownership of this object, and deletes it when the node is itself deleted.
childrenthe children of this node

◆ ExpressionTreeNode() [2/7]

PLMD::ExpressionTreeNode::ExpressionTreeNode ( Operation * operation,
const ExpressionTreeNode & child1,
const ExpressionTreeNode & child2 )

Create a new ExpressionTreeNode with two children.

Parameters
operationthe operation for this node. The ExpressionTreeNode takes over ownership of this object, and deletes it when the node is itself deleted.
child1the first child of this node
child2the second child of this node

◆ ExpressionTreeNode() [3/7]

PLMD::ExpressionTreeNode::ExpressionTreeNode ( Operation * operation,
const ExpressionTreeNode & child )

Create a new ExpressionTreeNode with one child.

Parameters
operationthe operation for this node. The ExpressionTreeNode takes over ownership of this object, and deletes it when the node is itself deleted.
childthe child of this node

◆ ExpressionTreeNode() [4/7]

PLMD::ExpressionTreeNode::ExpressionTreeNode ( Operation * operation)

Create a new ExpressionTreeNode with no children.

Parameters
operationthe operation for this node. The ExpressionTreeNode takes over ownership of this object, and deletes it when the node is itself deleted.

◆ ExpressionTreeNode() [5/7]

PLMD::ExpressionTreeNode::ExpressionTreeNode ( const ExpressionTreeNode & node)

◆ ExpressionTreeNode() [6/7]

PLMD::ExpressionTreeNode::ExpressionTreeNode ( ExpressionTreeNode && node)

◆ ExpressionTreeNode() [7/7]

PLMD::ExpressionTreeNode::ExpressionTreeNode ( )

◆ ~ExpressionTreeNode()

PLMD::ExpressionTreeNode::~ExpressionTreeNode ( )

Member Function Documentation

◆ assignTags()

void PLMD::ExpressionTreeNode::assignTags ( std::vector< const ExpressionTreeNode * > & examples) const
private

◆ getChildren()

const vector< ExpressionTreeNode > & PLMD::ExpressionTreeNode::getChildren ( ) const

Get this node's child nodes.

◆ getOperation()

const Operation & PLMD::ExpressionTreeNode::getOperation ( ) const

Get the Operation performed by this node.

◆ operator!=()

bool PLMD::ExpressionTreeNode::operator!= ( const ExpressionTreeNode & node) const

◆ operator=() [1/2]

ExpressionTreeNode & PLMD::ExpressionTreeNode::operator= ( const ExpressionTreeNode & node)

◆ operator=() [2/2]

ExpressionTreeNode & PLMD::ExpressionTreeNode::operator= ( ExpressionTreeNode && node)

◆ operator==()

bool PLMD::ExpressionTreeNode::operator== ( const ExpressionTreeNode & node) const

◆ ParsedExpression

friend class ParsedExpression
friend

Member Data Documentation

◆ children

std::vector<ExpressionTreeNode> PLMD::lepton::ExpressionTreeNode::children
private

◆ operation

Operation* PLMD::lepton::ExpressionTreeNode::operation
private

◆ tag

int PLMD::lepton::ExpressionTreeNode::tag
mutableprivate

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