Skip to content

Commit

Permalink
Checking if it is a leaf before calling the getSymbol functin
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdafunction committed Sep 28, 2010
1 parent 04d9f16 commit e87492b
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions regex.cpp
Expand Up @@ -355,23 +355,26 @@ regexNode* unionNode::simplify(){
// this->type();
leftChild = leftChild->simplify();
rightChild = rightChild->simplify();
if(leftChild->isLeaf() && rightChild->isLeaf()){
/* NULLSET U R = R */
if (leftChild->getSymbol() == NULLSET){
regexNode* temp = rightChild;//becaue rightChild will no longer exist after deleting this
rightChild = 0;
delete this;
return temp;
if (leftChild->isLeaf()) {
if(leftChild->getSymbol() == NULLSET){
regexNode* temp = rightChild;//becaue rightChild will no longer exist after deleting this
rightChild = 0;
delete this;
return temp;
}
}
/* R U NULLSET = R */
else if (rightChild->getSymbol() == NULLSET){
regexNode* temp = leftChild;
leftChild = 0;
delete this;
return temp;
if (rightChild=>isleaf()){
if (rightChild->getSymbol() == NULLSET){
regexNode* temp = leftChild;
leftChild = 0;
delete this;
return temp;
}
}

}

return this;

}
Expand Down Expand Up @@ -415,7 +418,6 @@ regexNode* concatNode::simplify(){
// this->type();
leftChild = leftChild->simplify();
rightChild = rightChild->simplify();
if(leftChild->isLeaf() && rightChild->isLeaf()){
/*NULLSET . R = NULLSET */
if (leftChild->getSymbol() == NULLSET){
regexNode* temp = leftChild;
Expand Down Expand Up @@ -447,7 +449,7 @@ regexNode* concatNode::simplify(){
delete this;
return temp;
}
}

return this;
}

Expand Down

0 comments on commit e87492b

Please sign in to comment.