00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #define YYBISON 1
00025
00026
00027 #define YYBISON_VERSION "2.1"
00028
00029
00030 #define YYSKELETON_NAME "glr.c"
00031
00032
00033 #define YYPURE 0
00034
00035
00036 #define YYLSP_NEEDED 0
00037
00038
00039
00040
00041 #ifndef YYTOKENTYPE
00042 # define YYTOKENTYPE
00043
00044
00045 enum yytokentype {
00046 ZZ_NUM = 258,
00047 ZZ_DOTDOTDOT = 259,
00048 ZZ_STRING = 260,
00049 ZZ_EQEQ = 261,
00050 ZZ_INCLUDE = 262,
00051 ZZ_PREDICATE = 263,
00052 ZZ_FUNCTION = 264,
00053 ZZ_CONSTANT = 265,
00054 ZZ_VARIABLE = 266,
00055 ZZ_TYPE = 267,
00056 ZZ_FORALL = 268,
00057 ZZ_EXIST = 269,
00058 ZZ_EQUIV = 270,
00059 ZZ_IMPLY = 271
00060 };
00061 #endif
00062
00063 #define ZZ_NUM 258
00064 #define ZZ_DOTDOTDOT 259
00065 #define ZZ_STRING 260
00066 #define ZZ_EQEQ 261
00067 #define ZZ_INCLUDE 262
00068 #define ZZ_PREDICATE 263
00069 #define ZZ_FUNCTION 264
00070 #define ZZ_CONSTANT 265
00071 #define ZZ_VARIABLE 266
00072 #define ZZ_TYPE 267
00073 #define ZZ_FORALL 268
00074 #define ZZ_EXIST 269
00075 #define ZZ_EQUIV 270
00076 #define ZZ_IMPLY 271
00077
00078
00079
00080
00081
00082 #line 66 "../src/parser/fol.y"
00083
00084 #define YYSTYPE int
00085 #define YYDEBUG 1
00086
00087 #include "fol.h"
00088 #include "follex.cpp"
00089
00090
00091 int folDbg = 0;
00092
00093
00094
00095
00096
00097
00098 #ifndef YYDEBUG
00099 # define YYDEBUG 0
00100 #endif
00101
00102
00103 #ifdef YYERROR_VERBOSE
00104 # undef YYERROR_VERBOSE
00105 # define YYERROR_VERBOSE 1
00106 #else
00107 # define YYERROR_VERBOSE 1
00108 #endif
00109
00110
00111 #ifndef YYTOKEN_TABLE
00112 # define YYTOKEN_TABLE 0
00113 #endif
00114
00115 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
00116 typedef int YYSTYPE;
00117 # define YYSTYPE_IS_DECLARED 1
00118 # define YYSTYPE_IS_TRIVIAL 1
00119 #endif
00120
00121 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
00122 typedef struct YYLTYPE
00123 {
00124
00125 char yydummy;
00126
00127 } YYLTYPE;
00128 # define YYLTYPE_IS_DECLARED 1
00129 # define YYLTYPE_IS_TRIVIAL 1
00130 #endif
00131
00132
00133
00134
00135
00136
00137 static YYSTYPE yyval_default;
00138
00139
00140
00141
00142
00143 #line 144 "fol.cpp"
00144
00145 #include <stdio.h>
00146 #include <stdlib.h>
00147 #include <string.h>
00148 #include <stdarg.h>
00149
00150 #ifndef YY_
00151 # if YYENABLE_NLS
00152 # if ENABLE_NLS
00153 # include <libintl.h>
00154 # define YY_(msgid) dgettext ("bison-runtime", msgid)
00155 # endif
00156 # endif
00157 # ifndef YY_
00158 # define YY_(msgid) msgid
00159 # endif
00160 #endif
00161
00162 #ifndef YYFREE
00163 # define YYFREE free
00164 #endif
00165 #ifndef YYMALLOC
00166 # define YYMALLOC malloc
00167 #endif
00168 #ifndef YYREALLOC
00169 # define YYREALLOC realloc
00170 #endif
00171
00172 #define YYSIZEMAX ((size_t) -1)
00173
00174 #ifdef __cplusplus
00175 typedef bool yybool;
00176 #else
00177 typedef unsigned char yybool;
00178 #endif
00179 #define yytrue 1
00180 #define yyfalse 0
00181
00182 #ifndef YYSETJMP
00183 # include <setjmp.h>
00184 # define YYJMP_BUF jmp_buf
00185 # define YYSETJMP(env) setjmp (env)
00186 # define YYLONGJMP(env, val) longjmp (env, val)
00187 #endif
00188
00189
00190
00191
00192
00193 #ifndef __attribute__
00194
00195 # if (!defined (__GNUC__) || __GNUC__ < 2 \
00196 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
00197 # define __attribute__(Spec)
00198 # endif
00199 #endif
00200
00201
00202 #ifdef __cplusplus
00203 # define YYOPTIONAL_LOC(Name)
00204 #else
00205 # define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
00206 #endif
00207
00208 #ifndef YYASSERT
00209 # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
00210 #endif
00211
00212
00213 #define YYFINAL 2
00214
00215 #define YYLAST 205
00216
00217
00218 #define YYNTOKENS 38
00219
00220 #define YYNNTS 86
00221
00222 #define YYNRULES 154
00223
00224 #define YYNSTATES 215
00225
00226 #define YYMAXRHS 10
00227
00228
00229 #define YYMAXLEFT 0
00230
00231
00232 #define YYUNDEFTOK 2
00233 #define YYMAXUTOK 271
00234
00235 #define YYTRANSLATE(YYX) \
00236 ((YYX <= 0) ? YYEOF : \
00237 (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
00238
00239
00240 static const unsigned char yytranslate[] =
00241 {
00242 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00243 25, 2, 2, 28, 2, 2, 2, 2, 2, 2,
00244 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00245 2, 2, 2, 21, 2, 2, 2, 24, 2, 2,
00246 33, 34, 22, 14, 32, 13, 27, 23, 2, 2,
00247 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00248 37, 29, 36, 35, 26, 2, 2, 2, 2, 2,
00249 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00250 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00251 2, 2, 2, 2, 20, 2, 2, 2, 2, 2,
00252 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00253 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
00254 2, 2, 2, 30, 2, 31, 2, 2, 2, 2,
00255 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00256 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00257 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00258 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00259 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00260 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00261 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00262 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00263 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00264 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00265 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00266 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00267 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
00268 5, 6, 7, 8, 9, 10, 11, 12, 15, 16,
00269 17, 18
00270 };
00271
00272 #if YYDEBUG
00273
00274
00275 static const unsigned short int yyprhs[] =
00276 {
00277 0, 0, 3, 4, 8, 11, 14, 18, 22, 26,
00278 30, 35, 39, 43, 44, 45, 46, 55, 57, 60,
00279 61, 63, 65, 67, 68, 70, 72, 76, 78, 80,
00280 81, 88, 90, 92, 93, 94, 99, 101, 103, 105,
00281 106, 108, 112, 115, 118, 119, 120, 121, 132, 136,
00282 138, 139, 144, 146, 148, 149, 150, 151, 159, 160,
00283 161, 162, 171, 173, 175, 176, 181, 182, 187, 189,
00284 191, 193, 195, 196, 198, 200, 201, 202, 209, 210,
00285 211, 212, 222, 224, 228, 230, 232, 234, 236, 238,
00286 240, 242, 244, 245, 247, 248, 253, 254, 257, 258,
00287 264, 265, 271, 272, 278, 279, 285, 286, 287, 288,
00288 295, 296, 300, 302, 304, 305, 306, 312, 314, 316,
00289 317, 318, 326, 327, 328, 334, 336, 338, 341, 344,
00290 346, 347, 349, 350, 355, 357, 359, 361, 363, 365,
00291 368, 372, 373, 375, 376, 377, 384, 385, 386, 387,
00292 396, 398, 400, 402, 404
00293 };
00294
00295
00296 static const signed char yyrhs[] =
00297 {
00298 39, 0, -1, -1, 39, 1, 25, -1, 39, 45,
00299 -1, 39, 47, -1, 39, 49, 45, -1, 39, 56,
00300 45, -1, 39, 64, 45, -1, 39, 68, 45, -1,
00301 39, 43, 78, 79, -1, 39, 43, 82, -1, 39,
00302 43, 45, -1, -1, -1, -1, 39, 40, 89, 41,
00303 90, 44, 42, 45, -1, 26, -1, 43, 26, -1,
00304 -1, 27, -1, 25, -1, 28, -1, -1, 25, -1,
00305 28, -1, 7, 5, 48, -1, 25, -1, 28, -1,
00306 -1, 51, 29, 30, 50, 52, 31, -1, 11, -1,
00307 12, -1, -1, -1, 52, 55, 53, 54, -1, 11,
00308 -1, 5, -1, 10, -1, -1, 32, -1, 25, 32,
00309 25, -1, 25, 32, -1, 32, 25, -1, -1, -1,
00310 -1, 51, 29, 30, 57, 3, 58, 32, 59, 60,
00311 31, -1, 4, 32, 3, -1, 61, -1, -1, 63,
00312 32, 62, 61, -1, 63, -1, 3, -1, -1, -1,
00313 -1, 11, 65, 33, 66, 73, 67, 34, -1, -1,
00314 -1, -1, 72, 69, 11, 70, 33, 71, 73, 34,
00315 -1, 12, -1, 11, -1, -1, 73, 32, 74, 76,
00316 -1, -1, 73, 32, 75, 77, -1, 76, -1, 77,
00317 -1, 12, -1, 11, -1, -1, 21, -1, 35, -1,
00318 -1, -1, 8, 80, 33, 81, 86, 34, -1, -1,
00319 -1, -1, 88, 29, 83, 9, 84, 33, 85, 86,
00320 34, -1, 87, -1, 86, 55, 87, -1, 10, -1,
00321 5, -1, 3, -1, 11, -1, 10, -1, 5, -1,
00322 3, -1, 11, -1, -1, 3, -1, -1, 33, 91,
00323 90, 34, -1, -1, 92, 106, -1, -1, 90, 18,
00324 93, 46, 90, -1, -1, 90, 17, 94, 46, 90,
00325 -1, -1, 90, 19, 95, 46, 90, -1, -1, 90,
00326 20, 96, 46, 90, -1, -1, -1, -1, 97, 101,
00327 98, 102, 99, 90, -1, -1, 21, 100, 90, -1,
00328 15, -1, 16, -1, -1, -1, 103, 105, 32, 104,
00329 102, -1, 105, -1, 11, -1, -1, -1, 112, 8,
00330 107, 33, 108, 113, 34, -1, -1, -1, 109, 115,
00331 111, 110, 115, -1, 36, -1, 37, -1, 36, 29,
00332 -1, 37, 29, -1, 29, -1, -1, 22, -1, -1,
00333 113, 32, 114, 115, -1, 115, -1, 117, -1, 10,
00334 -1, 5, -1, 3, -1, 116, 11, -1, 116, 11,
00335 21, -1, -1, 14, -1, -1, -1, 9, 118, 33,
00336 119, 113, 34, -1, -1, -1, -1, 120, 33, 121,
00337 115, 123, 122, 115, 34, -1, 14, -1, 13, -1,
00338 22, -1, 23, -1, 24, -1
00339 };
00340
00341
00342 static const unsigned short int yyrline[] =
00343 {
00344 0, 114, 114, 116, 127, 128, 129, 130, 131, 132,
00345 133, 135, 137, 141, 146, 151, 140, 209, 210, 213,
00346 216, 226, 228, 231, 234, 236, 242, 305, 307, 318,
00347 316, 336, 349, 364, 369, 368, 389, 389, 389, 394,
00348 397, 399, 406, 412, 423, 429, 456, 421, 467, 504,
00349 511, 509, 518, 521, 558, 570, 571, 557, 591, 614,
00350 639, 590, 668, 668, 674, 673, 678, 677, 680, 681,
00351 685, 698, 717, 720, 726, 738, 751, 737, 795, 801,
00352 846, 793, 891, 899, 909, 910, 916, 925, 933, 942,
00353 954, 963, 978, 981, 996, 995, 1010, 1010, 1014, 1013,
00354 1026, 1025, 1038, 1037, 1049, 1048, 1060, 1062, 1068, 1060,
00355 1079, 1078, 1094, 1102, 1115, 1117, 1115, 1124, 1128, 1155,
00356 1185, 1154, 1342, 1361, 1342, 1518, 1532, 1546, 1563, 1580,
00357 1595, 1597, 1615, 1613, 1625, 1653, 1844, 1854, 1866, 1881,
00358 1887, 1911, 1913, 1925, 1961, 1924, 2043, 2059, 2064, 2043,
00359 2148, 2157, 2166, 2175, 2184
00360 };
00361 #endif
00362
00363 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
00364
00365
00366 static const char *const yytname[] =
00367 {
00368 "$end", "error", "$undefined", "ZZ_NUM", "ZZ_DOTDOTDOT", "ZZ_STRING",
00369 "ZZ_EQEQ", "ZZ_INCLUDE", "ZZ_PREDICATE", "ZZ_FUNCTION", "ZZ_CONSTANT",
00370 "ZZ_VARIABLE", "ZZ_TYPE", "'-'", "'+'", "ZZ_FORALL", "ZZ_EXIST",
00371 "ZZ_EQUIV", "ZZ_IMPLY", "'v'", "'^'", "'!'", "'*'", "'/'", "'%'",
00372 "'\\n'", "'@'", "'.'", "'\\r'", "'='", "'{'", "'}'", "','", "'('", "')'",
00373 "'?'", "'>'", "'<'", "$accept", "input", "@1", "@2", "@3", "at",
00374 "fullstop", "newline", "optnewline", "include", "nnewline",
00375 "type_declaration", "@4", "is_variable_type", "constant_declarations",
00376 "@5", "variable_or_string_or_constant", "constant_sep",
00377 "numeric_type_declaration", "@6", "@7", "@8", "numeric_types",
00378 "single_numeric_types", "@9", "single_numeric_type",
00379 "predicate_declaration", "@10", "@11", "@12", "function_declaration",
00380 "@13", "@14", "@15", "function_return_type", "types", "@16", "@17",
00381 "type_code", "variable_code", "pd_not_qs", "predicate_definition", "@18",
00382 "@19", "function_definition", "@20", "@21", "@22",
00383 "constants_in_groundings", "is_constant_string_num_variable",
00384 "function_return_constant", "weight", "sentence", "@23", "@24", "@25",
00385 "@26", "@27", "@28", "@29", "@30", "@31", "@32", "quantifier",
00386 "variables", "@33", "@34", "quant_variable", "atomic_sentence", "@35",
00387 "@36", "@37", "@38", "internal_predicate_sign", "asterisk", "terms",
00388 "@39", "term", "plus", "function_term", "@40", "@41", "@42", "@43",
00389 "@44", "internal_function_sign", 0
00390 };
00391 #endif
00392
00393
00394 static const unsigned char yyr1[] =
00395 {
00396 0, 38, 39, 39, 39, 39, 39, 39, 39, 39,
00397 39, 39, 39, 40, 41, 42, 39, 43, 43, 44,
00398 44, 45, 45, 46, 46, 46, 47, 48, 48, 50,
00399 49, 51, 51, 52, 53, 52, 54, 54, 54, 55,
00400 55, 55, 55, 55, 57, 58, 59, 56, 60, 60,
00401 62, 61, 61, 63, 65, 66, 67, 64, 69, 70,
00402 71, 68, 72, 72, 74, 73, 75, 73, 73, 73,
00403 76, 77, 78, 78, 78, 80, 81, 79, 83, 84,
00404 85, 82, 86, 86, 87, 87, 87, 87, 88, 88,
00405 88, 88, 89, 89, 91, 90, 92, 90, 93, 90,
00406 94, 90, 95, 90, 96, 90, 97, 98, 99, 90,
00407 100, 90, 101, 101, 103, 104, 102, 102, 105, 107,
00408 108, 106, 109, 110, 106, 111, 111, 111, 111, 111,
00409 112, 112, 114, 113, 113, 115, 115, 115, 115, 115,
00410 115, 116, 116, 118, 119, 117, 120, 121, 122, 117,
00411 123, 123, 123, 123, 123
00412 };
00413
00414
00415 static const unsigned char yyr2[] =
00416 {
00417 0, 2, 0, 3, 2, 2, 3, 3, 3, 3,
00418 4, 3, 3, 0, 0, 0, 8, 1, 2, 0,
00419 1, 1, 1, 0, 1, 1, 3, 1, 1, 0,
00420 6, 1, 1, 0, 0, 4, 1, 1, 1, 0,
00421 1, 3, 2, 2, 0, 0, 0, 10, 3, 1,
00422 0, 4, 1, 1, 0, 0, 0, 7, 0, 0,
00423 0, 8, 1, 1, 0, 4, 0, 4, 1, 1,
00424 1, 1, 0, 1, 1, 0, 0, 6, 0, 0,
00425 0, 9, 1, 3, 1, 1, 1, 1, 1, 1,
00426 1, 1, 0, 1, 0, 4, 0, 2, 0, 5,
00427 0, 5, 0, 5, 0, 5, 0, 0, 0, 6,
00428 0, 3, 1, 1, 0, 0, 5, 1, 1, 0,
00429 0, 7, 0, 0, 5, 1, 1, 2, 2, 1,
00430 0, 1, 0, 4, 1, 1, 1, 1, 1, 2,
00431 3, 0, 1, 0, 0, 6, 0, 0, 0, 8,
00432 1, 1, 1, 1, 1
00433 };
00434
00435
00436 static const unsigned char yydprec[] =
00437 {
00438 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00439 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00440 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00441 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00442 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00443 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00444 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00445 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00446 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00447 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
00448 0, 1, 0, 1, 0, 1, 0, 0, 0, 2,
00449 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00450 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00451 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00452 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00453 0, 0, 0, 0, 0
00454 };
00455
00456
00457 static const unsigned char yymerger[] =
00458 {
00459 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00460 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00461 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00462 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00463 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00464 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00465 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00466 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00467 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00468 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00469 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00470 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00471 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00472 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00473 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00474 0, 0, 0, 0, 0
00475 };
00476
00477
00478
00479
00480 static const unsigned char yydefact[] =
00481 {
00482 2, 0, 1, 0, 0, 31, 32, 21, 17, 22,
00483 92, 72, 4, 5, 0, 0, 0, 0, 0, 58,
00484 3, 0, 0, 93, 14, 90, 89, 88, 91, 73,
00485 18, 74, 12, 0, 11, 0, 6, 0, 7, 8,
00486 9, 0, 27, 28, 26, 55, 96, 75, 10, 78,
00487 29, 59, 0, 110, 94, 19, 122, 0, 0, 0,
00488 33, 0, 0, 71, 70, 56, 68, 69, 96, 96,
00489 100, 98, 102, 104, 20, 15, 131, 97, 141, 0,
00490 112, 113, 107, 76, 79, 39, 45, 60, 64, 0,
00491 111, 0, 23, 23, 23, 23, 0, 138, 137, 143,
00492 136, 142, 0, 0, 135, 0, 119, 0, 0, 0,
00493 0, 30, 40, 34, 0, 0, 0, 0, 57, 95,
00494 24, 25, 96, 96, 96, 96, 16, 0, 129, 125,
00495 126, 123, 139, 147, 0, 118, 108, 0, 117, 86,
00496 85, 84, 87, 39, 82, 80, 42, 43, 0, 46,
00497 0, 65, 67, 101, 99, 103, 105, 144, 127, 128,
00498 141, 140, 141, 120, 96, 0, 77, 0, 0, 41,
00499 37, 38, 36, 35, 0, 61, 141, 124, 0, 141,
00500 109, 115, 83, 39, 53, 0, 0, 49, 52, 0,
00501 134, 151, 150, 152, 153, 154, 148, 0, 0, 81,
00502 0, 47, 50, 132, 145, 141, 121, 116, 48, 0,
00503 141, 0, 51, 133, 149
00504 };
00505
00506
00507 static const short int yydefgoto[] =
00508 {
00509 -1, 1, 10, 46, 96, 11, 75, 12, 122, 13,
00510 44, 14, 60, 15, 85, 148, 173, 167, 16, 61,
00511 114, 174, 186, 187, 209, 188, 17, 22, 52, 89,
00512 18, 41, 62, 115, 19, 65, 116, 117, 66, 67,
00513 33, 48, 58, 108, 34, 59, 109, 168, 143, 144,
00514 35, 24, 55, 69, 56, 93, 92, 94, 95, 57,
00515 107, 164, 68, 82, 136, 137, 198, 138, 77, 134,
00516 179, 78, 160, 131, 79, 189, 210, 190, 103, 104,
00517 127, 176, 105, 162, 205, 196
00518 };
00519
00520
00521
00522 #define YYPACT_NINF -79
00523 static const short int yypact[] =
00524 {
00525 -79, 11, -79, -1, 33, -4, 19, -79, -79, -79,
00526 57, 38, -79, -79, 25, 36, 25, 25, 25, -79,
00527 -79, 55, 45, -79, -79, -79, -79, -79, -79, -79,
00528 -79, -79, -79, 77, -79, 58, -79, 62, -79, -79,
00529 -79, 98, -79, -79, -79, -79, 46, -79, -79, -79,
00530 123, -79, -7, -79, -79, 121, 9, 147, 85, 122,
00531 -79, 139, 113, -79, -79, 128, -79, -79, 53, 56,
00532 -79, -79, -79, -79, -79, -79, -79, -79, 37, 160,
00533 -79, -79, -79, -79, -79, 3, -79, -79, 158, 136,
00534 -79, 103, 89, 89, 89, 89, 25, -79, -79, -79,
00535 -79, -79, 107, 161, -79, 138, -79, 162, 100, 141,
00536 143, -79, 151, -79, 146, -7, 165, 168, -79, -79,
00537 -79, -79, 60, 75, 79, 83, -79, 148, -79, 153,
00538 154, -79, 159, -79, 152, -79, -79, 173, -79, -79,
00539 -79, -79, -79, 20, -79, -79, 164, -79, 140, -79,
00540 -19, -79, -79, 110, 145, 166, -79, -79, -79, -79,
00541 37, -79, 37, -79, 86, 155, -79, 100, 100, -79,
00542 -79, -79, -79, -79, 163, -79, 37, -79, 111, 37,
00543 135, -79, -79, 81, -79, 156, 167, -79, 169, 115,
00544 -79, -79, -79, -79, -79, -79, -79, 127, 179, -79,
00545 188, -79, -79, -79, -79, 37, -79, -79, -79, 189,
00546 37, 170, -79, -79, -79
00547 };
00548
00549
00550 static const signed char yypgoto[] =
00551 {
00552 -79, -79, -79, -79, -79, -79, -79, -8, 63, -79,
00553 -79, -79, -79, -79, -79, -79, -79, 108, -79, -79,
00554 -79, -79, -79, -15, -79, -79, -79, -79, -79, -79,
00555 -79, -79, -79, -79, -79, 80, -79, -79, 84, 82,
00556 -79, -79, -79, -79, -79, -79, -79, -79, 28, 30,
00557 -79, -79, -67, -79, -79, -79, -79, -79, -79, -79,
00558 -79, -79, -79, -79, 4, -79, -79, 66, -79, -79,
00559 -79, -79, -79, -79, -79, 26, -79, -78, -79, -79,
00560 -79, -79, -79, -79, -79, -79
00561 };
00562
00563
00564
00565
00566
00567 #define YYTABLE_NINF -147
00568 static const short int yytable[] =
00569 {
00570 102, 90, 91, 32, 63, 64, 36, -63, 38, 39,
00571 40, 2, 3, 88, -13, 175, -13, -130, 4, -13,
00572 -13, -13, 5, 6, 20, -13, -13, -13, 110, -54,
00573 -62, 76, -13, -13, 111, 112, 7, 8, 21, 9,
00574 97, 25, 98, 26, -13, 110, 99, 100, 27, 28,
00575 7, 101, 112, 9, 166, 153, 154, 155, 156, 29,
00576 23, -106, -106, 7, 30, 37, 9, 53, -106, -106,
00577 -146, -106, -106, 31, 53, -106, -106, 53, 45, 54,
00578 42, 53, 177, 43, 178, 47, 54, 49, 126, 54,
00579 -106, -106, 50, 54, -106, -106, 53, 180, -106, -106,
00580 53, -106, -106, 139, 53, 140, 110, 53, 54, 51,
00581 141, 142, 54, 112, 120, 199, 54, 121, 83, 54,
00582 70, 71, 72, 73, 191, 192, -44, 211, 71, 72,
00583 73, 84, 213, 193, 194, 195, 128, 119, 70, 71,
00584 72, 73, 86, 129, 130, 170, 87, 203, 74, 204,
00585 171, 172, 70, 71, 72, 73, 123, 124, 125, 203,
00586 88, 206, 80, 81, 72, 73, 184, 185, 106, -66,
00587 118, 133, 132, 135, 145, 146, 147, 64, 149, 63,
00588 161, 157, 158, 159, 135, 163, 73, 181, 200, 169,
00589 135, 208, 184, 113, 212, 150, 183, 182, 201, 152,
00590 151, 202, 207, 165, 214, 197
00591 };
00592
00593
00594
00595
00596
00597 static const unsigned char yyconflp[] =
00598 {
00599 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00600 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00601 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
00602 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00603 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00604 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00605 3, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00606 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
00607 0, 0, 0, 0, 0, 0, 7, 0, 0, 9,
00608 0, 0, 0, 13, 0, 0, 0, 0, 0, 0,
00609 0, 0, 0, 0, 0, 0, 0, 0, 15, 0,
00610 0, 0, 17, 0, 0, 0, 19, 0, 0, 21,
00611 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00612 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00613 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00614 0, 0, 23, 25, 27, 29, 0, 0, 0, 0,
00615 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00616 0, 0, 0, 11, 0, 0, 0, 0, 0, 0,
00617 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00618 31, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00619 0, 0, 0, 0, 0, 0
00620 };
00621
00622
00623
00624 static const short int yyconfl[] =
00625 {
00626 0, 13, 0, 92, 0, 96, 0, 96, 0, 96,
00627 0, 114, 0, 96, 0, 96, 0, 96, 0, 96,
00628 0, 96, 0, 109, 0, 109, 0, 109, 0, 109,
00629 0, 114, 0
00630 };
00631
00632 static const unsigned char yycheck[] =
00633 {
00634 78, 68, 69, 11, 11, 12, 14, 11, 16, 17,
00635 18, 0, 1, 32, 3, 34, 5, 8, 7, 8,
00636 9, 10, 11, 12, 25, 14, 15, 16, 25, 33,
00637 11, 22, 21, 22, 31, 32, 25, 26, 5, 28,
00638 3, 3, 5, 5, 33, 25, 9, 10, 10, 11,
00639 25, 14, 32, 28, 34, 122, 123, 124, 125, 21,
00640 3, 15, 16, 25, 26, 29, 28, 21, 15, 16,
00641 33, 15, 16, 35, 21, 15, 16, 21, 33, 33,
00642 25, 21, 160, 28, 162, 8, 33, 29, 96, 33,
00643 15, 16, 30, 33, 15, 16, 21, 164, 15, 16,
00644 21, 15, 16, 3, 21, 5, 25, 21, 33, 11,
00645 10, 11, 33, 32, 25, 34, 33, 28, 33, 33,
00646 17, 18, 19, 20, 13, 14, 3, 205, 18, 19,
00647 20, 9, 210, 22, 23, 24, 29, 34, 17, 18,
00648 19, 20, 3, 36, 37, 5, 33, 32, 27, 34,
00649 10, 11, 17, 18, 19, 20, 93, 94, 95, 32,
00650 32, 34, 15, 16, 19, 20, 3, 4, 8, 11,
00651 34, 33, 11, 11, 33, 32, 25, 12, 32, 11,
00652 21, 33, 29, 29, 11, 33, 20, 32, 32, 25,
00653 11, 3, 3, 85, 209, 115, 168, 167, 31, 117,
00654 116, 32, 198, 137, 34, 179
00655 };
00656
00657
00658
00659 static const unsigned char yystos[] =
00660 {
00661 0, 39, 0, 1, 7, 11, 12, 25, 26, 28,
00662 40, 43, 45, 47, 49, 51, 56, 64, 68, 72,
00663 25, 5, 65, 3, 89, 3, 5, 10, 11, 21,
00664 26, 35, 45, 78, 82, 88, 45, 29, 45, 45,
00665 45, 69, 25, 28, 48, 33, 41, 8, 79, 29,
00666 30, 11, 66, 21, 33, 90, 92, 97, 80, 83,
00667 50, 57, 70, 11, 12, 73, 76, 77, 100, 91,
00668 17, 18, 19, 20, 27, 44, 22, 106, 109, 112,
00669 15, 16, 101, 33, 9, 52, 3, 33, 32, 67,
00670 90, 90, 94, 93, 95, 96, 42, 3, 5, 9,
00671 10, 14, 115, 116, 117, 120, 8, 98, 81, 84,
00672 25, 31, 32, 55, 58, 71, 74, 75, 34, 34,
00673 25, 28, 46, 46, 46, 46, 45, 118, 29, 36,
00674 37, 111, 11, 33, 107, 11, 102, 103, 105, 3,
00675 5, 10, 11, 86, 87, 33, 32, 25, 53, 32,
00676 73, 76, 77, 90, 90, 90, 90, 33, 29, 29,
00677 110, 21, 121, 33, 99, 105, 34, 55, 85, 25,
00678 5, 10, 11, 54, 59, 34, 119, 115, 115, 108,
00679 90, 32, 87, 86, 3, 4, 60, 61, 63, 113,
00680 115, 13, 14, 22, 23, 24, 123, 113, 104, 34,
00681 32, 31, 32, 32, 34, 122, 34, 102, 3, 62,
00682 114, 115, 61, 115, 34
00683 };
00684
00685
00686
00687 int yyparse (void);
00688
00689
00690 #define YYTERROR 1
00691
00692
00693
00694
00695
00696
00697 #ifndef YYLLOC_DEFAULT
00698 # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
00699 #endif
00700
00701
00702 #ifndef YY_LOCATION_PRINT
00703 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
00704 #endif
00705
00706
00707
00708 #define YYLEX yylex ()
00709
00710 YYSTYPE yylval;
00711
00712 YYLTYPE yylloc;
00713
00714 int yynerrs;
00715 int yychar;
00716
00717 static const int YYEOF = 0;
00718 static const int YYEMPTY = -2;
00719
00720 typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
00721
00722 #define YYCHK(YYE) \
00723 do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
00724 while (0)
00725
00726 #if YYDEBUG
00727
00728 #if ! defined (YYFPRINTF)
00729 # define YYFPRINTF fprintf
00730 #endif
00731
00732 # define YYDPRINTF(Args) \
00733 do { \
00734 if (yydebug) \
00735 YYFPRINTF Args; \
00736 } while (0)
00737
00738
00739
00740
00741
00742 static void
00743 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
00744 {
00745
00746 (void) yyvaluep;
00747
00748 if (yytype < YYNTOKENS)
00749 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
00750 else
00751 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
00752
00753
00754 # ifdef YYPRINT
00755 if (yytype < YYNTOKENS)
00756 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
00757 # endif
00758 switch (yytype)
00759 {
00760 default:
00761 break;
00762 }
00763 YYFPRINTF (yyoutput, ")");
00764 }
00765
00766
00767 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
00768 do { \
00769 if (yydebug) \
00770 { \
00771 YYFPRINTF (stderr, "%s ", Title); \
00772 yysymprint (stderr, \
00773 Type, Value); \
00774 YYFPRINTF (stderr, "\n"); \
00775 } \
00776 } while (0)
00777
00778
00779
00780 int yydebug;
00781
00782 #else
00783
00784 # define YYDPRINTF(Args)
00785 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
00786
00787 #endif
00788
00789
00790 #ifndef YYINITDEPTH
00791 # define YYINITDEPTH 200
00792 #endif
00793
00794
00795
00796
00797
00798
00799
00800
00801 #ifndef YYMAXDEPTH
00802 # define YYMAXDEPTH 10000
00803 #endif
00804
00805
00806
00807
00808
00809
00810 #define YYHEADROOM 2
00811
00812 #ifndef YYSTACKEXPANDABLE
00813 # if (! defined (__cplusplus) \
00814 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))
00815 # define YYSTACKEXPANDABLE 1
00816 # else
00817 # define YYSTACKEXPANDABLE 0
00818 # endif
00819 #endif
00820
00821 #if YYERROR_VERBOSE
00822
00823 # ifndef yystpcpy
00824 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
00825 # define yystpcpy stpcpy
00826 # else
00827
00828
00829 static char *
00830 yystpcpy (char *yydest, const char *yysrc)
00831 {
00832 char *yyd = yydest;
00833 const char *yys = yysrc;
00834
00835 while ((*yyd++ = *yys++) != '\0')
00836 continue;
00837
00838 return yyd - 1;
00839 }
00840 # endif
00841 # endif
00842
00843 # ifndef yytnamerr
00844
00845
00846
00847
00848
00849
00850
00851 static size_t
00852 yytnamerr (char *yyres, const char *yystr)
00853 {
00854 if (*yystr == '"')
00855 {
00856 size_t yyn = 0;
00857 char const *yyp = yystr;
00858
00859 for (;;)
00860 switch (*++yyp)
00861 {
00862 case '\'':
00863 case ',':
00864 goto do_not_strip_quotes;
00865
00866 case '\\':
00867 if (*++yyp != '\\')
00868 goto do_not_strip_quotes;
00869
00870 default:
00871 if (yyres)
00872 yyres[yyn] = *yyp;
00873 yyn++;
00874 break;
00875
00876 case '"':
00877 if (yyres)
00878 yyres[yyn] = '\0';
00879 return yyn;
00880 }
00881 do_not_strip_quotes: ;
00882 }
00883
00884 if (! yyres)
00885 return strlen (yystr);
00886
00887 return yystpcpy (yyres, yystr) - yyres;
00888 }
00889 # endif
00890
00891 #endif
00892
00894 typedef int yyStateNum;
00895
00897 typedef int yyRuleNum;
00898
00900 typedef short int yySymbol;
00901
00903 typedef short int yyItemNum;
00904
00905 typedef struct yyGLRState yyGLRState;
00906 typedef struct yySemanticOption yySemanticOption;
00907 typedef union yyGLRStackItem yyGLRStackItem;
00908 typedef struct yyGLRStack yyGLRStack;
00909 typedef struct yyGLRStateSet yyGLRStateSet;
00910
00911 struct yyGLRState {
00913 yybool yyisState;
00916 yybool yyresolved;
00918 yyStateNum yylrState;
00920 yyGLRState* yypred;
00922 size_t yyposn;
00923 union {
00927 yySemanticOption* yyfirstVal;
00929 YYSTYPE yysval;
00930 } yysemantics;
00932 YYLTYPE yyloc;
00933 };
00934
00935 struct yyGLRStateSet {
00936 yyGLRState** yystates;
00937 size_t yysize, yycapacity;
00938 };
00939
00940 struct yySemanticOption {
00942 yybool yyisState;
00944 yyRuleNum yyrule;
00946 yyGLRState* yystate;
00949 yySemanticOption* yynext;
00950 };
00951
00954 union yyGLRStackItem {
00955 yyGLRState yystate;
00956 yySemanticOption yyoption;
00957 };
00958
00959 struct yyGLRStack {
00960 int yyerrState;
00961
00962
00963 yySymbol* yytokenp;
00964 YYJMP_BUF yyexception_buffer;
00965 yyGLRStackItem* yyitems;
00966 yyGLRStackItem* yynextFree;
00967 size_t yyspaceLeft;
00968 yyGLRState* yysplitPoint;
00969 yyGLRState* yylastDeleted;
00970 yyGLRStateSet yytops;
00971 };
00972
00973 static void yyexpandGLRStack (yyGLRStack* yystack);
00974
00975 static void yyFail (yyGLRStack* yystack, const char* yymsg)
00976 __attribute__ ((__noreturn__));
00977 static void
00978 yyFail (yyGLRStack* yystack, const char* yymsg)
00979 {
00980 if (yymsg != NULL)
00981 yyerror (yymsg);
00982 YYLONGJMP (yystack->yyexception_buffer, 1);
00983 }
00984
00985 static void yyMemoryExhausted (yyGLRStack* yystack)
00986 __attribute__ ((__noreturn__));
00987 static void
00988 yyMemoryExhausted (yyGLRStack* yystack)
00989 {
00990 YYLONGJMP (yystack->yyexception_buffer, 2);
00991 }
00992
00993 #if YYDEBUG || YYERROR_VERBOSE
00994
00995 static inline const char*
00996 yytokenName (yySymbol yytoken)
00997 {
00998 if (yytoken == YYEMPTY)
00999 return "";
01000
01001 if (yytoken < 0) { char* buf = new char[1]; buf[0]='\0'; return buf; } return yytname[yytoken];
01002 }
01003 #endif
01004
01009 static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));
01010 static void
01011 yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
01012 {
01013 yyGLRState* s;
01014 int i;
01015 s = yyvsp[yylow0].yystate.yypred;
01016 for (i = yylow0-1; i >= yylow1; i -= 1)
01017 {
01018 YYASSERT (s->yyresolved);
01019 yyvsp[i].yystate.yyresolved = yytrue;
01020 yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;
01021 yyvsp[i].yystate.yyloc = s->yyloc;
01022 s = yyvsp[i].yystate.yypred = s->yypred;
01023 }
01024 }
01025
01026
01027
01028
01029 static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
01030 __attribute__ ((__unused__));
01031 static inline int
01032 yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
01033 {
01034 if (!yynormal && yylow1 < *yylow)
01035 {
01036 yyfillin (yyvsp, *yylow, yylow1);
01037 *yylow = yylow1;
01038 }
01039 return yylow1;
01040 }
01041
01047 static YYRESULTTAG
01048 yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
01049 YYSTYPE* yyvalp,
01050 YYLTYPE* YYOPTIONAL_LOC (yylocp),
01051 yyGLRStack* yystack
01052 )
01053 {
01054 yybool yynormal __attribute__ ((__unused__)) =
01055 (yystack->yysplitPoint == NULL);
01056 int yylow;
01057
01058 # undef yyerrok
01059 # define yyerrok (yystack->yyerrState = 0)
01060 # undef YYACCEPT
01061 # define YYACCEPT return yyaccept
01062 # undef YYABORT
01063 # define YYABORT return yyabort
01064 # undef YYERROR
01065 # define YYERROR return yyerrok, yyerr
01066 # undef YYRECOVERING
01067 # define YYRECOVERING (yystack->yyerrState != 0)
01068 # undef yyclearin
01069 # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
01070 # undef YYFILL
01071 # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
01072 # undef YYBACKUP
01073 # define YYBACKUP(Token, Value) \
01074 return yyerror (YY_("parse error: cannot back up")), \
01075 yyerrok, yyerr
01076
01077 yylow = 1;
01078 if (yyrhslen == 0)
01079 *yyvalp = yyval_default;
01080 else
01081 *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;
01082 YYLLOC_DEFAULT (*yylocp, yyvsp - yyrhslen, yyrhslen);
01083
01084 switch (yyn)
01085 {
01086 case 2:
01087 #line 114 "../src/parser/fol.y"
01088 { if (folDbg >= 2) printf("input: empty\n"); ;}
01089 break;
01090
01091 case 3:
01092 #line 117 "../src/parser/fol.y"
01093 {
01094 yyerrok;
01095 const char* tok;
01096 while (true)
01097 {
01098 tok = zztokenList.removeLast();
01099 if (strcmp(tok,"\n")==0) { delete tok; break; }
01100 delete tok;
01101 }
01102 ;}
01103 break;
01104
01105 case 13:
01106 #line 141 "../src/parser/fol.y"
01107 {
01108 if (folDbg >= 2) printf("input: weight\n");
01109 zzreset();
01110 ;}
01111 break;
01112
01113 case 14:
01114 #line 146 "../src/parser/fol.y"
01115 {
01116 if (folDbg >= 2) printf("input: sentence\n");
01117
01118 ;}
01119 break;
01120
01121 case 15:
01122 #line 151 "../src/parser/fol.y"
01123 {
01124
01125 ListObj* formula;
01126 zzassert(zzoldNewVarList.size()==0,"expected zzoldNewVarList.size()==0");
01127 zzassert(zzformulaListObjs.size()==1,"expected zzformulaListObjs.size()=1");
01128 formula = zzformulaListObjs.top(); zzformulaListObjs.pop();
01129
01130 zzdetermineEqPredTypes(formula);
01131 zzeqPredList.clear();
01132 zzdetermineIntPredTypes(formula);
01133 zzintPredList.clear();
01134 zzdetermineIntFuncTypes(formula);
01135 zzintFuncList.clear();
01136 zzsetPlusVarTypeId();
01137 zzcheckVarNameToIdMap();
01138
01139 if (zzhasFullStop && zzwt != NULL)
01140 {
01141 zzerr("A weight must not be specified for a formula that is "
01142 "terminated with a period (i.e. the formula is hard).");
01143 delete zzwt; zzwt = NULL;
01144 }
01145
01146
01147
01148
01149 if (zzuniqueVarIndexes.size() > 0)
01150 {
01151 if (zzfdnumPreds != 1 || zznumAsterisk > 0)
01152 zzerr("'!' can only be used in a clause with one predicate, "
01153 "and cannot be used with '*'.");
01154 if (zzformulaStr.find("EXIST") != string::npos ||
01155 zzformulaStr.find("FORALL") != string::npos)
01156 zzerr("'!' cannot be used with quantifiers");
01157 }
01158
01159
01160 if (zznumErrors == 0)
01161 {
01162
01163
01164
01165 ZZFormulaInfo* epfi
01166 = new ZZFormulaInfo(formula, zzformulaStr, zzfdnumPreds, zzwt,
01167 zzdefaultWt, zzdomain, zzmln, zzvarNameToIdMap,
01168 zzplusVarMap, zznumAsterisk, zzuniqueVarIndexes,
01169 zzhasFullStop, zzreadHardClauseWts,
01170 zzmustHaveWtOrFullStop);
01171 zzformulaInfos.append(epfi);
01172 }
01173
01174 if (zzwt) { delete zzwt; zzwt = NULL; }
01175 ;}
01176 break;
01177
01178 case 17:
01179 #line 209 "../src/parser/fol.y"
01180 { zzconsumeToken(zztokenList,"@"); ;}
01181 break;
01182
01183 case 18:
01184 #line 210 "../src/parser/fol.y"
01185 { zzconsumeToken(zztokenList,"@"); ;}
01186 break;
01187
01188 case 20:
01189 #line 217 "../src/parser/fol.y"
01190 {
01191 if (folDbg >= 1) printf(".\n"); zzconsumeToken(zztokenList,".");
01192 zzassert(!zzhasFullStop, "expecting no full stop");
01193 zzhasFullStop = true;
01194 zzformulaStr.append(".");
01195 ;}
01196 break;
01197
01198 case 21:
01199 #line 226 "../src/parser/fol.y"
01200 { if (folDbg >= 1) printf("\\n\n"); zzconsumeToken(zztokenList,"\n"); ;}
01201 break;
01202
01203 case 22:
01204 #line 228 "../src/parser/fol.y"
01205 { if (folDbg >= 1) printf("\\r\n"); zzconsumeToken(zztokenList,"\r"); ;}
01206 break;
01207
01208 case 24:
01209 #line 234 "../src/parser/fol.y"
01210 { if (folDbg >= 1) printf("\\n\n"); zzconsumeToken(zztokenList,"\n"); ;}
01211 break;
01212
01213 case 25:
01214 #line 236 "../src/parser/fol.y"
01215 { if (folDbg >= 1) printf("\\r\n"); zzconsumeToken(zztokenList,"\r"); ;}
01216 break;
01217
01218 case 26:
01219 #line 243 "../src/parser/fol.y"
01220 {
01221 const char* inc = zztokenList.removeLast();
01222 const char* str = zztokenList.removeLast();
01223 const char* nl = zztokenList.removeLast();
01224 zzassert(strcmp(inc,"#include")==0,"expecting #include keyword");
01225
01226 if (folDbg >= 1) printf("#include %s ", str);
01227
01228 string s(str);
01229 if (s.length() == 0)
01230 {
01231 zzerr("empty string used with #include");
01232 delete [] inc;
01233 delete [] str;
01234 delete [] nl;
01235 break;
01236 }
01237
01238 zzassert(s.at(0) == '"' && s.at(s.length()-1) == '"', "no enclosing \"");
01239 s = s.substr(1, s.length()-2);
01240 int len = s.length();
01241
01242
01243 if (s.at(len-4)=='.' && s.at(len-3)=='c' && s.at(len-2)=='p' &&
01244 s.at(len-1)=='p') {
01245
01246 zzcompileFunctions(str);
01247 zzusingLinkedPredicates = true;
01248 zzusingLinkedFunctions = true;
01249 break;
01250 }
01251
01252 FILE* newin = fopen(s.c_str(), "r" );
01253 if (newin)
01254 {
01255 zzinStack.push(ZZFileState(yyin, string(zzinFileName), zznumCharRead,
01256 zzline, zzcolumn));
01257 ungetc('\n', newin);
01258 zzline = 1;
01259 zzcolumn = -1;
01260 zzline--;
01261 zzinFileName = str;
01262 yyrestart(newin);
01263 zznumCharRead = 0;
01264
01265
01266 if ((s.at(len-3)=='.' && s.at(len-2)=='d' && s.at(len-1)=='b'))
01267
01268
01269
01270 zzparseGroundPred = true;
01271 }
01272 else
01273 zzerr("Failed to open file %s.", str);
01274
01275 delete [] inc;
01276 delete [] str;
01277 delete [] nl;
01278 ;}
01279 break;
01280
01281 case 27:
01282 #line 305 "../src/parser/fol.y"
01283 { if (folDbg >= 1) printf("\\n\n"); ;}
01284 break;
01285
01286 case 28:
01287 #line 307 "../src/parser/fol.y"
01288 { if (folDbg >= 1) printf("\\r\n"); ;}
01289 break;
01290
01291 case 29:
01292 #line 318 "../src/parser/fol.y"
01293 {
01294 zzconsumeToken(zztokenList,"=");
01295 zzconsumeToken(zztokenList,"{");
01296 if (folDbg >= 1) printf("= { ");
01297 if (folDbg >= 2) printf("type_declarations: constant_declarations\n");
01298 ;}
01299 break;
01300
01301 case 30:
01302 #line 326 "../src/parser/fol.y"
01303 {
01304 if (folDbg >= 1) printf("} ");
01305 zzconsumeToken(zztokenList, "}");
01306 delete [] zztypeName;
01307 zztypeName = NULL;
01308 ;}
01309 break;
01310
01311 case 31:
01312 #line 337 "../src/parser/fol.y"
01313 {
01314 const char* idf = zztokenList.removeLast();
01315 if (folDbg >= 1) printf("type t_%s ", idf);
01316 zzassert(!zzdomain->isType(idf), "expecting type to be undefined");
01317 int id = zzaddTypeToDomain(zzdomain, idf);
01318 zzassert(id >= 0,"expecting id >= 0");
01319 zzassert(zztypeName==NULL,"expecting zztypeName==NULL");
01320 zztypeName = new char[strlen(idf)+1];
01321 strcpy(zztypeName, idf);
01322 delete [] idf;
01323 ;}
01324 break;
01325
01326 case 32:
01327 #line 350 "../src/parser/fol.y"
01328 {
01329 const char* idf = zztokenList.removeLast();
01330 if (folDbg >= 1) printf("type t_%s ", idf);
01331 zzassert(zzdomain->isType(idf),"expecting type to be defined");
01332
01333 zzassert(zztypeName==NULL,"expecting zztypeName==NULL");
01334 zztypeName = new char[strlen(idf)+1];
01335 strcpy(zztypeName, idf);
01336 delete [] idf;
01337 ;}
01338 break;
01339
01340 case 34:
01341 #line 369 "../src/parser/fol.y"
01342 { if (folDbg >= 2) printf("constant_declarations: ZZ_VARIABLE\n"); ;}
01343 break;
01344
01345 case 35:
01346 #line 371 "../src/parser/fol.y"
01347 {
01348 const char* vsc = zztokenList.removeLast();
01349 if (folDbg >= 1) printf("cd_%s ", vsc);
01350 int constId = zzdomain->getConstantId(vsc);
01351 if (constId < 0)
01352 zzaddConstantToDomain(vsc, zztypeName);
01353 else
01354 {
01355 const char* prevType = zzdomain->getConstantTypeName(constId);
01356 if (strcmp(prevType,zztypeName)!=0)
01357 zzerr("constant %s previously declared to be of type %s is redeclared "
01358 "to be of type %s", vsc, prevType, zztypeName);
01359 }
01360 delete [] vsc;
01361 ;}
01362 break;
01363
01364 case 40:
01365 #line 397 "../src/parser/fol.y"
01366 { zzconsumeToken(zztokenList, ","); ;}
01367 break;
01368
01369 case 41:
01370 #line 400 "../src/parser/fol.y"
01371 {
01372 zzconsumeToken(zztokenList,"\n");
01373 zzconsumeToken(zztokenList,",");
01374 zzconsumeToken(zztokenList,"\n");
01375 ;}
01376 break;
01377
01378 case 42:
01379 #line 407 "../src/parser/fol.y"
01380 {
01381 zzconsumeToken(zztokenList,"\n");
01382 zzconsumeToken(zztokenList,",");
01383 ;}
01384 break;
01385
01386 case 43:
01387 #line 413 "../src/parser/fol.y"
01388 {
01389 zzconsumeToken(zztokenList,",");
01390 zzconsumeToken(zztokenList,"\n");
01391 ;}
01392 break;
01393
01394 case 44:
01395 #line 423 "../src/parser/fol.y"
01396 {
01397 if (folDbg >= 2) printf("numeric_type_declarations: \n");
01398 zzconsumeToken(zztokenList,"=");
01399 zzconsumeToken(zztokenList,"{");
01400 ;}
01401 break;
01402
01403 case 45:
01404 #line 429 "../src/parser/fol.y"
01405 {
01406 const char* numStr = zztokenList.removeLast();
01407 if (folDbg >= 1) printf(" %s ", numStr);
01408
01409 double d = atof(numStr);
01410 zzinitialNumDeclaration = int(d);
01411 if (d != zzinitialNumDeclaration) zzerr("constant %s must be an integer", numStr);
01412
01413 char constStr[100];
01414 zzcreateIntConstant(constStr, zztypeName, zzinitialNumDeclaration);
01415 int constId = zzdomain->getConstantId(constStr);
01416 if (constId < 0)
01417 zzaddConstantToDomain(constStr, zztypeName);
01418 else
01419 {
01420 const char* prevType = zzdomain->getConstantTypeName(constId);
01421 if (strcmp(prevType,zztypeName)!=0)
01422 {
01423 char buf[30]; sprintf(buf, "%d", zzinitialNumDeclaration);
01424 zzerr("constant %s previously declared to be of type %s is redeclared "
01425 "to be of type %s", buf, prevType, zztypeName);
01426 }
01427 }
01428
01429 delete [] numStr;
01430 ;}
01431 break;
01432
01433 case 46:
01434 #line 456 "../src/parser/fol.y"
01435 {
01436 zzconsumeToken(zztokenList, ",");
01437 ;}
01438 break;
01439
01440 case 47:
01441 #line 461 "../src/parser/fol.y"
01442 {
01443 zzconsumeToken(zztokenList, "}");
01444 ;}
01445 break;
01446
01447 case 48:
01448 #line 468 "../src/parser/fol.y"
01449 {
01450
01451 zzconsumeToken(zztokenList, "...");
01452 zzconsumeToken(zztokenList, ",");
01453 const char* numStr2 = zztokenList.removeLast();
01454 if (folDbg >= 1) printf("= ... , %s } ", numStr2);
01455
01456 double d2 = atof(numStr2);
01457 int i2 = int(d2);
01458 if (d2 != i2) zzerr("constant %s must be an integer", numStr2);
01459 if (zzinitialNumDeclaration > i2)
01460 zzerr("first constant cannot be larger than last constant %s", numStr2);
01461
01462 for (int i = zzinitialNumDeclaration + 1; i <= i2; i++)
01463 {
01464 char constStr[100];
01465 zzcreateIntConstant(constStr, zztypeName, i);
01466 int constId = zzdomain->getConstantId(constStr);
01467 if (constId < 0)
01468 zzaddConstantToDomain(constStr, zztypeName);
01469 else
01470 {
01471 const char* prevType = zzdomain->getConstantTypeName(constId);
01472 if (strcmp(prevType,zztypeName)!=0)
01473 {
01474 char buf[30]; sprintf(buf, "%d", i);
01475 zzerr("constant %s previously declared to be of type %s is redeclared "
01476 "to be of type %s", buf, prevType, zztypeName);
01477 }
01478 }
01479 }
01480
01481 delete [] numStr2; delete [] zztypeName;
01482 zztypeName = NULL;
01483 ;}
01484 break;
01485
01486 case 50:
01487 #line 511 "../src/parser/fol.y"
01488 {
01489 zzconsumeToken(zztokenList, ",");
01490 if (folDbg >= 1) printf(", ");
01491 if (folDbg >= 2) printf("single_numeric_types: single_numeric_type\n");
01492 ;}
01493 break;
01494
01495 case 53:
01496 #line 522 "../src/parser/fol.y"
01497 {
01498 const char* numStr = zztokenList.removeLast();
01499 if (folDbg >= 1) printf(" %s ", numStr);
01500
01501 double d = atof(numStr);
01502 int i = int(d);
01503 if (d != i) zzerr("constant %s must be an integer", numStr);
01504
01505 char constStr[100];
01506 zzcreateIntConstant(constStr, zztypeName, i);
01507 int constId = zzdomain->getConstantId(constStr);
01508 if (constId < 0)
01509 zzaddConstantToDomain(constStr, zztypeName);
01510 else
01511 {
01512 const char* prevType = zzdomain->getConstantTypeName(constId);
01513 if (strcmp(prevType,zztypeName)!=0)
01514 {
01515 char buf[30]; sprintf(buf, "%d", i);
01516 zzerr("constant %s previously declared to be of type %s is redeclared "
01517 "to be of type %s", buf, prevType, zztypeName);
01518 }
01519 }
01520
01521 delete [] numStr;
01522 ;}
01523 break;
01524
01525 case 54:
01526 #line 558 "../src/parser/fol.y"
01527 {
01528 const char* predName = zztokenList.removeLast();
01529
01530 if (folDbg >= 1) printf("ZZ_PREDICATE pc_%s ", predName);
01531
01532 zzassert(zzdomain->getFunctionId(predName) < 0,
01533 "not expecting pred name to be declared as a function name");
01534 zzassert(zzpredTemplate==NULL,"expecting zzpredTemplate==NULL");
01535 zzpredTemplate = new PredicateTemplate();
01536 zzpredTemplate->setName(predName);
01537 delete [] predName;
01538 ;}
01539 break;
01540
01541 case 55:
01542 #line 570 "../src/parser/fol.y"
01543 { if (folDbg >= 1) printf("( "); zzconsumeToken(zztokenList,"("); ;}
01544 break;
01545
01546 case 56:
01547 #line 571 "../src/parser/fol.y"
01548 { if (folDbg >= 2) printf("predicate_declaration: types\n"); ;}
01549 break;
01550
01551 case 57:
01552 #line 573 "../src/parser/fol.y"
01553 {
01554 if (folDbg >= 1) printf(") ");
01555
01556 zzconsumeToken(zztokenList,")");
01557
01558 zzassert(zzpredTemplate, "not expecting zzpredTemplate==NULL");
01559 int id = zzdomain->addPredicateTemplate(zzpredTemplate);
01560 zzassert(id >= 0, "expecting pred template id >= 0");
01561 zzpredTemplate->setId(id);
01562 zzpredTemplate = NULL;
01563 ;}
01564 break;
01565
01566 case 58:
01567 #line 591 "../src/parser/fol.y"
01568 {
01569 const char* retTypeName = zztokenList.removeLast();
01570 if (folDbg >= 1) printf("ZZ_FUNCTION t_%s ", retTypeName);
01571 if (folDbg >= 2) printf("function_declaration: ZZ_VARIABLE\n");
01572
01573 if (!zzdomain->isType(retTypeName))
01574 {
01575 int id = zzaddTypeToDomain(zzdomain, retTypeName);
01576 zzassert(id >= 0, "expecting retTypeName's id >= 0");
01577 }
01578
01579 zzassert(zzfuncTemplate==NULL, "expecting zzfuncTemplate==NULL");
01580 zzfuncTemplate = new FunctionTemplate();
01581 zzfuncTemplate->setRetTypeName(retTypeName,zzdomain);
01582
01583
01584 zzassert(zzpredTemplate==NULL,"expecting zzpredTemplate==NULL");
01585 zzpredTemplate = new PredicateTemplate();
01586 zzaddType(retTypeName, zzpredTemplate, NULL, false, zzdomain);
01587
01588 delete [] retTypeName;
01589 ;}
01590 break;
01591
01592 case 59:
01593 #line 614 "../src/parser/fol.y"
01594 {
01595 const char* funcName = zztokenList.removeLast();
01596
01597 if (folDbg >= 1) printf("fc_%s ", funcName);
01598 zzassert(zzdomain->getPredicateId(funcName) < 0,
01599 "not expecting func name to be declared as pred name");
01600 zzfuncTemplate->setName(funcName);
01601
01602
01603 char* predName;
01604 predName = (char *)malloc((strlen(PredicateTemplate::ZZ_RETURN_PREFIX) +
01605 strlen(funcName) + 1)*sizeof(char));
01606 strcpy(predName, PredicateTemplate::ZZ_RETURN_PREFIX);
01607 strcat(predName, funcName);
01608
01609
01610 zzassert(zzdomain->getFunctionId(predName) < 0,
01611 "not expecting pred name to be declared as a function name");
01612 zzassert(zzpredTemplate,"expecting zzpredTemplate!=NULL");
01613 zzpredTemplate->setName(predName);
01614
01615 free(predName);
01616 delete [] funcName;
01617 ;}
01618 break;
01619
01620 case 60:
01621 #line 639 "../src/parser/fol.y"
01622 {
01623 zzconsumeToken(zztokenList,"(");
01624 if (folDbg >= 1) printf("( ");
01625 if (folDbg >= 2) printf("function_declaration: types\n");
01626 ;}
01627 break;
01628
01629 case 61:
01630 #line 645 "../src/parser/fol.y"
01631 {
01632 zzconsumeToken(zztokenList,")");
01633 if (folDbg >= 1) printf(") ");
01634 zzassert(zzfuncTemplate, "expecting zzfuncTemplate != NULL");
01635 int id = zzdomain->addFunctionTemplate(zzfuncTemplate);
01636 zzassert(id >= 0, "expecting function template's id >= 0");
01637 zzfuncTemplate->setId(id);
01638 zzfuncTemplate = NULL;
01639
01640 zzassert(zzpredTemplate, "not expecting zzpredTemplate==NULL");
01641
01642 if (!zzdomain->isPredicate(zzpredTemplate->getName()))
01643 {
01644 int predId = zzdomain->addPredicateTemplate(zzpredTemplate);
01645 zzassert(predId >= 0, "expecting pred template id >= 0");
01646 zzpredTemplate->setId(predId);
01647 }
01648 zzpredTemplate = NULL;
01649
01650 ;}
01651 break;
01652
01653 case 64:
01654 #line 674 "../src/parser/fol.y"
01655 { if (folDbg >= 1) printf(", "); zzconsumeToken(zztokenList,","); ;}
01656 break;
01657
01658 case 66:
01659 #line 678 "../src/parser/fol.y"
01660 { if (folDbg >= 1) printf(", "); zzconsumeToken(zztokenList,","); ;}
01661 break;
01662
01663 case 70:
01664 #line 686 "../src/parser/fol.y"
01665 {
01666 const char* ttype = zztokenList.removeLast();
01667 if (folDbg >= 1) printf("t_%s ", ttype);
01668 zzaddType(ttype, zzpredTemplate, NULL, false, zzdomain);
01669
01670 if (zzfuncTemplate)
01671 zzaddType(ttype, NULL, zzfuncTemplate, false, zzdomain);
01672
01673 delete [] ttype;
01674 ;}
01675 break;
01676
01677 case 71:
01678 #line 699 "../src/parser/fol.y"
01679 {
01680 const char* varName = zztokenList.removeLast();;
01681 if (folDbg >= 1) printf("t_%s ", varName);
01682 zzassert(!zzdomain->isType(varName), "expecting varName to be not a type");
01683 int id = zzaddTypeToDomain(zzdomain, varName);
01684 zzassert(id >= 0, "expecting var id >= 0");
01685 zzaddType(varName, zzpredTemplate, NULL, false, zzdomain);
01686
01687 if (zzfuncTemplate)
01688 zzaddType(varName, NULL, zzfuncTemplate, false, zzdomain);
01689 delete [] varName;
01690 ;}
01691 break;
01692
01693 case 72:
01694 #line 717 "../src/parser/fol.y"
01695 {
01696 zztrueFalseUnknown = 't';
01697 ;}
01698 break;
01699
01700 case 73:
01701 #line 721 "../src/parser/fol.y"
01702 {
01703 zzconsumeToken(zztokenList,"!");
01704 if (folDbg >= 1) printf("! ");
01705 zztrueFalseUnknown = 'f';
01706 ;}
01707 break;
01708
01709 case 74:
01710 #line 727 "../src/parser/fol.y"
01711 {
01712 zzconsumeToken(zztokenList,"?");
01713 if (folDbg >= 1) printf("? ");
01714 zztrueFalseUnknown = 'u';
01715 ;}
01716 break;
01717
01718 case 75:
01719 #line 738 "../src/parser/fol.y"
01720 {
01721 const char* predName = zztokenList.removeLast();
01722 if (folDbg >= 1) printf("pd_%s ", predName);
01723
01724 zzcreatePred(zzpred, predName);
01725 if (zztrueFalseUnknown == 't') zzpred->setTruthValue(TRUE);
01726 else if (zztrueFalseUnknown == 'f') zzpred->setTruthValue(FALSE);
01727 else if (zztrueFalseUnknown == 'u') zzpred->setTruthValue(UNKNOWN);
01728 else { zzassert(false, "expecting t,f,u"); }
01729
01730 delete [] predName;
01731 ;}
01732 break;
01733
01734 case 76:
01735 #line 751 "../src/parser/fol.y"
01736 {
01737 zzconsumeToken(zztokenList,"(");
01738 if (folDbg >= 1) printf("( ");
01739 if (folDbg >= 2) printf("predicate_definition: constants_in_groundings\n");
01740 ;}
01741 break;
01742
01743 case 77:
01744 #line 757 "../src/parser/fol.y"
01745 {
01746 zzconsumeToken(zztokenList,")");
01747 if (folDbg >= 1) printf(")\n");
01748
01749 zzcheckPredNumTerm(zzpred);
01750 int predId = zzpred->getId();
01751 hash_map<int,PredicateHashArray*>::iterator it;
01752 if ((it=zzpredIdToGndPredMap.find(predId)) == zzpredIdToGndPredMap.end())
01753 zzpredIdToGndPredMap[predId] = new PredicateHashArray;
01754
01755 PredicateHashArray* pha = zzpredIdToGndPredMap[predId];
01756 if (pha->append(zzpred) < 0)
01757 {
01758 int a = pha->find(zzpred);
01759 zzassert(a >= 0, "expecting ground predicate to be found");
01760 string origTvStr = (*pha)[a]->getTruthValueAsStr();
01761 (*pha)[a]->setTruthValue(zzpred->getTruthValue());
01762 string newTvStr = (*pha)[a]->getTruthValueAsStr();
01763
01764 if (zzwarnDuplicates)
01765 {
01766 ostringstream oss;
01767 oss << "Duplicate ground predicate "; zzpred->print(oss, zzdomain);
01768 oss << " found. ";
01769 if (origTvStr.compare(newTvStr) != 0)
01770 oss << "Changed its truthValue from " << origTvStr << " to " <<newTvStr
01771 << endl;
01772 zzwarn(oss.str().c_str());
01773 }
01774 delete zzpred;
01775 }
01776 zzpred = NULL;
01777 ;}
01778 break;
01779
01780 case 78:
01781 #line 795 "../src/parser/fol.y"
01782 {
01783 zzconsumeToken(zztokenList,"=");
01784 if (folDbg >= 1) printf("= ");
01785 if (folDbg >= 2) printf("function_definition: constants_in_groundings\n");
01786 ;}
01787 break;
01788
01789 case 79:
01790 #line 801 "../src/parser/fol.y"
01791 {
01792
01793 const char* funcName = zztokenList.removeLast();
01794 char* predName;
01795 predName = (char *)malloc((strlen(PredicateTemplate::ZZ_RETURN_PREFIX) +
01796 strlen(funcName) + 1)*sizeof(char));
01797 strcpy(predName, PredicateTemplate::ZZ_RETURN_PREFIX);
01798 strcat(predName, funcName);
01799
01800 if (folDbg >= 1) printf("pd_%s ", predName);
01801
01802 zzcreatePred(zzpred, predName);
01803 zzpred->setTruthValue(TRUE);
01804
01805 char constName[100];
01806 char* constString;
01807 if (zztmpReturnNum)
01808 {
01809 zzcreateAndCheckIntConstant(zztmpReturnConstant, zzfunc, zzpred, zzdomain, constName);
01810 if (constName == NULL)
01811 {
01812 constString = (char *)malloc((strlen(zztmpReturnConstant) + 1)*sizeof(char));
01813 strcpy(constString, zztmpReturnConstant);
01814 } else
01815 {
01816 constString = (char *)malloc((strlen(constName) + 1)*sizeof(char));
01817 strcpy(constString, constName);
01818 }
01819 }
01820 else
01821 {
01822 constString = (char *)malloc((strlen(zztmpReturnConstant) + 1)*sizeof(char));
01823 strcpy(constString, zztmpReturnConstant);
01824 }
01825
01826
01827 zzaddConstantToPredFunc(constString);
01828
01829 zztmpReturnNum = false;
01830 free(zztmpReturnConstant);
01831 delete [] funcName;
01832 free(predName);
01833 free(constString);
01834 ;}
01835 break;
01836
01837 case 80:
01838 #line 846 "../src/parser/fol.y"
01839 {
01840 zzconsumeToken(zztokenList,"(");
01841 if (folDbg >= 1) printf("( ");
01842 if (folDbg >= 2) printf("function_definition: constants_in_groundings\n");
01843 ;}
01844 break;
01845
01846 case 81:
01847 #line 852 "../src/parser/fol.y"
01848 {
01849 zzconsumeToken(zztokenList,")");
01850 if (folDbg >= 1) printf(")\n");
01851
01852 zzcheckPredNumTerm(zzpred);
01853 int predId = zzpred->getId();
01854 hash_map<int,PredicateHashArray*>::iterator it;
01855 if ((it=zzpredIdToGndPredMap.find(predId)) == zzpredIdToGndPredMap.end())
01856 zzpredIdToGndPredMap[predId] = new PredicateHashArray;
01857
01858 PredicateHashArray* pha = zzpredIdToGndPredMap[predId];
01859 if (pha->append(zzpred) < 0)
01860 {
01861 int a = pha->find(zzpred);
01862 zzassert(a >= 0, "expecting ground predicate to be found");
01863 string origTvStr = (*pha)[a]->getTruthValueAsStr();
01864 (*pha)[a]->setTruthValue(zzpred->getTruthValue());
01865 string newTvStr = (*pha)[a]->getTruthValueAsStr();
01866
01867 if (zzwarnDuplicates)
01868 {
01869 ostringstream oss;
01870 oss << "Duplicate ground predicate "; zzpred->print(oss, zzdomain);
01871 oss << " found. ";
01872 if (origTvStr.compare(newTvStr) != 0)
01873 oss << "Changed its truthValue from " << origTvStr << " to " <<newTvStr
01874 << endl;
01875 zzwarn(oss.str().c_str());
01876 }
01877
01878 }
01879
01880
01881
01882 zzpred = NULL;
01883 ;}
01884 break;
01885
01886 case 82:
01887 #line 892 "../src/parser/fol.y"
01888 {
01889 const char* constName = zztokenList.removeLast();
01890 if (folDbg >= 1) printf("cg_%s ", constName);
01891 zzaddConstantToPredFunc(constName);
01892 delete [] constName;
01893 ;}
01894 break;
01895
01896 case 83:
01897 #line 900 "../src/parser/fol.y"
01898 {
01899 const char* constName = zztokenList.removeLast();
01900 if (folDbg >= 1) printf("cg_%s ", constName);
01901 zzaddConstantToPredFunc(constName);
01902 delete [] constName;
01903 ;}
01904 break;
01905
01906 case 85:
01907 #line 911 "../src/parser/fol.y"
01908 {
01909 if (zzconstantMustBeDeclared)
01910 zzerr("Constant %s must be declared before it is used.",
01911 zztokenList.back());
01912 ;}
01913 break;
01914
01915 case 86:
01916 #line 917 "../src/parser/fol.y"
01917 {
01918 const char* intStr = zztokenList.removeLast();
01919 char constName[100];
01920 zzcreateAndCheckIntConstant(intStr, zzfunc, zzpred, zzdomain, constName);
01921 if (constName == NULL) zztokenList.addLast(intStr);
01922 else zztokenList.addLast(constName);
01923 delete [] intStr;
01924 ;}
01925 break;
01926
01927 case 87:
01928 #line 926 "../src/parser/fol.y"
01929 {
01930 if (zzconstantMustBeDeclared)
01931 zzerr("Constant %s must be declared before it is used",
01932 zztokenList.back());
01933 ;}
01934 break;
01935
01936 case 88:
01937 #line 934 "../src/parser/fol.y"
01938 {
01939 const char* tmp = zztokenList.removeLast();
01940 zztmpReturnConstant = (char *)malloc((strlen(tmp) + 1)*sizeof(char));
01941 strcpy(zztmpReturnConstant, tmp);
01942 zztmpReturnNum = false;
01943 delete []tmp;
01944 if (folDbg >= 1) printf("ic_%s ", zztmpReturnConstant);
01945 ;}
01946 break;
01947
01948 case 89:
01949 #line 943 "../src/parser/fol.y"
01950 {
01951 if (zzconstantMustBeDeclared)
01952 zzerr("Constant %s must be declared before it is used.",
01953 zztokenList.back());
01954 const char* tmp = zztokenList.removeLast();
01955 zztmpReturnConstant = (char *)malloc((strlen(tmp) + 1)*sizeof(char));
01956 strcpy(zztmpReturnConstant, tmp);
01957 zztmpReturnNum = false;
01958 delete []tmp;
01959 if (folDbg >= 1) printf("ic_%s ", zztmpReturnConstant);
01960 ;}
01961 break;
01962
01963 case 90:
01964 #line 955 "../src/parser/fol.y"
01965 {
01966 const char* tmp = zztokenList.removeLast();
01967 zztmpReturnConstant = (char *)malloc((strlen(tmp) + 1)*sizeof(char));
01968 strcpy(zztmpReturnConstant, tmp);
01969 zztmpReturnNum = true;
01970 delete []tmp;
01971 if (folDbg >= 1) printf("icnum_%s ", zztmpReturnConstant);
01972 ;}
01973 break;
01974
01975 case 91:
01976 #line 964 "../src/parser/fol.y"
01977 {
01978 if (zzconstantMustBeDeclared)
01979 zzerr("Constant %s must be declared before it is used",
01980 zztokenList.back());
01981 const char* tmp = zztokenList.removeLast();
01982 zztmpReturnConstant = (char *)malloc((strlen(tmp) + 1)*sizeof(char));
01983 strcpy(zztmpReturnConstant, tmp);
01984 zztmpReturnNum = false;
01985 delete []tmp;
01986 if (folDbg >= 1) printf("ic_%s ", zztmpReturnConstant);
01987 ;}
01988 break;
01989
01990 case 93:
01991 #line 982 "../src/parser/fol.y"
01992 {
01993 const char* wt = zztokenList.removeLast();
01994 if (folDbg >= 1) printf("n_%f ", atof(wt));
01995 if (zzwt) delete zzwt;
01996 zzwt = new double(atof(wt));
01997 delete [] wt;
01998 ;}
01999 break;
02000
02001 case 94:
02002 #line 996 "../src/parser/fol.y"
02003 {
02004 zzconsumeToken(zztokenList,"(");
02005 if (folDbg >= 1) printf("( ");
02006 if (folDbg >= 2) printf("sentence: '(' sentence\n");
02007 zzformulaStr.append("(");
02008 ;}
02009 break;
02010
02011 case 95:
02012 #line 1004 "../src/parser/fol.y"
02013 {
02014 zzconsumeToken(zztokenList,")");
02015 if (folDbg >= 1) printf(") ");
02016 zzformulaStr.append(")");
02017 ;}
02018 break;
02019
02020 case 96:
02021 #line 1010 "../src/parser/fol.y"
02022 { if (folDbg >= 2) printf("sentence: atomic_sentence\n"); ;}
02023 break;
02024
02025 case 98:
02026 #line 1014 "../src/parser/fol.y"
02027 {
02028 const char* imp = zztokenList.removeLast();
02029 if (folDbg >= 1) printf("=> ");
02030 zzformulaStr.append(" => ");
02031 delete [] imp;
02032 ;}
02033 break;
02034
02035 case 99:
02036 #line 1022 "../src/parser/fol.y"
02037 { zzcreateListObjFromTopTwo(zzformulaListObjs, "=>"); ;}
02038 break;
02039
02040 case 100:
02041 #line 1026 "../src/parser/fol.y"
02042 {
02043 const char* eq = zztokenList.removeLast();
02044 if (folDbg >= 1) printf("<=> ");
02045 zzformulaStr.append(" <=> ");
02046 delete [] eq;
02047 ;}
02048 break;
02049
02050 case 101:
02051 #line 1034 "../src/parser/fol.y"
02052 { zzcreateListObjFromTopTwo(zzformulaListObjs, "<=>"); ;}
02053 break;
02054
02055 case 102:
02056 #line 1038 "../src/parser/fol.y"
02057 {
02058 zzconsumeToken(zztokenList,"v");
02059 if (folDbg >= 1) printf("v ");
02060 zzformulaStr.append(" v ");
02061 ;}
02062 break;
02063
02064 case 103:
02065 #line 1045 "../src/parser/fol.y"
02066 { zzcreateListObjFromTopTwo(zzformulaListObjs, "v"); ;}
02067 break;
02068
02069 case 104:
02070 #line 1049 "../src/parser/fol.y"
02071 {
02072 zzconsumeToken(zztokenList,"^");
02073 if (folDbg >= 1) printf("^ ");
02074 zzformulaStr.append(" ^ ");
02075 ;}
02076 break;
02077
02078 case 105:
02079 #line 1056 "../src/parser/fol.y"
02080 { zzcreateListObjFromTopTwo(zzformulaListObjs, "^"); ;}
02081 break;
02082
02083 case 106:
02084 #line 1060 "../src/parser/fol.y"
02085 { if (folDbg >= 2) printf("sentence: quantifier\n"); ;}
02086 break;
02087
02088 case 107:
02089 #line 1062 "../src/parser/fol.y"
02090 {
02091 if (folDbg >= 2) printf("sentence: variables\n");
02092 zzformulaListObjs.push(new ListObj);
02093 pair<StringToStringMap*,int> pr(new StringToStringMap,zzscopeCounter++);
02094 zzoldNewVarList.push_front(pr);
02095 ;}
02096 break;
02097
02098 case 108:
02099 #line 1068 "../src/parser/fol.y"
02100 { if (folDbg >= 2) printf("sentence: sentence\n"); ;}
02101 break;
02102
02103 case 109:
02104 #line 1070 "../src/parser/fol.y"
02105 {
02106 zzcreateListObjFromTopThree(zzformulaListObjs);
02107 pair<StringToStringMap*, int> pr = zzoldNewVarList.front();
02108 zzoldNewVarList.pop_front();
02109 delete pr.first;
02110 ;}
02111 break;
02112
02113 case 110:
02114 #line 1079 "../src/parser/fol.y"
02115 {
02116 zzassert(!zzisNegated,"expecting !zzisNegated");
02117 zzisNegated = true;
02118
02119 zzconsumeToken(zztokenList,"!");
02120 if (folDbg >= 1) printf("! ");
02121 if (folDbg >= 2) printf("sentence: sentence\n");
02122 zzformulaStr.append("!");
02123 ;}
02124 break;
02125
02126 case 111:
02127 #line 1089 "../src/parser/fol.y"
02128 { zzcreateListObjFromTop(zzformulaListObjs, "!"); ;}
02129 break;
02130
02131 case 112:
02132 #line 1095 "../src/parser/fol.y"
02133 {
02134 const char* fa = zztokenList.removeLast();
02135 if (folDbg >= 1) printf("FORALL ");
02136 zzformulaListObjs.push(new ListObj("FORALL"));
02137 zzformulaStr.append("FORALL ");
02138 delete [] fa;
02139 ;}
02140 break;
02141
02142 case 113:
02143 #line 1103 "../src/parser/fol.y"
02144 {
02145 const char* ex = zztokenList.removeLast();
02146 if (folDbg >= 1) printf("EXIST ");
02147 zzformulaListObjs.push(new ListObj("EXIST"));
02148 zzformulaStr.append("EXIST ");
02149 delete [] ex;
02150 ;}
02151 break;
02152
02153 case 114:
02154 #line 1115 "../src/parser/fol.y"
02155 { if (folDbg >= 2) printf("variables: variables\n"); ;}
02156 break;
02157
02158 case 115:
02159 #line 1117 "../src/parser/fol.y"
02160 {
02161 zzconsumeToken(zztokenList,",");
02162 if (folDbg >= 1) printf(", ");
02163 zzformulaStr.append(",");
02164 ;}
02165 break;
02166
02167 case 117:
02168 #line 1124 "../src/parser/fol.y"
02169 { zzformulaStr.append(" "); ;}
02170 break;
02171
02172 case 118:
02173 #line 1129 "../src/parser/fol.y"
02174 {
02175 const char* varName = zztokenList.removeLast();
02176 if (folDbg >= 1) printf("v_%s ", varName);
02177
02178
02179 if (zzisConstant(varName))
02180 {
02181 zzerr("Variable %s must be begin with a lowercase character.", varName);
02182 ((char*)varName)[0] = tolower(varName[0]);
02183 }
02184
02185 int scopeNum = zzoldNewVarList.front().second;
02186 string newVarName = zzappend(varName,scopeNum);
02187
02188 StringToStringMap* oldNewVarMap = zzoldNewVarList.front().first;
02189 (*oldNewVarMap)[varName]=newVarName;
02190 zzvarNameToIdMap[newVarName] = ZZVarIdType(--zzvarCounter, zzanyTypeId);
02191 zzformulaListObjs.top()->append(newVarName.c_str());
02192 zzformulaStr.append(varName);
02193 delete [] varName;
02194 ;}
02195 break;
02196
02197 case 119:
02198 #line 1155 "../src/parser/fol.y"
02199 {
02200 const char* predName = zztokenList.removeLast();
02201 if (folDbg >= 1) printf("p_%s ", predName);
02202
02203 zzfdnumPreds++;
02204 ListObj* predlo = new ListObj;
02205
02206 if (PredicateTemplate::isInternalPredicateTemplateName(predName))
02207 {
02208
02209 zzinfixPredName = (char *)malloc((strlen(predName)
02210 + 1)*sizeof(char));
02211 strcpy(zzinfixPredName, predName);
02212 const PredicateTemplate* t = zzdomain->getEmptyPredicateTemplate();
02213 zzassert(zzpred == NULL,"expecting zzpred==NULL");
02214 zzpred = new Predicate(t);
02215 predlo->append(PredicateTemplate::EMPTY_NAME);
02216 }
02217 else
02218 {
02219 zzcreatePred(zzpred, predName);
02220 predlo->append(predName);
02221 }
02222
02223 zzformulaStr.append(predName);
02224 if(zzisNegated) { zzpred->setSense(false); zzisNegated = false; }
02225 zzpredFuncListObjs.push(predlo);
02226 delete [] predName;
02227 ;}
02228 break;
02229
02230 case 120:
02231 #line 1185 "../src/parser/fol.y"
02232 {
02233 zzconsumeToken(zztokenList, "(");
02234 if (folDbg >= 1) printf("( ");
02235 if (folDbg >= 2) printf("atomic_sentence: terms\n");
02236 zzformulaStr.append("(");
02237
02238 ;}
02239 break;
02240
02241 case 121:
02242 #line 1194 "../src/parser/fol.y"
02243 {
02244 zzconsumeToken(zztokenList, ")");
02245 if (folDbg >= 1) printf(") ");
02246
02247
02248
02249 if (zzinfixPredName)
02250 {
02251 ListObj* predlo = zzpredFuncListObjs.top();
02252 predlo->replace(PredicateTemplate::EMPTY_NAME, zzinfixPredName);
02253
02254
02255
02256 int lTypeId = zzgetTypeId(zzpred->getTerm(0), (*predlo)[1]->getStr());
02257 int rTypeId = zzgetTypeId(zzpred->getTerm(1), (*predlo)[2]->getStr());
02258
02259 if (lTypeId > 0 && rTypeId > 0)
02260 {
02261 if (lTypeId != rTypeId)
02262 zzerr("The types on the left and right of '=' must match.");
02263 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02264 {
02265 zzsetEqPredTypeName(lTypeId);
02266 }
02267 else
02268 {
02269 zzsetInternalPredTypeName(zzinfixPredName, lTypeId);
02270 }
02271 }
02272 else
02273 if ( (lTypeId<=0 && rTypeId>0) || (lTypeId>0 && rTypeId<=0) )
02274 {
02275 int knownTypeId = (lTypeId>0) ? lTypeId : rTypeId;
02276 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02277 {
02278 zzsetEqPredTypeName(knownTypeId);
02279 }
02280 else
02281 {
02282 zzsetInternalPredTypeName(zzinfixPredName, knownTypeId);
02283 }
02284 const char* lvarName = (*predlo)[1]->getStr();
02285 const char* rvarName = (*predlo)[2]->getStr();
02286 const char* unknownVarName = (lTypeId>0) ? rvarName : lvarName;
02287 zzvarNameToIdMap[unknownVarName].typeId_ = knownTypeId;
02288 }
02289 else
02290 {
02291
02292 const char* lvarName = (*predlo)[1]->getStr();
02293 const char* rvarName = (*predlo)[2]->getStr();
02294 lTypeId = zzgetVarTypeId(lvarName);
02295 rTypeId = zzgetVarTypeId(rvarName);
02296
02297 if (lTypeId > 0 && rTypeId > 0)
02298 {
02299 if (lTypeId != rTypeId)
02300 zzerr("The types of %s and %s on the left and right of "
02301 "'=' must match.", lvarName, rvarName);
02302 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02303 {
02304 zzsetEqPredTypeName(lTypeId);
02305 }
02306 else
02307 {
02308 zzsetInternalPredTypeName(zzinfixPredName, lTypeId);
02309 }
02310 }
02311 else
02312 if ( (lTypeId<=0 && rTypeId>0) || (lTypeId>0 && rTypeId<=0) )
02313 {
02314 int knownTypeId = (lTypeId>0) ? lTypeId : rTypeId;
02315 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02316 {
02317 zzsetEqPredTypeName(knownTypeId);
02318 }
02319 else
02320 {
02321 zzsetInternalPredTypeName(zzinfixPredName, knownTypeId);
02322 }
02323 const char* unknowVarName = (lTypeId>0) ? rvarName : lvarName;
02324 zzvarNameToIdMap[unknowVarName].typeId_ = knownTypeId;
02325 }
02326 else
02327 {
02328 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02329 {
02330 string unknownEqName = zzappend(PredicateTemplate::EQUAL_NAME,
02331 zzeqTypeCounter++);
02332 zzeqPredList.push_back(ZZUnknownEqPredInfo(unknownEqName,lvarName,
02333 rvarName));
02334 predlo->replace(PredicateTemplate::EQUAL_NAME, unknownEqName.c_str());
02335 }
02336 else
02337 {
02338 string unknownIntPredName =
02339 zzappendWithUnderscore(zzinfixPredName, zzintPredTypeCounter++);
02340 zzintPredList.push_back(ZZUnknownIntPredInfo(unknownIntPredName, lvarName,
02341 rvarName));
02342 predlo->replace(zzinfixPredName, unknownIntPredName.c_str());
02343 }
02344 }
02345 }
02346 free(zzinfixPredName);
02347 zzinfixPredName = NULL;
02348 }
02349
02350 zzcheckPredNumTerm(zzpred);
02351 delete zzpred;
02352 zzpred = NULL;
02353 zzassert(zzpredFuncListObjs.size()==1,
02354 "expecting zzpredFuncListObjs.size()==1");
02355 ListObj* predlo = zzpredFuncListObjs.top();
02356 zzpredFuncListObjs.pop();
02357
02358 if(zzisAsterisk)
02359 {
02360 zzisAsterisk = false;
02361 ListObj* lo = new ListObj;
02362 lo->append("*"); lo->append(predlo);
02363 zzformulaListObjs.push(lo);
02364 }
02365 else
02366 zzformulaListObjs.push(predlo);
02367
02368 zzformulaStr.append(")");
02369
02370
02371
02372 while (!zzfuncConjStack.empty())
02373 {
02374
02375
02376 ListObj* topPredlo = zzfuncConjStack.top();
02377 zzfuncConjStack.pop();
02378 zzformulaListObjs.push(topPredlo);
02379 zzcreateListObjFromTopTwo(zzformulaListObjs, "^");
02380 }
02381
02382 if (!zzfuncConjStr.empty())
02383 {
02384 zzformulaStr.append(zzfuncConjStr);
02385 zzfuncConjStr.clear();
02386 }
02387 zzfunc = NULL;
02388 ;}
02389 break;
02390
02391 case 122:
02392 #line 1342 "../src/parser/fol.y"
02393 {
02394 ++zzfdnumPreds;
02395
02396
02397 const PredicateTemplate* t = zzdomain->getEmptyPredicateTemplate();
02398
02399 zzassert(zzpred == NULL,"expecting zzpred==NULL");
02400 zzpred = new Predicate(t);
02401
02402 ListObj* predlo = new ListObj;
02403
02404 predlo->append(PredicateTemplate::EMPTY_NAME);
02405 zzpredFuncListObjs.push(predlo);
02406 if(zzisNegated) { zzpred->setSense(false); zzisNegated = false; }
02407
02408 if (folDbg >= 2) printf("atomic_sentence (left): term\n");
02409 ;}
02410 break;
02411
02412 case 123:
02413 #line 1361 "../src/parser/fol.y"
02414 {
02415 ListObj* predlo = zzpredFuncListObjs.top();
02416 predlo->replace(PredicateTemplate::EMPTY_NAME, zzinfixPredName);
02417
02418
02419 int lTypeId = zzgetTypeId(zzpred->getTerm(0), (*predlo)[1]->getStr());
02420 if (lTypeId>0)
02421 {
02422 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02423 {
02424 zzsetEqPredTypeName(lTypeId);
02425 }
02426 else
02427 {
02428 zzsetInternalPredTypeName(zzinfixPredName, lTypeId);
02429 }
02430 }
02431 ;}
02432 break;
02433
02434 case 124:
02435 #line 1380 "../src/parser/fol.y"
02436 {
02437 ListObj* predlo = zzpredFuncListObjs.top();
02438
02439
02440
02441
02442
02443 int lTypeId = zzgetTypeId(zzpred->getTerm(0), (*predlo)[1]->getStr());
02444 int rTypeId = zzgetTypeId(zzpred->getTerm(1), (*predlo)[2]->getStr());
02445
02446 if (lTypeId > 0 && rTypeId > 0)
02447 {
02448 if (lTypeId != rTypeId)
02449 zzerr("The types on the left and right of '=' must match.");
02450 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02451 {
02452 zzsetEqPredTypeName(lTypeId);
02453 }
02454 else
02455 {
02456 zzsetInternalPredTypeName(zzinfixPredName, lTypeId);
02457 }
02458 }
02459 else
02460 if ( (lTypeId<=0 && rTypeId>0) || (lTypeId>0 && rTypeId<=0) )
02461 {
02462 int knownTypeId = (lTypeId>0) ? lTypeId : rTypeId;
02463 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02464 {
02465 zzsetEqPredTypeName(knownTypeId);
02466 }
02467 else
02468 {
02469 zzsetInternalPredTypeName(zzinfixPredName, knownTypeId);
02470 }
02471 const char* lvarName = (*predlo)[1]->getStr();
02472 const char* rvarName = (*predlo)[2]->getStr();
02473 const char* unknownVarName = (lTypeId>0) ? rvarName : lvarName;
02474 zzvarNameToIdMap[unknownVarName].typeId_ = knownTypeId;
02475 }
02476 else
02477 {
02478
02479 const char* lvarName = (*predlo)[1]->getStr();
02480 const char* rvarName = (*predlo)[2]->getStr();
02481 lTypeId = zzgetVarTypeId(lvarName);
02482 rTypeId = zzgetVarTypeId(rvarName);
02483
02484 if (lTypeId > 0 && rTypeId > 0)
02485 {
02486 if (lTypeId != rTypeId)
02487 zzerr("The types of %s and %s on the left and right of "
02488 "'=' must match.", lvarName, rvarName);
02489 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02490 {
02491 zzsetEqPredTypeName(lTypeId);
02492 }
02493 else
02494 {
02495 zzsetInternalPredTypeName(zzinfixPredName, lTypeId);
02496 }
02497 }
02498 else
02499 if ( (lTypeId<=0 && rTypeId>0) || (lTypeId>0 && rTypeId<=0) )
02500 {
02501 int knownTypeId = (lTypeId>0) ? lTypeId : rTypeId;
02502 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02503 {
02504 zzsetEqPredTypeName(knownTypeId);
02505 }
02506 else
02507 {
02508 zzsetInternalPredTypeName(zzinfixPredName, knownTypeId);
02509 }
02510 const char* unknowVarName = (lTypeId>0) ? rvarName : lvarName;
02511 zzvarNameToIdMap[unknowVarName].typeId_ = knownTypeId;
02512 }
02513 else
02514 {
02515 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02516 {
02517 string unknownEqName = zzappend(PredicateTemplate::EQUAL_NAME,
02518 zzeqTypeCounter++);
02519 zzeqPredList.push_back(ZZUnknownEqPredInfo(unknownEqName,lvarName,
02520 rvarName));
02521 predlo->replace(PredicateTemplate::EQUAL_NAME, unknownEqName.c_str());
02522 }
02523 else
02524 {
02525 string unknownIntPredName =
02526 zzappendWithUnderscore(zzinfixPredName, zzintPredTypeCounter++);
02527 zzintPredList.push_back(ZZUnknownIntPredInfo(unknownIntPredName, lvarName,
02528 rvarName));
02529 predlo->replace(zzinfixPredName, unknownIntPredName.c_str());
02530 }
02531 }
02532 }
02533
02534
02535
02536
02537
02538
02539
02540 zzassert(zzpredFuncListObjs.size()==1,
02541 "expecting zzpredFuncListObjs.size()==1");
02542 ListObj* topPredlo = zzpredFuncListObjs.top();
02543 zzpredFuncListObjs.pop();
02544 zzformulaListObjs.push(topPredlo);
02545
02546 delete zzpred;
02547 zzpred = NULL;
02548
02549
02550
02551 while (!zzfuncConjStack.empty())
02552 {
02553
02554
02555
02556 ListObj* topPredlo = zzfuncConjStack.top();
02557 zzfuncConjStack.pop();
02558 zzformulaListObjs.push(topPredlo);
02559 zzcreateListObjFromTopTwo(zzformulaListObjs, "^");
02560 }
02561
02562 if (!zzfuncConjStr.empty())
02563 {
02564 zzformulaStr.append(zzfuncConjStr);
02565 zzfuncConjStr.clear();
02566 }
02567 zzfunc = NULL;
02568 free(zzinfixPredName);
02569 zzinfixPredName = NULL;
02570 ;}
02571 break;
02572
02573 case 125:
02574 #line 1519 "../src/parser/fol.y"
02575 {
02576 zzconsumeToken(zztokenList, ">");
02577 if (folDbg >= 1) printf("> ");
02578 if (folDbg >= 2) printf("atomic_sentence (right): term\n");
02579 zzformulaStr.append(" > ");
02580 zzinfixPredName = (char *)malloc((strlen(PredicateTemplate::GT_NAME)
02581 + 1)*sizeof(char));
02582 strcpy(zzinfixPredName, PredicateTemplate::GT_NAME);
02583
02584
02585
02586 ;}
02587 break;
02588
02589 case 126:
02590 #line 1533 "../src/parser/fol.y"
02591 {
02592 zzconsumeToken(zztokenList, "<");
02593 if (folDbg >= 1) printf("< ");
02594 if (folDbg >= 2) printf("atomic_sentence (right): term\n");
02595 zzformulaStr.append(" < ");
02596 zzinfixPredName = (char *)malloc((strlen(PredicateTemplate::LT_NAME)
02597 + 1)*sizeof(char));
02598 strcpy(zzinfixPredName, PredicateTemplate::LT_NAME);
02599
02600
02601
02602 ;}
02603 break;
02604
02605 case 127:
02606 #line 1547 "../src/parser/fol.y"
02607 {
02608 zzconsumeToken(zztokenList, ">");
02609 if (folDbg >= 1) printf(">");
02610 zzformulaStr.append(" >");
02611 zzconsumeToken(zztokenList, "=");
02612 if (folDbg >= 1) printf("= ");
02613 if (folDbg >= 2) printf("atomic_sentence (right): term\n");
02614 zzformulaStr.append("= ");
02615 zzinfixPredName = (char *)malloc((strlen(PredicateTemplate::GTEQ_NAME)
02616 + 1)*sizeof(char));
02617 strcpy(zzinfixPredName, PredicateTemplate::GTEQ_NAME);
02618
02619
02620
02621 ;}
02622 break;
02623
02624 case 128:
02625 #line 1564 "../src/parser/fol.y"
02626 {
02627 zzconsumeToken(zztokenList, "<");
02628 if (folDbg >= 1) printf("<");
02629 zzformulaStr.append(" <");
02630 zzconsumeToken(zztokenList, "=");
02631 if (folDbg >= 1) printf("= ");
02632 if (folDbg >= 2) printf("atomic_sentence (right): term\n");
02633 zzformulaStr.append("= ");
02634 zzinfixPredName = (char *)malloc((strlen(PredicateTemplate::LTEQ_NAME)
02635 + 1)*sizeof(char));
02636 strcpy(zzinfixPredName, PredicateTemplate::LTEQ_NAME);
02637
02638
02639
02640 ;}
02641 break;
02642
02643 case 129:
02644 #line 1581 "../src/parser/fol.y"
02645 {
02646 zzconsumeToken(zztokenList, "=");
02647 if (folDbg >= 1) printf("= ");
02648 if (folDbg >= 2) printf("atomic_sentence (right): term\n");
02649 zzformulaStr.append(" = ");
02650 zzinfixPredName = (char *)malloc((strlen(PredicateTemplate::EQUAL_NAME)
02651 + 1)*sizeof(char));
02652 strcpy(zzinfixPredName, PredicateTemplate::EQUAL_NAME);
02653 const PredicateTemplate* t = zzdomain->getEqualPredicateTemplate();
02654 zzpred->setTemplate((PredicateTemplate*)t);
02655 ;}
02656 break;
02657
02658 case 131:
02659 #line 1598 "../src/parser/fol.y"
02660 {
02661 zzconsumeToken(zztokenList, "*");
02662 if (folDbg >= 1) printf("* ");
02663 if (zzisNegated) zzerr("'!' and '*' cannot be used at the same time");
02664 zznumAsterisk++;
02665 zzassert(!zzisAsterisk,"expecting !zzisAsterisk");
02666 zzisAsterisk = true;
02667 zzformulaStr.append("*");
02668 ;}
02669 break;
02670
02671 case 132:
02672 #line 1615 "../src/parser/fol.y"
02673 {
02674 zzconsumeToken(zztokenList, ",");
02675 if (folDbg >= 1) printf(", ");
02676 if (folDbg >= 2) printf("terms: term\n");
02677
02678 if (zzfunc == NULL) zzformulaStr.append(",");
02679 ;}
02680 break;
02681
02682 case 134:
02683 #line 1626 "../src/parser/fol.y"
02684 {
02685
02686 if (zzpred && zzpred->isEmptyPred() &&
02687 zzpred->getNumTerms() == 1 && zzinfixPredName)
02688 {
02689 ListObj* predlo = zzpredFuncListObjs.top();
02690 predlo->replace(PredicateTemplate::EMPTY_NAME, zzinfixPredName);
02691
02692
02693 int lTypeId = zzgetTypeId(zzpred->getTerm(0), (*predlo)[1]->getStr());
02694 if (lTypeId>0)
02695 {
02696 if (strcmp(zzinfixPredName, PredicateTemplate::EQUAL_NAME)==0)
02697 {
02698 zzsetEqPredTypeName(lTypeId);
02699 }
02700 else
02701 {
02702 zzsetInternalPredTypeName(zzinfixPredName, lTypeId);
02703 }
02704 }
02705 }
02706 ;}
02707 break;
02708
02709 case 135:
02710 #line 1654 "../src/parser/fol.y"
02711 {
02712 zzassert(zzfunc != NULL,"expecting zzfunc != NULL");
02713 zzcheckFuncNumTerm(zzfunc);
02714 zzassert(zzpred != NULL, "expecting zzpred != NULL");
02715
02716
02717
02718
02719
02720
02721
02722 char* varName;
02723 string newVarName;
02724
02725
02726 ZZFuncToFuncVarMap::iterator mit;
02727 if ((mit = zzfuncToFuncVarMap.find(zzfunc)) != zzfuncToFuncVarMap.end())
02728 {
02729 newVarName = (*mit).second;
02730 varName = (char *)malloc((strlen(newVarName.c_str()) + 1) * sizeof(char));
02731 strcpy(varName, newVarName.c_str());
02732 }
02733 else
02734 {
02735 char funcVarCounterString[10];
02736 int funcVarCounterLength =
02737 sprintf(funcVarCounterString, "%d", zzfuncVarCounter);
02738 varName = (char *)malloc((strlen(ZZ_FUNCVAR_PREFIX) +
02739 funcVarCounterLength + 1)*sizeof(char));
02740 strcpy(varName, ZZ_FUNCVAR_PREFIX);
02741 strcat(varName, funcVarCounterString);
02742 ++zzfdnumVars;
02743 ++zzfuncVarCounter;
02744 newVarName = zzgetNewVarName(varName);
02745
02746 Function* func = new Function(*zzfunc);
02747 zzfuncToFuncVarMap[func] = newVarName;
02748 }
02749
02750 bool rightNumTerms = true;
02751 bool rightType = true;
02752 int exp, unexp;
02753
02754
02755
02756 char* predName;
02757 predName = (char *)malloc((strlen(PredicateTemplate::ZZ_RETURN_PREFIX) +
02758 strlen(zzfunc->getName()) + 1)*sizeof(char));
02759 strcpy(predName, PredicateTemplate::ZZ_RETURN_PREFIX);
02760 strcat(predName, zzfunc->getName());
02761
02762
02763 if (zzdomain->getPredicateId(predName) < 0)
02764 {
02765 zzassert(zzpredTemplate==NULL,"expecting zzpredTemplate==NULL");
02766 zzpredTemplate = new PredicateTemplate();
02767 zzpredTemplate->setName(predName);
02768
02769
02770
02771 const char* ttype = zzfunc->getRetTypeName();
02772 zzaddType(ttype, zzpredTemplate, NULL, false, zzdomain);
02773
02774
02775 for (int i = 0; i < zzfunc->getNumTerms(); i++)
02776 {
02777 const char* ttype = zzfunc->getTermTypeAsStr(i);
02778 zzaddType(ttype, zzpredTemplate, NULL, false, zzdomain);
02779 }
02780
02781 zzassert(zzpredTemplate, "not expecting zzpredTemplate==NULL");
02782 int id = zzdomain->addPredicateTemplate(zzpredTemplate);
02783 zzassert(id >= 0, "expecting pred template id >= 0");
02784 zzpredTemplate->setId(id);
02785 zzpredTemplate = NULL;
02786 }
02787
02788 Predicate* prevPred = zzpred;
02789 zzpred = NULL;
02790 zzfdnumPreds++;
02791 zzcreatePred(zzpred, predName);
02792
02793 ListObj* predlo = new ListObj;
02794 predlo->append(predName);
02795
02796
02797 zzfuncConjStack.push(predlo);
02798 zzfuncConjStr.append(" ^ ");
02799 zzfuncConjStr.append(predName);
02800 zzfuncConjStr.append("(");
02801 zzputVariableInPred(varName, folDbg);
02802 zzfuncConjStack.top()->append(varName);
02803 zzfuncConjStr.append(varName);
02804
02805
02806 for (int i = 0; i < zzfunc->getNumTerms(); i++)
02807 {
02808 zzfuncConjStr.append(", ");
02809 Term* term = new Term(*zzfunc->getTerm(i));
02810 zzpred->appendTerm(term);
02811
02812 const char* name;
02813 if (term->getType() == Term::VARIABLE)
02814 {
02815 name = (*zzpredFuncListObjs.top())[i+1]->getStr();
02816 }
02817 else if (term->getType() == Term::CONSTANT)
02818 {
02819 name = zzdomain->getConstantName(term->getId());
02820 }
02821 zzpredFuncListObjs.top()->append(name);
02822 zzfuncConjStack.top()->append(name);
02823 zzfuncConjStr.append(name);
02824 }
02825 zzfuncConjStr.append(")");
02826
02827
02828 if (!zzfuncStack.empty())
02829 {
02830 Function* prevFunc = zzfuncStack.top();
02831 zzfuncStack.pop();
02832
02833
02834 if ((unexp=prevFunc->getNumTerms()) ==
02835 (exp=prevFunc->getTemplate()->getNumTerms()))
02836 {
02837 rightNumTerms = false;
02838 zzerr("Wrong number of terms for function %s. "
02839 "Expected %d but given %d", prevFunc->getName(), exp, unexp+1);
02840 }
02841
02842 int varId = -1;
02843 if (rightNumTerms)
02844 {
02845
02846 int typeId = prevFunc->getTermTypeAsInt(prevFunc->getNumTerms());
02847 rightType = zzcheckRightTypeAndGetVarId(typeId, newVarName.c_str(),
02848 varId);
02849 }
02850
02851 if (rightNumTerms && rightType)
02852 {
02853 prevFunc->appendTerm(new Term(varId, (void*)prevFunc, false));
02854 zzpredFuncListObjs.pop();
02855 zzpredFuncListObjs.top()->append(newVarName.c_str());
02856 }
02857
02858 zzfunc = prevFunc;
02859 }
02860 else
02861 {
02862
02863 if ((unexp=prevPred->getNumTerms()) ==
02864 (exp=prevPred->getTemplate()->getNumTerms()))
02865 {
02866 rightNumTerms = false;
02867 zzerr("Wrong number of terms for predicate %s. "
02868 "Expected %d but given %d", prevPred->getName(), exp, unexp+1);
02869 }
02870
02871 int varId = -1;
02872 if (rightNumTerms)
02873 {
02874
02875 int typeId = prevPred->getTermTypeAsInt(prevPred->getNumTerms());
02876 rightType = zzcheckRightTypeAndGetVarId(typeId, newVarName.c_str(),
02877 varId);
02878 }
02879
02880 if (rightNumTerms && rightType)
02881 {
02882 prevPred->appendTerm(new Term(varId, (void*)prevPred, true));
02883
02884
02885 zzoldFuncLo = zzpredFuncListObjs.top();
02886 zzpredFuncListObjs.pop();
02887 zzpredFuncListObjs.top()->append(newVarName.c_str());
02888 zzformulaStr.append(varName);
02889 }
02890 zzfunc = NULL;
02891
02892 }
02893 free(varName);
02894 free(predName);
02895
02896
02897 delete zzpred;
02898 zzpred = prevPred;
02899 ;}
02900 break;
02901
02902 case 136:
02903 #line 1845 "../src/parser/fol.y"
02904 {
02905 const char* constName = zztokenList.removeLast();
02906 if (folDbg >= 1) printf("c2_%s ", constName);
02907 zztermIsConstant(constName);
02908 if (zzfunc) zzfdfuncConstants.append(string(constName));
02909 else zzfdconstName = constName;
02910 delete [] constName;
02911 ;}
02912 break;
02913
02914 case 137:
02915 #line 1855 "../src/parser/fol.y"
02916 {
02917 const char* constName = zztokenList.removeLast();
02918 if (folDbg >= 1) printf("c2_%s ", constName);
02919 if (zzconstantMustBeDeclared)
02920 zzerr("Constant %s must be declared before it is used", constName);
02921 zztermIsConstant(constName);
02922 if (zzfunc) zzfdfuncConstants.append(string(constName));
02923 else zzfdconstName = constName;
02924 delete [] constName;
02925 ;}
02926 break;
02927
02928 case 138:
02929 #line 1867 "../src/parser/fol.y"
02930 {
02931 const char* intStr = zztokenList.removeLast();
02932 if (folDbg >= 1) printf("c3_%s ", intStr);
02933
02934 char constName[100];
02935 zzcreateAndCheckIntConstant(intStr, zzfunc, zzpred, zzdomain, constName);
02936 if (constName == NULL) { break; delete [] intStr; }
02937
02938 zztermIsConstant(constName);
02939 if (zzfunc) zzfdfuncConstants.append(string(constName));
02940 else zzfdconstName = constName;
02941 delete [] intStr;
02942 ;}
02943 break;
02944
02945 case 139:
02946 #line 1882 "../src/parser/fol.y"
02947 {
02948 zztermIsVariable(folDbg);
02949 if (zzisPlus) zzisPlus = false;
02950 ;}
02951 break;
02952
02953 case 140:
02954 #line 1888 "../src/parser/fol.y"
02955 {
02956 zztermIsVariable(folDbg);
02957
02958 zzconsumeToken(zztokenList, "!");
02959 if (folDbg >= 1) printf("! ");
02960 if (zzisPlus) { zzisPlus = false; zzerr("'+' cannot be used with '!'"); }
02961 if (zzfunc) zzerr("'+' cannot be used in a function");
02962 if (zzpred)
02963 {
02964 if (!zzpred->getSense())
02965 zzerr("'!' cannot be used on a variable of a negated predicate.");
02966 int termIdx = zzpred->getNumTerms()-1;
02967 if (zzpred->getTerm(termIdx)->isConstant())
02968 zzerr("'!' cannot be used with a constant term.");
02969 zzuniqueVarIndexes.append(termIdx);
02970 }
02971 else
02972 { zzexit("zzpred is NULL in 'not' grammar rule"); }
02973
02974 zzformulaStr.append("!");
02975 ;}
02976 break;
02977
02978 case 142:
02979 #line 1914 "../src/parser/fol.y"
02980 {
02981 zzconsumeToken(zztokenList, "+");
02982 if (folDbg >= 1) printf("+ ");
02983 zzassert(!zzisPlus,"expecting !zzisPlus");
02984 zzisPlus = true;
02985 zzformulaStr.append("+");
02986 ;}
02987 break;
02988
02989 case 143:
02990 #line 1925 "../src/parser/fol.y"
02991 {
02992 const char* funcName = zztokenList.removeLast();
02993 if (folDbg >= 1) printf("f_%s ", funcName);
02994 if (zzfunc != NULL) { zzfuncStack.push(zzfunc); zzfunc = NULL; }
02995 ++zzfdnumFuncs;
02996 zzfdfuncName = funcName;
02997
02998 ListObj* funclo = new ListObj;
02999
03000
03001 if (FunctionTemplate::isInternalFunctionTemplateName(funcName))
03002 {
03003 zzinfixFuncName = (char *)malloc((strlen(funcName)
03004 + 1)*sizeof(char));
03005 strcpy(zzinfixFuncName, funcName);
03006 const FunctionTemplate* t;
03007 if (FunctionTemplate::isInternalFunctionUnaryTemplateName(funcName))
03008 t = zzdomain->getEmptyFunctionUnaryTemplate();
03009 else
03010 t = zzdomain->getEmptyFunctionBinaryTemplate();
03011 zzassert(zzfunc == NULL,"expecting zzfunc==NULL");
03012 zzfunc = new Function(t);
03013 funclo->append(FunctionTemplate::EMPTY_FTEMPLATE_NAME);
03014 }
03015 else
03016 {
03017 zzcreateFunc(zzfunc, funcName);
03018 funclo->append(funcName);
03019 }
03020
03021 zzpredFuncListObjs.push(funclo);
03022
03023
03024 delete [] funcName;
03025 ;}
03026 break;
03027
03028 case 144:
03029 #line 1961 "../src/parser/fol.y"
03030 {
03031 zzconsumeToken(zztokenList, "(");
03032 if (folDbg >= 1) printf("( ");
03033 if (folDbg >= 2) printf("term: terms\n");
03034 ;}
03035 break;
03036
03037 case 145:
03038 #line 1967 "../src/parser/fol.y"
03039 {
03040
03041 if (zzinfixFuncName)
03042 {
03043 ListObj* funclo = zzpredFuncListObjs.top();
03044 funclo->replace(FunctionTemplate::EMPTY_FTEMPLATE_NAME, zzinfixFuncName);
03045 const FunctionTemplate* t = zzgetGenericInternalFunctionTemplate(zzinfixFuncName);
03046
03047 if (zzpred)
03048 {
03049 ((FunctionTemplate*)t)->setRetTypeId(
03050 zzpred->getTermTypeAsInt(zzpred->getNumTerms()), zzdomain);
03051 }
03052 zzfunc->setTemplate((FunctionTemplate*)t);
03053
03054
03055 bool unknownTypes = false;
03056
03057
03058 Array<int> typeIds(zzfunc->getNumTerms() + 1);
03059 typeIds.append(zzfunc->getRetTypeId());
03060 if (typeIds[0] <= 0) unknownTypes = true;
03061
03062
03063 for (int i = 1; i <= zzfunc->getNumTerms(); i++)
03064 {
03065 typeIds.append(zzgetTypeId(zzfunc->getTerm(i-1), (*funclo)[i]->getStr()));
03066 if (typeIds[i] <= 0) unknownTypes = true;
03067 }
03068
03069
03070 if (!unknownTypes)
03071 {
03072 zzsetInternalFuncTypeName(zzinfixFuncName, typeIds);
03073 }
03074 else
03075 {
03076 Array<string> varNames(typeIds.size());
03077
03078 char* varName;
03079 char funcVarCounterString[10];
03080 int funcVarCounterLength =
03081 sprintf(funcVarCounterString, "%d", zzfuncVarCounter);
03082 varName = (char *)malloc((strlen(ZZ_FUNCVAR_PREFIX) +
03083 funcVarCounterLength + 1)*sizeof(char));
03084 strcpy(varName, ZZ_FUNCVAR_PREFIX);
03085 strcat(varName, funcVarCounterString);
03086 string newVarName = zzgetNewVarName(varName);
03087
03088 varNames.append(newVarName);
03089
03090 for (int i = 1; i < typeIds.size(); i++)
03091 varNames[i] = (*funclo)[i]->getStr();
03092
03093
03094 char* predName;
03095 predName = (char *)malloc((strlen(PredicateTemplate::ZZ_RETURN_PREFIX) +
03096 strlen(zzfunc->getName()) + 1)*sizeof(char));
03097 strcpy(predName, PredicateTemplate::ZZ_RETURN_PREFIX);
03098 strcat(predName, zzinfixFuncName);
03099
03100 string unknownIntFuncName =
03101 zzappendWithUnderscore(predName, zzintFuncTypeCounter++);
03102 zzintFuncList.push_back(ZZUnknownIntFuncInfo(unknownIntFuncName, varNames));
03103
03104 free(predName);
03105 free(varName);
03106 }
03107 free(zzinfixFuncName);
03108 zzinfixFuncName = NULL;
03109 }
03110
03111 zzconsumeToken(zztokenList, ")");
03112 if (folDbg >= 1) printf(") ");
03113 ;}
03114 break;
03115
03116 case 146:
03117 #line 2043 "../src/parser/fol.y"
03118 {
03119
03120 const char* funcName = FunctionTemplate::EMPTY_FTEMPLATE_NAME;
03121 if (zzfunc != NULL) { zzfuncStack.push(zzfunc); zzfunc = NULL; }
03122 ++zzfdnumFuncs;
03123 zzfdfuncName = funcName;
03124
03125 const FunctionTemplate* t = zzdomain->getEmptyFunctionBinaryTemplate();
03126 zzassert(zzfunc == NULL, "expect zzfunc == NULL");
03127 zzfunc = new Function(t);
03128
03129 ListObj* funclo = new ListObj;
03130 funclo->append(funcName);
03131 zzpredFuncListObjs.push(funclo);
03132 ;}
03133 break;
03134
03135 case 147:
03136 #line 2059 "../src/parser/fol.y"
03137 {
03138 zzconsumeToken(zztokenList, "(");
03139 if (folDbg >= 1) printf("( ");
03140 ;}
03141 break;
03142
03143 case 148:
03144 #line 2064 "../src/parser/fol.y"
03145 {
03146
03147
03148
03149
03150
03151
03152
03153
03154
03155 ;}
03156 break;
03157
03158 case 149:
03159 #line 2076 "../src/parser/fol.y"
03160 {
03161 ListObj* funclo = zzpredFuncListObjs.top();
03162 funclo->replace(FunctionTemplate::EMPTY_FTEMPLATE_NAME, zzinfixFuncName);
03163 const FunctionTemplate* t = zzgetGenericInternalFunctionTemplate(zzinfixFuncName);
03164
03165 if (zzpred)
03166 ((FunctionTemplate*)t)->setRetTypeId(
03167 zzpred->getTermTypeAsInt(zzpred->getNumTerms()), zzdomain);
03168 zzfunc->setTemplate((FunctionTemplate*)t);
03169
03170
03171 bool unknownTypes = false;
03172
03173
03174 Array<int> typeIds(zzfunc->getNumTerms() + 1);
03175 typeIds.append(zzfunc->getRetTypeId());
03176 if (typeIds[0] <= 0) unknownTypes = true;
03177
03178
03179 for (int i = 1; i <= zzfunc->getNumTerms(); i++)
03180 {
03181 typeIds.append(zzgetTypeId(zzfunc->getTerm(i-1), (*funclo)[i]->getStr()));
03182 if (typeIds[i] <= 0) unknownTypes = true;
03183 }
03184
03185
03186 if (!unknownTypes)
03187 {
03188 zzsetInternalFuncTypeName(zzinfixFuncName, typeIds);
03189 }
03190 else
03191 {
03192 Array<string> varNames(typeIds.size());
03193
03194 char* varName;
03195 char funcVarCounterString[10];
03196 int funcVarCounterLength =
03197 sprintf(funcVarCounterString, "%d", zzfuncVarCounter);
03198 varName = (char *)malloc((strlen(ZZ_FUNCVAR_PREFIX) +
03199 funcVarCounterLength + 1)*sizeof(char));
03200 strcpy(varName, ZZ_FUNCVAR_PREFIX);
03201 strcat(varName, funcVarCounterString);
03202 string newVarName = zzgetNewVarName(varName);
03203
03204 varNames.append(newVarName);
03205
03206 for (int i = 1; i < typeIds.size(); i++)
03207 varNames[i] = (*funclo)[i]->getStr();
03208
03209 char* predName;
03210 predName = (char *)malloc((strlen(PredicateTemplate::ZZ_RETURN_PREFIX) +
03211 strlen(zzfunc->getName()) + 1)*sizeof(char));
03212 strcpy(predName, PredicateTemplate::ZZ_RETURN_PREFIX);
03213 strcat(predName, zzinfixFuncName);
03214
03215 string unknownIntFuncName =
03216 zzappendWithUnderscore(predName, zzintFuncTypeCounter++);
03217 zzintFuncList.push_back(ZZUnknownIntFuncInfo(unknownIntFuncName, varNames));
03218
03219 free(predName);
03220 free(varName);
03221 }
03222 free(zzinfixFuncName);
03223 zzinfixFuncName = NULL;
03224
03225 zzconsumeToken(zztokenList, ")");
03226 if (folDbg >= 1) printf(") ");
03227 ;}
03228 break;
03229
03230 case 150:
03231 #line 2149 "../src/parser/fol.y"
03232 {
03233 zzconsumeToken(zztokenList, "+");
03234 if (folDbg >= 1) printf("+ ");
03235 zzinfixFuncName = (char *)malloc((strlen(PredicateTemplate::PLUS_NAME)
03236 + 1)*sizeof(char));
03237 strcpy(zzinfixFuncName, PredicateTemplate::PLUS_NAME);
03238 ;}
03239 break;
03240
03241 case 151:
03242 #line 2158 "../src/parser/fol.y"
03243 {
03244 zzconsumeToken(zztokenList, "-");
03245 if (folDbg >= 1) printf("- ");
03246 zzinfixFuncName = (char *)malloc((strlen(PredicateTemplate::MINUS_NAME)
03247 + 1)*sizeof(char));
03248 strcpy(zzinfixFuncName, PredicateTemplate::MINUS_NAME);
03249 ;}
03250 break;
03251
03252 case 152:
03253 #line 2167 "../src/parser/fol.y"
03254 {
03255 zzconsumeToken(zztokenList, "*");
03256 if (folDbg >= 1) printf("* ");
03257 zzinfixFuncName = (char *)malloc((strlen(PredicateTemplate::TIMES_NAME)
03258 + 1)*sizeof(char));
03259 strcpy(zzinfixFuncName, PredicateTemplate::TIMES_NAME);
03260 ;}
03261 break;
03262
03263 case 153:
03264 #line 2176 "../src/parser/fol.y"
03265 {
03266 zzconsumeToken(zztokenList, "/");
03267 if (folDbg >= 1) printf("/ ");
03268 zzinfixFuncName = (char *)malloc((strlen(PredicateTemplate::DIVIDEDBY_NAME)
03269 + 1)*sizeof(char));
03270 strcpy(zzinfixFuncName, PredicateTemplate::DIVIDEDBY_NAME);
03271 ;}
03272 break;
03273
03274 case 154:
03275 #line 2185 "../src/parser/fol.y"
03276 {
03277 zzconsumeToken(zztokenList, "%");
03278 if (folDbg >= 1) printf("%% ");
03279 zzinfixFuncName = (char *)malloc((strlen(PredicateTemplate::MOD_NAME)
03280 + 1)*sizeof(char));
03281 strcpy(zzinfixFuncName, PredicateTemplate::MOD_NAME);
03282 ;}
03283 break;
03284
03285
03286 default: break;
03287 }
03288
03289 return yyok;
03290 # undef yyerrok
03291 # undef YYABORT
03292 # undef YYACCEPT
03293 # undef YYERROR
03294 # undef YYBACKUP
03295 # undef yyclearin
03296 # undef YYRECOVERING
03297
03298 #line 3299 "fol.cpp"
03299 }
03300
03301
03302 static void
03303 yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
03304 {
03305
03306 (void) yy0;
03307 (void) yy1;
03308
03309 switch (yyn)
03310 {
03311
03312 default: break;
03313 }
03314 }
03315
03316
03317
03318
03319
03320
03321
03322 static void
03323 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
03324 {
03325
03326 (void) yyvaluep;
03327
03328 if (!yymsg)
03329 yymsg = "Deleting";
03330 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
03331
03332 switch (yytype)
03333 {
03334
03335 default:
03336 break;
03337 }
03338 }
03339
03341 static inline int
03342 yyrhsLength (yyRuleNum yyrule)
03343 {
03344 return yyr2[yyrule];
03345 }
03346
03347 static void
03348 yydestroyGLRState (char const *yymsg, yyGLRState *yys)
03349 {
03350 if (yys->yyresolved)
03351 yydestruct (yymsg, yystos[yys->yylrState],
03352 &yys->yysemantics.yysval);
03353 else
03354 {
03355 #if YYDEBUG
03356 if (yydebug)
03357 {
03358 YYFPRINTF (stderr, "%s unresolved ", yymsg);
03359 yysymprint (stderr, yystos[yys->yylrState],
03360 &yys->yysemantics.yysval);
03361 YYFPRINTF (stderr, "\n");
03362 }
03363 #endif
03364
03365 if (yys->yysemantics.yyfirstVal)
03366 {
03367 yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;
03368 yyGLRState *yyrh;
03369 int yyn;
03370 for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
03371 yyn > 0;
03372 yyrh = yyrh->yypred, yyn -= 1)
03373 yydestroyGLRState (yymsg, yyrh);
03374 }
03375 }
03376 }
03377
03379 static inline yySymbol
03380 yylhsNonterm (yyRuleNum yyrule)
03381 {
03382 return yyr1[yyrule];
03383 }
03384
03385 #define yyis_pact_ninf(yystate) \
03386 ((yystate) == YYPACT_NINF)
03387
03390 static inline yybool
03391 yyisDefaultedState (yyStateNum yystate)
03392 {
03393 return yyis_pact_ninf (yypact[yystate]);
03394 }
03395
03397 static inline yyRuleNum
03398 yydefaultAction (yyStateNum yystate)
03399 {
03400 return yydefact[yystate];
03401 }
03402
03403 #define yyis_table_ninf(yytable_value) \
03404 0
03405
03414 static inline void
03415 yygetLRActions (yyStateNum yystate, int yytoken,
03416 int* yyaction, const short int** yyconflicts)
03417 {
03418 int yyindex = yypact[yystate] + yytoken;
03419 if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
03420 {
03421 *yyaction = -yydefact[yystate];
03422 *yyconflicts = yyconfl;
03423 }
03424 else if (! yyis_table_ninf (yytable[yyindex]))
03425 {
03426 *yyaction = yytable[yyindex];
03427 *yyconflicts = yyconfl + yyconflp[yyindex];
03428 }
03429 else
03430 {
03431 *yyaction = 0;
03432 *yyconflicts = yyconfl + yyconflp[yyindex];
03433 }
03434 }
03435
03436 static inline yyStateNum
03437 yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
03438 {
03439 int yyr;
03440 yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
03441 if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
03442 return yytable[yyr];
03443 else
03444 return yydefgoto[yylhs - YYNTOKENS];
03445 }
03446
03447 static inline yybool
03448 yyisShiftAction (int yyaction)
03449 {
03450 return 0 < yyaction;
03451 }
03452
03453 static inline yybool
03454 yyisErrorAction (int yyaction)
03455 {
03456 return yyaction == 0;
03457 }
03458
03459
03460
03461 static void
03462 yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,
03463 yyGLRState* rhs, yyRuleNum yyrule)
03464 {
03465 yySemanticOption* yynewItem;
03466 yynewItem = &yystack->yynextFree->yyoption;
03467 yystack->yyspaceLeft -= 1;
03468 yystack->yynextFree += 1;
03469 yynewItem->yyisState = yyfalse;
03470 yynewItem->yystate = rhs;
03471 yynewItem->yyrule = yyrule;
03472 yynewItem->yynext = yystate->yysemantics.yyfirstVal;
03473 yystate->yysemantics.yyfirstVal = yynewItem;
03474 if (yystack->yyspaceLeft < YYHEADROOM)
03475 yyexpandGLRStack (yystack);
03476 }
03477
03478
03479
03481 static yybool
03482 yyinitStateSet (yyGLRStateSet* yyset)
03483 {
03484 yyset->yysize = 1;
03485 yyset->yycapacity = 16;
03486 yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
03487 if (! yyset->yystates)
03488 return yyfalse;
03489 yyset->yystates[0] = NULL;
03490 return yytrue;
03491 }
03492
03493 static void yyfreeStateSet (yyGLRStateSet* yyset)
03494 {
03495 YYFREE (yyset->yystates);
03496 }
03497
03500 static yybool
03501 yyinitGLRStack (yyGLRStack* yystack, size_t yysize)
03502 {
03503 yystack->yyerrState = 0;
03504 yynerrs = 0;
03505 yystack->yyspaceLeft = yysize;
03506 yystack->yyitems =
03507 (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystack->yynextFree[0]);
03508 if (!yystack->yyitems)
03509 return yyfalse;
03510 yystack->yynextFree = yystack->yyitems;
03511 yystack->yysplitPoint = NULL;
03512 yystack->yylastDeleted = NULL;
03513 return yyinitStateSet (&yystack->yytops);
03514 }
03515
03516 #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
03517 &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
03518
03524 static void
03525 yyexpandGLRStack (yyGLRStack* yystack)
03526 {
03527 #if YYSTACKEXPANDABLE
03528 yyGLRStackItem* yynewItems;
03529 yyGLRStackItem* yyp0, *yyp1;
03530 size_t yysize, yynewSize;
03531 size_t yyn;
03532 yysize = yystack->yynextFree - yystack->yyitems;
03533 if (YYMAXDEPTH <= yysize)
03534 yyMemoryExhausted (yystack);
03535 yynewSize = 2*yysize;
03536 if (YYMAXDEPTH < yynewSize)
03537 yynewSize = YYMAXDEPTH;
03538 yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]);
03539 if (! yynewItems)
03540 yyMemoryExhausted (yystack);
03541 for (yyp0 = yystack->yyitems, yyp1 = yynewItems, yyn = yysize;
03542 0 < yyn;
03543 yyn -= 1, yyp0 += 1, yyp1 += 1)
03544 {
03545 *yyp1 = *yyp0;
03546 if (*(yybool *) yyp0)
03547 {
03548 yyGLRState* yys0 = &yyp0->yystate;
03549 yyGLRState* yys1 = &yyp1->yystate;
03550 if (yys0->yypred != NULL)
03551 yys1->yypred =
03552 YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
03553 if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != NULL)
03554 yys1->yysemantics.yyfirstVal =
03555 YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
03556 }
03557 else
03558 {
03559 yySemanticOption* yyv0 = &yyp0->yyoption;
03560 yySemanticOption* yyv1 = &yyp1->yyoption;
03561 if (yyv0->yystate != NULL)
03562 yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
03563 if (yyv0->yynext != NULL)
03564 yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
03565 }
03566 }
03567 if (yystack->yysplitPoint != NULL)
03568 yystack->yysplitPoint = YYRELOC (yystack->yyitems, yynewItems,
03569 yystack->yysplitPoint, yystate);
03570
03571 for (yyn = 0; yyn < yystack->yytops.yysize; yyn += 1)
03572 if (yystack->yytops.yystates[yyn] != NULL)
03573 yystack->yytops.yystates[yyn] =
03574 YYRELOC (yystack->yyitems, yynewItems,
03575 yystack->yytops.yystates[yyn], yystate);
03576 YYFREE (yystack->yyitems);
03577 yystack->yyitems = yynewItems;
03578 yystack->yynextFree = yynewItems + yysize;
03579 yystack->yyspaceLeft = yynewSize - yysize;
03580
03581 #else
03582 yyMemoryExhausted (yystack);
03583 #endif
03584 }
03585
03586 static void
03587 yyfreeGLRStack (yyGLRStack* yystack)
03588 {
03589 YYFREE (yystack->yyitems);
03590 yyfreeStateSet (&yystack->yytops);
03591 }
03592
03596 static inline void
03597 yyupdateSplit (yyGLRStack* yystack, yyGLRState* yys)
03598 {
03599 if (yystack->yysplitPoint != NULL && yystack->yysplitPoint > yys)
03600 yystack->yysplitPoint = yys;
03601 }
03602
03604 static inline void
03605 yymarkStackDeleted (yyGLRStack* yystack, size_t yyk)
03606 {
03607 if (yystack->yytops.yystates[yyk] != NULL)
03608 yystack->yylastDeleted = yystack->yytops.yystates[yyk];
03609 yystack->yytops.yystates[yyk] = NULL;
03610 }
03611
03615 static void
03616 yyundeleteLastStack (yyGLRStack* yystack)
03617 {
03618 if (yystack->yylastDeleted == NULL || yystack->yytops.yysize != 0)
03619 return;
03620 yystack->yytops.yystates[0] = yystack->yylastDeleted;
03621 yystack->yytops.yysize = 1;
03622 YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
03623 yystack->yylastDeleted = NULL;
03624 }
03625
03626 static inline void
03627 yyremoveDeletes (yyGLRStack* yystack)
03628 {
03629 size_t yyi, yyj;
03630 yyi = yyj = 0;
03631 while (yyj < yystack->yytops.yysize)
03632 {
03633 if (yystack->yytops.yystates[yyi] == NULL)
03634 {
03635 if (yyi == yyj)
03636 {
03637 YYDPRINTF ((stderr, "Removing dead stacks.\n"));
03638 }
03639 yystack->yytops.yysize -= 1;
03640 }
03641 else
03642 {
03643 yystack->yytops.yystates[yyj] = yystack->yytops.yystates[yyi];
03644 if (yyj != yyi)
03645 {
03646 YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
03647 (unsigned long int) yyi, (unsigned long int) yyj));
03648 }
03649 yyj += 1;
03650 }
03651 yyi += 1;
03652 }
03653 }
03654
03657 static inline void
03658 yyglrShift (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState,
03659 size_t yyposn,
03660 YYSTYPE yysval, YYLTYPE* yylocp)
03661 {
03662 yyGLRStackItem* yynewItem;
03663
03664 yynewItem = yystack->yynextFree;
03665 yystack->yynextFree += 1;
03666 yystack->yyspaceLeft -= 1;
03667 yynewItem->yystate.yyisState = yytrue;
03668 yynewItem->yystate.yylrState = yylrState;
03669 yynewItem->yystate.yyposn = yyposn;
03670 yynewItem->yystate.yyresolved = yytrue;
03671 yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
03672 yystack->yytops.yystates[yyk] = &yynewItem->yystate;
03673 yynewItem->yystate.yysemantics.yysval = yysval;
03674 yylocp->yydummy = 'a'; yynewItem->yystate.yyloc = *yylocp;
03675 if (yystack->yyspaceLeft < YYHEADROOM)
03676 yyexpandGLRStack (yystack);
03677 }
03678
03682 static inline void
03683 yyglrShiftDefer (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState,
03684 size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
03685 {
03686 yyGLRStackItem* yynewItem;
03687
03688 yynewItem = yystack->yynextFree;
03689 yynewItem->yystate.yyisState = yytrue;
03690 yynewItem->yystate.yylrState = yylrState;
03691 yynewItem->yystate.yyposn = yyposn;
03692 yynewItem->yystate.yyresolved = yyfalse;
03693 yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
03694 yynewItem->yystate.yysemantics.yyfirstVal = NULL;
03695 yystack->yytops.yystates[yyk] = &yynewItem->yystate;
03696 yystack->yynextFree += 1;
03697 yystack->yyspaceLeft -= 1;
03698 yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule);
03699 }
03700
03707 static inline YYRESULTTAG
03708 yydoAction (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
03709 YYSTYPE* yyvalp, YYLTYPE* yylocp)
03710 {
03711 int yynrhs = yyrhsLength (yyrule);
03712
03713 if (yystack->yysplitPoint == NULL)
03714 {
03715
03716 yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
03717 YYASSERT (yyk == 0);
03718 yystack->yynextFree -= yynrhs;
03719 yystack->yyspaceLeft += yynrhs;
03720 yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate;
03721 return yyuserAction (yyrule, yynrhs, rhs,
03722 yyvalp, yylocp, yystack);
03723 }
03724 else
03725 {
03726 int yyi;
03727 yyGLRState* yys;
03728 yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
03729 yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
03730 = yystack->yytops.yystates[yyk];
03731 for (yyi = 0; yyi < yynrhs; yyi += 1)
03732 {
03733 yys = yys->yypred;
03734 YYASSERT (yys);
03735 }
03736 yyupdateSplit (yystack, yys);
03737 yystack->yytops.yystates[yyk] = yys;
03738 return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
03739 yyvalp, yylocp, yystack);
03740 }
03741 }
03742
03743 #if !YYDEBUG
03744 # define YY_REDUCE_PRINT(K, Rule)
03745 #else
03746 # define YY_REDUCE_PRINT(K, Rule) \
03747 do { \
03748 if (yydebug) \
03749 yy_reduce_print (K, Rule); \
03750 } while (0)
03751
03752
03753
03754
03755
03756 static inline void
03757 yy_reduce_print (size_t yyk, yyRuleNum yyrule)
03758 {
03759 int yyi;
03760 YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu), ",
03761 (unsigned long int) yyk, yyrule - 1,
03762 (unsigned long int) yyrline[yyrule]);
03763
03764 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
03765 YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
03766 YYFPRINTF (stderr, "-> %s\n", yytokenName (yyr1[yyrule]));
03767 }
03768 #endif
03769
03781 static inline YYRESULTTAG
03782 yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
03783 yybool yyforceEval)
03784 {
03785 size_t yyposn = yystack->yytops.yystates[yyk]->yyposn;
03786
03787 if (yyforceEval || yystack->yysplitPoint == NULL)
03788 {
03789 YYSTYPE yysval;
03790 YYLTYPE yyloc;
03791
03792 YY_REDUCE_PRINT (yyk, yyrule);
03793 YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc));
03794 yyglrShift (yystack, yyk,
03795 yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState,
03796 yylhsNonterm (yyrule)),
03797 yyposn, yysval, &yyloc);
03798 }
03799 else
03800 {
03801 size_t yyi;
03802 int yyn;
03803 yyGLRState* yys, *yys0 = yystack->yytops.yystates[yyk];
03804 yyStateNum yynewLRState;
03805
03806 for (yys = yystack->yytops.yystates[yyk], yyn = yyrhsLength (yyrule);
03807 0 < yyn; yyn -= 1)
03808 {
03809 yys = yys->yypred;
03810 YYASSERT (yys);
03811 }
03812 yyupdateSplit (yystack, yys);
03813 yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
03814 YYDPRINTF ((stderr,
03815 "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
03816 (unsigned long int) yyk, yyrule - 1, yynewLRState));
03817 for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
03818 if (yyi != yyk && yystack->yytops.yystates[yyi] != NULL)
03819 {
03820 yyGLRState* yyp, *yysplit = yystack->yysplitPoint;
03821 yyp = yystack->yytops.yystates[yyi];
03822 while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn)
03823 {
03824 if (yyp->yylrState == yynewLRState && yyp->yypred == yys)
03825 {
03826 yyaddDeferredAction (yystack, yyp, yys0, yyrule);
03827 yymarkStackDeleted (yystack, yyk);
03828 YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
03829 (unsigned long int) yyk,
03830 (unsigned long int) yyi));
03831 return yyok;
03832 }
03833 yyp = yyp->yypred;
03834 }
03835 }
03836 yystack->yytops.yystates[yyk] = yys;
03837 yyglrShiftDefer (yystack, yyk, yynewLRState, yyposn, yys0, yyrule);
03838 }
03839 return yyok;
03840 }
03841
03842 static size_t
03843 yysplitStack (yyGLRStack* yystack, size_t yyk)
03844 {
03845 if (yystack->yysplitPoint == NULL)
03846 {
03847 YYASSERT (yyk == 0);
03848 yystack->yysplitPoint = yystack->yytops.yystates[yyk];
03849 }
03850 if (yystack->yytops.yysize >= yystack->yytops.yycapacity)
03851 {
03852 yyGLRState** yynewStates;
03853 if (! ((yystack->yytops.yycapacity
03854 <= (YYSIZEMAX / (2 * sizeof yynewStates[0])))
03855 && (yynewStates =
03856 (yyGLRState**) YYREALLOC (yystack->yytops.yystates,
03857 ((yystack->yytops.yycapacity *= 2)
03858 * sizeof yynewStates[0])))))
03859 yyMemoryExhausted (yystack);
03860 yystack->yytops.yystates = yynewStates;
03861 }
03862 yystack->yytops.yystates[yystack->yytops.yysize]
03863 = yystack->yytops.yystates[yyk];
03864 yystack->yytops.yysize += 1;
03865 return yystack->yytops.yysize-1;
03866 }
03867
03871 static yybool
03872 yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
03873 {
03874 if (yyy0->yyrule == yyy1->yyrule)
03875 {
03876 yyGLRState *yys0, *yys1;
03877 int yyn;
03878 for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
03879 yyn = yyrhsLength (yyy0->yyrule);
03880 yyn > 0;
03881 yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
03882 if (yys0->yyposn != yys1->yyposn)
03883 return yyfalse;
03884 return yytrue;
03885 }
03886 else
03887 return yyfalse;
03888 }
03889
03892 static void
03893 yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
03894 {
03895 yyGLRState *yys0, *yys1;
03896 int yyn;
03897 for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
03898 yyn = yyrhsLength (yyy0->yyrule);
03899 yyn > 0;
03900 yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
03901 {
03902 if (yys0 == yys1)
03903 break;
03904 else if (yys0->yyresolved)
03905 {
03906 yys1->yyresolved = yytrue;
03907 yys1->yysemantics.yysval = yys0->yysemantics.yysval;
03908 }
03909 else if (yys1->yyresolved)
03910 {
03911 yys0->yyresolved = yytrue;
03912 yys0->yysemantics.yysval = yys1->yysemantics.yysval;
03913 }
03914 else
03915 {
03916 yySemanticOption** yyz0p;
03917 yySemanticOption* yyz1;
03918 yyz0p = &yys0->yysemantics.yyfirstVal;
03919 yyz1 = yys1->yysemantics.yyfirstVal;
03920 while (yytrue)
03921 {
03922 if (yyz1 == *yyz0p || yyz1 == NULL)
03923 break;
03924 else if (*yyz0p == NULL)
03925 {
03926 *yyz0p = yyz1;
03927 break;
03928 }
03929 else if (*yyz0p < yyz1)
03930 {
03931 yySemanticOption* yyz = *yyz0p;
03932 *yyz0p = yyz1;
03933 yyz1 = yyz1->yynext;
03934 (*yyz0p)->yynext = yyz;
03935 }
03936 yyz0p = &(*yyz0p)->yynext;
03937 }
03938 yys1->yysemantics.yyfirstVal = yys0->yysemantics.yyfirstVal;
03939 }
03940 }
03941 }
03942
03946 static int
03947 yypreference (yySemanticOption* y0, yySemanticOption* y1)
03948 {
03949 yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule;
03950 int p0 = yydprec[r0], p1 = yydprec[r1];
03951
03952 if (p0 == p1)
03953 {
03954 if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1])
03955 return 0;
03956 else
03957 return 1;
03958 }
03959 if (p0 == 0 || p1 == 0)
03960 return 0;
03961 if (p0 < p1)
03962 return 3;
03963 if (p1 < p0)
03964 return 2;
03965 return 0;
03966 }
03967
03968 static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList,
03969 yyGLRStack* yystack, YYSTYPE* yyvalp,
03970 YYLTYPE* yylocp);
03971
03972 static YYRESULTTAG
03973 yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack)
03974 {
03975 YYRESULTTAG yyflag;
03976 if (0 < yyn)
03977 {
03978 YYASSERT (yys->yypred);
03979 yyflag = yyresolveStates (yys->yypred, yyn-1, yystack);
03980 if (yyflag != yyok)
03981 return yyflag;
03982 if (! yys->yyresolved)
03983 {
03984 yyflag = yyresolveValue (yys->yysemantics.yyfirstVal, yystack,
03985 &yys->yysemantics.yysval, &yys->yyloc
03986 );
03987 if (yyflag != yyok)
03988 return yyflag;
03989 yys->yyresolved = yytrue;
03990 }
03991 }
03992 return yyok;
03993 }
03994
03995 static YYRESULTTAG
03996 yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack,
03997 YYSTYPE* yyvalp, YYLTYPE* yylocp)
03998 {
03999 yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
04000 int yynrhs;
04001
04002 yynrhs = yyrhsLength (yyopt->yyrule);
04003 YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack));
04004 yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;
04005 return yyuserAction (yyopt->yyrule, yynrhs,
04006 yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
04007 yyvalp, yylocp, yystack);
04008 }
04009
04010 #if YYDEBUG
04011 static void
04012 yyreportTree (yySemanticOption* yyx, int yyindent)
04013 {
04014 int yynrhs = yyrhsLength (yyx->yyrule);
04015 int yyi;
04016 yyGLRState* yys;
04017 yyGLRState* yystates[YYMAXRHS];
04018 yyGLRState yyleftmost_state;
04019
04020 for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
04021 yystates[yyi] = yys;
04022 if (yys == NULL)
04023 {
04024 yyleftmost_state.yyposn = 0;
04025 yystates[0] = &yyleftmost_state;
04026 }
04027 else
04028 yystates[0] = yys;
04029
04030 if (yyx->yystate->yyposn < yys->yyposn + 1)
04031 YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
04032 yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
04033 yyx->yyrule);
04034 else
04035 YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
04036 yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
04037 yyx->yyrule, (unsigned long int) (yys->yyposn + 1),
04038 (unsigned long int) yyx->yystate->yyposn);
04039 for (yyi = 1; yyi <= yynrhs; yyi += 1)
04040 {
04041 if (yystates[yyi]->yyresolved)
04042 {
04043 if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
04044 YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
04045 yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
04046 else
04047 YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
04048 yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
04049 (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
04050 (unsigned long int) yystates[yyi]->yyposn);
04051 }
04052 else
04053 yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
04054 }
04055 }
04056 #endif
04057
04058 static void yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
04059 yyGLRStack* yystack)
04060 __attribute__ ((__noreturn__));
04061 static void
04062 yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
04063 yyGLRStack* yystack)
04064 {
04065
04066 (void) yyx0;
04067 (void) yyx1;
04068
04069 #if YYDEBUG
04070 YYFPRINTF (stderr, "Ambiguity detected.\n");
04071 YYFPRINTF (stderr, "Option 1,\n");
04072 yyreportTree (yyx0, 2);
04073 YYFPRINTF (stderr, "\nOption 2,\n");
04074 yyreportTree (yyx1, 2);
04075 YYFPRINTF (stderr, "\n");
04076 #endif
04077 yyFail (yystack, YY_("syntax is ambiguous"));
04078 }
04079
04080
04083 static YYRESULTTAG
04084 yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack,
04085 YYSTYPE* yyvalp, YYLTYPE* yylocp)
04086 {
04087 yySemanticOption* yybest;
04088 yySemanticOption** yypp;
04089 yybool yymerge;
04090
04091 yybest = yyoptionList;
04092 yymerge = yyfalse;
04093 for (yypp = &yyoptionList->yynext; *yypp != NULL; )
04094 {
04095 yySemanticOption* yyp = *yypp;
04096
04097 if (yyidenticalOptions (yybest, yyp))
04098 {
04099 yymergeOptionSets (yybest, yyp);
04100 *yypp = yyp->yynext;
04101 }
04102 else
04103 {
04104 switch (yypreference (yybest, yyp))
04105 {
04106 case 0:
04107 yyreportAmbiguity (yybest, yyp, yystack);
04108 break;
04109 case 1:
04110 yymerge = yytrue;
04111 break;
04112 case 2:
04113 break;
04114 case 3:
04115 yybest = yyp;
04116 yymerge = yyfalse;
04117 break;
04118 default:
04119
04120
04121
04122 break;
04123 }
04124 yypp = &yyp->yynext;
04125 }
04126 }
04127
04128 if (yymerge)
04129 {
04130 yySemanticOption* yyp;
04131 int yyprec = yydprec[yybest->yyrule];
04132 YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp));
04133 for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext)
04134 {
04135 if (yyprec == yydprec[yyp->yyrule])
04136 {
04137 YYSTYPE yyval1;
04138 YYLTYPE yydummy;
04139 YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy));
04140 yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1);
04141 }
04142 }
04143 return yyok;
04144 }
04145 else
04146 return yyresolveAction (yybest, yystack, yyvalp, yylocp);
04147 }
04148
04149 static YYRESULTTAG
04150 yyresolveStack (yyGLRStack* yystack)
04151 {
04152 if (yystack->yysplitPoint != NULL)
04153 {
04154 yyGLRState* yys;
04155 int yyn;
04156
04157 for (yyn = 0, yys = yystack->yytops.yystates[0];
04158 yys != yystack->yysplitPoint;
04159 yys = yys->yypred, yyn += 1)
04160 continue;
04161 YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack
04162 ));
04163 }
04164 return yyok;
04165 }
04166
04167 static void
04168 yycompressStack (yyGLRStack* yystack)
04169 {
04170 yyGLRState* yyp, *yyq, *yyr;
04171
04172 if (yystack->yytops.yysize != 1 || yystack->yysplitPoint == NULL)
04173 return;
04174
04175 for (yyp = yystack->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL;
04176 yyp != yystack->yysplitPoint;
04177 yyr = yyp, yyp = yyq, yyq = yyp->yypred)
04178 yyp->yypred = yyr;
04179
04180 yystack->yyspaceLeft += yystack->yynextFree - yystack->yyitems;
04181 yystack->yynextFree = ((yyGLRStackItem*) yystack->yysplitPoint) + 1;
04182 yystack->yyspaceLeft -= yystack->yynextFree - yystack->yyitems;
04183 yystack->yysplitPoint = NULL;
04184 yystack->yylastDeleted = NULL;
04185
04186 while (yyr != NULL)
04187 {
04188 yystack->yynextFree->yystate = *yyr;
04189 yyr = yyr->yypred;
04190 yystack->yynextFree->yystate.yypred = & yystack->yynextFree[-1].yystate;
04191 yystack->yytops.yystates[0] = &yystack->yynextFree->yystate;
04192 yystack->yynextFree += 1;
04193 yystack->yyspaceLeft -= 1;
04194 }
04195 }
04196
04197 static YYRESULTTAG
04198 yyprocessOneStack (yyGLRStack* yystack, size_t yyk,
04199 size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp
04200 )
04201 {
04202 int yyaction;
04203 const short int* yyconflicts;
04204 yyRuleNum yyrule;
04205 yySymbol* const yytokenp = yystack->yytokenp;
04206
04207 while (yystack->yytops.yystates[yyk] != NULL)
04208 {
04209 yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
04210 YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
04211 (unsigned long int) yyk, yystate));
04212
04213 YYASSERT (yystate != YYFINAL);
04214
04215 if (yyisDefaultedState (yystate))
04216 {
04217 yyrule = yydefaultAction (yystate);
04218 if (yyrule == 0)
04219 {
04220 YYDPRINTF ((stderr, "Stack %lu dies.\n",
04221 (unsigned long int) yyk));
04222 yymarkStackDeleted (yystack, yyk);
04223 return yyok;
04224 }
04225 YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse));
04226 }
04227 else
04228 {
04229 if (*yytokenp == YYEMPTY)
04230 {
04231 YYDPRINTF ((stderr, "Reading a token: "));
04232 yychar = YYLEX;
04233 *yytokenp = YYTRANSLATE (yychar);
04234 YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
04235 }
04236 yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts);
04237
04238 while (*yyconflicts != 0)
04239 {
04240 size_t yynewStack = yysplitStack (yystack, yyk);
04241 YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
04242 (unsigned long int) yynewStack,
04243 (unsigned long int) yyk));
04244 YYCHK (yyglrReduce (yystack, yynewStack,
04245 *yyconflicts, yyfalse));
04246 YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn,
04247 yylvalp, yyllocp));
04248 yyconflicts += 1;
04249 }
04250
04251 if (yyisShiftAction (yyaction))
04252 {
04253 YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yyk));
04254 YY_SYMBOL_PRINT ("shifting", *yytokenp, yylvalp, yyllocp);
04255 yyglrShift (yystack, yyk, yyaction, yyposn+1,
04256 *yylvalp, yyllocp);
04257 YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
04258 (unsigned long int) yyk,
04259 yystack->yytops.yystates[yyk]->yylrState));
04260 break;
04261 }
04262 else if (yyisErrorAction (yyaction))
04263 {
04264 YYDPRINTF ((stderr, "Stack %lu dies.\n",
04265 (unsigned long int) yyk));
04266 yymarkStackDeleted (yystack, yyk);
04267 break;
04268 }
04269 else
04270 YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse));
04271 }
04272 }
04273 return yyok;
04274 }
04275
04276 static void
04277 yyreportSyntaxError (yyGLRStack* yystack,
04278 YYSTYPE* yylvalp, YYLTYPE* yyllocp)
04279 {
04280
04281 (void) yylvalp;
04282 (void) yyllocp;
04283
04284 if (yystack->yyerrState == 0)
04285 {
04286 #if YYERROR_VERBOSE
04287 yySymbol* const yytokenp = yystack->yytokenp;
04288 int yyn;
04289 yyn = yypact[yystack->yytops.yystates[0]->yylrState];
04290 if (YYPACT_NINF < yyn && yyn < YYLAST)
04291 {
04292 size_t yysize0 = yytnamerr (NULL, yytokenName (*yytokenp));
04293 size_t yysize = yysize0;
04294 size_t yysize1;
04295 yybool yysize_overflow = yyfalse;
04296 char* yymsg = NULL;
04297 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
04298 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
04299 int yyx;
04300 char *yyfmt;
04301 char const *yyf;
04302 static char const yyunexpected[] = "parse error, unexpected %s";
04303 static char const yyexpecting[] = ", expecting %s";
04304 static char const yyor[] = " or %s";
04305 char yyformat[sizeof yyunexpected
04306 + sizeof yyexpecting - 1
04307 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
04308 * (sizeof yyor - 1))];
04309 char const *yyprefix = yyexpecting;
04310
04311
04312
04313 int yyxbegin = yyn < 0 ? -yyn : 0;
04314
04315
04316 int yychecklim = YYLAST - yyn;
04317 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
04318 int yycount = 1;
04319
04320 yyarg[0] = yytokenName (*yytokenp);
04321 yyfmt = yystpcpy (yyformat, yyunexpected);
04322
04323 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
04324 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
04325 {
04326 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
04327 {
04328 yycount = 1;
04329 yysize = yysize0;
04330 yyformat[sizeof yyunexpected - 1] = '\0';
04331 break;
04332 }
04333 yyarg[yycount++] = yytokenName (yyx);
04334 yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx));
04335 yysize_overflow |= yysize1 < yysize;
04336 yysize = yysize1;
04337 yyfmt = yystpcpy (yyfmt, yyprefix);
04338 yyprefix = yyor;
04339 }
04340
04341 yyf = YY_(yyformat);
04342 yysize1 = yysize + strlen (yyf);
04343 yysize_overflow |= yysize1 < yysize;
04344 yysize = yysize1;
04345
04346 if (!yysize_overflow)
04347 yymsg = (char *) YYMALLOC (yysize);
04348
04349 if (yymsg)
04350 {
04351 char *yyp = yymsg;
04352 int yyi = 0;
04353 while ((*yyp = *yyf))
04354 {
04355 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
04356 {
04357 yyp += yytnamerr (yyp, yyarg[yyi++]);
04358 yyf += 2;
04359 }
04360 else
04361 {
04362 yyp++;
04363 yyf++;
04364 }
04365 }
04366 yyerror (yymsg);
04367 YYFREE (yymsg);
04368 }
04369 else
04370 {
04371 yyerror (YY_("parse error"));
04372 yyMemoryExhausted (yystack);
04373 }
04374 }
04375 else
04376 #endif
04377 yyerror (YY_("parse error"));
04378 yynerrs += 1;
04379 }
04380 }
04381
04382
04383
04384
04385 static void
04386 yyrecoverSyntaxError (yyGLRStack* yystack,
04387 YYSTYPE* yylvalp,
04388 YYLTYPE* YYOPTIONAL_LOC (yyllocp)
04389 )
04390 {
04391 yySymbol* const yytokenp = yystack->yytokenp;
04392 size_t yyk;
04393 int yyj;
04394
04395 if (yystack->yyerrState == 3)
04396
04397
04398 while (yytrue)
04399 {
04400 if (*yytokenp == YYEOF)
04401 yyFail (yystack, NULL);
04402 if (*yytokenp != YYEMPTY)
04403 {
04404 yydestruct ("Error: discarding",
04405 *yytokenp, yylvalp);
04406 }
04407 YYDPRINTF ((stderr, "Reading a token: "));
04408 yychar = YYLEX;
04409 *yytokenp = YYTRANSLATE (yychar);
04410 YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
04411 yyj = yypact[yystack->yytops.yystates[0]->yylrState];
04412 if (yyis_pact_ninf (yyj))
04413 return;
04414 yyj += *yytokenp;
04415 if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp)
04416 {
04417 if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0)
04418 return;
04419 }
04420 else if (yytable[yyj] != 0 && ! yyis_table_ninf (yytable[yyj]))
04421 return;
04422 }
04423
04424
04425 for (yyk = 0; yyk < yystack->yytops.yysize; yyk += 1)
04426 if (yystack->yytops.yystates[yyk] != NULL)
04427 break;
04428 if (yyk >= yystack->yytops.yysize)
04429 yyFail (yystack, NULL);
04430 for (yyk += 1; yyk < yystack->yytops.yysize; yyk += 1)
04431 yymarkStackDeleted (yystack, yyk);
04432 yyremoveDeletes (yystack);
04433 yycompressStack (yystack);
04434
04435
04436 yystack->yyerrState = 3;
04437 while (yystack->yytops.yystates[0] != NULL)
04438 {
04439 yyGLRState *yys = yystack->yytops.yystates[0];
04440 yyj = yypact[yys->yylrState];
04441 if (! yyis_pact_ninf (yyj))
04442 {
04443 yyj += YYTERROR;
04444 if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
04445 && yyisShiftAction (yytable[yyj]))
04446 {
04447
04448 YYLTYPE yyerrloc;
04449 YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
04450 yylvalp, &yyerrloc);
04451 yyglrShift (yystack, 0, yytable[yyj],
04452 yys->yyposn, *yylvalp, &yyerrloc);
04453 yys = yystack->yytops.yystates[0];
04454 break;
04455 }
04456 }
04457
04458 yydestroyGLRState ("Error: popping", yys);
04459 yystack->yytops.yystates[0] = yys->yypred;
04460 yystack->yynextFree -= 1;
04461 yystack->yyspaceLeft += 1;
04462 }
04463 if (yystack->yytops.yystates[0] == NULL)
04464 yyFail (yystack, NULL);
04465 }
04466
04467 #define YYCHK1(YYE) \
04468 do { \
04469 switch (YYE) { \
04470 case yyok: \
04471 break; \
04472 case yyabort: \
04473 goto yyabortlab; \
04474 case yyaccept: \
04475 goto yyacceptlab; \
04476 case yyerr: \
04477 goto yyuser_error; \
04478 default: \
04479 goto yybuglab; \
04480 } \
04481 } while (0)
04482
04483
04484
04485
04486
04487
04488 int
04489 yyparse (void)
04490 {
04491 int yyresult;
04492 yySymbol yytoken;
04493 yyGLRStack yystack;
04494 size_t yyposn;
04495
04496
04497 YYSTYPE* const yylvalp = &yylval;
04498 YYLTYPE* const yyllocp = &yylloc;
04499
04500 YYDPRINTF ((stderr, "Starting parse\n"));
04501
04502 yytoken = YYEMPTY;
04503 yylval = yyval_default;
04504
04505
04506 if (! yyinitGLRStack (&yystack, YYINITDEPTH))
04507 goto yyexhaustedlab;
04508 switch (YYSETJMP (yystack.yyexception_buffer))
04509 {
04510 case 0: break;
04511 case 1: goto yyabortlab;
04512 case 2: goto yyexhaustedlab;
04513 default: goto yybuglab;
04514 }
04515 yystack.yytokenp = &yytoken;
04516 yyglrShift (&yystack, 0, 0, 0, yylval, &yylloc);
04517 yyposn = 0;
04518
04519 while (yytrue)
04520 {
04521
04522
04523
04524
04525 while (yytrue)
04526 {
04527 yyRuleNum yyrule;
04528 int yyaction;
04529 const short int* yyconflicts;
04530
04531 yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
04532 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
04533 if (yystate == YYFINAL)
04534 goto yyacceptlab;
04535 if (yyisDefaultedState (yystate))
04536 {
04537 yyrule = yydefaultAction (yystate);
04538 if (yyrule == 0)
04539 {
04540
04541 yyreportSyntaxError (&yystack, yylvalp, yyllocp);
04542 goto yyuser_error;
04543 }
04544 YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue));
04545 }
04546 else
04547 {
04548 if (yytoken == YYEMPTY)
04549 {
04550 YYDPRINTF ((stderr, "Reading a token: "));
04551 yychar = YYLEX;
04552 yytoken = YYTRANSLATE (yychar);
04553 YY_SYMBOL_PRINT ("Next token is", yytoken, yylvalp, yyllocp);
04554 }
04555 yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
04556 if (*yyconflicts != 0)
04557 break;
04558 if (yyisShiftAction (yyaction))
04559 {
04560 YY_SYMBOL_PRINT ("Shifting", yytoken, yylvalp, yyllocp);
04561 if (yytoken != YYEOF)
04562 yytoken = YYEMPTY;
04563 yyposn += 1;
04564 yyglrShift (&yystack, 0, yyaction, yyposn, yylval, yyllocp);
04565 if (0 < yystack.yyerrState)
04566 yystack.yyerrState -= 1;
04567 }
04568 else if (yyisErrorAction (yyaction))
04569 {
04570
04571 yyreportSyntaxError (&yystack, yylvalp, yyllocp);
04572 goto yyuser_error;
04573 }
04574 else
04575 YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue));
04576 }
04577 }
04578
04579 while (yytrue)
04580 {
04581 size_t yys;
04582 size_t yyn = yystack.yytops.yysize;
04583 for (yys = 0; yys < yyn; yys += 1)
04584 YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn,
04585 yylvalp, yyllocp));
04586 yytoken = YYEMPTY;
04587 yyposn += 1;
04588 yyremoveDeletes (&yystack);
04589 if (yystack.yytops.yysize == 0)
04590 {
04591 yyundeleteLastStack (&yystack);
04592 if (yystack.yytops.yysize == 0)
04593 yyFail (&yystack, YY_("parse error"));
04594 YYCHK1 (yyresolveStack (&yystack));
04595 YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
04596
04597 yyreportSyntaxError (&yystack, yylvalp, yyllocp);
04598 goto yyuser_error;
04599 }
04600 else if (yystack.yytops.yysize == 1)
04601 {
04602 YYCHK1 (yyresolveStack (&yystack));
04603 YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
04604 yycompressStack (&yystack);
04605 break;
04606 }
04607 }
04608 continue;
04609 yyuser_error:
04610 yyrecoverSyntaxError (&yystack, yylvalp, yyllocp);
04611 yyposn = yystack.yytops.yystates[0]->yyposn;
04612 }
04613
04614 yyacceptlab:
04615 yyresult = 0;
04616 goto yyreturn;
04617
04618 yybuglab:
04619 YYASSERT (yyfalse);
04620
04621
04622 yyabortlab:
04623 yyresult = 1;
04624 goto yyreturn;
04625
04626 yyexhaustedlab:
04627 yyerror (YY_("memory exhausted"));
04628 yyresult = 2;
04629
04630
04631 yyreturn:
04632 if (yytoken != YYEOF && yytoken != YYEMPTY)
04633 yydestruct ("Cleanup: discarding lookahead",
04634 yytoken, yylvalp);
04635
04636
04637
04638
04639 if (yystack.yyitems)
04640 {
04641 yyGLRState** yystates = yystack.yytops.yystates;
04642 if (yystates)
04643 while (yystates[0])
04644 {
04645 yyGLRState *yys = yystates[0];
04646 yydestroyGLRState ("Cleanup: popping", yys);
04647 yystates[0] = yys->yypred;
04648 yystack.yynextFree -= 1;
04649 yystack.yyspaceLeft += 1;
04650 }
04651 yyfreeGLRStack (&yystack);
04652 }
04653
04654 return yyresult;
04655 }
04656
04657
04658 #ifdef YYDEBUG
04659 static void yypstack (yyGLRStack* yystack, size_t yyk)
04660 __attribute__ ((__unused__));
04661 static void yypdumpstack (yyGLRStack* yystack) __attribute__ ((__unused__));
04662
04663 static void
04664 yy_yypstack (yyGLRState* yys)
04665 {
04666 if (yys->yypred)
04667 {
04668 yy_yypstack (yys->yypred);
04669 fprintf (stderr, " -> ");
04670 }
04671 fprintf (stderr, "%d@%lu", yys->yylrState, (unsigned long int) yys->yyposn);
04672 }
04673
04674 static void
04675 yypstates (yyGLRState* yyst)
04676 {
04677 if (yyst == NULL)
04678 fprintf (stderr, "<null>");
04679 else
04680 yy_yypstack (yyst);
04681 fprintf (stderr, "\n");
04682 }
04683
04684 static void
04685 yypstack (yyGLRStack* yystack, size_t yyk)
04686 {
04687 yypstates (yystack->yytops.yystates[yyk]);
04688 }
04689
04690 #define YYINDEX(YYX) \
04691 ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
04692
04693
04694 static void
04695 yypdumpstack (yyGLRStack* yystack)
04696 {
04697 yyGLRStackItem* yyp;
04698 size_t yyi;
04699 for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1)
04700 {
04701 fprintf (stderr, "%3lu. ", (unsigned long int) (yyp - yystack->yyitems));
04702 if (*(yybool *) yyp)
04703 {
04704 fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
04705 yyp->yystate.yyresolved, yyp->yystate.yylrState,
04706 (unsigned long int) yyp->yystate.yyposn,
04707 (long int) YYINDEX (yyp->yystate.yypred));
04708 if (! yyp->yystate.yyresolved)
04709 fprintf (stderr, ", firstVal: %ld",
04710 (long int) YYINDEX (yyp->yystate.yysemantics.yyfirstVal));
04711 }
04712 else
04713 {
04714 fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld",
04715 yyp->yyoption.yyrule,
04716 (long int) YYINDEX (yyp->yyoption.yystate),
04717 (long int) YYINDEX (yyp->yyoption.yynext));
04718 }
04719 fprintf (stderr, "\n");
04720 }
04721 fprintf (stderr, "Tops:");
04722 for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
04723 fprintf (stderr, "%lu: %ld; ", (unsigned long int) yyi,
04724 (long int) YYINDEX (yystack->yytops.yystates[yyi]));
04725 fprintf (stderr, "\n");
04726 }
04727 #endif
04728
04729
04730 #line 2195 "../src/parser/fol.y"
04731
04732
04733
04734
04735
04736 bool runYYParser(MLN* const & mln, Domain* const & dom,
04737 const char* const & fileName,
04738 const bool& allPredsExceptQueriesAreClosedWorld,
04739 const StringHashArray* const & openWorldPredNames,
04740 const StringHashArray* const & queryPredNames,
04741 const bool& addUnitClauses, const bool& warnDuplicates,
04742 const double& defaultWt, const bool& mustHaveWtOrFullStop,
04743 const Domain* const & domain0, const bool& lazyInference,
04744 const bool& flipWtsOfFlippedClause)
04745 {
04746 zzinit();
04747 if (fileName) { yyin = fopen(fileName, "r" ); zzinFileName = fileName; }
04748 else yyin = stdin;
04749 if (yyin == NULL) zzexit("Failed to open file %s.", fileName);
04750
04751 signal(SIGFPE,zzsigHandler);
04752 signal(SIGABRT,zzsigHandler);
04753 signal(SIGILL,zzsigHandler);
04754 signal(SIGSEGV,zzsigHandler);
04755
04756 zzwarnDuplicates = warnDuplicates;
04757 zzdefaultWt = defaultWt;
04758 zzmustHaveWtOrFullStop = mustHaveWtOrFullStop;
04759 zzflipWtsOfFlippedClause = flipWtsOfFlippedClause;
04760
04761 ungetc('\n', yyin);
04762 zzmln = mln;
04763 zzdomain = dom;
04764
04765 zzanyTypeId = zzdomain->getTypeId(PredicateTemplate::ANY_TYPE_NAME);
04766 zzassert(zzanyTypeId >= 0, "expecting zzanyTypeId >= 0");
04767
04768
04769
04770
04771 zzisParsing = true;
04772 yyparse();
04773 zzisParsing = false;
04774
04775 zzcheckAllTypesHaveConstants(zzdomain);
04776
04777
04778 zzgenerateGroundingsFromInternalPredicatesAndFunctions();
04779
04780
04781 if (zzusingLinkedPredicates) zzgenerateGroundingsFromLinkedPredicates(zzdomain);
04782
04783
04784 if (zzusingLinkedFunctions) zzgenerateGroundingsFromLinkedFunctions(zzdomain);
04785
04786 if (zzok)
04787 {
04788
04789 cout << "Adding clauses to MLN..." << endl;
04790 zzappendFormulasToMLN(zzformulaInfos, mln, domain0);
04791
04792 if (addUnitClauses) zzappendUnitClausesToMLN(zzdomain, zzmln, zzdefaultWt);
04793
04794 zzmln->setClauseInfoPriorMeansToClauseWts();
04795
04796
04797
04798
04799 zzdomain->reorderConstants(zzmln, zzpredIdToGndPredMap);
04800
04801 zzmln->compress();
04802
04803 Array<bool> isClosedWorldArr;
04804 zzfillClosedWorldArray(isClosedWorldArr,allPredsExceptQueriesAreClosedWorld,
04805 openWorldPredNames, queryPredNames);
04806
04807 Database* db = new Database(zzdomain, isClosedWorldArr, zzstoreGroundPreds);
04808 if (lazyInference) db->setLazyFlag();
04809 zzaddGndPredsToDb(db);
04810 zzdomain->setDB(db);
04811 zzdomain->compress();
04812 }
04813
04814 if (zznumErrors > 0) cout << "Num of errors detected = " << zznumErrors<<endl;
04815
04816 zzcleanUp();
04817
04818 signal(SIGFPE,SIG_DFL);
04819 signal(SIGABRT,SIG_DFL);
04820 signal(SIGILL,SIG_DFL);
04821 signal(SIGSEGV,SIG_DFL);
04822
04823 return zzok;
04824 }
04825
04826
04827