Skip to content

Commit

Permalink
Fixed a few memory related bugs. Removed old style used compiler warn…
Browse files Browse the repository at this point in the history
…ing.
  • Loading branch information
samidhtalsania committed Oct 19, 2016
1 parent 09b67da commit e77861f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 47 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AC_INIT([LPMLN],1.0)
AM_INIT_AUTOMAKE([subdir-objects])
CC=${CC-/usr/bin/g++-4.8}
CXXFLAGS="$CXXFLAGS -g -std=c++11 -Wall -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused"
CXXFLAGS="$CXXFLAGS -g -std=c++11 -Wall -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused"
AC_SUBST([PROJECT_ROOT],`pwd`)
AC_PROG_CXX([g++])
AC_PROG_CC
Expand Down
2 changes: 1 addition & 1 deletion src/includes/BodyDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BodyDef
}


std::string setString(std::string s){
void setString(std::string s){
str = s;
aggregateString = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/includes/Predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Predicate
std::string getExtra(const std::set<Variable>& variable);
std::string getExtraConstants() const;

std::string setString(std::string s){
void setString(std::string s){
aggregateString = s;
isAggregate = true;
}
Expand Down
41 changes: 19 additions & 22 deletions src/src/MVSMParserGrammar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,14 +1450,14 @@ static void yy_reduce(
case 35: /* body ::= bodydef */
{
yygotominor.yy49 = new Body;
yygotominor.yy49->addPredicate(yymsp[0].minor.yy43->getPredicate());
yygotominor.yy49->appendStr(yymsp[0].minor.yy43->getPredicate(),false,false,false);
Predicate p = yymsp[0].minor.yy43->getPredicate();
yygotominor.yy49->addPredicate(p);
yygotominor.yy49->appendStr(p,false,false,false);
delete yymsp[0].minor.yy43;
}
break;
case 36: /* bodydef ::= literal */
{

yygotominor.yy43 = yymsp[0].minor.yy43;
}
break;
Expand Down Expand Up @@ -1608,54 +1608,51 @@ static void yy_reduce(
break;
case 46: /* literal ::= string EQUAL COUNT LPAREN aggregateCum RPAREN */
{
Predicate p;

yygotominor.yy43 = new BodyDef;
std::string s = (*yymsp[-5].minor.yy0).toString();
// std::string s1 = (*S1).toString();
Util::toUpper(s);
// Util::toUpper(s1);

std::string str = s + "= #count{" + yymsp[-1].minor.yy0->toString() + "}";
p.setString(str);

s = s + "= #count{" + yymsp[-1].minor.yy0->toString() + "}";
Predicate p(yymsp[-5].minor.yy0->token);
p.setString(s);
yygotominor.yy43 = new BodyDef;
yygotominor.yy43->addPredicate(p);
delete yymsp[-1].minor.yy0;
}
break;
case 47: /* aggregate ::= string COLON literal */
{
yygotominor.yy0 = new Token(*(yymsp[-2].minor.yy0->token));
std::string s1 = yygotominor.yy0->toString();
Util::toUpper(s1);
std::string str = s1 + ":" + yymsp[0].minor.yy43->toString();
yygotominor.yy0->modifyToken(str);
s1 = s1 + ":" + yymsp[0].minor.yy43->toString();
yygotominor.yy0->modifyToken(s1);
delete yymsp[0].minor.yy43;
}
break;
case 48: /* aggregate ::= number COLON literal */
{
yygotominor.yy0 = new Token(*(yymsp[-2].minor.yy0->token));
std::string s1 = yygotominor.yy0->toString();
// Util::toUpper(s1);
std::string str = s1 + ":" + yymsp[0].minor.yy43->toString();
yygotominor.yy0->modifyToken(str);
s1 = s1 + ":" + yymsp[0].minor.yy43->toString();
yygotominor.yy0->modifyToken(s1);
delete yymsp[0].minor.yy43;
}
break;
case 49: /* aggregate ::= string COMMA literal COLON literal */
{
yygotominor.yy0 = new Token(*(yymsp[-4].minor.yy0->token));
std::string s1 = (*yymsp[-4].minor.yy0).toString();
std::string s1 = yygotominor.yy0->toString();
Util::toUpper(s1);
std::string str = s1 + "," + yymsp[-2].minor.yy43->toString() + ":" + yymsp[0].minor.yy43->toString();
yygotominor.yy0->modifyToken(str);
s1 = s1 + "," + yymsp[-2].minor.yy43->toString() + ":" + yymsp[0].minor.yy43->toString();
yygotominor.yy0->modifyToken(s1);
}
break;
case 50: /* aggregate ::= number COMMA literal COLON literal */
{
yygotominor.yy0 = new Token(*(yymsp[-4].minor.yy0->token));
std::string s1 = (*yymsp[-4].minor.yy0).toString();
// Util::toUpper(s1);
std::string str = s1 + "," + yymsp[-2].minor.yy43->toString()+ ":" + yymsp[0].minor.yy43->toString();
yygotominor.yy0->modifyToken(str);
s1 = s1 + "," + yymsp[-2].minor.yy43->toString()+ ":" + yymsp[0].minor.yy43->toString();
yygotominor.yy0->modifyToken(s1);
}
break;
case 51: /* aggregateCum ::= aggregate */
Expand Down
41 changes: 19 additions & 22 deletions src/src/MVSMParserGrammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,16 @@ head(H) ::= bodydef(Bd).{

body(B) ::= bodydef(Bd).{
B = new Body;
B->addPredicate(Bd->getPredicate());
B->appendStr(Bd->getPredicate(),false,false,false);
Predicate p = Bd->getPredicate();
B->addPredicate(p);
B->appendStr(p,false,false,false);
delete Bd;
}



// BodyDef without negation in front
bodydef(B) ::= literal(L).{

B = L;
}

Expand Down Expand Up @@ -787,52 +787,49 @@ literal(L) ::= variable(V).{
}

literal(L) ::= string(S) EQUAL COUNT LPAREN aggregateCum(A) RPAREN.{
Predicate p;

L = new BodyDef;
std::string s = (*S).toString();
// std::string s1 = (*S1).toString();
Util::toUpper(s);
// Util::toUpper(s1);

std::string str = s + "= #count{" + A->toString() + "}";
p.setString(str);

s = s + "= #count{" + A->toString() + "}";
Predicate p(S->token);
p.setString(s);
L = new BodyDef;
L->addPredicate(p);
delete A;
}


aggregate(A) ::= string(S1) COLON literal(L1).{
A = new Token(*(S1->token));
std::string s1 = A->toString();
Util::toUpper(s1);
std::string str = s1 + ":" + L1->toString();
A->modifyToken(str);
s1 = s1 + ":" + L1->toString();
A->modifyToken(s1);
delete L1;
}

aggregate(A) ::= number(S1) COLON literal(L1).{
A = new Token(*(S1->token));
std::string s1 = A->toString();
// Util::toUpper(s1);
std::string str = s1 + ":" + L1->toString();
A->modifyToken(str);
s1 = s1 + ":" + L1->toString();
A->modifyToken(s1);
delete L1;
}

aggregate(A) ::= string(S1) COMMA literal(L2) COLON literal(L1).{
A = new Token(*(S1->token));
std::string s1 = (*S1).toString();
std::string s1 = A->toString();
Util::toUpper(s1);
std::string str = s1 + "," + L2->toString() + ":" + L1->toString();
A->modifyToken(str);
s1 = s1 + "," + L2->toString() + ":" + L1->toString();
A->modifyToken(s1);
}


aggregate(A) ::= number(S1) COMMA literal(L2) COLON literal(L1).{
A = new Token(*(S1->token));
std::string s1 = (*S1).toString();
// Util::toUpper(s1);
std::string str = s1 + "," + L2->toString()+ ":" + L1->toString();
A->modifyToken(str);
s1 = s1 + "," + L2->toString()+ ":" + L1->toString();
A->modifyToken(s1);
}

aggregateCum(A) ::= aggregate(A1).{
Expand Down

0 comments on commit e77861f

Please sign in to comment.