diff --git a/parser.sh b/parser.sh index 41c14ac..458c8df 100755 --- a/parser.sh +++ b/parser.sh @@ -6,7 +6,7 @@ cd src/src #lemon -l -m ASPParserGrammar.y #mv ASPParserGrammar.c ASPParserGrammar.cpp -lemon -m MVSMParserGrammar.y +lemon -l -m MVSMParserGrammar.y mv MVSMParserGrammar.c MVSMParserGrammar.cpp cd .. diff --git a/src/includes/BodyDef.h b/src/includes/BodyDef.h index 2692cd0..9af42ee 100644 --- a/src/includes/BodyDef.h +++ b/src/includes/BodyDef.h @@ -1,4 +1,5 @@ #include "Predicate.h" +#include "Util.h" class BodyDef { @@ -16,9 +17,20 @@ class BodyDef } std::string toString(){ - return p.toString(); + if(!aggregateString){ + if(!hasVariables){ + std::string s = p.toString(); + Util::toUpper(s); + return s; + } + return p.toString(); + } + else + return str; } + + bool getHasVariables(){ return hasVariables; } @@ -28,8 +40,20 @@ class BodyDef hasVariables = false; } + + std::string setString(std::string s){ + str = s; + aggregateString = true; + } + private: Predicate p; /*By default every BodyDef is assumed to have variables */ - bool hasVariables = true; + bool hasVariables = true; + + /*Used by aggregates to store strings*/ + std::string str; + bool aggregateString = false; + + }; \ No newline at end of file diff --git a/src/includes/Constants.h b/src/includes/Constants.h index 93333c0..e5b1f44 100644 --- a/src/includes/Constants.h +++ b/src/includes/Constants.h @@ -37,6 +37,7 @@ #define ASP_PARSE_TOKEN_COMMA 2 #define ASP_PARSE_TOKEN_EQUAL 1 + #define MVSM_PARSE_TOKEN_REVERSE_IMPLICATION 1 #define MVSM_PARSE_TOKEN_EQUAL 2 #define MVSM_PARSE_TOKEN_COMMA 3 @@ -56,6 +57,6 @@ #define MVSM_PARSE_TOKEN_OBJECTS 17 #define MVSM_PARSE_TOKEN_COLON 18 #define MVSM_PARSE_TOKEN_CONSTANTS 19 -#define MVSM_PARSE_TOKEN_STRING 20 -#define MVSM_PARSE_TOKEN_NUMBER 21 -#define MVSM_PARSE_TOKEN_MINUS 22 \ No newline at end of file +#define MVSM_PARSE_TOKEN_COUNT 20 +#define MVSM_PARSE_TOKEN_STRING 21 +#define MVSM_PARSE_TOKEN_NUMBER 22 \ No newline at end of file diff --git a/src/includes/Predicate.h b/src/includes/Predicate.h index e1ed2e1..631864d 100644 --- a/src/includes/Predicate.h +++ b/src/includes/Predicate.h @@ -94,6 +94,11 @@ class Predicate std::string getExtra(const std::set& variable); std::string getExtraConstants() const; + std::string setString(std::string s){ + aggregateString = s; + isAggregate = true; + } + private: std::string var; std::string lVar; @@ -107,11 +112,14 @@ class Predicate std::set extraConstants; + std::string aggregateString; + bool isEquality = false; bool isInEquality = false; bool toBeCompleted = true; bool singleNegation = false; bool doubleNegation = false; + bool isAggregate = false; void checkConstant(std::string str, const std::set& domainList){ auto it = domainList.find(str); diff --git a/src/src/ASPLexer.cpp b/src/src/ASPLexer.cpp index 3be0538..dc04ca1 100644 --- a/src/src/ASPLexer.cpp +++ b/src/src/ASPLexer.cpp @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 on Tue Aug 16 20:18:41 2016 */ +/* Generated by re2c 0.16 on Mon Oct 17 21:05:22 2016 */ #line 1 "src/src/ASPLexer.re" #include "ASPLexer.h" #include "exceptions/syntax_exception.h" diff --git a/src/src/FOLLexer.cpp b/src/src/FOLLexer.cpp index 804d585..1cba5d6 100644 --- a/src/src/FOLLexer.cpp +++ b/src/src/FOLLexer.cpp @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 on Tue Aug 16 20:18:41 2016 */ +/* Generated by re2c 0.16 on Mon Oct 17 21:05:22 2016 */ #line 1 "src/src/FOLLexer.re" #include "FOLLexer.h" #include "exceptions/syntax_exception.h" diff --git a/src/src/MVSMLexer.cpp b/src/src/MVSMLexer.cpp index 355505e..6533a23 100644 --- a/src/src/MVSMLexer.cpp +++ b/src/src/MVSMLexer.cpp @@ -1,5 +1,5 @@ -/* Generated by re2c 0.16 on Tue Aug 16 20:19:02 2016 */ -#line 1 "MVSMLexer.re" +/* Generated by re2c 0.16 on Mon Oct 17 21:05:22 2016 */ +#line 1 "src/src/MVSMLexer.re" #include "MVSMLexer.h" #include "exceptions/syntax_exception.h" @@ -19,7 +19,7 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) { YYCTYPE yych; unsigned int yyaccept = 0; - if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + if ((YYLIMIT - YYCURSOR) < 6) YYFILL(6); yych = *YYCURSOR; switch (yych) { case 0x00: goto yy2; @@ -29,10 +29,11 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) case ' ': goto yy6; case '\n': goto yy8; case '!': goto yy10; - case '(': goto yy12; - case ')': goto yy14; - case ',': goto yy16; - case '-': goto yy18; + case '#': goto yy12; + case '(': goto yy13; + case ')': goto yy15; + case ',': goto yy17; + case '-': goto yy19; case '.': goto yy20; case '0': case '1': @@ -107,18 +108,18 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) } yy2: ++YYCURSOR; -#line 20 "MVSMLexer.re" +#line 20 "src/src/MVSMLexer.re" { return 0; } -#line 113 "" +#line 114 "" yy4: ++YYCURSOR; yy5: -#line 55 "MVSMLexer.re" +#line 56 "src/src/MVSMLexer.re" { std::string str(--lexeme->current,0,1); throw syntax_exception("Syntax Error - Unexpected "+ str +"\n"); } -#line 122 "" +#line 123 "" yy6: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); @@ -131,37 +132,44 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) default: goto yy7; } yy7: -#line 53 "MVSMLexer.re" +#line 54 "src/src/MVSMLexer.re" { return -1; } -#line 137 "" +#line 138 "" yy8: ++YYCURSOR; -#line 54 "MVSMLexer.re" +#line 55 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_NEWLINE; } -#line 142 "" +#line 143 "" yy10: ++YYCURSOR; -#line 43 "MVSMLexer.re" +#line 44 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_NEGATION;} -#line 147 "" +#line 148 "" yy12: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'c': goto yy47; + default: goto yy5; + } +yy13: ++YYCURSOR; -#line 30 "MVSMLexer.re" +#line 30 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_LBRACKET; } -#line 152 "" -yy14: +#line 160 "" +yy15: ++YYCURSOR; -#line 31 "MVSMLexer.re" +#line 31 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_RBRACKET; } -#line 157 "" -yy16: +#line 165 "" +yy17: ++YYCURSOR; -#line 32 "MVSMLexer.re" +#line 32 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_COMMA; } -#line 162 "" -yy18: - ++YYCURSOR; - switch ((yych = *YYCURSOR)) { +#line 170 "" +yy19: + yych = *++YYCURSOR; + switch (yych) { case '0': case '1': case '2': @@ -172,24 +180,20 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) case '7': case '8': case '9': goto yy22; - default: goto yy19; + default: goto yy5; } -yy19: -#line 41 "MVSMLexer.re" - { return MVSM_PARSE_TOKEN_MINUS;} -#line 181 "" yy20: ++YYCURSOR; -#line 19 "MVSMLexer.re" +#line 19 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_DOT; } -#line 186 "" +#line 190 "" yy22: - yyaccept = 1; + yyaccept = 2; YYMARKER = ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { - case '.': goto yy47; + case '.': goto yy48; case '0': case '1': case '2': @@ -203,41 +207,41 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) default: goto yy24; } yy24: -#line 22 "MVSMLexer.re" +#line 22 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_NUMBER; } -#line 209 "" +#line 213 "" yy25: - yyaccept = 2; + yyaccept = 3; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { - case '-': goto yy48; + case '-': goto yy49; default: goto yy26; } yy26: -#line 51 "MVSMLexer.re" +#line 52 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_COLON; } -#line 220 "" +#line 224 "" yy27: ++YYCURSOR; -#line 49 "MVSMLexer.re" +#line 50 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_SEMI_COLON;} -#line 225 "" +#line 229 "" yy29: yych = *++YYCURSOR; switch (yych) { - case '=': goto yy50; + case '=': goto yy51; default: goto yy5; } yy30: ++YYCURSOR; switch ((yych = *YYCURSOR)) { - case '>': goto yy52; + case '>': goto yy53; default: goto yy31; } yy31: -#line 29 "MVSMLexer.re" +#line 29 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_EQUAL; } -#line 241 "" +#line 245 "" yy32: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -309,36 +313,36 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) default: goto yy34; } yy34: -#line 24 "MVSMLexer.re" +#line 24 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_STRING; } -#line 315 "" +#line 319 "" yy35: yych = *++YYCURSOR; switch (yych) { - case 'O': goto yy54; + case 'O': goto yy55; default: goto yy33; } yy36: ++YYCURSOR; -#line 33 "MVSMLexer.re" +#line 33 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_CONJUNCTION; } -#line 326 "" +#line 330 "" yy38: yych = *++YYCURSOR; switch (yych) { - case 'o': goto yy55; + case 'o': goto yy56; default: goto yy33; } yy39: ++YYCURSOR; -#line 28 "MVSMLexer.re" +#line 28 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_LPAREN; } -#line 337 "" +#line 341 "" yy41: ++YYCURSOR; -#line 27 "MVSMLexer.re" +#line 27 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_RPAREN; } -#line 342 "" +#line 346 "" yy43: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -355,7 +359,8 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) YYCURSOR = YYMARKER; switch (yyaccept) { case 0: goto yy7; - case 1: goto yy24; + case 1: goto yy5; + case 2: goto yy24; default: goto yy26; } yy46: @@ -364,10 +369,16 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) case '\t': case '\v': case '\f': - case ' ': goto yy56; + case ' ': goto yy57; default: goto yy45; } yy47: + yych = *++YYCURSOR; + switch (yych) { + case 'o': goto yy60; + default: goto yy45; + } +yy48: yych = *++YYCURSOR; switch (yych) { case '0': @@ -379,10 +390,10 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) case '6': case '7': case '8': - case '9': goto yy59; + case '9': goto yy61; default: goto yy45; } -yy48: +yy49: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 9) YYFILL(9); yych = *YYCURSOR; @@ -390,35 +401,35 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) case '\t': case '\v': case '\f': - case ' ': goto yy48; - case 'c': goto yy61; - case 'o': goto yy62; - case 's': goto yy63; + case ' ': goto yy49; + case 'c': goto yy63; + case 'o': goto yy64; + case 's': goto yy65; default: goto yy45; } -yy50: +yy51: ++YYCURSOR; -#line 26 "MVSMLexer.re" +#line 26 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_REVERSE_IMPLICATION; } -#line 404 "" -yy52: +#line 415 "" +yy53: ++YYCURSOR; -#line 25 "MVSMLexer.re" +#line 25 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_IMPLICATION; } -#line 409 "" -yy54: +#line 420 "" +yy55: yych = *++YYCURSOR; switch (yych) { - case 'T': goto yy64; + case 'T': goto yy66; default: goto yy33; } -yy55: +yy56: yych = *++YYCURSOR; switch (yych) { - case 't': goto yy64; + case 't': goto yy66; default: goto yy33; } -yy56: +yy57: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -426,19 +437,25 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) case '\t': case '\v': case '\f': - case ' ': goto yy56; - default: goto yy58; + case ' ': goto yy57; + default: goto yy59; } -yy58: -#line 34 "MVSMLexer.re" +yy59: +#line 35 "src/src/MVSMLexer.re" { while(*(lexeme->start) != 'v') lexeme->start++; while(*(lexeme->current) != 'v') lexeme->current--; lexeme->current++; return MVSM_PARSE_TOKEN_DISJUNCTION; } -#line 441 "" -yy59: +#line 452 "" +yy60: + yych = *++YYCURSOR; + switch (yych) { + case 'u': goto yy68; + default: goto yy45; + } +yy61: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -452,28 +469,28 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) case '6': case '7': case '8': - case '9': goto yy59; + case '9': goto yy61; default: goto yy24; } -yy61: +yy63: yych = *++YYCURSOR; switch (yych) { - case 'o': goto yy66; + case 'o': goto yy69; default: goto yy45; } -yy62: +yy64: yych = *++YYCURSOR; switch (yych) { - case 'b': goto yy67; + case 'b': goto yy70; default: goto yy45; } -yy63: +yy65: yych = *++YYCURSOR; switch (yych) { - case 'o': goto yy68; + case 'o': goto yy71; default: goto yy45; } -yy64: +yy66: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case '0': @@ -538,119 +555,136 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) case 'x': case 'y': case 'z': goto yy32; - default: goto yy65; - } -yy65: -#line 23 "MVSMLexer.re" - { return MVSM_PARSE_TOKEN_NEGATION;} -#line 547 "" -yy66: - yych = *++YYCURSOR; - switch (yych) { - case 'n': goto yy69; - default: goto yy45; + default: goto yy67; } yy67: - yych = *++YYCURSOR; - switch (yych) { - case 'j': goto yy70; - default: goto yy45; - } +#line 23 "src/src/MVSMLexer.re" + { return MVSM_PARSE_TOKEN_NEGATION;} +#line 564 "" yy68: yych = *++YYCURSOR; switch (yych) { - case 'r': goto yy71; + case 'n': goto yy72; default: goto yy45; } yy69: yych = *++YYCURSOR; switch (yych) { - case 's': goto yy72; + case 'n': goto yy73; default: goto yy45; } yy70: yych = *++YYCURSOR; switch (yych) { - case 'e': goto yy73; + case 'j': goto yy74; default: goto yy45; } yy71: yych = *++YYCURSOR; switch (yych) { - case 't': goto yy74; + case 'r': goto yy75; default: goto yy45; } yy72: yych = *++YYCURSOR; switch (yych) { - case 't': goto yy75; + case 't': goto yy76; default: goto yy45; } yy73: yych = *++YYCURSOR; switch (yych) { - case 'c': goto yy76; + case 's': goto yy78; default: goto yy45; } yy74: yych = *++YYCURSOR; switch (yych) { - case 's': goto yy77; + case 'e': goto yy79; default: goto yy45; } yy75: yych = *++YYCURSOR; switch (yych) { - case 'a': goto yy79; + case 't': goto yy80; default: goto yy45; } yy76: + ++YYCURSOR; +#line 34 "src/src/MVSMLexer.re" + { return MVSM_PARSE_TOKEN_COUNT;} +#line 617 "" +yy78: yych = *++YYCURSOR; switch (yych) { - case 't': goto yy80; + case 't': goto yy81; default: goto yy45; } -yy77: - ++YYCURSOR; -#line 45 "MVSMLexer.re" - { return MVSM_PARSE_TOKEN_SORTS;} -#line 618 "" yy79: yych = *++YYCURSOR; switch (yych) { - case 'n': goto yy81; + case 'c': goto yy82; default: goto yy45; } yy80: yych = *++YYCURSOR; switch (yych) { - case 's': goto yy82; + case 's': goto yy83; default: goto yy45; } yy81: yych = *++YYCURSOR; switch (yych) { - case 't': goto yy84; + case 'a': goto yy85; default: goto yy45; } yy82: + yych = *++YYCURSOR; + switch (yych) { + case 't': goto yy86; + default: goto yy45; + } +yy83: ++YYCURSOR; -#line 46 "MVSMLexer.re" +#line 46 "src/src/MVSMLexer.re" + { return MVSM_PARSE_TOKEN_SORTS;} +#line 652 "" +yy85: + yych = *++YYCURSOR; + switch (yych) { + case 'n': goto yy87; + default: goto yy45; + } +yy86: + yych = *++YYCURSOR; + switch (yych) { + case 's': goto yy88; + default: goto yy45; + } +yy87: + yych = *++YYCURSOR; + switch (yych) { + case 't': goto yy90; + default: goto yy45; + } +yy88: + ++YYCURSOR; +#line 47 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_OBJECTS;} -#line 641 "" -yy84: +#line 675 "" +yy90: yych = *++YYCURSOR; switch (yych) { - case 's': goto yy85; + case 's': goto yy91; default: goto yy45; } -yy85: +yy91: ++YYCURSOR; -#line 47 "MVSMLexer.re" +#line 48 "src/src/MVSMLexer.re" { return MVSM_PARSE_TOKEN_CONSTANTS;} -#line 652 "" +#line 686 "" } -#line 60 "MVSMLexer.re" +#line 61 "src/src/MVSMLexer.re" } \ No newline at end of file diff --git a/src/src/MVSMLexer.re b/src/src/MVSMLexer.re index 6dc2329..65b9c66 100644 --- a/src/src/MVSMLexer.re +++ b/src/src/MVSMLexer.re @@ -30,7 +30,8 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) "(" { return MVSM_PARSE_TOKEN_LBRACKET; } ")" { return MVSM_PARSE_TOKEN_RBRACKET; } "," { return MVSM_PARSE_TOKEN_COMMA; } - "^"|"," { return MVSM_PARSE_TOKEN_CONJUNCTION; } + "^" { return MVSM_PARSE_TOKEN_CONJUNCTION; } + "#count" { return MVSM_PARSE_TOKEN_COUNT;} WS+ "v"{1} WS+ { while(*(lexeme->start) != 'v') lexeme->start++; while(*(lexeme->current) != 'v') lexeme->current--; @@ -38,7 +39,7 @@ int MVSMLexer::Tokenize(const char * YYCURSOR, int len , lexeme_t* lexeme) return MVSM_PARSE_TOKEN_DISJUNCTION; } - "-" { return MVSM_PARSE_TOKEN_MINUS;} + "!" { return MVSM_PARSE_TOKEN_NEGATION;} diff --git a/src/src/MVSMParserGrammar.cpp b/src/src/MVSMParserGrammar.cpp index c05aa45..0ebcdba 100644 --- a/src/src/MVSMParserGrammar.cpp +++ b/src/src/MVSMParserGrammar.cpp @@ -24,7 +24,6 @@ */ #include /************ Begin %include sections from the grammar ************************/ -#line 4 "MVSMParserGrammar.y" #include #include @@ -46,6 +45,7 @@ #include "Body.h" #include "BodyDef.h" #include "LanguageConstants.h" + #include "Util.h" #include "exceptions/undefined_predicate.h" @@ -70,7 +70,6 @@ void RuleCompletion_HD_BT(Head*, Tree*); void RuleCompletion_HD_BC(Head*, Body*, bool, Tree*); -#line 74 "MVSMParserGrammar.c" #include "MVSMParserGrammar.h" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols @@ -97,8 +96,9 @@ #define MVSM_PARSE_TOKEN_OBJECTS 17 #define MVSM_PARSE_TOKEN_COLON 18 #define MVSM_PARSE_TOKEN_CONSTANTS 19 -#define MVSM_PARSE_TOKEN_STRING 20 -#define MVSM_PARSE_TOKEN_NUMBER 21 +#define MVSM_PARSE_TOKEN_COUNT 20 +#define MVSM_PARSE_TOKEN_STRING 21 +#define MVSM_PARSE_TOKEN_NUMBER 22 #endif /**************** End makeheaders token definitions ***************************/ @@ -154,22 +154,22 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 43 -#define YYACTIONTYPE unsigned char +#define YYNOCODE 46 +#define YYACTIONTYPE unsigned short int #if INTERFACE #define MVSMParserGrammarTOKENTYPE Token* #endif typedef union { int yyinit; MVSMParserGrammarTOKENTYPE yy0; - Tree* yy7; - Predicate* yy24; - Variable* yy37; - std::vector* yy43; - Head* yy53; - RuleCompletion* yy57; - BodyDef* yy72; - Body* yy73; + RuleCompletion* yy3; + Predicate* yy42; + BodyDef* yy43; + Body* yy49; + Head* yy65; + Tree* yy67; + Variable* yy73; + std::vector* yy85; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -180,16 +180,16 @@ typedef union { #define MVSMParserGrammarARG_FETCH Tree* tree = yypParser->tree #define MVSMParserGrammarARG_STORE yypParser->tree = tree #endif -#define YYNSTATE 79 -#define YYNRULE 57 -#define YY_MAX_SHIFT 78 -#define YY_MIN_SHIFTREDUCE 124 -#define YY_MAX_SHIFTREDUCE 180 -#define YY_MIN_REDUCE 181 -#define YY_MAX_REDUCE 237 -#define YY_ERROR_ACTION 238 -#define YY_ACCEPT_ACTION 239 -#define YY_NO_ACTION 240 +#define YYNSTATE 94 +#define YYNRULE 64 +#define YY_MAX_SHIFT 93 +#define YY_MIN_SHIFTREDUCE 146 +#define YY_MAX_SHIFTREDUCE 209 +#define YY_MIN_REDUCE 210 +#define YY_MAX_REDUCE 273 +#define YY_ERROR_ACTION 274 +#define YY_ACCEPT_ACTION 275 +#define YY_NO_ACTION 276 /************* End control #defines *******************************************/ /* The yyzerominor constant is used to initialize instances of @@ -261,101 +261,113 @@ static const YYMINORTYPE yyzerominor = { 0 }; ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (278) +#define YY_ACTTAB_COUNT (318) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 239, 41, 143, 17, 58, 31, 42, 137, 59, 179, - /* 10 */ 142, 145, 155, 158, 42, 46, 2, 64, 169, 144, - /* 20 */ 78, 158, 42, 46, 2, 64, 169, 10, 177, 158, - /* 30 */ 4, 53, 178, 47, 169, 72, 166, 22, 178, 18, - /* 40 */ 167, 36, 164, 42, 179, 180, 179, 180, 24, 43, - /* 50 */ 159, 42, 69, 178, 160, 169, 9, 165, 158, 42, - /* 60 */ 44, 178, 160, 169, 72, 45, 159, 141, 20, 178, - /* 70 */ 160, 169, 11, 42, 58, 179, 180, 135, 59, 50, - /* 80 */ 159, 42, 138, 178, 160, 169, 179, 180, 158, 42, - /* 90 */ 51, 178, 160, 169, 72, 67, 159, 37, 21, 178, - /* 100 */ 160, 169, 133, 42, 24, 179, 180, 174, 7, 68, - /* 110 */ 159, 42, 17, 178, 160, 169, 28, 56, 159, 179, - /* 120 */ 180, 178, 160, 169, 60, 177, 177, 132, 61, 60, - /* 130 */ 179, 177, 130, 61, 170, 178, 178, 176, 175, 32, - /* 140 */ 42, 178, 60, 175, 177, 129, 61, 66, 42, 3, - /* 150 */ 178, 160, 169, 179, 178, 157, 175, 42, 178, 160, - /* 160 */ 169, 179, 180, 42, 52, 181, 150, 178, 160, 169, - /* 170 */ 156, 1, 5, 178, 160, 169, 54, 34, 35, 14, - /* 180 */ 74, 23, 13, 163, 30, 54, 178, 161, 169, 74, - /* 190 */ 178, 49, 169, 74, 27, 178, 48, 169, 17, 178, - /* 200 */ 63, 169, 217, 178, 70, 169, 74, 152, 55, 217, - /* 210 */ 177, 71, 57, 24, 177, 38, 178, 162, 169, 183, - /* 220 */ 178, 39, 175, 76, 178, 40, 175, 183, 19, 58, - /* 230 */ 25, 183, 134, 59, 183, 179, 180, 179, 180, 127, - /* 240 */ 62, 126, 62, 218, 219, 65, 125, 62, 15, 6, - /* 250 */ 218, 219, 17, 214, 8, 154, 15, 31, 17, 31, - /* 260 */ 214, 16, 29, 136, 73, 183, 77, 148, 26, 183, - /* 270 */ 12, 131, 33, 128, 183, 183, 183, 75, + /* 0 */ 275, 49, 165, 17, 70, 36, 50, 159, 71, 186, + /* 10 */ 164, 167, 177, 180, 50, 54, 2, 76, 191, 166, + /* 20 */ 208, 180, 50, 54, 2, 76, 191, 10, 64, 180, + /* 30 */ 4, 61, 207, 55, 191, 84, 187, 9, 63, 18, + /* 40 */ 77, 65, 197, 15, 50, 84, 44, 208, 209, 20, + /* 50 */ 51, 181, 50, 31, 207, 182, 191, 208, 209, 180, + /* 60 */ 50, 52, 207, 182, 191, 84, 53, 181, 208, 21, + /* 70 */ 207, 182, 191, 11, 203, 50, 70, 208, 209, 157, + /* 80 */ 71, 58, 181, 50, 188, 207, 182, 191, 208, 209, + /* 90 */ 180, 50, 59, 207, 182, 191, 22, 79, 181, 19, + /* 100 */ 40, 207, 182, 191, 208, 209, 50, 208, 209, 64, + /* 110 */ 208, 209, 80, 181, 50, 208, 207, 182, 191, 63, + /* 120 */ 68, 181, 25, 198, 207, 182, 191, 72, 206, 206, + /* 130 */ 154, 73, 72, 17, 206, 152, 73, 26, 207, 207, + /* 140 */ 189, 204, 174, 50, 207, 72, 204, 206, 151, 73, + /* 150 */ 78, 50, 163, 207, 182, 191, 199, 207, 179, 204, + /* 160 */ 50, 207, 182, 191, 149, 74, 50, 60, 210, 160, + /* 170 */ 207, 182, 191, 178, 1, 32, 207, 182, 191, 62, + /* 180 */ 42, 155, 67, 208, 209, 13, 62, 38, 7, 207, + /* 190 */ 183, 191, 207, 57, 191, 17, 207, 56, 191, 67, + /* 200 */ 208, 209, 67, 70, 170, 67, 156, 71, 67, 207, + /* 210 */ 75, 191, 207, 82, 191, 207, 196, 191, 207, 85, + /* 220 */ 191, 67, 148, 74, 67, 37, 158, 67, 147, 74, + /* 230 */ 67, 207, 194, 191, 207, 195, 191, 207, 86, 191, + /* 240 */ 207, 193, 191, 66, 206, 206, 3, 17, 67, 69, + /* 250 */ 176, 206, 87, 208, 207, 207, 205, 204, 207, 184, + /* 260 */ 191, 207, 43, 204, 5, 246, 172, 247, 17, 31, + /* 270 */ 192, 14, 246, 81, 247, 248, 6, 243, 8, 33, + /* 280 */ 34, 28, 248, 15, 243, 16, 39, 88, 90, 39, + /* 290 */ 39, 45, 185, 89, 31, 35, 29, 92, 24, 12, + /* 300 */ 153, 23, 30, 212, 93, 41, 150, 83, 212, 27, + /* 310 */ 212, 212, 87, 46, 47, 91, 212, 48, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 23, 24, 25, 7, 29, 3, 29, 32, 33, 20, - /* 10 */ 25, 34, 16, 36, 29, 38, 39, 40, 41, 34, - /* 20 */ 18, 36, 29, 38, 39, 40, 41, 1, 29, 36, - /* 30 */ 4, 38, 39, 40, 41, 9, 29, 13, 39, 13, - /* 40 */ 41, 2, 29, 29, 20, 21, 20, 21, 9, 35, - /* 50 */ 36, 29, 13, 39, 40, 41, 1, 29, 36, 29, - /* 60 */ 38, 39, 40, 41, 9, 35, 36, 29, 13, 39, - /* 70 */ 40, 41, 6, 29, 29, 20, 21, 32, 33, 35, - /* 80 */ 36, 29, 29, 39, 40, 41, 20, 21, 36, 29, - /* 90 */ 38, 39, 40, 41, 9, 35, 36, 2, 13, 39, - /* 100 */ 40, 41, 29, 29, 9, 20, 21, 16, 9, 35, - /* 110 */ 36, 29, 7, 39, 40, 41, 6, 35, 36, 20, - /* 120 */ 21, 39, 40, 41, 27, 29, 29, 30, 31, 27, - /* 130 */ 20, 29, 30, 31, 16, 39, 39, 41, 41, 6, - /* 140 */ 29, 39, 27, 41, 29, 30, 31, 36, 29, 1, - /* 150 */ 39, 40, 41, 20, 39, 36, 41, 29, 39, 40, - /* 160 */ 41, 20, 21, 29, 36, 0, 16, 39, 40, 41, - /* 170 */ 36, 6, 1, 39, 40, 41, 29, 12, 2, 8, - /* 180 */ 29, 13, 17, 10, 19, 29, 39, 40, 41, 29, - /* 190 */ 39, 40, 41, 29, 2, 39, 40, 41, 7, 39, - /* 200 */ 40, 41, 1, 39, 40, 41, 29, 16, 27, 8, - /* 210 */ 29, 13, 27, 9, 29, 18, 39, 40, 41, 42, - /* 220 */ 39, 18, 41, 18, 39, 18, 41, 42, 13, 29, - /* 230 */ 13, 42, 32, 33, 42, 20, 21, 20, 21, 28, - /* 240 */ 29, 28, 29, 1, 1, 5, 28, 29, 8, 1, - /* 250 */ 8, 8, 7, 1, 1, 10, 8, 3, 7, 3, - /* 260 */ 8, 8, 15, 16, 10, 42, 10, 16, 9, 42, - /* 270 */ 15, 16, 15, 16, 42, 42, 42, 18, + /* 0 */ 24, 25, 26, 7, 30, 6, 30, 33, 34, 30, + /* 10 */ 26, 35, 16, 37, 30, 39, 40, 41, 42, 35, + /* 20 */ 21, 37, 30, 39, 40, 41, 42, 1, 30, 37, + /* 30 */ 4, 39, 40, 41, 42, 9, 30, 1, 40, 13, + /* 40 */ 5, 43, 44, 8, 30, 9, 2, 21, 22, 13, + /* 50 */ 36, 37, 30, 9, 40, 41, 42, 21, 22, 37, + /* 60 */ 30, 39, 40, 41, 42, 9, 36, 37, 21, 13, + /* 70 */ 40, 41, 42, 6, 16, 30, 30, 21, 22, 33, + /* 80 */ 34, 36, 37, 30, 30, 40, 41, 42, 21, 22, + /* 90 */ 37, 30, 39, 40, 41, 42, 13, 36, 37, 13, + /* 100 */ 6, 40, 41, 42, 21, 22, 30, 21, 22, 30, + /* 110 */ 21, 22, 36, 37, 30, 21, 40, 41, 42, 40, + /* 120 */ 36, 37, 3, 44, 40, 41, 42, 28, 30, 30, + /* 130 */ 31, 32, 28, 7, 30, 31, 32, 18, 40, 40, + /* 140 */ 42, 42, 16, 30, 40, 28, 42, 30, 31, 32, + /* 150 */ 37, 30, 30, 40, 41, 42, 16, 40, 37, 42, + /* 160 */ 30, 40, 41, 42, 29, 30, 30, 37, 0, 30, + /* 170 */ 40, 41, 42, 37, 6, 13, 40, 41, 42, 30, + /* 180 */ 12, 30, 30, 21, 22, 17, 30, 19, 9, 40, + /* 190 */ 41, 42, 40, 41, 42, 7, 40, 41, 42, 30, + /* 200 */ 21, 22, 30, 30, 16, 30, 33, 34, 30, 40, + /* 210 */ 41, 42, 40, 41, 42, 40, 41, 42, 40, 41, + /* 220 */ 42, 30, 29, 30, 30, 15, 16, 30, 29, 30, + /* 230 */ 30, 40, 41, 42, 40, 41, 42, 40, 41, 42, + /* 240 */ 40, 41, 42, 28, 30, 30, 1, 7, 30, 28, + /* 250 */ 10, 30, 20, 21, 40, 40, 42, 42, 40, 41, + /* 260 */ 42, 40, 2, 42, 1, 1, 16, 1, 7, 9, + /* 270 */ 5, 8, 8, 13, 8, 1, 1, 1, 1, 9, + /* 280 */ 15, 3, 8, 8, 8, 8, 3, 2, 18, 3, + /* 290 */ 3, 2, 10, 10, 9, 2, 18, 10, 18, 15, + /* 300 */ 16, 13, 4, 45, 18, 15, 16, 13, 45, 18, + /* 310 */ 45, 45, 20, 18, 18, 18, 45, 18, }; -#define YY_SHIFT_USE_DFLT (-12) -#define YY_SHIFT_COUNT (78) -#define YY_SHIFT_MIN (-11) -#define YY_SHIFT_MAX (259) +#define YY_SHIFT_USE_DFLT (-5) +#define YY_SHIFT_COUNT (93) +#define YY_SHIFT_MIN (-4) +#define YY_SHIFT_MAX (299) static const short yy_shift_ofst[] = { - /* 0 */ 26, 26, 55, 85, 85, 85, 85, 85, 85, 85, - /* 10 */ 85, 66, 66, 66, 85, 85, 85, 85, 24, 99, - /* 20 */ 215, 217, 141, 141, 141, 141, 141, 141, 110, 110, - /* 30 */ 110, 141, 133, 133, 133, -11, -11, -11, -11, -11, - /* 40 */ -11, 165, 39, -4, 240, 191, 171, 201, 242, 243, - /* 50 */ 245, 248, 252, 253, 95, 254, 251, 256, 259, 247, - /* 60 */ 2, 255, 257, 91, 118, 148, 150, 105, 105, 176, - /* 70 */ 173, 168, 198, 192, 204, 197, 203, 205, 207, + /* 0 */ 26, 26, 36, 56, 56, 56, 56, 56, 56, 56, + /* 10 */ 56, 67, 67, 67, 56, 56, 56, 56, 83, 179, + /* 20 */ 86, 162, 89, 89, 89, 89, 89, 89, 89, 89, + /* 30 */ 89, 89, 89, 89, 89, 89, -1, -1, -1, 89, + /* 40 */ 94, 94, 94, 232, 232, 47, 47, 47, 47, 168, + /* 50 */ 260, -4, 35, 126, 263, 264, 266, 274, 240, 275, + /* 60 */ 276, 277, 44, 119, 278, 265, 283, 285, 188, 287, + /* 70 */ 270, 210, 286, 284, 290, 58, 140, 245, 250, 261, + /* 80 */ 261, 289, 282, 288, 294, 280, 291, 298, 292, 293, + /* 90 */ 295, 296, 297, 299, }; -#define YY_REDUCE_USE_DFLT (-26) -#define YY_REDUCE_COUNT (40) -#define YY_REDUCE_MIN (-25) -#define YY_REDUCE_MAX (218) +#define YY_REDUCE_USE_DFLT (-27) +#define YY_REDUCE_COUNT (48) +#define YY_REDUCE_MIN (-26) +#define YY_REDUCE_MAX (221) static const short yy_reduce_ofst[] = { - /* 0 */ -23, -15, -7, 14, 22, 30, 44, 52, 60, 74, - /* 10 */ 82, 97, 102, 115, 111, 119, 128, 134, 147, 151, - /* 20 */ 156, 147, 160, 164, 181, 177, 185, -1, -25, 45, - /* 30 */ 200, 96, 211, 213, 218, 7, 13, 28, 38, 53, - /* 40 */ 73, + /* 0 */ -24, -16, -8, 14, 22, 30, 45, 53, 61, 76, + /* 10 */ 84, 99, 104, 117, 113, 121, 130, 136, 149, 152, + /* 20 */ 156, 149, 169, 172, 175, 178, 191, 194, 197, 200, + /* 30 */ -2, 215, 218, 221, 79, 98, -26, 46, 173, 214, + /* 40 */ 135, 193, 199, -21, 6, 54, 122, 139, 151, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 204, 203, 235, 238, 238, 238, 238, 238, 238, 238, - /* 10 */ 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, - /* 20 */ 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, - /* 30 */ 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, - /* 40 */ 238, 238, 234, 238, 238, 238, 238, 228, 230, 229, - /* 50 */ 238, 238, 208, 238, 234, 238, 238, 238, 197, 238, - /* 60 */ 238, 238, 238, 219, 217, 238, 214, 210, 206, 238, - /* 70 */ 238, 238, 238, 225, 234, 238, 238, 196, 238, + /* 0 */ 233, 232, 271, 274, 274, 274, 274, 274, 274, 274, + /* 10 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 20 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 30 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 40 */ 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + /* 50 */ 270, 274, 274, 274, 274, 264, 266, 265, 274, 274, + /* 60 */ 237, 274, 270, 274, 274, 274, 274, 270, 274, 274, + /* 70 */ 226, 274, 274, 274, 274, 248, 246, 274, 243, 239, + /* 80 */ 235, 274, 274, 274, 274, 274, 274, 274, 274, 254, + /* 90 */ 274, 274, 225, 274, }; /********** End of lemon-generated parsing tables *****************************/ @@ -462,12 +474,13 @@ static const char *const yyTokenName[] = { "DISJUNCTION", "LBRACKET", "RBRACKET", "IMPLICATION", "SORTS", "NEGATION", "WS", "SEMI_COLON", "DOT", "OBJECTS", "COLON", "CONSTANTS", - "STRING", "NUMBER", "error", "start", - "prog", "predicate", "decl", "variables", - "sortdecl", "string", "objectdecl", "object", - "constantdecl", "constant", "rule", "body", - "bodydef", "bodydef2", "head", "number", - "literal", "variable", + "COUNT", "STRING", "NUMBER", "error", + "start", "prog", "predicate", "decl", + "variables", "sortdecl", "string", "objectdecl", + "object", "constantdecl", "constant", "rule", + "body", "bodydef", "bodydef2", "head", + "number", "literal", "variable", "aggregateCum", + "aggregate", }; #endif /* NDEBUG */ @@ -521,17 +534,24 @@ static const char *const yyRuleName[] = { /* 43 */ "literal ::= string LBRACKET variables RBRACKET EQUAL variable", /* 44 */ "literal ::= string LBRACKET variables RBRACKET", /* 45 */ "literal ::= variable", - /* 46 */ "predicate ::= literal DOT", - /* 47 */ "predicate ::= number literal", - /* 48 */ "predicate ::= number NEGATION NEGATION literal", - /* 49 */ "predicate ::= number NEGATION literal", - /* 50 */ "predicate ::= NEGATION NEGATION literal DOT", - /* 51 */ "variables ::= variable", - /* 52 */ "variables ::= variables COMMA variable", - /* 53 */ "variable ::= string", - /* 54 */ "variable ::= number", - /* 55 */ "string ::= STRING", - /* 56 */ "number ::= NUMBER", + /* 46 */ "literal ::= string EQUAL COUNT LPAREN aggregateCum RPAREN", + /* 47 */ "aggregate ::= string COLON literal", + /* 48 */ "aggregate ::= number COLON literal", + /* 49 */ "aggregate ::= string COMMA literal COLON literal", + /* 50 */ "aggregate ::= number COMMA literal COLON literal", + /* 51 */ "aggregateCum ::= aggregate", + /* 52 */ "aggregateCum ::= aggregateCum SEMI_COLON aggregate", + /* 53 */ "predicate ::= literal DOT", + /* 54 */ "predicate ::= number literal", + /* 55 */ "predicate ::= number NEGATION NEGATION literal", + /* 56 */ "predicate ::= number NEGATION literal", + /* 57 */ "predicate ::= NEGATION NEGATION literal DOT", + /* 58 */ "variables ::= variable", + /* 59 */ "variables ::= variables COMMA variable", + /* 60 */ "variable ::= string", + /* 61 */ "variable ::= number", + /* 62 */ "string ::= STRING", + /* 63 */ "number ::= NUMBER", }; #endif /* NDEBUG */ @@ -860,63 +880,70 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ unsigned char nrhs; /* Number of right-hand side symbols in the rule */ } yyRuleInfo[] = { - { 23, 1 }, - { 24, 3 }, - { 28, 3 }, - { 28, 2 }, - { 28, 2 }, - { 24, 3 }, - { 30, 3 }, - { 30, 2 }, - { 30, 2 }, - { 31, 4 }, - { 24, 3 }, - { 32, 3 }, - { 32, 2 }, - { 32, 2 }, - { 33, 7 }, - { 33, 4 }, - { 33, 1 }, - { 33, 4 }, - { 24, 3 }, - { 24, 1 }, - { 24, 3 }, { 24, 1 }, - { 24, 2 }, - { 24, 0 }, - { 34, 3 }, - { 34, 3 }, - { 34, 4 }, - { 34, 4 }, + { 25, 3 }, + { 29, 3 }, + { 29, 2 }, + { 29, 2 }, + { 25, 3 }, + { 31, 3 }, + { 31, 2 }, + { 31, 2 }, + { 32, 4 }, + { 25, 3 }, + { 33, 3 }, + { 33, 2 }, + { 33, 2 }, + { 34, 7 }, { 34, 4 }, + { 34, 1 }, { 34, 4 }, - { 34, 8 }, - { 34, 6 }, + { 25, 3 }, + { 25, 1 }, + { 25, 3 }, + { 25, 1 }, + { 25, 2 }, + { 25, 0 }, { 35, 3 }, - { 38, 3 }, - { 38, 1 }, - { 35, 1 }, - { 36, 1 }, - { 36, 2 }, - { 36, 3 }, - { 36, 5 }, + { 35, 3 }, + { 35, 4 }, + { 35, 4 }, + { 35, 4 }, + { 35, 4 }, + { 35, 8 }, + { 35, 6 }, { 36, 3 }, - { 36, 4 }, - { 36, 4 }, - { 40, 6 }, - { 40, 4 }, - { 40, 1 }, - { 25, 2 }, - { 25, 2 }, - { 25, 4 }, - { 25, 3 }, - { 25, 4 }, - { 27, 1 }, - { 27, 3 }, - { 41, 1 }, - { 41, 1 }, - { 29, 1 }, + { 39, 3 }, { 39, 1 }, + { 36, 1 }, + { 37, 1 }, + { 37, 2 }, + { 37, 3 }, + { 37, 5 }, + { 37, 3 }, + { 37, 4 }, + { 37, 4 }, + { 41, 6 }, + { 41, 4 }, + { 41, 1 }, + { 41, 6 }, + { 44, 3 }, + { 44, 3 }, + { 44, 5 }, + { 44, 5 }, + { 43, 1 }, + { 43, 3 }, + { 26, 2 }, + { 26, 2 }, + { 26, 4 }, + { 26, 3 }, + { 26, 4 }, + { 28, 1 }, + { 28, 3 }, + { 42, 1 }, + { 42, 1 }, + { 30, 1 }, + { 40, 1 }, }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -957,7 +984,6 @@ static void yy_reduce( */ /********** Begin reduce actions **********************************************/ case 2: /* sortdecl ::= string SEMI_COLON sortdecl */ -#line 120 "MVSMParserGrammar.y" { std::string str = yymsp[-2].minor.yy0->toString(); auto it = tree->domainNamesList.find(str); @@ -966,10 +992,8 @@ static void yy_reduce( else tree->domainNamesList.insert(yymsp[-2].minor.yy0->toString()); } -#line 970 "MVSMParserGrammar.c" break; case 4: /* sortdecl ::= string DOT */ -#line 131 "MVSMParserGrammar.y" { std::string str = yymsp[-1].minor.yy0->toString(); auto it = tree->domainNamesList.find(str); @@ -978,16 +1002,14 @@ static void yy_reduce( else tree->domainNamesList.insert(str); } -#line 982 "MVSMParserGrammar.c" break; case 9: /* object ::= variables COLON COLON string */ -#line 148 "MVSMParserGrammar.y" { // if(tree->cdp == Tree::Current_Decl_Part::DECL_OBJECTS){ auto itr = tree->domainNamesList.find(yymsp[0].minor.yy0->toString()); if(itr != tree->domainNamesList.end()){ Domain* d = new Domain(yymsp[0].minor.yy0->toString()); - d->setVars(*yymsp[-3].minor.yy43); + d->setVars(*yymsp[-3].minor.yy85); tree->domains.insert(*d); for(auto& v : d->getVars()){ tree->domainList.insert(v); @@ -999,18 +1021,16 @@ static void yy_reduce( throw syntax_exception("Domain " + yymsp[0].minor.yy0->toString() +" not declared.\n"); } - delete yymsp[-3].minor.yy43; + delete yymsp[-3].minor.yy85; } -#line 1005 "MVSMParserGrammar.c" break; case 14: /* constant ::= string LBRACKET variables RBRACKET COLON COLON string */ -#line 176 "MVSMParserGrammar.y" { Variable* va = new Variable; std::map posMap; std::set::iterator itr; int i=0; - for(auto& v : *yymsp[-4].minor.yy43){ + for(auto& v : *yymsp[-4].minor.yy85){ itr = tree->domains.find(*v); if (itr == tree->domains.end()){ // std::cout<<"Error:Domain:"+ *v +" not found.\n"; @@ -1042,18 +1062,16 @@ static void yy_reduce( cout<toString(); delete va; - delete yymsp[-4].minor.yy43; + delete yymsp[-4].minor.yy85; } -#line 1048 "MVSMParserGrammar.c" break; case 15: /* constant ::= string LBRACKET variables RBRACKET */ -#line 216 "MVSMParserGrammar.y" { Variable* va = new Variable; std::map posMap; std::set::iterator itr; int i=0; - for(auto& v : *yymsp[-1].minor.yy43){ + for(auto& v : *yymsp[-1].minor.yy85){ itr = tree->domains.find(*v); if (itr == tree->domains.end()){ throw syntax_exception("Syntax Error - Domain " + *v + " not found.\n"); @@ -1070,13 +1088,11 @@ static void yy_reduce( /*for ASP output we do not print constants */ if(tree->outputType != OutputType::OUTPUT_ASP) cout<toString(); - delete yymsp[-1].minor.yy43; + delete yymsp[-1].minor.yy85; delete va; } -#line 1077 "MVSMParserGrammar.c" break; case 16: /* constant ::= string */ -#line 242 "MVSMParserGrammar.y" { Variable* va = new Variable; va->setVar(yymsp[0].minor.yy0->toString()); @@ -1087,10 +1103,8 @@ static void yy_reduce( delete va; } -#line 1091 "MVSMParserGrammar.c" break; case 17: /* constant ::= string COLON COLON string */ -#line 253 "MVSMParserGrammar.y" { Variable* va = new Variable; std::map posMap; @@ -1116,83 +1130,73 @@ static void yy_reduce( delete va; } -#line 1120 "MVSMParserGrammar.c" break; case 18: /* prog ::= prog NEWLINE predicate */ -#line 280 "MVSMParserGrammar.y" { - if(yymsp[0].minor.yy24->needsToBeCompleted()){ - FactCompletion f(*yymsp[0].minor.yy24); + if(yymsp[0].minor.yy42->needsToBeCompleted()){ + FactCompletion f(*yymsp[0].minor.yy42); tree->facts.insert(std::pair(f.getHead().getVar(),f)); } - delete yymsp[0].minor.yy24; + delete yymsp[0].minor.yy42; } -#line 1133 "MVSMParserGrammar.c" break; case 19: /* prog ::= predicate */ -#line 290 "MVSMParserGrammar.y" { - if(yymsp[0].minor.yy24->needsToBeCompleted()){ - FactCompletion f(*yymsp[0].minor.yy24); + if(yymsp[0].minor.yy42->needsToBeCompleted()){ + FactCompletion f(*yymsp[0].minor.yy42); tree->facts.insert(std::pair(f.getHead().getVar(),f)); } - delete yymsp[0].minor.yy24; + delete yymsp[0].minor.yy42; } -#line 1144 "MVSMParserGrammar.c" break; case 20: /* prog ::= prog NEWLINE rule */ case 21: /* prog ::= rule */ yytestcase(yyruleno==21); -#line 298 "MVSMParserGrammar.y" { - if((yymsp[0].minor.yy57->isHeadTop == false) && (yymsp[0].minor.yy57->toBeCompleted == true)) - tree->rules.insert(std::pair(yymsp[0].minor.yy57->getHead().getVar(),*yymsp[0].minor.yy57)); - delete yymsp[0].minor.yy57; + if((yymsp[0].minor.yy3->isHeadTop == false) && (yymsp[0].minor.yy3->toBeCompleted == true)) + tree->rules.insert(std::pair(yymsp[0].minor.yy3->getHead().getVar(),*yymsp[0].minor.yy3)); + delete yymsp[0].minor.yy3; } -#line 1154 "MVSMParserGrammar.c" break; case 24: /* rule ::= REVERSE_IMPLICATION body DOT */ -#line 331 "MVSMParserGrammar.y" { - yygotominor.yy57 = new RuleCompletion; - yygotominor.yy57->isHeadTop = true; + yygotominor.yy3 = new RuleCompletion; + yygotominor.yy3->isHeadTop = true; if(tree->outputType != OutputType::OUTPUT_ASP){ std::cout<<"(" - <toNNFString() + <toNNFString() <<")" <toString() + <toString() <isHeadTop = true; + yygotominor.yy3 = new RuleCompletion; + yygotominor.yy3->isHeadTop = true; if(tree->outputType != OutputType::OUTPUT_ASP){ std::cout<toString()<toNNFString() + <toNNFString() <<")" <<"\n"; } else{ std::string str = ":~" - + yymsp[0].minor.yy73->toString() + + yymsp[0].minor.yy49->toString() + " , " - + yymsp[0].minor.yy73->getExtra(tree->variables) + + yymsp[0].minor.yy49->getExtra(tree->variables) + LanguageConstants::LINE_END + " " + "[" @@ -1200,7 +1204,7 @@ static void yy_reduce( + "," + std::to_string(tree->weak_constraint_counter); - std::string temp = yymsp[0].minor.yy73->getExtraConstants(); + std::string temp = yymsp[0].minor.yy49->getExtraConstants(); if(temp.length() > 0){ str += "," + temp; @@ -1212,115 +1216,107 @@ static void yy_reduce( tree->weak_constraint_counter++; } - // std::cout<toString()<toNNFString()<<")"<<"\n"; - delete yymsp[0].minor.yy73; + // std::cout<toString()<toNNFString()<<")"<<"\n"; + delete yymsp[0].minor.yy49; } -#line 1219 "MVSMParserGrammar.c" break; case 26: /* rule ::= head DISJUNCTION bodydef DOT */ -#line 394 "MVSMParserGrammar.y" { //Doing this - yygotominor.yy57 = new RuleCompletion; - yygotominor.yy57->isHeadTop = true; - yymsp[-3].minor.yy53->addPredicate(yymsp[-1].minor.yy72->getPredicate()); - // RULE_COMPLETION_HEAD_DIS_BODY_TOP(yymsp[-3].minor.yy53,yymsp[-1].minor.yy72) + yygotominor.yy3 = new RuleCompletion; + yygotominor.yy3->isHeadTop = true; + yymsp[-3].minor.yy65->addPredicate(yymsp[-1].minor.yy43->getPredicate()); + // RULE_COMPLETION_HEAD_DIS_BODY_TOP(yymsp[-3].minor.yy65,yymsp[-1].minor.yy43) try{ - RuleCompletion_HD_BT(yymsp[-3].minor.yy53,tree); + RuleCompletion_HD_BT(yymsp[-3].minor.yy65,tree); } catch(const std::out_of_range& e){ throw syntax_exception("Error : Invalid number of arguments in some literal in the Rule.\n"); } - yymsp[-3].minor.yy53->appendStr(yymsp[-1].minor.yy72->getPredicate().toString(),false,true,false); + yymsp[-3].minor.yy65->appendStr(yymsp[-1].minor.yy43->getPredicate().toString(),false,true,false); std::string temp; if(tree->outputType == OutputType::OUTPUT_ASP){ - temp = yymsp[-3].minor.yy53->getExtra(tree->variables); + temp = yymsp[-3].minor.yy65->getExtra(tree->variables); if(temp.length() > 0){ - temp = yymsp[-3].minor.yy53->toString() + ":-" + temp; + temp = yymsp[-3].minor.yy65->toString() + ":-" + temp; } else{ - temp = yymsp[-3].minor.yy53->toString(); + temp = yymsp[-3].minor.yy65->toString(); } } std::cout<isHeadTop = true; - yymsp[-2].minor.yy53->addPredicate(yymsp[0].minor.yy72->getPredicate()); - // RULE_COMPLETION_HEAD_DIS_BODY_TOP(yymsp[-2].minor.yy53,yymsp[0].minor.yy72) + yygotominor.yy3 = new RuleCompletion; + yygotominor.yy3->isHeadTop = true; + yymsp[-2].minor.yy65->addPredicate(yymsp[0].minor.yy43->getPredicate()); + // RULE_COMPLETION_HEAD_DIS_BODY_TOP(yymsp[-2].minor.yy65,yymsp[0].minor.yy43) try{ - RuleCompletion_HD_BT(yymsp[-2].minor.yy53,tree); + RuleCompletion_HD_BT(yymsp[-2].minor.yy65,tree); } catch(const std::out_of_range& e){ throw syntax_exception("Error : Invalid number of arguments in some literal in the Rule.\n"); } - yymsp[-2].minor.yy53->appendStr(yymsp[0].minor.yy72->getPredicate().toString(),false,true,false); - std::cout<toString()<toString()<<"\n"; - delete yymsp[-2].minor.yy53; - delete yymsp[0].minor.yy72; + yymsp[-2].minor.yy65->appendStr(yymsp[0].minor.yy43->getPredicate().toString(),false,true,false); + std::cout<toString()<toString()<<"\n"; + delete yymsp[-2].minor.yy65; + delete yymsp[0].minor.yy43; } -#line 1275 "MVSMParserGrammar.c" break; case 28: /* rule ::= head REVERSE_IMPLICATION body DOT */ -#line 452 "MVSMParserGrammar.y" { - yygotominor.yy57 = new RuleCompletion; + yygotominor.yy3 = new RuleCompletion; - if (yymsp[-3].minor.yy53->getDisjunction()){ - // RULE_COMPLETION_HEAD_DIS_BODY_TOP(yymsp[-3].minor.yy53,yymsp[-1].minor.yy73) - yygotominor.yy57->isHeadTop = true; - RuleCompletion_HD_BC(yymsp[-3].minor.yy53,yymsp[-1].minor.yy73,true,tree); + if (yymsp[-3].minor.yy65->getDisjunction()){ + // RULE_COMPLETION_HEAD_DIS_BODY_TOP(yymsp[-3].minor.yy65,yymsp[-1].minor.yy49) + yygotominor.yy3->isHeadTop = true; + RuleCompletion_HD_BC(yymsp[-3].minor.yy65,yymsp[-1].minor.yy49,true,tree); if(tree->outputType == OutputType::OUTPUT_ALCHEMY) - std::cout<toString() + std::cout<toString() <<" => " - <toString() + <toString() <outputType == OutputType::OUTPUT_ASP) - tree->printASPRuleHB(yymsp[-3].minor.yy53,yymsp[-1].minor.yy73); + tree->printASPRuleHB(yymsp[-3].minor.yy65,yymsp[-1].minor.yy49); } else{ - // RULE_COMPLETION_BH(yymsp[-1].minor.yy73,yymsp[-3].minor.yy53); - // yygotominor.yy57 = new RuleCompletion(yymsp[-3].minor.yy53->getPredicate(),predList, resultMap, varMap); + // RULE_COMPLETION_BH(yymsp[-1].minor.yy49,yymsp[-3].minor.yy65); + // yygotominor.yy3 = new RuleCompletion(yymsp[-3].minor.yy65->getPredicate(),predList, resultMap, varMap); try{ - yygotominor.yy57 = RuleCompletion_BH(yymsp[-1].minor.yy73,yymsp[-3].minor.yy53,tree); + yygotominor.yy3 = RuleCompletion_BH(yymsp[-1].minor.yy49,yymsp[-3].minor.yy65,tree); } catch(const std::out_of_range& e){ throw syntax_exception("Error : Invalid number of arguments in some literal in the Rule.\n"); } if(tree->outputType == OutputType::OUTPUT_ALCHEMY) - std::cout<toString() + std::cout<toString() <<" => " - <toString() + <toString() <outputType == OutputType::OUTPUT_ASP) - tree->printASPRuleHB(yymsp[-3].minor.yy53,yymsp[-1].minor.yy73); + tree->printASPRuleHB(yymsp[-3].minor.yy65,yymsp[-1].minor.yy49); } - delete yymsp[-1].minor.yy73; - delete yymsp[-3].minor.yy53; + delete yymsp[-1].minor.yy49; + delete yymsp[-3].minor.yy65; } -#line 1316 "MVSMParserGrammar.c" break; case 29: /* rule ::= number head REVERSE_IMPLICATION body */ -#line 493 "MVSMParserGrammar.y" { - // RULE_COMPLETION_BH(yymsp[0].minor.yy73,yymsp[-2].minor.yy53); - // yygotominor.yy57 = new RuleCompletion(yymsp[-2].minor.yy53->getPredicate(),predList, resultMap, varMap); + // RULE_COMPLETION_BH(yymsp[0].minor.yy49,yymsp[-2].minor.yy65); + // yygotominor.yy3 = new RuleCompletion(yymsp[-2].minor.yy65->getPredicate(),predList, resultMap, varMap); try{ - yygotominor.yy57 = RuleCompletion_BH(yymsp[0].minor.yy73,yymsp[-2].minor.yy53,tree); + yygotominor.yy3 = RuleCompletion_BH(yymsp[0].minor.yy49,yymsp[-2].minor.yy65,tree); } catch(const std::out_of_range& e){ throw syntax_exception("Error : Invalid number of arguments in some literal in the Rule.\n"); @@ -1329,25 +1325,25 @@ static void yy_reduce( if(tree->outputType == OutputType::OUTPUT_ALCHEMY) std::cout<< yymsp[-3].minor.yy0->toString() <toString() + <toString() <<" => " - <toString() + <toString() <<"\n"; if(tree->outputType == OutputType::OUTPUT_ASP){ std::cout << "unsat(" << tree->weak_constraint_counter << ")" << " :- " - << yymsp[0].minor.yy73->toString() + << yymsp[0].minor.yy49->toString() << " , " /*Change this to NNF String*/ - << yymsp[-2].minor.yy53->toNNFString() + << yymsp[-2].minor.yy65->toNNFString() <toString() + std::cout << yymsp[-2].minor.yy65->toString() << " :- " - << yymsp[0].minor.yy73->toString() + << yymsp[0].minor.yy49->toString() << " , " << "not " << "unsat(" << tree->weak_constraint_counter << ")" @@ -1371,147 +1367,126 @@ static void yy_reduce( } - delete yymsp[0].minor.yy73; - delete yymsp[-2].minor.yy53; + delete yymsp[0].minor.yy49; + delete yymsp[-2].minor.yy65; } -#line 1378 "MVSMParserGrammar.c" break; case 30: /* rule ::= number NEGATION NEGATION LBRACKET head REVERSE_IMPLICATION body RBRACKET */ -#line 555 "MVSMParserGrammar.y" { - yygotominor.yy57 = new RuleCompletion; - yygotominor.yy57->isHeadTop = true; + yygotominor.yy3 = new RuleCompletion; + yygotominor.yy3->isHeadTop = true; tree->statHasDblNeg = true; if(tree->outputType == OutputType::OUTPUT_ALCHEMY) std::cout<< yymsp[-7].minor.yy0->toString() << SPACE <<"!!(" - <toString() + <toString() <<" => " - <toString() + <toString() <<"\n"; if(tree->outputType == OutputType::OUTPUT_ASP) std::cout<< yymsp[-7].minor.yy0->toString() << SPACE - <toString() + <toString() <<" :- " - <toString() + <toString() <getPredicate().checkEquality() != 0){ + if (yymsp[-4].minor.yy65->getPredicate().checkEquality() != 0){ throw syntax_exception("Cannot have equality/Inequlity as a part of choice rule\n"); } - // RULE_COMPLETION_BH(yymsp[-1].minor.yy73,yymsp[-4].minor.yy53); - // yygotominor.yy57 = new RuleCompletion(yymsp[-4].minor.yy53->getPredicate(),predList, resultMap, varMap); + // RULE_COMPLETION_BH(yymsp[-1].minor.yy49,yymsp[-4].minor.yy65); + // yygotominor.yy3 = new RuleCompletion(yymsp[-4].minor.yy65->getPredicate(),predList, resultMap, varMap); try{ - yygotominor.yy57 = RuleCompletion_BH(yymsp[-1].minor.yy73,yymsp[-4].minor.yy53,tree); + yygotominor.yy3 = RuleCompletion_BH(yymsp[-1].minor.yy49,yymsp[-4].minor.yy65,tree); } catch(const std::out_of_range& e){ throw syntax_exception("Error : Invalid number of arguments in some literal in the Rule.\n"); } if(tree->outputType == OutputType::OUTPUT_ALCHEMY) - std::cout<toString()<<" => "<toString()<<"\n"; + std::cout<toString()<<" => "<toString()<<"\n"; if(tree->outputType == OutputType::OUTPUT_ASP) - std::cout<toString()<<" :- "<toString()<toString()<<" :- "<toString()<addPredicate(yymsp[0].minor.yy72->getPredicate()); - yygotominor.yy73->appendStr(yymsp[0].minor.yy72->getPredicate(),false,false,true); - delete yymsp[0].minor.yy72; + yygotominor.yy49 = yymsp[-2].minor.yy49; + yymsp[-2].minor.yy49->addPredicate(yymsp[0].minor.yy43->getPredicate()); + yygotominor.yy49->appendStr(yymsp[0].minor.yy43->getPredicate(),false,false,true); + delete yymsp[0].minor.yy43; } -#line 1443 "MVSMParserGrammar.c" break; case 33: /* head ::= head DISJUNCTION bodydef */ -#line 612 "MVSMParserGrammar.y" { - yygotominor.yy53 = yymsp[-2].minor.yy53; - yymsp[-2].minor.yy53->addPredicate(yymsp[0].minor.yy72->getPredicate()); - yygotominor.yy53->appendStr(yymsp[0].minor.yy72->getPredicate().toString(),false,true,false); - yygotominor.yy53->setDisjunction(true); - delete yymsp[0].minor.yy72; + yygotominor.yy65 = yymsp[-2].minor.yy65; + yymsp[-2].minor.yy65->addPredicate(yymsp[0].minor.yy43->getPredicate()); + yygotominor.yy65->appendStr(yymsp[0].minor.yy43->getPredicate().toString(),false,true,false); + yygotominor.yy65->setDisjunction(true); + delete yymsp[0].minor.yy43; } -#line 1454 "MVSMParserGrammar.c" break; case 34: /* head ::= bodydef */ -#line 620 "MVSMParserGrammar.y" { - yygotominor.yy53 = new Head(yymsp[0].minor.yy72->getPredicate()); - // yygotominor.yy53->addPredicate(yymsp[0].minor.yy72->getPredicate()); - yygotominor.yy53->appendStr(yymsp[0].minor.yy72->getPredicate().toString(),false,false,false); - delete yymsp[0].minor.yy72; + yygotominor.yy65 = new Head(yymsp[0].minor.yy43->getPredicate()); + // yygotominor.yy65->addPredicate(yymsp[0].minor.yy43->getPredicate()); + yygotominor.yy65->appendStr(yymsp[0].minor.yy43->getPredicate().toString(),false,false,false); + delete yymsp[0].minor.yy43; } -#line 1464 "MVSMParserGrammar.c" break; case 35: /* body ::= bodydef */ -#line 627 "MVSMParserGrammar.y" { - yygotominor.yy73 = new Body; - yygotominor.yy73->addPredicate(yymsp[0].minor.yy72->getPredicate()); - yygotominor.yy73->appendStr(yymsp[0].minor.yy72->getPredicate(),false,false,false); - delete yymsp[0].minor.yy72; + yygotominor.yy49 = new Body; + yygotominor.yy49->addPredicate(yymsp[0].minor.yy43->getPredicate()); + yygotominor.yy49->appendStr(yymsp[0].minor.yy43->getPredicate(),false,false,false); + delete yymsp[0].minor.yy43; } -#line 1474 "MVSMParserGrammar.c" break; case 36: /* bodydef ::= literal */ -#line 637 "MVSMParserGrammar.y" { - yygotominor.yy72 = yymsp[0].minor.yy72; + + yygotominor.yy43 = yymsp[0].minor.yy43; } -#line 1481 "MVSMParserGrammar.c" break; case 37: /* bodydef ::= NEGATION literal */ -#line 642 "MVSMParserGrammar.y" { - yygotominor.yy72 = yymsp[0].minor.yy72; - Predicate p = yygotominor.yy72->getPredicate(); + yygotominor.yy43 = yymsp[0].minor.yy43; + Predicate p = yygotominor.yy43->getPredicate(); p.setSingleNegation(true); - yygotominor.yy72->addPredicate(p); - // yygotominor.yy72->getPredicate().setSingleNegation(true); + yygotominor.yy43->addPredicate(p); + // yygotominor.yy43->getPredicate().setSingleNegation(true); } -#line 1492 "MVSMParserGrammar.c" break; case 38: /* bodydef ::= NEGATION NEGATION literal */ -#line 651 "MVSMParserGrammar.y" { - yygotominor.yy72 = yymsp[0].minor.yy72; + yygotominor.yy43 = yymsp[0].minor.yy43; tree->statHasDblNeg = true; - yygotominor.yy72->getPredicate().setDoubleNegation(true); + yygotominor.yy43->getPredicate().setDoubleNegation(true); } -#line 1501 "MVSMParserGrammar.c" break; case 39: /* bodydef ::= LBRACKET NEGATION NEGATION literal RBRACKET */ -#line 660 "MVSMParserGrammar.y" { - yygotominor.yy72 = yymsp[-1].minor.yy72; + yygotominor.yy43 = yymsp[-1].minor.yy43; tree->statHasDblNeg = true; - yygotominor.yy72->getPredicate().setDoubleNegation(true); + yygotominor.yy43->getPredicate().setDoubleNegation(true); } -#line 1510 "MVSMParserGrammar.c" break; case 40: /* bodydef ::= string EQUAL string */ -#line 667 "MVSMParserGrammar.y" { - yygotominor.yy72 = new BodyDef; + yygotominor.yy43 = new BodyDef; auto itr = tree->variables.find(*(yymsp[-2].minor.yy0->token)); if (itr != tree->variables.end()){ /*Treat it as a bodydef with 1 variable*/ @@ -1527,10 +1502,10 @@ static void yy_reduce( vars.push_back(*(yymsp[0].minor.yy0->token)); Predicate p(yymsp[-2].minor.yy0->token); p.setTokens(vars, tree->domainList); - yygotominor.yy72->addPredicate(p); + yygotominor.yy43->addPredicate(p); int expectedArgs = (tree->variables.find(*(yymsp[-2].minor.yy0->token)))->getSize(); if (expectedArgs != vars.size()){ - delete yygotominor.yy72; + delete yygotominor.yy43; throw invalid_arguments(expectedArgs, vars.size(), *(yymsp[-2].minor.yy0->token)); } } @@ -1538,32 +1513,28 @@ static void yy_reduce( else{ Predicate p(yymsp[-2].minor.yy0->token,yymsp[0].minor.yy0->token); p.setEquality(); - yygotominor.yy72->addPredicate(p); + yygotominor.yy43->addPredicate(p); } } -#line 1545 "MVSMParserGrammar.c" break; case 41: /* bodydef ::= NEGATION string EQUAL string */ -#line 700 "MVSMParserGrammar.y" { std::vector vars; vars.push_back(yymsp[0].minor.yy0->toString()); Predicate p(yymsp[-2].minor.yy0->token); p.setTokens(vars, tree->domainList); p.setSingleNegation(true); - yygotominor.yy72 = new BodyDef; - yygotominor.yy72->addPredicate(p); + yygotominor.yy43 = new BodyDef; + yygotominor.yy43->addPredicate(p); // delete Ve; int expectedArgs = (tree->variables.find(*(yymsp[-2].minor.yy0->token)))->getSize(); if (expectedArgs != vars.size()){ - delete yygotominor.yy72; + delete yygotominor.yy43; throw invalid_arguments(expectedArgs, vars.size(), *(yymsp[-2].minor.yy0->token)); } } -#line 1564 "MVSMParserGrammar.c" break; case 42: /* bodydef ::= string NEGATION EQUAL string */ -#line 716 "MVSMParserGrammar.y" { /*check if yymsp[-3].minor.yy0 is declared in constant section @@ -1576,83 +1547,140 @@ static void yy_reduce( Predicate p(yymsp[-3].minor.yy0->token,yymsp[0].minor.yy0->token); p.setInEquality(); - yygotominor.yy72 = new BodyDef; - yygotominor.yy72->addPredicate(p); + yygotominor.yy43 = new BodyDef; + yygotominor.yy43->addPredicate(p); } -#line 1583 "MVSMParserGrammar.c" break; case 43: /* literal ::= string LBRACKET variables RBRACKET EQUAL variable */ -#line 735 "MVSMParserGrammar.y" { std::vector vars; - for(auto& v : *yymsp[-3].minor.yy43) + for(auto& v : *yymsp[-3].minor.yy85) vars.push_back(*v); vars.push_back(*(yymsp[0].minor.yy0->token)); Predicate p(yymsp[-5].minor.yy0->token); p.setTokens(vars, tree->domainList); - yygotominor.yy72 = new BodyDef; - yygotominor.yy72->addPredicate(p); + yygotominor.yy43 = new BodyDef; + yygotominor.yy43->addPredicate(p); auto itr = tree->variables.find(yymsp[-5].minor.yy0->toString()); if(itr == tree->variables.end()){ - delete yygotominor.yy72; + delete yygotominor.yy43; throw syntax_exception("Literal "+ yymsp[-5].minor.yy0->toString() + " not found.\n"); } - delete yymsp[-3].minor.yy43; + delete yymsp[-3].minor.yy85; int expectedArgs = (tree->variables.find(yymsp[-5].minor.yy0->toString()))->getSize(); if (expectedArgs != vars.size()){ - delete yygotominor.yy72; + delete yygotominor.yy43; throw invalid_arguments(expectedArgs, vars.size(), *(yymsp[-5].minor.yy0->token)); } } -#line 1608 "MVSMParserGrammar.c" break; case 44: /* literal ::= string LBRACKET variables RBRACKET */ -#line 757 "MVSMParserGrammar.y" { std::vector vars; - for(auto& v : *yymsp[-1].minor.yy43) + for(auto& v : *yymsp[-1].minor.yy85) vars.push_back(*v); Predicate p(yymsp[-3].minor.yy0->token); p.setTokens(vars, tree->domainList); - yygotominor.yy72 = new BodyDef; - yygotominor.yy72->addPredicate(p); - delete yymsp[-1].minor.yy43; + yygotominor.yy43 = new BodyDef; + yygotominor.yy43->addPredicate(p); + delete yymsp[-1].minor.yy85; auto itr = tree->variables.find(yymsp[-3].minor.yy0->toString()); if(itr == tree->variables.end()){ - delete yygotominor.yy72; + delete yygotominor.yy43; throw syntax_exception("Literal "+ yymsp[-3].minor.yy0->toString() + " not found.\n"); } int expectedArgs = itr->getSize(); if (expectedArgs != vars.size()){ - delete yygotominor.yy72; + delete yygotominor.yy43; throw invalid_arguments(expectedArgs, vars.size(), *(yymsp[-3].minor.yy0->token)); } } -#line 1632 "MVSMParserGrammar.c" break; case 45: /* literal ::= variable */ -#line 778 "MVSMParserGrammar.y" { Predicate p(yymsp[0].minor.yy0->token); auto itr = tree->variables.find(yymsp[0].minor.yy0->toString()); - yygotominor.yy72 = new BodyDef; + yygotominor.yy43 = new BodyDef; /*Special Case: BodyDef does not have variables*/ - yygotominor.yy72->setHasVariables(); - yygotominor.yy72->addPredicate(p); + yygotominor.yy43->setHasVariables(); + yygotominor.yy43->addPredicate(p); +} + 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); + + yygotominor.yy43->addPredicate(p); +} + 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); +} + 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); } -#line 1644 "MVSMParserGrammar.c" break; - case 46: /* predicate ::= literal DOT */ -#line 788 "MVSMParserGrammar.y" + case 49: /* aggregate ::= string COMMA literal COLON literal */ { - yygotominor.yy24 = new Predicate; - *yygotominor.yy24 = yymsp[-1].minor.yy72->getPredicate(); - if(yymsp[-1].minor.yy72->getHasVariables() == false){ + 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); +} + 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); +} + break; + case 51: /* aggregateCum ::= aggregate */ +{ + yygotominor.yy0 = new Token(*(yymsp[0].minor.yy0->token)); + delete yymsp[0].minor.yy0; +} + break; + case 52: /* aggregateCum ::= aggregateCum SEMI_COLON aggregate */ +{ + yygotominor.yy0 = yymsp[-2].minor.yy0; + yygotominor.yy0->modifyToken(yymsp[-2].minor.yy0->toString() + ";" + yymsp[0].minor.yy0->toString()); + delete yymsp[0].minor.yy0; +} + break; + case 53: /* predicate ::= literal DOT */ +{ + yygotominor.yy42 = new Predicate; + *yygotominor.yy42 = yymsp[-1].minor.yy43->getPredicate(); + if(yymsp[-1].minor.yy43->getHasVariables() == false){ /*Its a special case*/ - yygotominor.yy24->notToBeCompleted(); + yygotominor.yy42->notToBeCompleted(); } - auto itr = tree->variables.find(yygotominor.yy24->getVar()); + auto itr = tree->variables.find(yygotominor.yy42->getVar()); if(itr != tree->variables.end()){ itr->setCompleted(); } @@ -1661,16 +1689,16 @@ static void yy_reduce( if(tree->outputType == OutputType::OUTPUT_ASP){ - s2 = yygotominor.yy24->getExtra(tree->variables); + s2 = yygotominor.yy42->getExtra(tree->variables); if(s2.length() > 0){ - s1 = yygotominor.yy24->toString(s1,false); + s1 = yygotominor.yy42->toString(s1,false); s1 += ":-"; s1 += s2; s1 += ".\n"; } else{ - s1 = yygotominor.yy24->toString(s1,true); + s1 = yygotominor.yy42->toString(s1,true); } @@ -1679,39 +1707,37 @@ static void yy_reduce( cout<getPredicate(); + yygotominor.yy42 = new Predicate; + *yygotominor.yy42 = yymsp[0].minor.yy43->getPredicate(); - if(yymsp[0].minor.yy72->getHasVariables() == false){ + if(yymsp[0].minor.yy43->getHasVariables() == false){ /*Its a special case*/ - yygotominor.yy24->notToBeCompleted(); + yygotominor.yy42->notToBeCompleted(); } - auto itr = tree->variables.find(yygotominor.yy24->getVar()); + auto itr = tree->variables.find(yygotominor.yy42->getVar()); if(itr != tree->variables.end()){ itr->setCompleted(); } if(tree->outputType == OutputType::OUTPUT_ALCHEMY){ - cout<toString(yymsp[-1].minor.yy0->toString()+SPACE, false); + cout<toString(yymsp[-1].minor.yy0->toString()+SPACE, false); } if(tree->outputType == OutputType::OUTPUT_ASP){ std::cout << "unsat(" << tree->weak_constraint_counter << ")" << " :- " << "not " - << yygotominor.yy24->toString() + << yygotominor.yy42->toString() <toString() + std::cout << yygotominor.yy42->toString() << " :- " << "not " << "unsat(" << tree->weak_constraint_counter << ")" @@ -1732,24 +1758,22 @@ static void yy_reduce( tree->weak_constraint_counter++; } - delete yymsp[0].minor.yy72; + delete yymsp[0].minor.yy43; } -#line 1738 "MVSMParserGrammar.c" break; - case 48: /* predicate ::= number NEGATION NEGATION literal */ -#line 876 "MVSMParserGrammar.y" + case 55: /* predicate ::= number NEGATION NEGATION literal */ { - yygotominor.yy24 = new Predicate; - *yygotominor.yy24 = yymsp[0].minor.yy72->getPredicate(); - yygotominor.yy24->notToBeCompleted(); + yygotominor.yy42 = new Predicate; + *yygotominor.yy42 = yymsp[0].minor.yy43->getPredicate(); + yygotominor.yy42->notToBeCompleted(); if(tree->outputType == OutputType::OUTPUT_ALCHEMY){ tree->statHasDblNeg = true; - cout<toString(yymsp[-3].minor.yy0->toString()+SPACE, false); + cout<toString(yymsp[-3].minor.yy0->toString()+SPACE, false); } else if(tree->outputType == OutputType::OUTPUT_ASP){ - std::string str = yygotominor.yy24->toString(":~ not ", false); - std::string temp = yygotominor.yy24->getExtra(tree->variables); + std::string str = yygotominor.yy42->toString(":~ not ", false); + std::string temp = yygotominor.yy42->getExtra(tree->variables); if(temp.length() > 0) str += ","; str += temp; @@ -1759,28 +1783,26 @@ static void yy_reduce( "," + std::to_string(tree->weak_constraint_counter++) + "," + - yygotominor.yy24->getExtraConstants()+ + yygotominor.yy42->getExtraConstants()+ "]\n"; cout<getPredicate(); - yygotominor.yy24->notToBeCompleted(); + yygotominor.yy42 = new Predicate; + *yygotominor.yy42 = yymsp[0].minor.yy43->getPredicate(); + yygotominor.yy42->notToBeCompleted(); if(tree->outputType == OutputType::OUTPUT_ALCHEMY){ - cout<toString(yymsp[-2].minor.yy0->toString()+SPACE, false); + cout<toString(yymsp[-2].minor.yy0->toString()+SPACE, false); } else if(tree->outputType == OutputType::OUTPUT_ASP){ - std::string str = yygotominor.yy24->toString(":~ ", false); - std::string temp = yygotominor.yy24->getExtra(tree->variables); + std::string str = yygotominor.yy42->toString(":~ ", false); + std::string temp = yygotominor.yy42->getExtra(tree->variables); if(temp.length() > 0) str += ","; str += " [" + @@ -1788,65 +1810,54 @@ static void yy_reduce( "," + std::to_string(tree->weak_constraint_counter++) + "," + - yygotominor.yy24->getExtraConstants() + + yygotominor.yy42->getExtraConstants() + "]\n"; cout<getPredicate(); - yygotominor.yy24->notToBeCompleted(); + yygotominor.yy42 = new Predicate; + *yygotominor.yy42 = yymsp[-1].minor.yy43->getPredicate(); + yygotominor.yy42->notToBeCompleted(); tree->statHasDblNeg = true; std::string s1; if(tree->outputType == OutputType::OUTPUT_ALCHEMY){ - cout<toString(s1, false); + cout<toString(s1, false); } else if(tree->outputType == OutputType::OUTPUT_ASP){ - cout<toString(":- not ", true); + cout<toString(":- not ", true); } - delete yymsp[-1].minor.yy72; + delete yymsp[-1].minor.yy43; } -#line 1822 "MVSMParserGrammar.c" break; - case 51: /* variables ::= variable */ -#line 952 "MVSMParserGrammar.y" + case 58: /* variables ::= variable */ { - yygotominor.yy43 = new std::vector(); - yygotominor.yy43->push_back(yymsp[0].minor.yy0->token); + yygotominor.yy85 = new std::vector(); + yygotominor.yy85->push_back(yymsp[0].minor.yy0->token); } -#line 1830 "MVSMParserGrammar.c" break; - case 52: /* variables ::= variables COMMA variable */ -#line 957 "MVSMParserGrammar.y" + case 59: /* variables ::= variables COMMA variable */ { - yygotominor.yy43 = yymsp[-2].minor.yy43; - yymsp[-2].minor.yy43->push_back(yymsp[0].minor.yy0->token); + yygotominor.yy85 = yymsp[-2].minor.yy85; + yymsp[-2].minor.yy85->push_back(yymsp[0].minor.yy0->token); } -#line 1838 "MVSMParserGrammar.c" break; - case 53: /* variable ::= string */ - case 54: /* variable ::= number */ yytestcase(yyruleno==54); - case 55: /* string ::= STRING */ yytestcase(yyruleno==55); -#line 962 "MVSMParserGrammar.y" + case 60: /* variable ::= string */ + case 61: /* variable ::= number */ yytestcase(yyruleno==61); + case 62: /* string ::= STRING */ yytestcase(yyruleno==62); { yygotominor.yy0=yymsp[0].minor.yy0;} -#line 1845 "MVSMParserGrammar.c" break; - case 56: /* number ::= NUMBER */ -#line 970 "MVSMParserGrammar.y" + case 63: /* number ::= NUMBER */ { yygotominor.yy0=yymsp[0].minor.yy0; } -#line 1850 "MVSMParserGrammar.c" break; default: /* (0) start ::= prog */ yytestcase(yyruleno==0); @@ -1909,11 +1920,9 @@ static void yy_parse_failed( /* Here code is inserted which will be executed whenever the ** parser fails */ /************ Begin %parse_failure code ***************************************/ -#line 65 "MVSMParserGrammar.y" std::cout<<"Giving up.Parser is lost...\n"; -#line 1917 "MVSMParserGrammar.c" /************ End %parse_failure code *****************************************/ MVSMParserGrammarARG_STORE; /* Suppress warning about unused %extra_argument variable */ } @@ -1930,7 +1939,6 @@ static void yy_syntax_error( MVSMParserGrammarARG_FETCH; #define TOKEN (yyminor.yy0) /************ Begin %syntax_error code ****************************************/ -#line 70 "MVSMParserGrammar.y" // std::cout << ; int n = sizeof(yyTokenName) / sizeof(yyTokenName[0]); @@ -1945,7 +1953,6 @@ static void yy_syntax_error( } throw syntax_exception("Parsing Failed. Unexpected sequence of tokens\n"); -#line 1949 "MVSMParserGrammar.c" /************ End %syntax_error code ******************************************/ MVSMParserGrammarARG_STORE; /* Suppress warning about unused %extra_argument variable */ } @@ -1966,13 +1973,11 @@ static void yy_accept( /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ -#line 57 "MVSMParserGrammar.y" if (tree->outputType == OutputType::OUTPUT_ASP) std::cout<<("%parsing complete!\n"); else std::cout<<("//parsing complete!\n"); -#line 1976 "MVSMParserGrammar.c" /*********** End %parse_accept code *******************************************/ MVSMParserGrammarARG_STORE; /* Suppress warning about unused %extra_argument variable */ } diff --git a/src/src/MVSMParserGrammar.out b/src/src/MVSMParserGrammar.out index af8cc1f..168eeef 100644 --- a/src/src/MVSMParserGrammar.out +++ b/src/src/MVSMParserGrammar.out @@ -29,6 +29,7 @@ State 0: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN predicate ::= * literal DOT predicate ::= * number literal predicate ::= * number NEGATION NEGATION literal @@ -41,19 +42,19 @@ State 0: REVERSE_IMPLICATION shift 10 LPAREN shift 4 - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 18 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER start accept - prog shift 41 + prog shift 49 predicate shift-reduce 19 prog ::= predicate - string shift 42 + string shift 50 rule shift-reduce 21 prog ::= rule bodydef shift-reduce 34 head ::= bodydef - head shift 46 + head shift 54 number shift 2 - literal shift 64 + literal shift 76 variable shift-reduce 45 literal ::= variable {default} reduce 23 prog ::= @@ -81,6 +82,7 @@ State 1: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN predicate ::= * literal DOT predicate ::= * number literal predicate ::= * number NEGATION NEGATION literal @@ -93,17 +95,17 @@ State 1: REVERSE_IMPLICATION shift 10 LPAREN shift 4 - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 18 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER predicate shift-reduce 18 prog ::= prog NEWLINE predicate - string shift 42 + string shift 50 rule shift-reduce 20 prog ::= prog NEWLINE rule bodydef shift-reduce 34 head ::= bodydef - head shift 46 + head shift 54 number shift 2 - literal shift 64 + literal shift 76 variable shift-reduce 45 literal ::= variable {default} reduce 22 prog ::= prog NEWLINE @@ -124,28 +126,29 @@ State 2: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN predicate ::= number * literal predicate ::= number * NEGATION NEGATION literal predicate ::= number * NEGATION literal variable ::= * string variable ::= * number - (54) variable ::= number * + (61) variable ::= number * string ::= * STRING number ::= * NUMBER REVERSE_IMPLICATION shift 9 - REVERSE_IMPLICATION reduce 54 ** Parsing conflict ** - LBRACKET shift 72 + REVERSE_IMPLICATION reduce 61 ** Parsing conflict ** + LBRACKET shift 84 NEGATION shift 20 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 bodydef shift-reduce 34 head ::= bodydef - head shift 53 - number shift-reduce 54 variable ::= number - literal shift 47 + head shift 61 + number shift-reduce 61 variable ::= number + literal shift 55 variable shift-reduce 45 literal ::= variable - {default} reduce 54 variable ::= number + {default} reduce 61 variable ::= number State 3: rule ::= LPAREN head RPAREN REVERSE_IMPLICATION * body DOT @@ -161,19 +164,20 @@ State 3: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 - body shift 43 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 + body shift 51 bodydef shift-reduce 35 body ::= bodydef - number shift-reduce 54 variable ::= number + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -191,19 +195,20 @@ State 4: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 bodydef shift-reduce 34 head ::= bodydef - head shift 44 - number shift-reduce 54 variable ::= number + head shift 52 + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -221,19 +226,20 @@ State 5: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 - body shift 45 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 + body shift 53 bodydef shift-reduce 35 body ::= bodydef - number shift-reduce 54 variable ::= number + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -251,19 +257,20 @@ State 6: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 - body shift 50 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 + body shift 58 bodydef shift-reduce 35 body ::= bodydef - number shift-reduce 54 variable ::= number + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -281,19 +288,20 @@ State 7: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 bodydef shift-reduce 34 head ::= bodydef - head shift 51 - number shift-reduce 54 variable ::= number + head shift 59 + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -311,19 +319,20 @@ State 8: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 - body shift 67 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 + body shift 79 bodydef shift-reduce 35 body ::= bodydef - number shift-reduce 54 variable ::= number + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -341,19 +350,20 @@ State 9: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 - body shift 68 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 + body shift 80 bodydef shift-reduce 35 body ::= bodydef - number shift-reduce 54 variable ::= number + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -371,19 +381,20 @@ State 10: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 - body shift 56 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 + body shift 68 bodydef shift-reduce 35 body ::= bodydef - number shift-reduce 54 variable ::= number + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -401,14 +412,14 @@ State 11: number ::= * NUMBER NEWLINE shift 11 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - variables shift 60 - string shift-reduce 53 variable ::= string + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + variables shift 72 + string shift-reduce 60 variable ::= string objectdecl shift-reduce 8 objectdecl ::= NEWLINE objectdecl - object shift 61 - number shift-reduce 54 variable ::= number - variable shift-reduce 51 variables ::= variable + object shift 73 + number shift-reduce 61 variable ::= number + variable shift-reduce 58 variables ::= variable State 12: objectdecl ::= * object SEMI_COLON objectdecl @@ -424,14 +435,14 @@ State 12: number ::= * NUMBER NEWLINE shift 11 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - variables shift 60 - string shift-reduce 53 variable ::= string + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + variables shift 72 + string shift-reduce 60 variable ::= string objectdecl shift-reduce 6 objectdecl ::= object SEMI_COLON objectdecl - object shift 61 - number shift-reduce 54 variable ::= number - variable shift-reduce 51 variables ::= variable + object shift 73 + number shift-reduce 61 variable ::= number + variable shift-reduce 58 variables ::= variable State 13: prog ::= prog OBJECTS * objectdecl @@ -447,14 +458,14 @@ State 13: number ::= * NUMBER NEWLINE shift 11 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - variables shift 60 - string shift-reduce 53 variable ::= string + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + variables shift 72 + string shift-reduce 60 variable ::= string objectdecl shift-reduce 5 prog ::= prog OBJECTS objectdecl - object shift 61 - number shift-reduce 54 variable ::= number - variable shift-reduce 51 variables ::= variable + object shift 73 + number shift-reduce 61 variable ::= number + variable shift-reduce 58 variables ::= variable State 14: rule ::= head DISJUNCTION * bodydef DOT @@ -469,18 +480,19 @@ State 14: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 - bodydef shift 66 - number shift-reduce 54 variable ::= number + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 + bodydef shift 78 + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -496,18 +508,19 @@ State 15: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 bodydef shift-reduce 33 head ::= head DISJUNCTION bodydef - number shift-reduce 54 variable ::= number + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -524,18 +537,19 @@ State 16: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 - bodydef shift 52 - number shift-reduce 54 variable ::= number + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 + bodydef shift 60 + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -551,18 +565,19 @@ State 17: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - LBRACKET shift 72 + LBRACKET shift 84 NEGATION shift 21 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 42 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 50 bodydef shift-reduce 32 body ::= body CONJUNCTION bodydef - number shift-reduce 54 variable ::= number + number shift-reduce 61 variable ::= number literal shift-reduce 36 bodydef ::= literal variable shift-reduce 45 literal ::= variable @@ -573,6 +588,7 @@ State 18: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN predicate ::= NEGATION * NEGATION literal DOT variable ::= * string variable ::= * number @@ -580,10 +596,10 @@ State 18: number ::= * NUMBER NEGATION shift 22 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 54 - number shift-reduce 54 variable ::= number + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 62 + number shift-reduce 61 variable ::= number literal shift-reduce 37 bodydef ::= NEGATION literal variable shift-reduce 45 literal ::= variable @@ -593,6 +609,7 @@ State 19: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN predicate ::= number NEGATION NEGATION * literal variable ::= * string variable ::= * number @@ -600,11 +617,11 @@ State 19: number ::= * NUMBER LBRACKET shift 7 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 74 - number shift-reduce 54 variable ::= number - literal shift 49 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift 57 variable shift-reduce 45 literal ::= variable State 20: @@ -615,6 +632,7 @@ State 20: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN predicate ::= number NEGATION * NEGATION literal predicate ::= number NEGATION * literal variable ::= * string @@ -623,11 +641,11 @@ State 20: number ::= * NUMBER NEGATION shift 19 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 54 - number shift-reduce 54 variable ::= number - literal shift 48 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 62 + number shift-reduce 61 variable ::= number + literal shift 56 variable shift-reduce 45 literal ::= variable State 21: @@ -637,16 +655,17 @@ State 21: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - NEGATION shift 25 - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 54 - number shift-reduce 54 variable ::= number + NEGATION shift 32 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 62 + number shift-reduce 61 variable ::= number literal shift-reduce 37 bodydef ::= NEGATION literal variable shift-reduce 45 literal ::= variable @@ -655,17 +674,18 @@ State 22: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN predicate ::= NEGATION NEGATION * literal DOT variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 74 - number shift-reduce 54 variable ::= number - literal shift 63 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift 75 variable shift-reduce 45 literal ::= variable State 23: @@ -673,19 +693,146 @@ State 23: literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 74 - number shift-reduce 54 variable ::= number - literal shift 70 + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift 82 variable shift-reduce 45 literal ::= variable State 24: + literal ::= * string LBRACKET variables RBRACKET EQUAL variable + literal ::= * string LBRACKET variables RBRACKET + literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN + aggregate ::= number COMMA literal COLON * literal + variable ::= * string + variable ::= * number + string ::= * STRING + number ::= * NUMBER + + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift-reduce 50 aggregate ::= number COMMA literal COLON literal + variable shift-reduce 45 literal ::= variable + +State 25: + literal ::= * string LBRACKET variables RBRACKET EQUAL variable + literal ::= * string LBRACKET variables RBRACKET + literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN + aggregate ::= number COMMA * literal COLON literal + variable ::= * string + variable ::= * number + string ::= * STRING + number ::= * NUMBER + + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift 85 + variable shift-reduce 45 literal ::= variable + +State 26: + literal ::= * string LBRACKET variables RBRACKET EQUAL variable + literal ::= * string LBRACKET variables RBRACKET + literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN + aggregate ::= number COLON * literal + variable ::= * string + variable ::= * number + string ::= * STRING + number ::= * NUMBER + + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift-reduce 48 aggregate ::= number COLON literal + variable shift-reduce 45 literal ::= variable + +State 27: + literal ::= * string LBRACKET variables RBRACKET EQUAL variable + literal ::= * string LBRACKET variables RBRACKET + literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN + aggregate ::= string COMMA literal COLON * literal + variable ::= * string + variable ::= * number + string ::= * STRING + number ::= * NUMBER + + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift-reduce 49 aggregate ::= string COMMA literal COLON literal + variable shift-reduce 45 literal ::= variable + +State 28: + literal ::= * string LBRACKET variables RBRACKET EQUAL variable + literal ::= * string LBRACKET variables RBRACKET + literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN + aggregate ::= string COMMA * literal COLON literal + variable ::= * string + variable ::= * number + string ::= * STRING + number ::= * NUMBER + + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift 86 + variable shift-reduce 45 literal ::= variable + +State 29: + literal ::= * string LBRACKET variables RBRACKET EQUAL variable + literal ::= * string LBRACKET variables RBRACKET + literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN + aggregate ::= string COLON * literal + variable ::= * string + variable ::= * number + string ::= * STRING + number ::= * NUMBER + + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number + literal shift-reduce 47 aggregate ::= string COLON literal + variable shift-reduce 45 literal ::= variable + +State 30: + literal ::= string EQUAL COUNT LPAREN * aggregateCum RPAREN + aggregate ::= * string COLON literal + aggregate ::= * number COLON literal + aggregate ::= * string COMMA literal COLON literal + aggregate ::= * number COMMA literal COLON literal + aggregateCum ::= * aggregate + aggregateCum ::= * aggregateCum SEMI_COLON aggregate + string ::= * STRING + number ::= * NUMBER + + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 64 + number shift 63 + aggregateCum shift 65 + aggregate shift-reduce 51 aggregateCum ::= aggregate + +State 31: literal ::= string LBRACKET * variables RBRACKET EQUAL variable literal ::= string LBRACKET * variables RBRACKET variables ::= * variable @@ -695,31 +842,32 @@ State 24: string ::= * STRING number ::= * NUMBER - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - variables shift 55 - string shift-reduce 53 variable ::= string - number shift-reduce 54 variable ::= number - variable shift-reduce 51 variables ::= variable + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + variables shift 66 + string shift-reduce 60 variable ::= string + number shift-reduce 61 variable ::= number + variable shift-reduce 58 variables ::= variable -State 25: +State 32: bodydef ::= NEGATION NEGATION * literal literal ::= * string LBRACKET variables RBRACKET EQUAL variable literal ::= * string LBRACKET variables RBRACKET literal ::= * variable + literal ::= * string EQUAL COUNT LPAREN aggregateCum RPAREN variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift 74 - number shift-reduce 54 variable ::= number + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 67 + number shift-reduce 61 variable ::= number literal shift-reduce 38 bodydef ::= NEGATION NEGATION literal variable shift-reduce 45 literal ::= variable -State 26: +State 33: constant ::= string LBRACKET * variables RBRACKET COLON COLON string constant ::= string LBRACKET * variables RBRACKET variables ::= * variable @@ -729,27 +877,42 @@ State 26: string ::= * STRING number ::= * NUMBER - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - variables shift 57 - string shift-reduce 53 variable ::= string - number shift-reduce 54 variable ::= number - variable shift-reduce 51 variables ::= variable + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + variables shift 69 + string shift-reduce 60 variable ::= string + number shift-reduce 61 variable ::= number + variable shift-reduce 58 variables ::= variable -State 27: +State 34: + aggregate ::= * string COLON literal + aggregate ::= * number COLON literal + aggregate ::= * string COMMA literal COLON literal + aggregate ::= * number COMMA literal COLON literal + aggregateCum ::= aggregateCum SEMI_COLON * aggregate + string ::= * STRING + number ::= * NUMBER + + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift 64 + number shift 63 + aggregate shift-reduce 52 aggregateCum ::= aggregateCum SEMI_COLON aggregate + +State 35: literal ::= string LBRACKET variables RBRACKET EQUAL * variable variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift-reduce 53 variable ::= string - number shift-reduce 54 variable ::= number + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift-reduce 60 variable ::= string + number shift-reduce 61 variable ::= number variable shift-reduce 43 literal ::= string LBRACKET variables RBRACKET EQUAL variable -State 28: +State 36: constantdecl ::= * constant SEMI_COLON constantdecl constantdecl ::= * constant DOT constantdecl ::= * NEWLINE constantdecl @@ -760,13 +923,13 @@ State 28: constant ::= * string COLON COLON string string ::= * STRING - NEWLINE shift 28 - STRING shift-reduce 55 string ::= STRING - string shift 58 + NEWLINE shift 36 + STRING shift-reduce 62 string ::= STRING + string shift 70 constantdecl shift-reduce 13 constantdecl ::= NEWLINE constantdecl - constant shift 59 + constant shift 71 -State 29: +State 37: constantdecl ::= * constant SEMI_COLON constantdecl constantdecl ::= constant SEMI_COLON * constantdecl constantdecl ::= * constant DOT @@ -777,13 +940,13 @@ State 29: constant ::= * string COLON COLON string string ::= * STRING - NEWLINE shift 28 - STRING shift-reduce 55 string ::= STRING - string shift 58 + NEWLINE shift 36 + STRING shift-reduce 62 string ::= STRING + string shift 70 constantdecl shift-reduce 11 constantdecl ::= constant SEMI_COLON constantdecl - constant shift 59 + constant shift 71 -State 30: +State 38: prog ::= prog CONSTANTS * constantdecl constantdecl ::= * constant SEMI_COLON constantdecl constantdecl ::= * constant DOT @@ -794,104 +957,108 @@ State 30: constant ::= * string COLON COLON string string ::= * STRING - NEWLINE shift 28 - STRING shift-reduce 55 string ::= STRING - string shift 58 + NEWLINE shift 36 + STRING shift-reduce 62 string ::= STRING + string shift 70 constantdecl shift-reduce 10 prog ::= prog CONSTANTS constantdecl - constant shift 59 + constant shift 71 -State 31: +State 39: variables ::= variables COMMA * variable variable ::= * string variable ::= * number string ::= * STRING number ::= * NUMBER - STRING shift-reduce 55 string ::= STRING - NUMBER shift-reduce 56 number ::= NUMBER - string shift-reduce 53 variable ::= string - number shift-reduce 54 variable ::= number - variable shift-reduce 52 variables ::= variables COMMA variable + STRING shift-reduce 62 string ::= STRING + NUMBER shift-reduce 63 number ::= NUMBER + string shift-reduce 60 variable ::= string + number shift-reduce 61 variable ::= number + variable shift-reduce 59 variables ::= variables COMMA variable -State 32: +State 40: sortdecl ::= * string SEMI_COLON sortdecl sortdecl ::= * NEWLINE sortdecl sortdecl ::= NEWLINE * sortdecl sortdecl ::= * string DOT string ::= * STRING - NEWLINE shift 32 - STRING shift-reduce 55 string ::= STRING + NEWLINE shift 40 + STRING shift-reduce 62 string ::= STRING sortdecl shift-reduce 3 sortdecl ::= NEWLINE sortdecl - string shift 62 + string shift 74 -State 33: +State 41: sortdecl ::= * string SEMI_COLON sortdecl sortdecl ::= string SEMI_COLON * sortdecl sortdecl ::= * NEWLINE sortdecl sortdecl ::= * string DOT string ::= * STRING - NEWLINE shift 32 - STRING shift-reduce 55 string ::= STRING + NEWLINE shift 40 + STRING shift-reduce 62 string ::= STRING sortdecl shift-reduce 2 sortdecl ::= string SEMI_COLON sortdecl - string shift 62 + string shift 74 -State 34: +State 42: prog ::= prog SORTS * sortdecl sortdecl ::= * string SEMI_COLON sortdecl sortdecl ::= * NEWLINE sortdecl sortdecl ::= * string DOT string ::= * STRING - NEWLINE shift 32 - STRING shift-reduce 55 string ::= STRING + NEWLINE shift 40 + STRING shift-reduce 62 string ::= STRING sortdecl shift-reduce 1 prog ::= prog SORTS sortdecl - string shift 62 - -State 35: - bodydef ::= string NEGATION EQUAL * string - string ::= * STRING - - STRING shift-reduce 55 string ::= STRING - string shift-reduce 42 bodydef ::= string NEGATION EQUAL string + string shift 74 -State 36: +State 43: bodydef ::= string EQUAL * string + literal ::= string EQUAL * COUNT LPAREN aggregateCum RPAREN string ::= * STRING - STRING shift-reduce 55 string ::= STRING + COUNT shift 87 + STRING shift-reduce 62 string ::= STRING string shift-reduce 40 bodydef ::= string EQUAL string -State 37: +State 44: bodydef ::= NEGATION string EQUAL * string + literal ::= string EQUAL * COUNT LPAREN aggregateCum RPAREN string ::= * STRING - STRING shift-reduce 55 string ::= STRING + COUNT shift 87 + STRING shift-reduce 62 string ::= STRING string shift-reduce 41 bodydef ::= NEGATION string EQUAL string -State 38: +State 45: + bodydef ::= string NEGATION EQUAL * string + string ::= * STRING + + STRING shift-reduce 62 string ::= STRING + string shift-reduce 42 bodydef ::= string NEGATION EQUAL string + +State 46: constant ::= string COLON COLON * string string ::= * STRING - STRING shift-reduce 55 string ::= STRING + STRING shift-reduce 62 string ::= STRING string shift-reduce 17 constant ::= string COLON COLON string -State 39: +State 47: constant ::= string LBRACKET variables RBRACKET COLON COLON * string string ::= * STRING - STRING shift-reduce 55 string ::= STRING + STRING shift-reduce 62 string ::= STRING string shift-reduce 14 constant ::= string LBRACKET variables RBRACKET COLON COLON string -State 40: +State 48: object ::= variables COLON COLON * string string ::= * STRING - STRING shift-reduce 55 string ::= STRING + STRING shift-reduce 62 string ::= STRING string shift-reduce 9 object ::= variables COLON COLON string -State 41: +State 49: (0) start ::= prog * prog ::= prog * SORTS sortdecl prog ::= prog * OBJECTS objectdecl @@ -902,44 +1069,45 @@ State 41: $ reduce 0 start ::= prog NEWLINE shift 1 - SORTS shift 34 + SORTS shift 42 OBJECTS shift 13 - CONSTANTS shift 30 + CONSTANTS shift 38 -State 42: +State 50: bodydef ::= string * EQUAL string bodydef ::= string * NEGATION EQUAL string literal ::= string * LBRACKET variables RBRACKET EQUAL variable literal ::= string * LBRACKET variables RBRACKET - (53) variable ::= string * + literal ::= string * EQUAL COUNT LPAREN aggregateCum RPAREN + (60) variable ::= string * - EQUAL shift 36 - LBRACKET shift 24 - NEGATION shift 69 - {default} reduce 53 variable ::= string + EQUAL shift 43 + LBRACKET shift 31 + NEGATION shift 81 + {default} reduce 60 variable ::= string -State 43: +State 51: rule ::= LPAREN head RPAREN REVERSE_IMPLICATION body * DOT body ::= body * CONJUNCTION bodydef CONJUNCTION shift 17 DOT shift-reduce 31 rule ::= LPAREN head RPAREN REVERSE_IMPLICATION body DOT -State 44: +State 52: rule ::= LPAREN head * RPAREN REVERSE_IMPLICATION body DOT head ::= head * DISJUNCTION bodydef - RPAREN shift 65 + RPAREN shift 77 DISJUNCTION shift 15 -State 45: +State 53: rule ::= head REVERSE_IMPLICATION body * DOT body ::= body * CONJUNCTION bodydef CONJUNCTION shift 17 DOT shift-reduce 28 rule ::= head REVERSE_IMPLICATION body DOT -State 46: +State 54: rule ::= head * DISJUNCTION bodydef DOT rule ::= head * REVERSE_IMPLICATION body DOT head ::= head * DISJUNCTION bodydef @@ -947,45 +1115,45 @@ State 46: REVERSE_IMPLICATION shift 5 DISJUNCTION shift 14 -State 47: +State 55: (36) bodydef ::= literal * - (47) predicate ::= number literal * + (54) predicate ::= number literal * REVERSE_IMPLICATION reduce 36 bodydef ::= literal DISJUNCTION reduce 36 bodydef ::= literal - {default} reduce 47 predicate ::= number literal + {default} reduce 54 predicate ::= number literal -State 48: +State 56: (37) bodydef ::= NEGATION literal * - (49) predicate ::= number NEGATION literal * + (56) predicate ::= number NEGATION literal * REVERSE_IMPLICATION reduce 37 bodydef ::= NEGATION literal DISJUNCTION reduce 37 bodydef ::= NEGATION literal - {default} reduce 49 predicate ::= number NEGATION literal + {default} reduce 56 predicate ::= number NEGATION literal -State 49: +State 57: (38) bodydef ::= NEGATION NEGATION literal * - (48) predicate ::= number NEGATION NEGATION literal * + (55) predicate ::= number NEGATION NEGATION literal * REVERSE_IMPLICATION reduce 38 bodydef ::= NEGATION NEGATION literal DISJUNCTION reduce 38 bodydef ::= NEGATION NEGATION literal - {default} reduce 48 predicate ::= number NEGATION NEGATION literal + {default} reduce 55 predicate ::= number NEGATION NEGATION literal -State 50: +State 58: rule ::= number NEGATION NEGATION LBRACKET head REVERSE_IMPLICATION body * RBRACKET body ::= body * CONJUNCTION bodydef CONJUNCTION shift 17 RBRACKET shift-reduce 30 rule ::= number NEGATION NEGATION LBRACKET head REVERSE_IMPLICATION body RBRACKET -State 51: +State 59: rule ::= number NEGATION NEGATION LBRACKET head * REVERSE_IMPLICATION body RBRACKET head ::= head * DISJUNCTION bodydef REVERSE_IMPLICATION shift 6 DISJUNCTION shift 15 -State 52: +State 60: (27) rule ::= number head DISJUNCTION bodydef * (33) head ::= head DISJUNCTION bodydef * @@ -993,7 +1161,7 @@ State 52: DISJUNCTION reduce 33 head ::= head DISJUNCTION bodydef {default} reduce 27 rule ::= number head DISJUNCTION bodydef -State 53: +State 61: rule ::= number head * DISJUNCTION bodydef rule ::= number head * REVERSE_IMPLICATION body head ::= head * DISJUNCTION bodydef @@ -1001,173 +1169,217 @@ State 53: REVERSE_IMPLICATION shift 8 DISJUNCTION shift 16 -State 54: +State 62: bodydef ::= NEGATION string * EQUAL string literal ::= string * LBRACKET variables RBRACKET EQUAL variable literal ::= string * LBRACKET variables RBRACKET - (53) variable ::= string * + literal ::= string * EQUAL COUNT LPAREN aggregateCum RPAREN + (60) variable ::= string * - EQUAL shift 37 - LBRACKET shift 24 - {default} reduce 53 variable ::= string + EQUAL shift 44 + LBRACKET shift 31 + {default} reduce 60 variable ::= string -State 55: +State 63: + aggregate ::= number * COLON literal + aggregate ::= number * COMMA literal COLON literal + + COMMA shift 25 + COLON shift 26 + +State 64: + aggregate ::= string * COLON literal + aggregate ::= string * COMMA literal COLON literal + + COMMA shift 28 + COLON shift 29 + +State 65: + literal ::= string EQUAL COUNT LPAREN aggregateCum * RPAREN + aggregateCum ::= aggregateCum * SEMI_COLON aggregate + + RPAREN shift-reduce 46 literal ::= string EQUAL COUNT LPAREN aggregateCum RPAREN + SEMI_COLON shift 34 + +State 66: literal ::= string LBRACKET variables * RBRACKET EQUAL variable literal ::= string LBRACKET variables * RBRACKET variables ::= variables * COMMA variable - COMMA shift 31 - RBRACKET shift 73 + COMMA shift 39 + RBRACKET shift 89 -State 56: +State 67: + literal ::= string * LBRACKET variables RBRACKET EQUAL variable + literal ::= string * LBRACKET variables RBRACKET + literal ::= string * EQUAL COUNT LPAREN aggregateCum RPAREN + (60) variable ::= string * + + EQUAL shift 88 + LBRACKET shift 31 + {default} reduce 60 variable ::= string + +State 68: rule ::= REVERSE_IMPLICATION body * DOT body ::= body * CONJUNCTION bodydef CONJUNCTION shift 17 DOT shift-reduce 24 rule ::= REVERSE_IMPLICATION body DOT -State 57: +State 69: constant ::= string LBRACKET variables * RBRACKET COLON COLON string constant ::= string LBRACKET variables * RBRACKET variables ::= variables * COMMA variable - COMMA shift 31 - RBRACKET shift 77 + COMMA shift 39 + RBRACKET shift 92 -State 58: +State 70: constant ::= string * LBRACKET variables RBRACKET COLON COLON string constant ::= string * LBRACKET variables RBRACKET (16) constant ::= string * constant ::= string * COLON COLON string - LBRACKET shift 26 - COLON shift 75 + LBRACKET shift 33 + COLON shift 90 {default} reduce 16 constant ::= string -State 59: +State 71: constantdecl ::= constant * SEMI_COLON constantdecl constantdecl ::= constant * DOT - SEMI_COLON shift 29 + SEMI_COLON shift 37 DOT shift-reduce 12 constantdecl ::= constant DOT -State 60: +State 72: object ::= variables * COLON COLON string variables ::= variables * COMMA variable - COMMA shift 31 - COLON shift 78 + COMMA shift 39 + COLON shift 93 -State 61: +State 73: objectdecl ::= object * SEMI_COLON objectdecl objectdecl ::= object * DOT SEMI_COLON shift 12 DOT shift-reduce 7 objectdecl ::= object DOT -State 62: +State 74: sortdecl ::= string * SEMI_COLON sortdecl sortdecl ::= string * DOT - SEMI_COLON shift 33 + SEMI_COLON shift 41 DOT shift-reduce 4 sortdecl ::= string DOT -State 63: +State 75: (38) bodydef ::= NEGATION NEGATION literal * predicate ::= NEGATION NEGATION literal * DOT - DOT shift-reduce 50 predicate ::= NEGATION NEGATION literal DOT + DOT shift-reduce 57 predicate ::= NEGATION NEGATION literal DOT {default} reduce 38 bodydef ::= NEGATION NEGATION literal -State 64: +State 76: (36) bodydef ::= literal * predicate ::= literal * DOT - DOT shift-reduce 46 predicate ::= literal DOT + DOT shift-reduce 53 predicate ::= literal DOT {default} reduce 36 bodydef ::= literal -State 65: +State 77: rule ::= LPAREN head RPAREN * REVERSE_IMPLICATION body DOT REVERSE_IMPLICATION shift 3 -State 66: +State 78: rule ::= head DISJUNCTION bodydef * DOT (33) head ::= head DISJUNCTION bodydef * DOT shift-reduce 26 rule ::= head DISJUNCTION bodydef DOT {default} reduce 33 head ::= head DISJUNCTION bodydef -State 67: +State 79: (29) rule ::= number head REVERSE_IMPLICATION body * body ::= body * CONJUNCTION bodydef CONJUNCTION shift 17 {default} reduce 29 rule ::= number head REVERSE_IMPLICATION body -State 68: +State 80: (25) rule ::= number REVERSE_IMPLICATION body * body ::= body * CONJUNCTION bodydef CONJUNCTION shift 17 {default} reduce 25 rule ::= number REVERSE_IMPLICATION body -State 69: +State 81: bodydef ::= string NEGATION * EQUAL string - EQUAL shift 35 + EQUAL shift 45 -State 70: +State 82: bodydef ::= LBRACKET NEGATION NEGATION literal * RBRACKET RBRACKET shift-reduce 39 bodydef ::= LBRACKET NEGATION NEGATION literal RBRACKET -State 71: +State 83: bodydef ::= LBRACKET NEGATION * NEGATION literal RBRACKET NEGATION shift 23 -State 72: +State 84: bodydef ::= LBRACKET * NEGATION NEGATION literal RBRACKET - NEGATION shift 71 + NEGATION shift 83 -State 73: +State 85: + aggregate ::= number COMMA literal * COLON literal + + COLON shift 24 + +State 86: + aggregate ::= string COMMA literal * COLON literal + + COLON shift 27 + +State 87: + literal ::= string EQUAL COUNT * LPAREN aggregateCum RPAREN + + LPAREN shift 30 + +State 88: + literal ::= string EQUAL * COUNT LPAREN aggregateCum RPAREN + + COUNT shift 87 + +State 89: literal ::= string LBRACKET variables RBRACKET * EQUAL variable (44) literal ::= string LBRACKET variables RBRACKET * - EQUAL shift 27 + EQUAL shift 35 {default} reduce 44 literal ::= string LBRACKET variables RBRACKET -State 74: - literal ::= string * LBRACKET variables RBRACKET EQUAL variable - literal ::= string * LBRACKET variables RBRACKET - (53) variable ::= string * - - LBRACKET shift 24 - {default} reduce 53 variable ::= string - -State 75: +State 90: constant ::= string COLON * COLON string - COLON shift 38 + COLON shift 46 -State 76: +State 91: constant ::= string LBRACKET variables RBRACKET COLON * COLON string - COLON shift 39 + COLON shift 47 -State 77: +State 92: constant ::= string LBRACKET variables RBRACKET * COLON COLON string (15) constant ::= string LBRACKET variables RBRACKET * - COLON shift 76 + COLON shift 91 {default} reduce 15 constant ::= string LBRACKET variables RBRACKET -State 78: +State 93: object ::= variables COLON * COLON string - COLON shift 40 + COLON shift 48 ---------------------------------------------------- Symbols: @@ -1191,25 +1403,28 @@ Symbols: 17: OBJECTS 18: COLON 19: CONSTANTS - 20: STRING - 21: NUMBER - 22: error: - 23: start: REVERSE_IMPLICATION LPAREN NEWLINE LBRACKET SORTS NEGATION OBJECTS CONSTANTS STRING NUMBER - 24: prog: REVERSE_IMPLICATION LPAREN NEWLINE LBRACKET SORTS NEGATION OBJECTS CONSTANTS STRING NUMBER - 25: predicate: NEGATION STRING NUMBER - 26: decl: - 27: variables: STRING NUMBER - 28: sortdecl: NEWLINE STRING - 29: string: STRING - 30: objectdecl: NEWLINE STRING NUMBER - 31: object: STRING NUMBER - 32: constantdecl: NEWLINE STRING - 33: constant: STRING - 34: rule: REVERSE_IMPLICATION LPAREN LBRACKET NEGATION STRING NUMBER - 35: body: LBRACKET NEGATION STRING NUMBER - 36: bodydef: LBRACKET NEGATION STRING NUMBER - 37: bodydef2: - 38: head: LBRACKET NEGATION STRING NUMBER - 39: number: NUMBER - 40: literal: STRING NUMBER - 41: variable: STRING NUMBER + 20: COUNT + 21: STRING + 22: NUMBER + 23: error: + 24: start: REVERSE_IMPLICATION LPAREN NEWLINE LBRACKET SORTS NEGATION OBJECTS CONSTANTS STRING NUMBER + 25: prog: REVERSE_IMPLICATION LPAREN NEWLINE LBRACKET SORTS NEGATION OBJECTS CONSTANTS STRING NUMBER + 26: predicate: NEGATION STRING NUMBER + 27: decl: + 28: variables: STRING NUMBER + 29: sortdecl: NEWLINE STRING + 30: string: STRING + 31: objectdecl: NEWLINE STRING NUMBER + 32: object: STRING NUMBER + 33: constantdecl: NEWLINE STRING + 34: constant: STRING + 35: rule: REVERSE_IMPLICATION LPAREN LBRACKET NEGATION STRING NUMBER + 36: body: LBRACKET NEGATION STRING NUMBER + 37: bodydef: LBRACKET NEGATION STRING NUMBER + 38: bodydef2: + 39: head: LBRACKET NEGATION STRING NUMBER + 40: number: NUMBER + 41: literal: STRING NUMBER + 42: variable: STRING NUMBER + 43: aggregateCum: STRING NUMBER + 44: aggregate: STRING NUMBER diff --git a/src/src/MVSMParserGrammar.y b/src/src/MVSMParserGrammar.y index 2e43d61..e3b3f0b 100644 --- a/src/src/MVSMParserGrammar.y +++ b/src/src/MVSMParserGrammar.y @@ -22,6 +22,7 @@ #include "Body.h" #include "BodyDef.h" #include "LanguageConstants.h" + #include "Util.h" #include "exceptions/undefined_predicate.h" @@ -635,6 +636,7 @@ body(B) ::= bodydef(Bd).{ // BodyDef without negation in front bodydef(B) ::= literal(L).{ + B = L; } @@ -784,6 +786,66 @@ literal(L) ::= variable(V).{ L->addPredicate(p); } +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); + + L->addPredicate(p); +} + + +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); +} + +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); +} + +aggregate(A) ::= string(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); +} + + +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); +} + +aggregateCum(A) ::= aggregate(A1).{ + A = new Token(*(A1->token)); + delete A1; +} + +aggregateCum(A) ::= aggregateCum(A1) SEMI_COLON aggregate(A2).{ + A = A1; + A->modifyToken(A1->toString() + ";" + A2->toString()); + delete A2; +} + predicate(P) ::= literal(L) DOT.{ P = new Predicate; diff --git a/src/src/Predicate.cpp b/src/src/Predicate.cpp index f948c49..b813b27 100644 --- a/src/src/Predicate.cpp +++ b/src/src/Predicate.cpp @@ -38,6 +38,11 @@ Predicate::~Predicate() } std::string Predicate::toString() const { + + if (isAggregate){ + return aggregateString; + } + std::string str; if(isEquality){