LogiXpr
|
Abstract syntax tree for logic expressions. More...
#include <expression.h>
Public Member Functions | |
Expression (std::string value) | |
Construct a new Expression object. | |
std::string | getValue () |
Get the value of the current expression. | |
bool | hasLeft () |
Check if the current expression has a left subexpression. | |
bool | hasRight () |
Check if the current expression has a right subexpression. | |
bool | isBinary () |
Check if the current expression is a binary expression. | |
bool | isVar () |
Check if the current expression is a variable. | |
std::shared_ptr< Expression > | getParent () |
Get the parent expression of the current expression. | |
std::shared_ptr< Expression > | getLeft () |
Get the left subexpression of the current expression. | |
std::shared_ptr< Expression > | getRight () |
Get the right subexpression of the current expression. | |
void | setLeft (std::shared_ptr< Expression > left, std::shared_ptr< Expression > parent) |
Sets the left child expression of this expression. | |
void | setRight (std::shared_ptr< Expression > right, std::shared_ptr< Expression > parent) |
Sets the right child expression of this expression. | |
void | setParent (std::shared_ptr< Expression > parent) |
Sets the parent node expression of this expression. | |
std::set< std::string > | getVariables () |
Get all the variables in the current expression and subexpressions. | |
std::shared_ptr< Expression > | clone () |
Create a clone of the current expression and subexpressions. | |
std::shared_ptr< Expression > | cloneTree () |
Create a clone of the whole expression tree and returns the pointer to the node where it is called. | |
bool | compare (std::shared_ptr< Expression > other) |
Compare the current expression to another expression. | |
bool | compareTree (std::shared_ptr< Expression > other) |
Compare the entire expression tree to another expression tree. | |
std::string | toString () |
Convert the current expression to a string. | |
std::string | toStringTree () |
Convert the whole expression tree to a string. | |
std::string | toStringMinimal () |
Convert the current expression to a string with minimal parentheses. | |
Private Attributes | |
std::string | value |
The current expression. | |
std::shared_ptr< Expression > | parent |
Pointer to parent expression. | |
std::shared_ptr< Expression > | left |
Pointer to left subexpression. | |
std::shared_ptr< Expression > | right |
Pointer to right subexpression. | |
Abstract syntax tree for logic expressions.
Definition at line 42 of file expression.h.
Expression::Expression | ( | std::string | value | ) |
Construct a new Expression object.
value | the current expression |
Definition at line 8 of file expression.cpp.
std::shared_ptr< Expression > Expression::clone | ( | ) |
Create a clone of the current expression and subexpressions.
Definition at line 92 of file expression.cpp.
std::shared_ptr< Expression > Expression::cloneTree | ( | ) |
Create a clone of the whole expression tree and returns the pointer to the node where it is called.
Definition at line 105 of file expression.cpp.
bool Expression::compare | ( | std::shared_ptr< Expression > | other | ) |
Compare the current expression to another expression.
other | pointer to other expression to compare to |
Definition at line 136 of file expression.cpp.
bool Expression::compareTree | ( | std::shared_ptr< Expression > | other | ) |
Compare the entire expression tree to another expression tree.
other | pointer to other expression to compare to |
Definition at line 160 of file expression.cpp.
std::shared_ptr< Expression > Expression::getLeft | ( | ) |
Get the left subexpression of the current expression.
Definition at line 44 of file expression.cpp.
std::shared_ptr< Expression > Expression::getParent | ( | ) |
Get the parent expression of the current expression.
Definition at line 39 of file expression.cpp.
std::shared_ptr< Expression > Expression::getRight | ( | ) |
Get the right subexpression of the current expression.
Definition at line 49 of file expression.cpp.
std::string Expression::getValue | ( | ) |
Get the value of the current expression.
Definition at line 13 of file expression.cpp.
std::set< std::string > Expression::getVariables | ( | ) |
Get all the variables in the current expression and subexpressions.
Definition at line 71 of file expression.cpp.
bool Expression::hasLeft | ( | ) |
Check if the current expression has a left subexpression.
Definition at line 18 of file expression.cpp.
bool Expression::hasRight | ( | ) |
Check if the current expression has a right subexpression.
Definition at line 23 of file expression.cpp.
bool Expression::isBinary | ( | ) |
Check if the current expression is a binary expression.
Definition at line 28 of file expression.cpp.
bool Expression::isVar | ( | ) |
Check if the current expression is a variable.
Definition at line 33 of file expression.cpp.
void Expression::setLeft | ( | std::shared_ptr< Expression > | left, |
std::shared_ptr< Expression > | parent | ||
) |
Sets the left child expression of this expression.
left | pointer to expression to be set as the left child |
parent | pointer to current expression |
Definition at line 54 of file expression.cpp.
void Expression::setParent | ( | std::shared_ptr< Expression > | parent | ) |
Sets the parent node expression of this expression.
parent | pointer to expression to be set as the parent |
Definition at line 66 of file expression.cpp.
void Expression::setRight | ( | std::shared_ptr< Expression > | right, |
std::shared_ptr< Expression > | parent | ||
) |
Sets the right child expression of this expression.
right | pointer to expression to be set as the right child |
parent | pointer to current expression |
Definition at line 60 of file expression.cpp.
std::string Expression::toString | ( | ) |
Convert the current expression to a string.
Definition at line 172 of file expression.cpp.
std::string Expression::toStringMinimal | ( | ) |
Convert the current expression to a string with minimal parentheses.
Definition at line 204 of file expression.cpp.
std::string Expression::toStringTree | ( | ) |
Convert the whole expression tree to a string.
Definition at line 191 of file expression.cpp.
|
private |
Pointer to left subexpression.
Definition at line 207 of file expression.h.
|
private |
Pointer to parent expression.
Definition at line 202 of file expression.h.
|
private |
Pointer to right subexpression.
Definition at line 212 of file expression.h.
|
private |
The current expression.
Definition at line 197 of file expression.h.