aboutsummaryrefslogtreecommitdiff
path: root/src/tree.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2013-10-19 21:41:19 +0200
committerAdrian Kummerländer2013-10-19 21:41:19 +0200
commit69ce370c9ebf92caea64ef1ba28a502affdad3d5 (patch)
tree35d84b2c3080622f990bfe75396966c861d75e92 /src/tree.cc
parentc292b29f3bb87cf11edf899c023cfb574c20ed6c (diff)
downloadSimpleParser-69ce370c9ebf92caea64ef1ba28a502affdad3d5.tar
SimpleParser-69ce370c9ebf92caea64ef1ba28a502affdad3d5.tar.gz
SimpleParser-69ce370c9ebf92caea64ef1ba28a502affdad3d5.tar.bz2
SimpleParser-69ce370c9ebf92caea64ef1ba28a502affdad3d5.tar.lz
SimpleParser-69ce370c9ebf92caea64ef1ba28a502affdad3d5.tar.xz
SimpleParser-69ce370c9ebf92caea64ef1ba28a502affdad3d5.tar.zst
SimpleParser-69ce370c9ebf92caea64ef1ba28a502affdad3d5.zip
Switched OperatorNode to TokenType
* OperatorNode class now uses TokenType for internal operator storage and logic selection * print-Method resolves the TokenType back into its character representation
Diffstat (limited to 'src/tree.cc')
-rw-r--r--src/tree.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/tree.cc b/src/tree.cc
index 2dfb786..e63b7b3 100644
--- a/src/tree.cc
+++ b/src/tree.cc
@@ -41,7 +41,7 @@ std::string Tree::print() {
<< "\"];"
<< std::endl;
- if ( (*it)->getType() == NodeType::OPERATOR_NODE ) {
+ if ( (*it)->getType() == NodeType::OPERATOR ) {
for ( auto iter = this->node_collection_.begin();
iter != this->node_collection_.end();
++iter ) {
@@ -96,9 +96,9 @@ Node* Tree::addOperand(Node** place, std::string value) {
return this->node_collection_.back().get();
}
-Node* Tree::addOperator(Node** place, char oper) {
+Node* Tree::addOperator(Node** place, TokenType token) {
this->node_collection_.emplace_back(
- new OperatorNode(oper)
+ new OperatorNode(token)
);
if ( place != nullptr ) {
@@ -137,9 +137,9 @@ Node* Tree::buildTree(std::string term) {
static_cast<OperatorNode*>(topNodeFrom(operatorStack))
);
- if ( token > getTokenType(lastNode->getFunction()) ) {
+ if ( token > lastNode->getToken() ) {
operatorStack.push(
- this->addOperator(nullptr, currTerm[0])
+ this->addOperator(nullptr, token)
);
} else {
Node* currOperator = topNodeFrom(operatorStack);
@@ -157,7 +157,7 @@ Node* Tree::buildTree(std::string term) {
}
} else {
operatorStack.push(
- this->addOperator(nullptr, currTerm[0])
+ this->addOperator(nullptr, token)
);
}
} else {