00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #define YYBISON 1
00048
00049
00050 #define YYBISON_VERSION "2.3"
00051
00052
00053 #define YYSKELETON_NAME "yacc.c"
00054
00055
00056 #define YYPURE 0
00057
00058
00059 #define YYLSP_NEEDED 0
00060
00061
00062
00063
00064 #ifndef YYTOKENTYPE
00065 # define YYTOKENTYPE
00066
00067
00068 enum yytokentype {
00069 INTTOK = 1,
00070 FLOATTOK = 2,
00071 COLONTOK = 3,
00072 MINUSTOK = 4,
00073 PLUSTOK = 5,
00074 STRINGTOK = 6,
00075 ASTERICKTOK = 7,
00076 DISCOUNTTOK = 8,
00077 VALUESTOK = 9,
00078 STATETOK = 10,
00079 ACTIONTOK = 11,
00080 OBSTOK = 12,
00081 TTOK = 13,
00082 OTOK = 14,
00083 RTOK = 15,
00084 UNIFORMTOK = 16,
00085 IDENTITYTOK = 17,
00086 REWARDTOK = 18,
00087 COSTTOK = 19,
00088 RESETTOK = 20,
00089 STARTTOK = 21,
00090 INCLUDETOK = 22,
00091 EXCLUDETOK = 23,
00092 EOFTOK = 258
00093 };
00094 #endif
00095
00096 #define INTTOK 1
00097 #define FLOATTOK 2
00098 #define COLONTOK 3
00099 #define MINUSTOK 4
00100 #define PLUSTOK 5
00101 #define STRINGTOK 6
00102 #define ASTERICKTOK 7
00103 #define DISCOUNTTOK 8
00104 #define VALUESTOK 9
00105 #define STATETOK 10
00106 #define ACTIONTOK 11
00107 #define OBSTOK 12
00108 #define TTOK 13
00109 #define OTOK 14
00110 #define RTOK 15
00111 #define UNIFORMTOK 16
00112 #define IDENTITYTOK 17
00113 #define REWARDTOK 18
00114 #define COSTTOK 19
00115 #define RESETTOK 20
00116 #define STARTTOK 21
00117 #define INCLUDETOK 22
00118 #define EXCLUDETOK 23
00119 #define EOFTOK 258
00120
00121
00122
00123
00124
00125 #line 1 "pomdp_spec.y"
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #include <stdio.h>
00152 #include <stdlib.h>
00153 #include "parse_err.h"
00154 #include "mdpCassandra.h"
00155 #include "parse_hash.h"
00156 #include "parse_constant.h"
00157 #include "sparse-matrix.h"
00158 #include "imm-reward.h"
00159
00160 #define YACCtrace(X)
00161
00162
00163
00164
00165 typedef enum { mc_none, mc_trans_single, mc_trans_row, mc_trans_all,
00166 mc_obs_single, mc_obs_row, mc_obs_all,
00167 mc_reward_single, mc_reward_row,
00168 mc_reward_all, mc_reward_mdp_only,
00169 mc_start_belief, mc_mdp_start,
00170 mc_start_include, mc_start_exclude } Matrix_Context;
00171
00172 extern int yylex();
00173
00174
00175 void yyerror(char *string);
00176 void checkMatrix();
00177 void enterString( Constant_Block *block );
00178 void enterUniformMatrix( );
00179 void enterIdentityMatrix( );
00180 void enterResetMatrix( );
00181 void enterMatrix( REAL_VALUE value );
00182 void setMatrixContext( Matrix_Context context,
00183 int a, int i, int j, int obs );
00184 void enterStartState( int i );
00185 void setStartStateUniform();
00186 void endStartStates();
00187 void verifyPreamble();
00188 void checkProbs();
00189
00190
00191 long currentLineNumber = 1;
00192
00193
00194
00195 Mnemonic_Type curMnemonic = nt_unknown;
00196
00197 Matrix_Context curMatrixContext = mc_none;
00198
00199
00200
00201
00202 int curRow;
00203 int curCol;
00204 int minA, maxA;
00205 int minI, maxI;
00206 int minJ, maxJ;
00207 int minObs, maxObs;
00208
00209
00210
00211
00212
00213
00214
00215
00216 I_Matrix *IP;
00217 I_Matrix *IR;
00218 I_Matrix **IW;
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 int discountDefined = 0;
00229 int valuesDefined = 0;
00230 int statesDefined = 0;
00231 int actionsDefined = 0;
00232 int observationsDefined = 0;
00233
00234
00235
00236 int observationSpecDefined = 0;
00237
00238
00239
00240
00241
00242 int gTooManyEntries = 0;
00243
00244
00245
00246
00247 #ifndef YYDEBUG
00248 # define YYDEBUG 0
00249 #endif
00250
00251
00252 #ifdef YYERROR_VERBOSE
00253 # undef YYERROR_VERBOSE
00254 # define YYERROR_VERBOSE 1
00255 #else
00256 # define YYERROR_VERBOSE 0
00257 #endif
00258
00259
00260 #ifndef YYTOKEN_TABLE
00261 # define YYTOKEN_TABLE 0
00262 #endif
00263
00264 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
00265 typedef union YYSTYPE
00266 #line 130 "pomdp_spec.y"
00267 {
00268 Constant_Block *constBlk;
00269 int i_num;
00270 REAL_VALUE f_num;
00271 }
00272
00273 #line 274 "include/pomdp_spec.tab.cc"
00274 YYSTYPE;
00275 # define yystype YYSTYPE
00276 # define YYSTYPE_IS_DECLARED 1
00277 # define YYSTYPE_IS_TRIVIAL 1
00278 #endif
00279
00280
00281
00282
00283
00284
00285
00286 #line 287 "include/pomdp_spec.tab.cc"
00287
00288 #ifdef short
00289 # undef short
00290 #endif
00291
00292 #ifdef YYTYPE_UINT8
00293 typedef YYTYPE_UINT8 yytype_uint8;
00294 #else
00295 typedef unsigned char yytype_uint8;
00296 #endif
00297
00298 #ifdef YYTYPE_INT8
00299 typedef YYTYPE_INT8 yytype_int8;
00300 #elif (defined __STDC__ || defined __C99__FUNC__ \
00301 || defined __cplusplus || defined _MSC_VER)
00302 typedef signed char yytype_int8;
00303 #else
00304 typedef short int yytype_int8;
00305 #endif
00306
00307 #ifdef YYTYPE_UINT16
00308 typedef YYTYPE_UINT16 yytype_uint16;
00309 #else
00310 typedef unsigned short int yytype_uint16;
00311 #endif
00312
00313 #ifdef YYTYPE_INT16
00314 typedef YYTYPE_INT16 yytype_int16;
00315 #else
00316 typedef short int yytype_int16;
00317 #endif
00318
00319 #ifndef YYSIZE_T
00320 # ifdef __SIZE_TYPE__
00321 # define YYSIZE_T __SIZE_TYPE__
00322 # elif defined size_t
00323 # define YYSIZE_T size_t
00324 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
00325 || defined __cplusplus || defined _MSC_VER)
00326 # include <stddef.h>
00327 # define YYSIZE_T size_t
00328 # else
00329 # define YYSIZE_T unsigned int
00330 # endif
00331 #endif
00332
00333 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
00334
00335 #ifndef YY_
00336 # if YYENABLE_NLS
00337 # if ENABLE_NLS
00338 # include <libintl.h>
00339 # define YY_(msgid) dgettext ("bison-runtime", msgid)
00340 # endif
00341 # endif
00342 # ifndef YY_
00343 # define YY_(msgid) msgid
00344 # endif
00345 #endif
00346
00347
00348 #if ! defined lint || defined __GNUC__
00349 # define YYUSE(e) ((void) (e))
00350 #else
00351 # define YYUSE(e)
00352 #endif
00353
00354
00355 #ifndef lint
00356 # define YYID(n) (n)
00357 #else
00358 #if (defined __STDC__ || defined __C99__FUNC__ \
00359 || defined __cplusplus || defined _MSC_VER)
00360 static int
00361 YYID (int i)
00362 #else
00363 static int
00364 YYID (i)
00365 int i;
00366 #endif
00367 {
00368 return i;
00369 }
00370 #endif
00371
00372 #if ! defined yyoverflow || YYERROR_VERBOSE
00373
00374
00375
00376 # ifdef YYSTACK_USE_ALLOCA
00377 # if YYSTACK_USE_ALLOCA
00378 # ifdef __GNUC__
00379 # define YYSTACK_ALLOC __builtin_alloca
00380 # elif defined __BUILTIN_VA_ARG_INCR
00381 # include <alloca.h>
00382 # elif defined _AIX
00383 # define YYSTACK_ALLOC __alloca
00384 # elif defined _MSC_VER
00385 # include <malloc.h>
00386 # define alloca _alloca
00387 # else
00388 # define YYSTACK_ALLOC alloca
00389 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00390 || defined __cplusplus || defined _MSC_VER)
00391 # include <stdlib.h>
00392 # ifndef _STDLIB_H
00393 # define _STDLIB_H 1
00394 # endif
00395 # endif
00396 # endif
00397 # endif
00398 # endif
00399
00400 # ifdef YYSTACK_ALLOC
00401
00402 # define YYSTACK_FREE(Ptr) do { ; } while (YYID (0))
00403 # ifndef YYSTACK_ALLOC_MAXIMUM
00404
00405
00406
00407
00408 # define YYSTACK_ALLOC_MAXIMUM 4032
00409 # endif
00410 # else
00411 # define YYSTACK_ALLOC YYMALLOC
00412 # define YYSTACK_FREE YYFREE
00413 # ifndef YYSTACK_ALLOC_MAXIMUM
00414 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
00415 # endif
00416 # if (defined __cplusplus && ! defined _STDLIB_H \
00417 && ! ((defined YYMALLOC || defined malloc) \
00418 && (defined YYFREE || defined free)))
00419 # include <stdlib.h>
00420 # ifndef _STDLIB_H
00421 # define _STDLIB_H 1
00422 # endif
00423 # endif
00424 # ifndef YYMALLOC
00425 # define YYMALLOC malloc
00426 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00427 || defined __cplusplus || defined _MSC_VER)
00428 void *malloc (YYSIZE_T);
00429 # endif
00430 # endif
00431 # ifndef YYFREE
00432 # define YYFREE free
00433 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00434 || defined __cplusplus || defined _MSC_VER)
00435 void free (void *);
00436 # endif
00437 # endif
00438 # endif
00439 #endif
00440
00441
00442 #if (! defined yyoverflow \
00443 && (! defined __cplusplus \
00444 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
00445
00446
00447 union yyalloc
00448 {
00449 yytype_int16 yyss;
00450 YYSTYPE yyvs;
00451 };
00452
00453
00454 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
00455
00456
00457
00458 # define YYSTACK_BYTES(N) \
00459 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
00460 + YYSTACK_GAP_MAXIMUM)
00461
00462
00463
00464 # ifndef YYCOPY
00465 # if defined __GNUC__ && 1 < __GNUC__
00466 # define YYCOPY(To, From, Count) \
00467 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
00468 # else
00469 # define YYCOPY(To, From, Count) \
00470 do \
00471 { \
00472 YYSIZE_T yyi; \
00473 for (yyi = 0; yyi < (Count); yyi++) \
00474 (To)[yyi] = (From)[yyi]; \
00475 } \
00476 while (YYID (0))
00477 # endif
00478 # endif
00479
00480
00481
00482
00483
00484
00485 # define YYSTACK_RELOCATE(Stack) \
00486 do \
00487 { \
00488 YYSIZE_T yynewbytes; \
00489 YYCOPY (&yyptr->Stack, Stack, yysize); \
00490 Stack = &yyptr->Stack; \
00491 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
00492 yyptr += yynewbytes / sizeof (*yyptr); \
00493 } \
00494 while (YYID (0))
00495
00496 #endif
00497
00498
00499 #define YYFINAL 3
00500
00501 #define YYLAST 115
00502
00503
00504 #define YYNTOKENS 27
00505
00506 #define YYNNTS 52
00507
00508 #define YYNRULES 93
00509
00510 #define YYNSTATES 133
00511
00512
00513 #define YYUNDEFTOK 2
00514 #define YYMAXUTOK 259
00515
00516 #define YYTRANSLATE(YYX) \
00517 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
00518
00519
00520 static const yytype_uint8 yytranslate[] =
00521 {
00522 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00523 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
00524 22, 23, 24, 25, 2, 2, 2, 2, 2, 2,
00525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00547 2, 2, 2, 2, 2, 2, 1, 2, 26, 2
00548 };
00549
00550 #if YYDEBUG
00551
00552
00553 static const yytype_uint8 yyprhs[] =
00554 {
00555 0, 0, 3, 4, 5, 11, 14, 15, 17, 19,
00556 21, 23, 25, 29, 33, 35, 37, 38, 43, 45,
00557 47, 48, 53, 55, 57, 58, 63, 65, 67, 68,
00558 73, 77, 78, 84, 85, 91, 92, 95, 97, 100,
00559 101, 103, 105, 107, 111, 112, 120, 121, 127, 128,
00560 132, 136, 137, 145, 146, 152, 153, 157, 161, 162,
00561 172, 173, 181, 182, 188, 189, 193, 195, 197, 199,
00562 201, 203, 205, 208, 210, 213, 215, 217, 219, 221,
00563 223, 225, 227, 229, 231, 233, 236, 238, 240, 242,
00564 245, 248, 250, 252
00565 };
00566
00567
00568 static const yytype_int8 yyrhs[] =
00569 {
00570 28, 0, -1, -1, -1, 31, 29, 45, 30, 50,
00571 -1, 31, 32, -1, -1, 33, -1, 34, -1, 36,
00572 -1, 39, -1, 42, -1, 10, 5, 77, -1, 11,
00573 5, 35, -1, 20, -1, 21, -1, -1, 12, 5,
00574 37, 38, -1, 3, -1, 75, -1, -1, 13, 5,
00575 40, 41, -1, 3, -1, 75, -1, -1, 14, 5,
00576 43, 44, -1, 3, -1, 75, -1, -1, 23, 5,
00577 46, 69, -1, 23, 5, 8, -1, -1, 23, 24,
00578 5, 47, 49, -1, -1, 23, 25, 5, 48, 49,
00579 -1, -1, 49, 72, -1, 72, -1, 50, 51, -1,
00580 -1, 52, -1, 57, -1, 62, -1, 15, 5, 53,
00581 -1, -1, 73, 5, 72, 5, 72, 54, 76, -1,
00582 -1, 73, 5, 72, 55, 69, -1, -1, 73, 56,
00583 68, -1, 16, 5, 58, -1, -1, 73, 5, 72,
00584 5, 74, 59, 76, -1, -1, 73, 5, 72, 60,
00585 69, -1, -1, 73, 61, 69, -1, 17, 5, 63,
00586 -1, -1, 73, 5, 72, 5, 72, 5, 74, 64,
00587 77, -1, -1, 73, 5, 72, 5, 72, 65, 71,
00588 -1, -1, 73, 5, 72, 66, 71, -1, -1, 73,
00589 67, 71, -1, 18, -1, 19, -1, 70, -1, 18,
00590 -1, 22, -1, 70, -1, 70, 76, -1, 76, -1,
00591 71, 77, -1, 77, -1, 3, -1, 8, -1, 9,
00592 -1, 3, -1, 8, -1, 9, -1, 3, -1, 8,
00593 -1, 9, -1, 75, 8, -1, 8, -1, 3, -1,
00594 4, -1, 78, 3, -1, 78, 4, -1, 7, -1,
00595 6, -1, -1
00596 };
00597
00598
00599 static const yytype_uint16 yyrline[] =
00600 {
00601 0, 143, 143, 167, 142, 202, 206, 208, 209, 210,
00602 211, 212, 214, 228, 234, 245, 251, 250, 269, 288,
00603 292, 291, 304, 323, 327, 326, 339, 358, 362, 361,
00604 378, 415, 414, 421, 420, 428, 432, 436, 441, 442,
00605 444, 445, 471, 473, 479, 478, 485, 484, 489, 489,
00606 494, 500, 499, 506, 505, 510, 510, 515, 523, 522,
00607 532, 531, 538, 537, 545, 544, 551, 555, 559, 565,
00608 569, 573, 578, 582, 587, 591, 596, 608, 622, 627,
00609 640, 654, 659, 671, 685, 690, 694, 699, 708, 721,
00610 729, 738, 742, 747
00611 };
00612 #endif
00613
00614 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
00615
00616
00617 static const char *const yytname[] =
00618 {
00619 "$end", "error", "$undefined", "INTTOK", "FLOATTOK", "COLONTOK",
00620 "MINUSTOK", "PLUSTOK", "STRINGTOK", "ASTERICKTOK", "DISCOUNTTOK",
00621 "VALUESTOK", "STATETOK", "ACTIONTOK", "OBSTOK", "TTOK", "OTOK", "RTOK",
00622 "UNIFORMTOK", "IDENTITYTOK", "REWARDTOK", "COSTTOK", "RESETTOK",
00623 "STARTTOK", "INCLUDETOK", "EXCLUDETOK", "EOFTOK", "$accept",
00624 "pomdp_file", "@1", "@2", "preamble", "param_type", "discount_param",
00625 "value_param", "value_tail", "state_param", "@3", "state_tail",
00626 "action_param", "@4", "action_tail", "obs_param", "@5", "obs_param_tail",
00627 "start_state", "@6", "@7", "@8", "start_state_list", "param_list",
00628 "param_spec", "trans_prob_spec", "trans_spec_tail", "@9", "@10", "@11",
00629 "obs_prob_spec", "obs_spec_tail", "@12", "@13", "@14", "reward_spec",
00630 "reward_spec_tail", "@15", "@16", "@17", "@18", "ui_matrix", "u_matrix",
00631 "prob_matrix", "num_matrix", "state", "action", "obs", "ident_list",
00632 "prob", "number", "optional_sign", 0
00633 };
00634 #endif
00635
00636 # ifdef YYPRINT
00637
00638
00639 static const yytype_uint16 yytoknum[] =
00640 {
00641 0, 256, 259, 1, 2, 3, 4, 5, 6, 7,
00642 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
00643 18, 19, 20, 21, 22, 23, 258
00644 };
00645 # endif
00646
00647
00648 static const yytype_uint8 yyr1[] =
00649 {
00650 0, 27, 29, 30, 28, 31, 31, 32, 32, 32,
00651 32, 32, 33, 34, 35, 35, 37, 36, 38, 38,
00652 40, 39, 41, 41, 43, 42, 44, 44, 46, 45,
00653 45, 47, 45, 48, 45, 45, 49, 49, 50, 50,
00654 51, 51, 51, 52, 54, 53, 55, 53, 56, 53,
00655 57, 59, 58, 60, 58, 61, 58, 62, 64, 63,
00656 65, 63, 66, 63, 67, 63, 68, 68, 68, 69,
00657 69, 69, 70, 70, 71, 71, 72, 72, 72, 73,
00658 73, 73, 74, 74, 74, 75, 75, 76, 76, 77,
00659 77, 78, 78, 78
00660 };
00661
00662
00663 static const yytype_uint8 yyr2[] =
00664 {
00665 0, 2, 0, 0, 5, 2, 0, 1, 1, 1,
00666 1, 1, 3, 3, 1, 1, 0, 4, 1, 1,
00667 0, 4, 1, 1, 0, 4, 1, 1, 0, 4,
00668 3, 0, 5, 0, 5, 0, 2, 1, 2, 0,
00669 1, 1, 1, 3, 0, 7, 0, 5, 0, 3,
00670 3, 0, 7, 0, 5, 0, 3, 3, 0, 9,
00671 0, 7, 0, 5, 0, 3, 1, 1, 1, 1,
00672 1, 1, 2, 1, 2, 1, 1, 1, 1, 1,
00673 1, 1, 1, 1, 1, 2, 1, 1, 1, 2,
00674 2, 1, 1, 0
00675 };
00676
00677
00678
00679
00680 static const yytype_uint8 yydefact[] =
00681 {
00682 6, 0, 2, 1, 0, 0, 0, 0, 0, 35,
00683 5, 7, 8, 9, 10, 11, 93, 0, 16, 20,
00684 24, 0, 3, 92, 91, 12, 0, 14, 15, 13,
00685 0, 0, 0, 28, 0, 0, 39, 89, 90, 18,
00686 86, 17, 19, 22, 21, 23, 26, 25, 27, 30,
00687 0, 31, 33, 4, 85, 87, 88, 69, 70, 29,
00688 71, 73, 0, 0, 0, 0, 0, 38, 40, 41,
00689 42, 72, 76, 77, 78, 32, 37, 34, 0, 0,
00690 0, 36, 79, 80, 81, 43, 48, 50, 55, 57,
00691 64, 0, 0, 0, 0, 0, 93, 46, 66, 67,
00692 49, 68, 53, 56, 62, 65, 75, 0, 0, 0,
00693 0, 0, 93, 74, 44, 47, 82, 83, 84, 51,
00694 54, 60, 63, 0, 0, 0, 93, 45, 52, 58,
00695 61, 93, 59
00696 };
00697
00698
00699 static const yytype_int16 yydefgoto[] =
00700 {
00701 -1, 1, 9, 36, 2, 10, 11, 12, 29, 13,
00702 30, 41, 14, 31, 44, 15, 32, 47, 22, 50,
00703 62, 63, 75, 53, 67, 68, 85, 123, 108, 92,
00704 69, 87, 124, 110, 94, 70, 89, 131, 126, 112,
00705 96, 100, 59, 60, 105, 76, 86, 119, 42, 61,
00706 106, 26
00707 };
00708
00709
00710
00711 #define YYPACT_NINF -106
00712 static const yytype_int8 yypact[] =
00713 {
00714 -106, 37, 35, -106, 28, 38, 55, 58, 67, 17,
00715 -106, -106, -106, -106, -106, -106, 52, 41, -106, -106,
00716 -106, 0, -106, -106, -106, -106, 63, -106, -106, -106,
00717 27, 33, 36, 44, 70, 71, -106, -106, -106, -106,
00718 -106, -106, 69, -106, -106, 69, -106, -106, 69, -106,
00719 5, -106, -106, 40, -106, -106, -106, -106, -106, -106,
00720 65, -106, 3, 3, 73, 74, 75, -106, -106, -106,
00721 -106, -106, -106, -106, -106, 3, -106, 3, 7, 7,
00722 7, -106, -106, -106, -106, -106, 76, -106, 77, -106,
00723 78, 3, 10, 3, 5, 3, 52, 79, -106, -106,
00724 -106, 65, 80, -106, 81, 47, -106, 3, 5, 23,
00725 5, 3, 52, -106, -106, -106, -106, -106, -106, -106,
00726 -106, 82, 47, 65, 65, 23, 52, -106, -106, -106,
00727 47, 52, -106
00728 };
00729
00730
00731 static const yytype_int8 yypgoto[] =
00732 {
00733 -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
00734 -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
00735 -106, -106, 25, -106, -106, -106, -106, -106, -106, -106,
00736 -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
00737 -106, -106, -91, -2, -105, -73, -9, -34, 42, -59,
00738 -16, -106
00739 };
00740
00741
00742
00743
00744
00745 #define YYTABLE_NINF -94
00746 static const yytype_int16 yytable[] =
00747 {
00748 25, 71, 81, 103, 81, 33, 72, 122, 55, 56,
00749 82, 73, 74, 55, 56, 83, 84, 115, 97, 120,
00750 102, 130, 104, 57, 34, 35, 116, 58, 98, 99,
00751 39, 117, 118, 16, 114, 40, 43, 3, 121, 46,
00752 21, 40, 71, 17, 40, 4, 5, 6, 7, 8,
00753 -93, -93, 49, 23, 24, 64, 65, 66, 23, 24,
00754 18, 27, 28, 19, 127, 128, 37, 38, 55, 56,
00755 88, 90, 20, 45, 48, 51, 52, 54, 78, 79,
00756 80, 91, 93, 95, 107, 109, 111, 125, 77, 113,
00757 101, 129, 0, 0, 0, 0, 0, 0, 0, 0,
00758 0, 0, 0, 0, 0, 0, 113, 0, 0, 0,
00759 0, 0, 0, 0, 113, 132
00760 };
00761
00762 static const yytype_int16 yycheck[] =
00763 {
00764 16, 60, 75, 94, 77, 5, 3, 112, 3, 4,
00765 3, 8, 9, 3, 4, 8, 9, 108, 91, 110,
00766 93, 126, 95, 18, 24, 25, 3, 22, 18, 19,
00767 3, 8, 9, 5, 107, 8, 3, 0, 111, 3,
00768 23, 8, 101, 5, 8, 10, 11, 12, 13, 14,
00769 3, 4, 8, 6, 7, 15, 16, 17, 6, 7,
00770 5, 20, 21, 5, 123, 124, 3, 4, 3, 4,
00771 79, 80, 5, 31, 32, 5, 5, 8, 5, 5,
00772 5, 5, 5, 5, 5, 5, 5, 5, 63, 105,
00773 92, 125, -1, -1, -1, -1, -1, -1, -1, -1,
00774 -1, -1, -1, -1, -1, -1, 122, -1, -1, -1,
00775 -1, -1, -1, -1, 130, 131
00776 };
00777
00778
00779
00780 static const yytype_uint8 yystos[] =
00781 {
00782 0, 28, 31, 0, 10, 11, 12, 13, 14, 29,
00783 32, 33, 34, 36, 39, 42, 5, 5, 5, 5,
00784 5, 23, 45, 6, 7, 77, 78, 20, 21, 35,
00785 37, 40, 43, 5, 24, 25, 30, 3, 4, 3,
00786 8, 38, 75, 3, 41, 75, 3, 44, 75, 8,
00787 46, 5, 5, 50, 8, 3, 4, 18, 22, 69,
00788 70, 76, 47, 48, 15, 16, 17, 51, 52, 57,
00789 62, 76, 3, 8, 9, 49, 72, 49, 5, 5,
00790 5, 72, 3, 8, 9, 53, 73, 58, 73, 63,
00791 73, 5, 56, 5, 61, 5, 67, 72, 18, 19,
00792 68, 70, 72, 69, 72, 71, 77, 5, 55, 5,
00793 60, 5, 66, 77, 72, 69, 3, 8, 9, 74,
00794 69, 72, 71, 54, 59, 5, 65, 76, 76, 74,
00795 71, 64, 77
00796 };
00797
00798 #define yyerrok (yyerrstatus = 0)
00799 #define yyclearin (yychar = YYEMPTY)
00800 #define YYEMPTY (-2)
00801 #define YYEOF 0
00802
00803 #define YYACCEPT goto yyacceptlab
00804 #define YYABORT goto yyabortlab
00805 #define YYERROR goto yyerrorlab
00806
00807
00808
00809
00810
00811
00812 #define YYFAIL goto yyerrlab
00813
00814 #define YYRECOVERING() (!!yyerrstatus)
00815
00816 #define YYBACKUP(Token, Value) \
00817 do \
00818 if (yychar == YYEMPTY && yylen == 1) \
00819 { \
00820 yychar = (Token); \
00821 yylval = (Value); \
00822 yytoken = YYTRANSLATE (yychar); \
00823 YYPOPSTACK (1); \
00824 goto yybackup; \
00825 } \
00826 else \
00827 { \
00828 yyerror (YY_("syntax error: cannot back up")); \
00829 YYERROR; \
00830 } \
00831 while (YYID (0))
00832
00833
00834 #define YYTERROR 1
00835 #define YYERRCODE 256
00836
00837
00838
00839
00840
00841
00842 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
00843 #ifndef YYLLOC_DEFAULT
00844 # define YYLLOC_DEFAULT(Current, Rhs, N) \
00845 do \
00846 if (YYID (N)) \
00847 { \
00848 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
00849 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
00850 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
00851 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
00852 } \
00853 else \
00854 { \
00855 (Current).first_line = (Current).last_line = \
00856 YYRHSLOC (Rhs, 0).last_line; \
00857 (Current).first_column = (Current).last_column = \
00858 YYRHSLOC (Rhs, 0).last_column; \
00859 } \
00860 while (YYID (0))
00861 #endif
00862
00863
00864
00865
00866
00867
00868 #ifndef YY_LOCATION_PRINT
00869 # if YYLTYPE_IS_TRIVIAL
00870 # define YY_LOCATION_PRINT(File, Loc) \
00871 fprintf (File, "%d.%d-%d.%d", \
00872 (Loc).first_line, (Loc).first_column, \
00873 (Loc).last_line, (Loc).last_column)
00874 # else
00875 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
00876 # endif
00877 #endif
00878
00879
00880
00881
00882 #ifdef YYLEX_PARAM
00883 # define YYLEX yylex (YYLEX_PARAM)
00884 #else
00885 # define YYLEX yylex ()
00886 #endif
00887
00888
00889 #if YYDEBUG
00890
00891 # ifndef YYFPRINTF
00892 # include <stdio.h>
00893 # define YYFPRINTF fprintf
00894 # endif
00895
00896 # define YYDPRINTF(Args) \
00897 do { \
00898 if (yydebug) \
00899 YYFPRINTF Args; \
00900 } while (YYID (0))
00901
00902 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
00903 do { \
00904 if (yydebug) \
00905 { \
00906 YYFPRINTF (stderr, "%s ", Title); \
00907 yy_symbol_print (stderr, \
00908 Type, Value); \
00909 YYFPRINTF (stderr, "\n"); \
00910 } \
00911 } while (YYID (0))
00912
00913
00914
00915
00916
00917
00918
00919 #if (defined __STDC__ || defined __C99__FUNC__ \
00920 || defined __cplusplus || defined _MSC_VER)
00921 static void
00922 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
00923 #else
00924 static void
00925 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
00926 FILE *yyoutput;
00927 int yytype;
00928 YYSTYPE const * const yyvaluep;
00929 #endif
00930 {
00931 if (!yyvaluep)
00932 return;
00933 # ifdef YYPRINT
00934 if (yytype < YYNTOKENS)
00935 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
00936 # else
00937 YYUSE (yyoutput);
00938 # endif
00939 switch (yytype)
00940 {
00941 default:
00942 break;
00943 }
00944 }
00945
00946
00947
00948
00949
00950
00951 #if (defined __STDC__ || defined __C99__FUNC__ \
00952 || defined __cplusplus || defined _MSC_VER)
00953 static void
00954 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
00955 #else
00956 static void
00957 yy_symbol_print (yyoutput, yytype, yyvaluep)
00958 FILE *yyoutput;
00959 int yytype;
00960 YYSTYPE const * const yyvaluep;
00961 #endif
00962 {
00963 if (yytype < YYNTOKENS)
00964 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
00965 else
00966 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
00967
00968 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
00969 YYFPRINTF (yyoutput, ")");
00970 }
00971
00972
00973
00974
00975
00976
00977 #if (defined __STDC__ || defined __C99__FUNC__ \
00978 || defined __cplusplus || defined _MSC_VER)
00979 static void
00980 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
00981 #else
00982 static void
00983 yy_stack_print (bottom, top)
00984 yytype_int16 *bottom;
00985 yytype_int16 *top;
00986 #endif
00987 {
00988 YYFPRINTF (stderr, "Stack now");
00989 for (; bottom <= top; ++bottom)
00990 YYFPRINTF (stderr, " %d", *bottom);
00991 YYFPRINTF (stderr, "\n");
00992 }
00993
00994 # define YY_STACK_PRINT(Bottom, Top) \
00995 do { \
00996 if (yydebug) \
00997 yy_stack_print ((Bottom), (Top)); \
00998 } while (YYID (0))
00999
01000
01001
01002
01003
01004
01005 #if (defined __STDC__ || defined __C99__FUNC__ \
01006 || defined __cplusplus || defined _MSC_VER)
01007 static void
01008 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
01009 #else
01010 static void
01011 yy_reduce_print (yyvsp, yyrule)
01012 YYSTYPE *yyvsp;
01013 int yyrule;
01014 #endif
01015 {
01016 int yynrhs = yyr2[yyrule];
01017 int yyi;
01018 unsigned long int yylno = yyrline[yyrule];
01019 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
01020 yyrule - 1, yylno);
01021
01022 for (yyi = 0; yyi < yynrhs; yyi++)
01023 {
01024 fprintf (stderr, " $%d = ", yyi + 1);
01025 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
01026 &(yyvsp[(yyi + 1) - (yynrhs)])
01027 );
01028 fprintf (stderr, "\n");
01029 }
01030 }
01031
01032 # define YY_REDUCE_PRINT(Rule) \
01033 do { \
01034 if (yydebug) \
01035 yy_reduce_print (yyvsp, Rule); \
01036 } while (YYID (0))
01037
01038
01039
01040 int yydebug;
01041 #else
01042 # define YYDPRINTF(Args)
01043 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
01044 # define YY_STACK_PRINT(Bottom, Top)
01045 # define YY_REDUCE_PRINT(Rule)
01046 #endif
01047
01048
01049
01050 #ifndef YYINITDEPTH
01051 # define YYINITDEPTH 200
01052 #endif
01053
01054
01055
01056
01057
01058
01059
01060
01061 #ifndef YYMAXDEPTH
01062 # define YYMAXDEPTH 10000
01063 #endif
01064
01065
01066
01067 #if YYERROR_VERBOSE
01068
01069 # ifndef yystrlen
01070 # if defined __GLIBC__ && defined _STRING_H
01071 # define yystrlen strlen
01072 # else
01073
01074 #if (defined __STDC__ || defined __C99__FUNC__ \
01075 || defined __cplusplus || defined _MSC_VER)
01076 static YYSIZE_T
01077 yystrlen (const char *yystr)
01078 #else
01079 static YYSIZE_T
01080 yystrlen (yystr)
01081 const char *yystr;
01082 #endif
01083 {
01084 YYSIZE_T yylen;
01085 for (yylen = 0; yystr[yylen]; yylen++)
01086 continue;
01087 return yylen;
01088 }
01089 # endif
01090 # endif
01091
01092 # ifndef yystpcpy
01093 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
01094 # define yystpcpy stpcpy
01095 # else
01096
01097
01098 #if (defined __STDC__ || defined __C99__FUNC__ \
01099 || defined __cplusplus || defined _MSC_VER)
01100 static char *
01101 yystpcpy (char *yydest, const char *yysrc)
01102 #else
01103 static char *
01104 yystpcpy (yydest, yysrc)
01105 char *yydest;
01106 const char *yysrc;
01107 #endif
01108 {
01109 char *yyd = yydest;
01110 const char *yys = yysrc;
01111
01112 while ((*yyd++ = *yys++) != '\0')
01113 continue;
01114
01115 return yyd - 1;
01116 }
01117 # endif
01118 # endif
01119
01120 # ifndef yytnamerr
01121
01122
01123
01124
01125
01126
01127
01128 static YYSIZE_T
01129 yytnamerr (char *yyres, const char *yystr)
01130 {
01131 if (*yystr == '"')
01132 {
01133 YYSIZE_T yyn = 0;
01134 char const *yyp = yystr;
01135
01136 for (;;)
01137 switch (*++yyp)
01138 {
01139 case '\'':
01140 case ',':
01141 goto do_not_strip_quotes;
01142
01143 case '\\':
01144 if (*++yyp != '\\')
01145 goto do_not_strip_quotes;
01146
01147 default:
01148 if (yyres)
01149 yyres[yyn] = *yyp;
01150 yyn++;
01151 break;
01152
01153 case '"':
01154 if (yyres)
01155 yyres[yyn] = '\0';
01156 return yyn;
01157 }
01158 do_not_strip_quotes: ;
01159 }
01160
01161 if (! yyres)
01162 return yystrlen (yystr);
01163
01164 return yystpcpy (yyres, yystr) - yyres;
01165 }
01166 # endif
01167
01168
01169
01170
01171
01172
01173
01174
01175 static YYSIZE_T
01176 yysyntax_error (char *yyresult, int yystate, int yychar)
01177 {
01178 int yyn = yypact[yystate];
01179
01180 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
01181 return 0;
01182 else
01183 {
01184 int yytype = YYTRANSLATE (yychar);
01185 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
01186 YYSIZE_T yysize = yysize0;
01187 YYSIZE_T yysize1;
01188 int yysize_overflow = 0;
01189 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
01190 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
01191 int yyx;
01192
01193 # if 0
01194
01195
01196 YY_("syntax error, unexpected %s");
01197 YY_("syntax error, unexpected %s, expecting %s");
01198 YY_("syntax error, unexpected %s, expecting %s or %s");
01199 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
01200 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
01201 # endif
01202 char *yyfmt;
01203 char const *yyf;
01204 static char const yyunexpected[] = "syntax error, unexpected %s";
01205 static char const yyexpecting[] = ", expecting %s";
01206 static char const yyor[] = " or %s";
01207 char yyformat[sizeof yyunexpected
01208 + sizeof yyexpecting - 1
01209 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
01210 * (sizeof yyor - 1))];
01211 char const *yyprefix = yyexpecting;
01212
01213
01214
01215 int yyxbegin = yyn < 0 ? -yyn : 0;
01216
01217
01218 int yychecklim = YYLAST - yyn + 1;
01219 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
01220 int yycount = 1;
01221
01222 yyarg[0] = yytname[yytype];
01223 yyfmt = yystpcpy (yyformat, yyunexpected);
01224
01225 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
01226 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
01227 {
01228 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
01229 {
01230 yycount = 1;
01231 yysize = yysize0;
01232 yyformat[sizeof yyunexpected - 1] = '\0';
01233 break;
01234 }
01235 yyarg[yycount++] = yytname[yyx];
01236 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
01237 yysize_overflow |= (yysize1 < yysize);
01238 yysize = yysize1;
01239 yyfmt = yystpcpy (yyfmt, yyprefix);
01240 yyprefix = yyor;
01241 }
01242
01243 yyf = YY_(yyformat);
01244 yysize1 = yysize + yystrlen (yyf);
01245 yysize_overflow |= (yysize1 < yysize);
01246 yysize = yysize1;
01247
01248 if (yysize_overflow)
01249 return YYSIZE_MAXIMUM;
01250
01251 if (yyresult)
01252 {
01253
01254
01255
01256 char *yyp = yyresult;
01257 int yyi = 0;
01258 while ((*yyp = *yyf) != '\0')
01259 {
01260 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
01261 {
01262 yyp += yytnamerr (yyp, yyarg[yyi++]);
01263 yyf += 2;
01264 }
01265 else
01266 {
01267 yyp++;
01268 yyf++;
01269 }
01270 }
01271 }
01272 return yysize;
01273 }
01274 }
01275 #endif
01276
01277
01278
01279
01280
01281
01282
01283 #if (defined __STDC__ || defined __C99__FUNC__ \
01284 || defined __cplusplus || defined _MSC_VER)
01285 static void
01286 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
01287 #else
01288 static void
01289 yydestruct (yymsg, yytype, yyvaluep)
01290 const char *yymsg;
01291 int yytype;
01292 YYSTYPE *yyvaluep;
01293 #endif
01294 {
01295 YYUSE (yyvaluep);
01296
01297 if (!yymsg)
01298 yymsg = "Deleting";
01299 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
01300
01301 switch (yytype)
01302 {
01303
01304 default:
01305 break;
01306 }
01307 }
01308
01309
01310
01311
01312 #ifdef YYPARSE_PARAM
01313 #if defined __STDC__ || defined __cplusplus
01314 int yyparse (void *YYPARSE_PARAM);
01315 #else
01316 int yyparse ();
01317 #endif
01318 #else
01319 #if defined __STDC__ || defined __cplusplus
01320 int yyparse (void);
01321 #else
01322 int yyparse ();
01323 #endif
01324 #endif
01325
01326
01327
01328
01329 int yychar;
01330
01331
01332 YYSTYPE yylval;
01333
01334
01335 int yynerrs;
01336
01337
01338
01339
01340
01341
01342
01343 #ifdef YYPARSE_PARAM
01344 #if (defined __STDC__ || defined __C99__FUNC__ \
01345 || defined __cplusplus || defined _MSC_VER)
01346 int
01347 yyparse (void *YYPARSE_PARAM)
01348 #else
01349 int
01350 yyparse (YYPARSE_PARAM)
01351 void *YYPARSE_PARAM;
01352 #endif
01353 #else
01354 #if (defined __STDC__ || defined __C99__FUNC__ \
01355 || defined __cplusplus || defined _MSC_VER)
01356 int
01357 yyparse (void)
01358 #else
01359 int
01360 yyparse ()
01361
01362 #endif
01363 #endif
01364 {
01365
01366 int yystate;
01367 int yyn;
01368 int yyresult;
01369
01370 int yyerrstatus;
01371
01372 int yytoken = 0;
01373 #if YYERROR_VERBOSE
01374
01375 char yymsgbuf[128];
01376 char *yymsg = yymsgbuf;
01377 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
01378 #endif
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389 yytype_int16 yyssa[YYINITDEPTH];
01390 yytype_int16 *yyss = yyssa;
01391 yytype_int16 *yyssp;
01392
01393
01394 YYSTYPE yyvsa[YYINITDEPTH];
01395 YYSTYPE *yyvs = yyvsa;
01396 YYSTYPE *yyvsp;
01397
01398
01399
01400 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
01401
01402 YYSIZE_T yystacksize = YYINITDEPTH;
01403
01404
01405
01406 YYSTYPE yyval;
01407
01408
01409
01410
01411 int yylen = 0;
01412
01413 YYDPRINTF ((stderr, "Starting parse\n"));
01414
01415 yystate = 0;
01416 yyerrstatus = 0;
01417 yynerrs = 0;
01418 yychar = YYEMPTY;
01419
01420
01421
01422
01423
01424
01425 yyssp = yyss;
01426 yyvsp = yyvs;
01427
01428 goto yysetstate;
01429
01430
01431
01432
01433 yynewstate:
01434
01435
01436 yyssp++;
01437
01438 yysetstate:
01439 *yyssp = yystate;
01440
01441 if (yyss + yystacksize - 1 <= yyssp)
01442 {
01443
01444 YYSIZE_T yysize = yyssp - yyss + 1;
01445
01446 #ifdef yyoverflow
01447 {
01448
01449
01450
01451 YYSTYPE *yyvs1 = yyvs;
01452 yytype_int16 *yyss1 = yyss;
01453
01454
01455
01456
01457
01458
01459 yyoverflow (YY_("memory exhausted"),
01460 &yyss1, yysize * sizeof (*yyssp),
01461 &yyvs1, yysize * sizeof (*yyvsp),
01462
01463 &yystacksize);
01464
01465 yyss = yyss1;
01466 yyvs = yyvs1;
01467 }
01468 #else
01469 # ifndef YYSTACK_RELOCATE
01470 goto yyexhaustedlab;
01471 # else
01472
01473 if (YYMAXDEPTH <= yystacksize)
01474 goto yyexhaustedlab;
01475 yystacksize *= 2;
01476 if (YYMAXDEPTH < yystacksize)
01477 yystacksize = YYMAXDEPTH;
01478
01479 {
01480 yytype_int16 *yyss1 = yyss;
01481 union yyalloc *yyptr =
01482 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01483 if (! yyptr)
01484 goto yyexhaustedlab;
01485 YYSTACK_RELOCATE (yyss);
01486 YYSTACK_RELOCATE (yyvs);
01487
01488 # undef YYSTACK_RELOCATE
01489 if (yyss1 != yyssa)
01490 YYSTACK_FREE (yyss1);
01491 }
01492 # endif
01493 #endif
01494
01495 yyssp = yyss + yysize - 1;
01496 yyvsp = yyvs + yysize - 1;
01497
01498
01499 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01500 (unsigned long int) yystacksize));
01501
01502 if (yyss + yystacksize - 1 <= yyssp)
01503 YYABORT;
01504 }
01505
01506 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01507
01508 goto yybackup;
01509
01510
01511
01512
01513 yybackup:
01514
01515
01516
01517
01518
01519 yyn = yypact[yystate];
01520 if (yyn == YYPACT_NINF)
01521 goto yydefault;
01522
01523
01524
01525
01526 if (yychar == YYEMPTY)
01527 {
01528 YYDPRINTF ((stderr, "Reading a token: "));
01529 yychar = YYLEX;
01530 }
01531
01532 if (yychar <= YYEOF)
01533 {
01534 yychar = yytoken = YYEOF;
01535 YYDPRINTF ((stderr, "Now at end of input.\n"));
01536 }
01537 else
01538 {
01539 yytoken = YYTRANSLATE (yychar);
01540 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
01541 }
01542
01543
01544
01545 yyn += yytoken;
01546 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01547 goto yydefault;
01548 yyn = yytable[yyn];
01549 if (yyn <= 0)
01550 {
01551 if (yyn == 0 || yyn == YYTABLE_NINF)
01552 goto yyerrlab;
01553 yyn = -yyn;
01554 goto yyreduce;
01555 }
01556
01557 if (yyn == YYFINAL)
01558 YYACCEPT;
01559
01560
01561
01562 if (yyerrstatus)
01563 yyerrstatus--;
01564
01565
01566 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
01567
01568
01569 if (yychar != YYEOF)
01570 yychar = YYEMPTY;
01571
01572 yystate = yyn;
01573 *++yyvsp = yylval;
01574
01575 goto yynewstate;
01576
01577
01578
01579
01580
01581 yydefault:
01582 yyn = yydefact[yystate];
01583 if (yyn == 0)
01584 goto yyerrlab;
01585 goto yyreduce;
01586
01587
01588
01589
01590
01591 yyreduce:
01592
01593 yylen = yyr2[yyn];
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603 yyval = yyvsp[1-yylen];
01604
01605
01606 YY_REDUCE_PRINT (yyn);
01607 switch (yyn)
01608 {
01609 case 2:
01610 #line 143 "pomdp_spec.y"
01611 {
01612
01613
01614
01615
01616
01617
01618
01619
01620 verifyPreamble();
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631 allocateIntermediateMDP();
01632 ;}
01633 break;
01634
01635 case 3:
01636 #line 167 "pomdp_spec.y"
01637 {
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649 endStartStates();
01650 ;}
01651 break;
01652
01653 case 4:
01654 #line 186 "pomdp_spec.y"
01655 {
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667 checkProbs();
01668 YACCtrace("pomdp_file -> preamble params\n");
01669 ;}
01670 break;
01671
01672 case 5:
01673 #line 203 "pomdp_spec.y"
01674 {
01675 YACCtrace("preamble -> preamble param_type\n");
01676 ;}
01677 break;
01678
01679 case 12:
01680 #line 215 "pomdp_spec.y"
01681 {
01682
01683
01684
01685
01686 gDiscount = (yyvsp[(3) - (3)].f_num);
01687 if(( gDiscount < 0.0 ) || ( gDiscount > 1.0 ))
01688 ERR_enter("Parser<ytab>:", currentLineNumber,
01689 BAD_DISCOUNT_VAL, "");
01690 discountDefined = 1;
01691 YACCtrace("discount_param -> DISCOUNTTOK COLONTOK number\n");
01692 ;}
01693 break;
01694
01695 case 13:
01696 #line 229 "pomdp_spec.y"
01697 {
01698 valuesDefined = 1;
01699 YACCtrace("value_param -> VALUESTOK COLONTOK value_tail\n");
01700 ;}
01701 break;
01702
01703 case 14:
01704 #line 242 "pomdp_spec.y"
01705 {
01706 gValueType = REWARD_value_type;
01707 ;}
01708 break;
01709
01710 case 15:
01711 #line 246 "pomdp_spec.y"
01712 {
01713 gValueType = COST_value_type;
01714 ;}
01715 break;
01716
01717 case 16:
01718 #line 251 "pomdp_spec.y"
01719 {
01720
01721
01722
01723
01724
01725
01726
01727 curMnemonic = nt_state;
01728
01729 ;}
01730 break;
01731
01732 case 17:
01733 #line 263 "pomdp_spec.y"
01734 {
01735 statesDefined = 1;
01736 curMnemonic = nt_unknown;
01737 YACCtrace("state_param -> STATETOK COLONTOK state_tail\n");
01738 ;}
01739 break;
01740
01741 case 18:
01742 #line 270 "pomdp_spec.y"
01743 {
01744
01745
01746
01747
01748 gNumStates = (yyvsp[(1) - (1)].constBlk)->theValue.theInt;
01749 if( gNumStates < 1 ) {
01750 ERR_enter("Parser<ytab>:", currentLineNumber,
01751 BAD_NUM_STATES, "");
01752 gNumStates = 1;
01753 }
01754
01755
01756
01757
01758
01759 free( (yyvsp[(1) - (1)].constBlk) );
01760 ;}
01761 break;
01762
01763 case 20:
01764 #line 292 "pomdp_spec.y"
01765 {
01766
01767
01768 curMnemonic = nt_action;
01769 ;}
01770 break;
01771
01772 case 21:
01773 #line 298 "pomdp_spec.y"
01774 {
01775 actionsDefined = 1;
01776 curMnemonic = nt_unknown;
01777 YACCtrace("action_param -> ACTIONTOK COLONTOK action_tail\n");
01778 ;}
01779 break;
01780
01781 case 22:
01782 #line 305 "pomdp_spec.y"
01783 {
01784
01785
01786
01787
01788 gNumActions = (yyvsp[(1) - (1)].constBlk)->theValue.theInt;
01789 if( gNumActions < 1 ) {
01790 ERR_enter("Parser<ytab>:", currentLineNumber,
01791 BAD_NUM_ACTIONS, "" );
01792 gNumActions = 1;
01793 }
01794
01795
01796
01797
01798
01799 free( (yyvsp[(1) - (1)].constBlk) );
01800 ;}
01801 break;
01802
01803 case 24:
01804 #line 327 "pomdp_spec.y"
01805 {
01806
01807
01808 curMnemonic = nt_observation;
01809 ;}
01810 break;
01811
01812 case 25:
01813 #line 333 "pomdp_spec.y"
01814 {
01815 observationsDefined = 1;
01816 curMnemonic = nt_unknown;
01817 YACCtrace("obs_param -> OBSTOK COLONTOK obs_param_tail\n");
01818 ;}
01819 break;
01820
01821 case 26:
01822 #line 340 "pomdp_spec.y"
01823 {
01824
01825
01826
01827
01828 gNumObservations = (yyvsp[(1) - (1)].constBlk)->theValue.theInt;
01829 if( gNumObservations < 1 ) {
01830 ERR_enter("Parser<ytab>:", currentLineNumber,
01831 BAD_NUM_OBS, "" );
01832 gNumObservations = 1;
01833 }
01834
01835
01836
01837
01838
01839 free( (yyvsp[(1) - (1)].constBlk) );
01840 ;}
01841 break;
01842
01843 case 28:
01844 #line 362 "pomdp_spec.y"
01845 {
01846
01847
01848
01849
01850
01851
01852
01853
01854 if( gProblemType == POMDP_problem_type )
01855 setMatrixContext(mc_start_belief, 0, 0, 0, 0);
01856 else
01857 setMatrixContext(mc_mdp_start, 0, 0, 0, 0);
01858 ;}
01859 break;
01860
01861 case 30:
01862 #line 395 "pomdp_spec.y"
01863 {
01864 int num;
01865
01866 num = H_lookup( (yyvsp[(3) - (3)].constBlk)->theValue.theString, nt_state );
01867 if(( num < 0 ) || (num >= gNumStates )) {
01868 ERR_enter("Parser<ytab>:", currentLineNumber,
01869 BAD_STATE_STR, (yyvsp[(3) - (3)].constBlk)->theValue.theString );
01870 }
01871 else
01872 if( gProblemType == MDP_problem_type )
01873 gInitialState = num;
01874 else
01875 gInitialBelief[num] = 1.0;
01876
01877
01878 free( (yyvsp[(3) - (3)].constBlk)->theValue.theString );
01879 free( (yyvsp[(3) - (3)].constBlk) );
01880 ;}
01881 break;
01882
01883 case 31:
01884 #line 415 "pomdp_spec.y"
01885 {
01886 setMatrixContext(mc_start_include, 0, 0, 0, 0);
01887 ;}
01888 break;
01889
01890 case 33:
01891 #line 421 "pomdp_spec.y"
01892 {
01893 setMatrixContext(mc_start_exclude, 0, 0, 0, 0);
01894 ;}
01895 break;
01896
01897 case 35:
01898 #line 428 "pomdp_spec.y"
01899 {
01900 setStartStateUniform();
01901 ;}
01902 break;
01903
01904 case 36:
01905 #line 433 "pomdp_spec.y"
01906 {
01907 enterStartState( (yyvsp[(2) - (2)].i_num) );
01908 ;}
01909 break;
01910
01911 case 37:
01912 #line 437 "pomdp_spec.y"
01913 {
01914 enterStartState( (yyvsp[(1) - (1)].i_num) );
01915 ;}
01916 break;
01917
01918 case 41:
01919 #line 446 "pomdp_spec.y"
01920 {
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943 observationSpecDefined = 1;
01944 ;}
01945 break;
01946
01947 case 43:
01948 #line 474 "pomdp_spec.y"
01949 {
01950 YACCtrace("trans_prob_spec -> TTOK COLONTOK trans_spec_tail\n");
01951 ;}
01952 break;
01953
01954 case 44:
01955 #line 479 "pomdp_spec.y"
01956 { setMatrixContext(mc_trans_single, (yyvsp[(1) - (5)].i_num), (yyvsp[(3) - (5)].i_num), (yyvsp[(5) - (5)].i_num), 0); ;}
01957 break;
01958
01959 case 45:
01960 #line 480 "pomdp_spec.y"
01961 {
01962 enterMatrix( (yyvsp[(7) - (7)].f_num) );
01963 YACCtrace("trans_spec_tail -> action COLONTOK state COLONTOK state prob \n");
01964 ;}
01965 break;
01966
01967 case 46:
01968 #line 485 "pomdp_spec.y"
01969 { setMatrixContext(mc_trans_row, (yyvsp[(1) - (3)].i_num), (yyvsp[(3) - (3)].i_num), 0, 0); ;}
01970 break;
01971
01972 case 47:
01973 #line 486 "pomdp_spec.y"
01974 {
01975 YACCtrace("trans_spec_tail -> action COLONTOK state ui_matrix \n");
01976 ;}
01977 break;
01978
01979 case 48:
01980 #line 489 "pomdp_spec.y"
01981 { setMatrixContext(mc_trans_all, (yyvsp[(1) - (1)].i_num), 0, 0, 0); ;}
01982 break;
01983
01984 case 49:
01985 #line 490 "pomdp_spec.y"
01986 {
01987 YACCtrace("trans_spec_tail -> action ui_matrix\n");
01988 ;}
01989 break;
01990
01991 case 50:
01992 #line 495 "pomdp_spec.y"
01993 {
01994 YACCtrace("obs_prob_spec -> OTOK COLONTOK obs_spec_tail\n");
01995 ;}
01996 break;
01997
01998 case 51:
01999 #line 500 "pomdp_spec.y"
02000 { setMatrixContext(mc_obs_single, (yyvsp[(1) - (5)].i_num), 0, (yyvsp[(3) - (5)].i_num), (yyvsp[(5) - (5)].i_num)); ;}
02001 break;
02002
02003 case 52:
02004 #line 501 "pomdp_spec.y"
02005 {
02006 enterMatrix( (yyvsp[(7) - (7)].f_num) );
02007 YACCtrace("obs_spec_tail -> action COLONTOK state COLONTOK obs prob \n");
02008 ;}
02009 break;
02010
02011 case 53:
02012 #line 506 "pomdp_spec.y"
02013 { setMatrixContext(mc_obs_row, (yyvsp[(1) - (3)].i_num), 0, (yyvsp[(3) - (3)].i_num), 0); ;}
02014 break;
02015
02016 case 54:
02017 #line 507 "pomdp_spec.y"
02018 {
02019 YACCtrace("obs_spec_tail -> action COLONTOK state COLONTOK u_matrix\n");
02020 ;}
02021 break;
02022
02023 case 55:
02024 #line 510 "pomdp_spec.y"
02025 { setMatrixContext(mc_obs_all, (yyvsp[(1) - (1)].i_num), 0, 0, 0); ;}
02026 break;
02027
02028 case 56:
02029 #line 511 "pomdp_spec.y"
02030 {
02031 YACCtrace("obs_spec_tail -> action u_matrix\n");
02032 ;}
02033 break;
02034
02035 case 57:
02036 #line 516 "pomdp_spec.y"
02037 {
02038 YACCtrace("reward_spec -> RTOK COLONTOK reward_spec_tail\n");
02039 ;}
02040 break;
02041
02042 case 58:
02043 #line 523 "pomdp_spec.y"
02044 { setMatrixContext(mc_reward_single, (yyvsp[(1) - (7)].i_num), (yyvsp[(3) - (7)].i_num), (yyvsp[(5) - (7)].i_num), (yyvsp[(7) - (7)].i_num)); ;}
02045 break;
02046
02047 case 59:
02048 #line 524 "pomdp_spec.y"
02049 {
02050 enterMatrix( (yyvsp[(9) - (9)].f_num) );
02051
02052
02053 checkMatrix();
02054 YACCtrace("reward_spec_tail -> action COLONTOK state COLONTOK state COLONTOK obs number\n");
02055 ;}
02056 break;
02057
02058 case 60:
02059 #line 532 "pomdp_spec.y"
02060 { setMatrixContext(mc_reward_row, (yyvsp[(1) - (5)].i_num), (yyvsp[(3) - (5)].i_num), (yyvsp[(5) - (5)].i_num), 0); ;}
02061 break;
02062
02063 case 61:
02064 #line 533 "pomdp_spec.y"
02065 {
02066 checkMatrix();
02067 YACCtrace("reward_spec_tail -> action COLONTOK state COLONTOK state num_matrix\n");
02068 ;}
02069 break;
02070
02071 case 62:
02072 #line 538 "pomdp_spec.y"
02073 { setMatrixContext(mc_reward_all, (yyvsp[(1) - (3)].i_num), (yyvsp[(3) - (3)].i_num), 0, 0); ;}
02074 break;
02075
02076 case 63:
02077 #line 539 "pomdp_spec.y"
02078 {
02079 checkMatrix();
02080 YACCtrace("reward_spec_tail -> action COLONTOK state num_matrix\n");
02081 ;}
02082 break;
02083
02084 case 64:
02085 #line 545 "pomdp_spec.y"
02086 { setMatrixContext(mc_reward_mdp_only, (yyvsp[(1) - (1)].i_num), 0, 0, 0); ;}
02087 break;
02088
02089 case 65:
02090 #line 546 "pomdp_spec.y"
02091 {
02092 checkMatrix();
02093 YACCtrace("reward_spec_tail -> action num_matrix\n");
02094 ;}
02095 break;
02096
02097 case 66:
02098 #line 552 "pomdp_spec.y"
02099 {
02100 enterUniformMatrix();
02101 ;}
02102 break;
02103
02104 case 67:
02105 #line 556 "pomdp_spec.y"
02106 {
02107 enterIdentityMatrix();
02108 ;}
02109 break;
02110
02111 case 68:
02112 #line 560 "pomdp_spec.y"
02113 {
02114 checkMatrix();
02115 ;}
02116 break;
02117
02118 case 69:
02119 #line 566 "pomdp_spec.y"
02120 {
02121 enterUniformMatrix();
02122 ;}
02123 break;
02124
02125 case 70:
02126 #line 570 "pomdp_spec.y"
02127 {
02128 enterResetMatrix();
02129 ;}
02130 break;
02131
02132 case 71:
02133 #line 574 "pomdp_spec.y"
02134 {
02135 checkMatrix();
02136 ;}
02137 break;
02138
02139 case 72:
02140 #line 579 "pomdp_spec.y"
02141 {
02142 enterMatrix( (yyvsp[(2) - (2)].f_num) );
02143 ;}
02144 break;
02145
02146 case 73:
02147 #line 583 "pomdp_spec.y"
02148 {
02149 enterMatrix( (yyvsp[(1) - (1)].f_num) );
02150 ;}
02151 break;
02152
02153 case 74:
02154 #line 588 "pomdp_spec.y"
02155 {
02156 enterMatrix( (yyvsp[(2) - (2)].f_num) );
02157 ;}
02158 break;
02159
02160 case 75:
02161 #line 592 "pomdp_spec.y"
02162 {
02163 enterMatrix( (yyvsp[(1) - (1)].f_num) );
02164 ;}
02165 break;
02166
02167 case 76:
02168 #line 597 "pomdp_spec.y"
02169 {
02170 if(( (yyvsp[(1) - (1)].constBlk)->theValue.theInt < 0 )
02171 || ((yyvsp[(1) - (1)].constBlk)->theValue.theInt >= gNumStates )) {
02172 ERR_enter("Parser<ytab>:", currentLineNumber,
02173 BAD_STATE_VAL, "");
02174 (yyval.i_num) = 0;
02175 }
02176 else
02177 (yyval.i_num) = (yyvsp[(1) - (1)].constBlk)->theValue.theInt;
02178 free( (yyvsp[(1) - (1)].constBlk) );
02179 ;}
02180 break;
02181
02182 case 77:
02183 #line 609 "pomdp_spec.y"
02184 {
02185 int num;
02186 num = H_lookup( (yyvsp[(1) - (1)].constBlk)->theValue.theString, nt_state );
02187 if(( num < 0 ) || (num >= gNumStates )) {
02188 ERR_enter("Parser<ytab>:", currentLineNumber,
02189 BAD_STATE_STR, (yyvsp[(1) - (1)].constBlk)->theValue.theString );
02190 (yyval.i_num) = 0;
02191 }
02192 else
02193 (yyval.i_num) = num;
02194 free( (yyvsp[(1) - (1)].constBlk)->theValue.theString );
02195 free( (yyvsp[(1) - (1)].constBlk) );
02196 ;}
02197 break;
02198
02199 case 78:
02200 #line 623 "pomdp_spec.y"
02201 {
02202 (yyval.i_num) = WILDCARD_SPEC;
02203 ;}
02204 break;
02205
02206 case 79:
02207 #line 628 "pomdp_spec.y"
02208 {
02209 (yyval.i_num) = (yyvsp[(1) - (1)].constBlk)->theValue.theInt;
02210 if(( (yyvsp[(1) - (1)].constBlk)->theValue.theInt < 0 )
02211 || ((yyvsp[(1) - (1)].constBlk)->theValue.theInt >= gNumActions )) {
02212 ERR_enter("Parser<ytab>:", currentLineNumber,
02213 BAD_ACTION_VAL, "" );
02214 (yyval.i_num) = 0;
02215 }
02216 else
02217 (yyval.i_num) = (yyvsp[(1) - (1)].constBlk)->theValue.theInt;
02218 free( (yyvsp[(1) - (1)].constBlk) );
02219 ;}
02220 break;
02221
02222 case 80:
02223 #line 641 "pomdp_spec.y"
02224 {
02225 int num;
02226 num = H_lookup( (yyvsp[(1) - (1)].constBlk)->theValue.theString, nt_action );
02227 if(( num < 0 ) || (num >= gNumActions )) {
02228 ERR_enter("Parser<ytab>:", currentLineNumber,
02229 BAD_ACTION_STR, (yyvsp[(1) - (1)].constBlk)->theValue.theString );
02230 (yyval.i_num) = 0;
02231 }
02232 else
02233 (yyval.i_num) = num;
02234 free( (yyvsp[(1) - (1)].constBlk)->theValue.theString );
02235 free( (yyvsp[(1) - (1)].constBlk) );
02236 ;}
02237 break;
02238
02239 case 81:
02240 #line 655 "pomdp_spec.y"
02241 {
02242 (yyval.i_num) = WILDCARD_SPEC;
02243 ;}
02244 break;
02245
02246 case 82:
02247 #line 660 "pomdp_spec.y"
02248 {
02249 if(( (yyvsp[(1) - (1)].constBlk)->theValue.theInt < 0 )
02250 || ((yyvsp[(1) - (1)].constBlk)->theValue.theInt >= gNumObservations )) {
02251 ERR_enter("Parser<ytab>:", currentLineNumber,
02252 BAD_OBS_VAL, "");
02253 (yyval.i_num) = 0;
02254 }
02255 else
02256 (yyval.i_num) = (yyvsp[(1) - (1)].constBlk)->theValue.theInt;
02257 free( (yyvsp[(1) - (1)].constBlk) );
02258 ;}
02259 break;
02260
02261 case 83:
02262 #line 672 "pomdp_spec.y"
02263 {
02264 int num;
02265 num = H_lookup( (yyvsp[(1) - (1)].constBlk)->theValue.theString, nt_observation );
02266 if(( num < 0 ) || (num >= gNumObservations )) {
02267 ERR_enter("Parser<ytab>:", currentLineNumber,
02268 BAD_OBS_STR, (yyvsp[(1) - (1)].constBlk)->theValue.theString);
02269 (yyval.i_num) = 0;
02270 }
02271 else
02272 (yyval.i_num) = num;
02273 free( (yyvsp[(1) - (1)].constBlk)->theValue.theString );
02274 free( (yyvsp[(1) - (1)].constBlk) );
02275 ;}
02276 break;
02277
02278 case 84:
02279 #line 686 "pomdp_spec.y"
02280 {
02281 (yyval.i_num) = WILDCARD_SPEC;
02282 ;}
02283 break;
02284
02285 case 85:
02286 #line 691 "pomdp_spec.y"
02287 {
02288 enterString( (yyvsp[(2) - (2)].constBlk) );
02289 ;}
02290 break;
02291
02292 case 86:
02293 #line 695 "pomdp_spec.y"
02294 {
02295 enterString( (yyvsp[(1) - (1)].constBlk) );
02296 ;}
02297 break;
02298
02299 case 87:
02300 #line 700 "pomdp_spec.y"
02301 {
02302 (yyval.f_num) = (yyvsp[(1) - (1)].constBlk)->theValue.theInt;
02303 if( curMatrixContext != mc_mdp_start )
02304 if(( (yyval.f_num) < 0 ) || ((yyval.f_num) > 1 ))
02305 ERR_enter("Parser<ytab>:", currentLineNumber,
02306 BAD_PROB_VAL, "");
02307 free( (yyvsp[(1) - (1)].constBlk) );
02308 ;}
02309 break;
02310
02311 case 88:
02312 #line 709 "pomdp_spec.y"
02313 {
02314 (yyval.f_num) = (yyvsp[(1) - (1)].constBlk)->theValue.theFloat;
02315 if( curMatrixContext == mc_mdp_start )
02316 ERR_enter("Parser<ytab>:", currentLineNumber,
02317 BAD_START_STATE_TYPE, "" );
02318 else
02319 if(( (yyval.f_num) < 0.0 ) || ((yyval.f_num) > 1.0 ))
02320 ERR_enter("Parser<ytab>:", currentLineNumber,
02321 BAD_PROB_VAL, "" );
02322 free( (yyvsp[(1) - (1)].constBlk) );
02323 ;}
02324 break;
02325
02326 case 89:
02327 #line 722 "pomdp_spec.y"
02328 {
02329 if( (yyvsp[(1) - (2)].i_num) )
02330 (yyval.f_num) = (yyvsp[(2) - (2)].constBlk)->theValue.theInt * -1.0;
02331 else
02332 (yyval.f_num) = (yyvsp[(2) - (2)].constBlk)->theValue.theInt;
02333 free( (yyvsp[(2) - (2)].constBlk) );
02334 ;}
02335 break;
02336
02337 case 90:
02338 #line 730 "pomdp_spec.y"
02339 {
02340 if( (yyvsp[(1) - (2)].i_num) )
02341 (yyval.f_num) = (yyvsp[(2) - (2)].constBlk)->theValue.theFloat * -1.0;
02342 else
02343 (yyval.f_num) = (yyvsp[(2) - (2)].constBlk)->theValue.theFloat;
02344 free( (yyvsp[(2) - (2)].constBlk) );
02345 ;}
02346 break;
02347
02348 case 91:
02349 #line 739 "pomdp_spec.y"
02350 {
02351 (yyval.i_num) = 0;
02352 ;}
02353 break;
02354
02355 case 92:
02356 #line 743 "pomdp_spec.y"
02357 {
02358 (yyval.i_num) = 1;
02359 ;}
02360 break;
02361
02362 case 93:
02363 #line 747 "pomdp_spec.y"
02364 {
02365 (yyval.i_num) = 0;
02366 ;}
02367 break;
02368
02369
02370
02371 #line 2372 "include/pomdp_spec.tab.cc"
02372 default: break;
02373 }
02374 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
02375
02376 YYPOPSTACK (yylen);
02377 yylen = 0;
02378 YY_STACK_PRINT (yyss, yyssp);
02379
02380 *++yyvsp = yyval;
02381
02382
02383
02384
02385
02386
02387 yyn = yyr1[yyn];
02388
02389 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
02390 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
02391 yystate = yytable[yystate];
02392 else
02393 yystate = yydefgoto[yyn - YYNTOKENS];
02394
02395 goto yynewstate;
02396
02397
02398
02399
02400
02401 yyerrlab:
02402
02403 if (!yyerrstatus)
02404 {
02405 ++yynerrs;
02406 #if ! YYERROR_VERBOSE
02407 yyerror (YY_("syntax error"));
02408 #else
02409 {
02410 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
02411 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
02412 {
02413 YYSIZE_T yyalloc = 2 * yysize;
02414 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
02415 yyalloc = YYSTACK_ALLOC_MAXIMUM;
02416 if (yymsg != yymsgbuf)
02417 YYSTACK_FREE (yymsg);
02418 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
02419 if (yymsg)
02420 yymsg_alloc = yyalloc;
02421 else
02422 {
02423 yymsg = yymsgbuf;
02424 yymsg_alloc = sizeof yymsgbuf;
02425 }
02426 }
02427
02428 if (0 < yysize && yysize <= yymsg_alloc)
02429 {
02430 (void) yysyntax_error (yymsg, yystate, yychar);
02431 yyerror (yymsg);
02432 }
02433 else
02434 {
02435 yyerror (YY_("syntax error"));
02436 if (yysize != 0)
02437 goto yyexhaustedlab;
02438 }
02439 }
02440 #endif
02441 }
02442
02443
02444
02445 if (yyerrstatus == 3)
02446 {
02447
02448
02449
02450 if (yychar <= YYEOF)
02451 {
02452
02453 if (yychar == YYEOF)
02454 YYABORT;
02455 }
02456 else
02457 {
02458 yydestruct ("Error: discarding",
02459 yytoken, &yylval);
02460 yychar = YYEMPTY;
02461 }
02462 }
02463
02464
02465
02466 goto yyerrlab1;
02467
02468
02469
02470
02471
02472 yyerrorlab:
02473
02474
02475
02476
02477 if ( 0)
02478 goto yyerrorlab;
02479
02480
02481
02482 YYPOPSTACK (yylen);
02483 yylen = 0;
02484 YY_STACK_PRINT (yyss, yyssp);
02485 yystate = *yyssp;
02486 goto yyerrlab1;
02487
02488
02489
02490
02491
02492 yyerrlab1:
02493 yyerrstatus = 3;
02494
02495 for (;;)
02496 {
02497 yyn = yypact[yystate];
02498 if (yyn != YYPACT_NINF)
02499 {
02500 yyn += YYTERROR;
02501 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
02502 {
02503 yyn = yytable[yyn];
02504 if (0 < yyn)
02505 break;
02506 }
02507 }
02508
02509
02510 if (yyssp == yyss)
02511 YYABORT;
02512
02513
02514 yydestruct ("Error: popping",
02515 yystos[yystate], yyvsp);
02516 YYPOPSTACK (1);
02517 yystate = *yyssp;
02518 YY_STACK_PRINT (yyss, yyssp);
02519 }
02520
02521 if (yyn == YYFINAL)
02522 YYACCEPT;
02523
02524 *++yyvsp = yylval;
02525
02526
02527
02528 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
02529
02530 yystate = yyn;
02531 goto yynewstate;
02532
02533
02534
02535
02536
02537 yyacceptlab:
02538 yyresult = 0;
02539 goto yyreturn;
02540
02541
02542
02543
02544 yyabortlab:
02545 yyresult = 1;
02546 goto yyreturn;
02547
02548 #ifndef yyoverflow
02549
02550
02551
02552 yyexhaustedlab:
02553 yyerror (YY_("memory exhausted"));
02554 yyresult = 2;
02555
02556 #endif
02557
02558 yyreturn:
02559 if (yychar != YYEOF && yychar != YYEMPTY)
02560 yydestruct ("Cleanup: discarding lookahead",
02561 yytoken, &yylval);
02562
02563
02564 YYPOPSTACK (yylen);
02565 YY_STACK_PRINT (yyss, yyssp);
02566 while (yyssp != yyss)
02567 {
02568 yydestruct ("Cleanup: popping",
02569 yystos[*yyssp], yyvsp);
02570 YYPOPSTACK (1);
02571 }
02572 #ifndef yyoverflow
02573 if (yyss != yyssa)
02574 YYSTACK_FREE (yyss);
02575 #endif
02576 #if YYERROR_VERBOSE
02577 if (yymsg != yymsgbuf)
02578 YYSTACK_FREE (yymsg);
02579 #endif
02580
02581 return YYID (yyresult);
02582 }
02583
02584
02585 #line 754 "pomdp_spec.y"
02586
02587
02588
02589
02590
02591
02592 #define EPSILON 0.00001
02593
02594 Constant_Block *aConst;
02595
02596
02597 void yyerror(char *string)
02598 {
02599 ERR_enter("Parser<yyparse>", currentLineNumber, PARSE_ERR,"");
02600 }
02601
02602 void checkMatrix() {
02603
02604
02605
02606
02607
02608
02609
02610
02611 switch( curMatrixContext ) {
02612 case mc_trans_row:
02613 if( curCol < gNumStates )
02614 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02615 TOO_FEW_ENTRIES, "");
02616 break;
02617 case mc_trans_all:
02618 if((curRow < (gNumStates-1) )
02619 || ((curRow == (gNumStates-1))
02620 && ( curCol < gNumStates )))
02621 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02622 TOO_FEW_ENTRIES, "" );
02623 break;
02624 case mc_obs_row:
02625 if( curCol < gNumObservations )
02626 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02627 TOO_FEW_ENTRIES, "");
02628 break;
02629 case mc_obs_all:
02630 if((curRow < (gNumStates-1) )
02631 || ((curRow == (gNumStates-1))
02632 && ( curCol < gNumObservations )))
02633 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02634 TOO_FEW_ENTRIES, "" );
02635 break;
02636 case mc_start_belief:
02637 if( curCol < gNumStates )
02638 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02639 TOO_FEW_ENTRIES, "");
02640 break;
02641
02642 case mc_mdp_start:
02643
02644
02645 break;
02646
02647 case mc_reward_row:
02648 if( gProblemType == POMDP_problem_type )
02649 if( curCol < gNumObservations )
02650 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02651 TOO_FEW_ENTRIES, "");
02652 break;
02653
02654 case mc_reward_all:
02655 if( gProblemType == POMDP_problem_type ) {
02656 if((curRow < (gNumStates-1) )
02657 || ((curRow == (gNumStates-1))
02658 && ( curCol < gNumObservations )))
02659 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02660 TOO_FEW_ENTRIES, "" );
02661 }
02662 else
02663 if( curCol < gNumStates )
02664 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02665 TOO_FEW_ENTRIES, "");
02666
02667 break;
02668 case mc_reward_single:
02669
02670 break;
02671
02672 case mc_reward_mdp_only:
02673 if((curRow < (gNumStates-1) )
02674 || ((curRow == (gNumStates-1))
02675 && ( curCol < gNumStates )))
02676 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02677 TOO_FEW_ENTRIES, "" );
02678 break;
02679
02680 default:
02681 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02682 BAD_MATRIX_CONTEXT, "" );
02683 break;
02684 }
02685
02686 if( gTooManyEntries )
02687 ERR_enter("Parser<checkMatrix>:", currentLineNumber,
02688 TOO_MANY_ENTRIES, "" );
02689
02690
02691
02692 switch( curMatrixContext ) {
02693 case mc_reward_row:
02694 case mc_reward_all:
02695 case mc_reward_mdp_only:
02696 doneImmReward();
02697 break;
02698
02699
02700
02701
02702 case mc_reward_single:
02703 if( gProblemType == POMDP_problem_type )
02704 doneImmReward();
02705 break;
02706 default:
02707 break;
02708 }
02709
02710
02711 curMatrixContext = mc_none;
02712 }
02713
02714 void enterString( Constant_Block *block ) {
02715
02716 if( H_enter( block->theValue.theString, curMnemonic ) == 0 )
02717 ERR_enter("Parser<enterString>:", currentLineNumber,
02718 DUPLICATE_STRING, block->theValue.theString );
02719
02720 free( block->theValue.theString );
02721 free( block );
02722 }
02723
02724 void enterUniformMatrix( ) {
02725 int a, i, j, obs;
02726 REAL_VALUE prob;
02727
02728 switch( curMatrixContext ) {
02729 case mc_trans_row:
02730 prob = 1.0/gNumStates;
02731 for( a = minA; a <= maxA; a++ )
02732 for( i = minI; i <= maxI; i++ )
02733 for( j = 0; j < gNumStates; j++ )
02734 addEntryToIMatrix( IP[a], i, j, prob );
02735 break;
02736 case mc_trans_all:
02737 prob = 1.0/gNumStates;
02738 for( a = minA; a <= maxA; a++ )
02739 for( i = 0; i < gNumStates; i++ )
02740 for( j = 0; j < gNumStates; j++ )
02741 addEntryToIMatrix( IP[a], i, j, prob );
02742 break;
02743 case mc_obs_row:
02744 prob = 1.0/gNumObservations;
02745 for( a = minA; a <= maxA; a++ )
02746 for( j = minJ; j <= maxJ; j++ )
02747 for( obs = 0; obs < gNumObservations; obs++ )
02748 addEntryToIMatrix( IR[a], j, obs, prob );
02749 break;
02750 case mc_obs_all:
02751 prob = 1.0/gNumObservations;
02752 for( a = minA; a <= maxA; a++ )
02753 for( j = 0; j < gNumStates; j++ )
02754 for( obs = 0; obs < gNumObservations; obs++ )
02755 addEntryToIMatrix( IR[a], j, obs, prob );
02756 break;
02757 case mc_start_belief:
02758 setStartStateUniform();
02759 break;
02760 case mc_mdp_start:
02761
02762 ERR_enter("Parser<enterUniformMatrix>:", currentLineNumber,
02763 BAD_START_STATE_TYPE, "" );
02764 break;
02765 default:
02766 ERR_enter("Parser<enterUniformMatrix>:", currentLineNumber,
02767 BAD_MATRIX_CONTEXT, "" );
02768 break;
02769 }
02770 }
02771
02772 void enterIdentityMatrix( ) {
02773 int a, i,j;
02774
02775 switch( curMatrixContext ) {
02776 case mc_trans_all:
02777 for( a = minA; a <= maxA; a++ )
02778 for( i = 0; i < gNumStates; i++ )
02779 for( j = 0; j < gNumStates; j++ )
02780 if( i == j )
02781 addEntryToIMatrix( IP[a], i, j, 1.0 );
02782 else
02783 addEntryToIMatrix( IP[a], i, j, 0.0 );
02784 break;
02785 default:
02786 ERR_enter("Parser<enterIdentityMatrix>:", currentLineNumber,
02787 BAD_MATRIX_CONTEXT, "" );
02788 break;
02789 }
02790 }
02791
02792 void enterResetMatrix( ) {
02793 int a, i, j;
02794
02795 if( curMatrixContext != mc_trans_row ) {
02796 ERR_enter("Parser<enterMatrix>:", currentLineNumber,
02797 BAD_RESET_USAGE, "" );
02798 return;
02799 }
02800
02801 if( gProblemType == POMDP_problem_type )
02802 for( a = minA; a <= maxA; a++ )
02803 for( i = minI; i <= maxI; i++ )
02804 for( j = 0; j < gNumStates; j++ )
02805 addEntryToIMatrix( IP[a], i, j, gInitialBelief[j] );
02806
02807 else
02808 for( a = minA; a <= maxA; a++ )
02809 for( i = minI; i <= maxI; i++ )
02810 addEntryToIMatrix( IP[a], i, gInitialState, 1.0 );
02811
02812
02813 }
02814
02815 void enterMatrix( REAL_VALUE value ) {
02816
02817
02818
02819
02820
02821
02822
02823 int a, i, j, obs;
02824
02825 switch( curMatrixContext ) {
02826 case mc_trans_single:
02827 for( a = minA; a <= maxA; a++ )
02828 for( i = minI; i <= maxI; i++ )
02829 for( j = minJ; j <= maxJ; j++ )
02830 addEntryToIMatrix( IP[a], i, j, value );
02831 break;
02832 case mc_trans_row:
02833 if( curCol < gNumStates ) {
02834 for( a = minA; a <= maxA; a++ )
02835 for( i = minI; i <= maxI; i++ )
02836 addEntryToIMatrix( IP[a], i, curCol, value );
02837 curCol++;
02838 }
02839 else
02840 gTooManyEntries = 1;
02841
02842 break;
02843 case mc_trans_all:
02844 if( curCol >= gNumStates ) {
02845 curRow++;
02846 curCol = 0;;
02847 }
02848
02849 if( curRow < gNumStates ) {
02850 for( a = minA; a <= maxA; a++ )
02851 addEntryToIMatrix( IP[a], curRow, curCol, value );
02852 curCol++;
02853 } else {
02854 gTooManyEntries = 1;
02855 }
02856
02857 break;
02858
02859 case mc_obs_single:
02860
02861 if( gProblemType == POMDP_problem_type ) {
02862
02863
02864 for( a = minA; a <= maxA; a++ )
02865 for( j = minJ; j <= maxJ; j++ )
02866 for( obs = minObs; obs <= maxObs; obs++ )
02867 addEntryToIMatrix( IR[a], j, obs, value );
02868 }
02869 break;
02870
02871 case mc_obs_row:
02872 {
02873 if( gProblemType == POMDP_problem_type ) {
02874
02875
02876 if( curCol < gNumObservations ) {
02877
02878 for( a = minA; a <= maxA; a++ ) {
02879 for( j = minJ; j <= maxJ; j++ ) {
02880 addEntryToIMatrix( IR[a], j, curCol, value );
02881 }
02882 }
02883 curCol++;
02884 } else {
02885 gTooManyEntries = 1;
02886 }
02887 }
02888
02889 break;
02890 }
02891
02892 case mc_obs_all:
02893 if( curCol >= gNumObservations ) {
02894 curRow++;
02895 curCol = 0;
02896 }
02897
02898 if( gProblemType == POMDP_problem_type ) {
02899
02900
02901 if( curRow < gNumStates ) {
02902 for( a = minA; a <= maxA; a++ )
02903 addEntryToIMatrix( IR[a], curRow, curCol, value );
02904
02905 curCol++;
02906 } else {
02907 gTooManyEntries = 1;
02908 }
02909 }
02910 break;
02911
02912
02913
02914
02915
02916
02917 case mc_reward_single:
02918 if( gProblemType == POMDP_problem_type ) {
02919
02920 if( curCol == 0 ) {
02921 enterImmReward( 0, 0, 0, value );
02922 curCol++;
02923 }
02924 else
02925 gTooManyEntries = 1;
02926
02927 }
02928 break;
02929
02930 case mc_reward_row:
02931 if( gProblemType == POMDP_problem_type ) {
02932
02933
02934
02935
02936 if( curCol < gNumObservations ) {
02937 enterImmReward( 0, 0, curCol, value );
02938 curCol++;
02939 }
02940 else
02941 gTooManyEntries = 1;
02942
02943 }
02944
02945 else
02946
02947 if( curCol == 0 ) {
02948 enterImmReward( 0, 0, 0, value );
02949 curCol++;
02950 }
02951 else
02952 gTooManyEntries = 1;
02953
02954
02955 break;
02956
02957 case mc_reward_all:
02958
02959
02960
02961
02962 if( gProblemType == POMDP_problem_type ) {
02963 if( curCol >= gNumObservations ) {
02964 curRow++;
02965 curCol = 0;
02966 }
02967 if( curRow < gNumStates ) {
02968 enterImmReward( 0, curRow, curCol, value );
02969 curCol++;
02970 }
02971 else
02972 gTooManyEntries = 1;
02973
02974 }
02975
02976
02977
02978
02979 else
02980 if( curCol < gNumStates ) {
02981 enterImmReward( 0, curCol, 0, value );
02982 curCol++;
02983 }
02984 else
02985 gTooManyEntries = 1;
02986
02987 break;
02988
02989
02990
02991
02992
02993
02994
02995 case mc_reward_mdp_only:
02996 if( gProblemType == MDP_problem_type ) {
02997 if( curCol >= gNumStates ) {
02998 curRow++;
02999 curCol = 0;
03000 }
03001 if( curRow < gNumStates ) {
03002 enterImmReward( curRow, curCol, 0, value );
03003 curCol++;
03004 }
03005 else
03006 gTooManyEntries = 1;
03007
03008 }
03009 break;
03010
03011 case mc_mdp_start:
03012
03013
03014
03015
03016 if( curCol > 0 )
03017 gTooManyEntries = 1;
03018
03019 else {
03020 gInitialState = (int) value;
03021 curCol++;
03022 }
03023 break;
03024
03025 case mc_start_belief:
03026
03027
03028
03029
03030
03031
03032 if( curCol < gNumStates ) {
03033 gInitialBelief[curCol] = value;
03034 curCol++;
03035 }
03036 else
03037 gTooManyEntries = 1;
03038
03039 break;
03040
03041 default:
03042 ERR_enter("Parser<enterMatrix>:", currentLineNumber,
03043 BAD_MATRIX_CONTEXT, "");
03044 break;
03045 }
03046
03047 }
03048
03049 void setMatrixContext( Matrix_Context context,
03050 int a, int i, int j, int obs ) {
03051
03052
03053
03054
03055
03056
03057
03058
03059
03060
03061
03062
03063
03064 int state;
03065
03066 curMatrixContext = context;
03067 gTooManyEntries = 0;
03068
03069 curRow = 0;
03070 curCol = 0;
03071
03072 switch( curMatrixContext ) {
03073
03074 #if 0
03075 mc_start_belief:
03076
03077 break;
03078 #endif
03079
03080 case mc_start_include:
03081
03082
03083
03084
03085
03086
03087 if( gProblemType == POMDP_problem_type )
03088 for( state = 0; state < gNumStates; state++ )
03089 gInitialBelief[state] = 0.0;
03090
03091 else
03092 ERR_enter("Parser<setMatrixContext>:", currentLineNumber,
03093 BAD_START_STATE_TYPE, "");
03094
03095 break;
03096
03097 case mc_start_exclude:
03098
03099
03100
03101
03102
03103
03104 if( gProblemType == POMDP_problem_type )
03105 for( state = 0; state < gNumStates; state++ )
03106 gInitialBelief[state] = 1.0;
03107
03108 else
03109 ERR_enter("Parser<setMatrixContext>:", currentLineNumber,
03110 BAD_START_STATE_TYPE, "");
03111
03112 break;
03113
03114
03115
03116
03117
03118
03119
03120 case mc_reward_mdp_only:
03121 if( gProblemType == POMDP_problem_type ) {
03122 ERR_enter("Parser<setMatrixContext>:", currentLineNumber,
03123 BAD_REWARD_SYNTAX, "");
03124 }
03125 else {
03126 newImmReward( a, NOT_PRESENT, NOT_PRESENT, 0 );
03127 }
03128 break;
03129
03130 case mc_reward_all:
03131 if( gProblemType == POMDP_problem_type )
03132 newImmReward( a, i, NOT_PRESENT, NOT_PRESENT );
03133
03134 else {
03135 newImmReward( a, i, NOT_PRESENT, 0 );
03136 }
03137 break;
03138 case mc_reward_row:
03139 if( gProblemType == POMDP_problem_type )
03140 newImmReward( a, i, j, NOT_PRESENT );
03141
03142 else {
03143 newImmReward( a, i, j, 0 );
03144 }
03145 break;
03146 case mc_reward_single:
03147
03148 if( gProblemType == MDP_problem_type ) {
03149 ERR_enter("Parser<setMatrixContext>:", currentLineNumber,
03150 BAD_REWARD_SYNTAX, "");
03151 }
03152 else {
03153 newImmReward( a, i, j, obs );
03154 }
03155 break;
03156
03157 default:
03158 break;
03159 }
03160
03161
03162
03163
03164
03165
03166
03167
03168
03169 if( a < 0 ) {
03170 minA = 0;
03171 maxA = gNumActions - 1;
03172 }
03173 else
03174 minA = maxA = a;
03175
03176 if( i < 0 ) {
03177 minI = 0;
03178 maxI = gNumStates - 1;
03179 }
03180 else
03181 minI = maxI = i;
03182
03183 if( j < 0 ) {
03184 minJ = 0;
03185 maxJ = gNumStates - 1;
03186 }
03187 else
03188 minJ = maxJ = j;
03189
03190 if( obs < 0 ) {
03191 minObs = 0;
03192 maxObs = gNumObservations - 1;
03193 }
03194 else
03195 minObs = maxObs = obs;
03196
03197 }
03198
03199 void enterStartState( int i ) {
03200
03201
03202
03203
03204
03205
03206 if( gProblemType == MDP_problem_type )
03207 return;
03208
03209 switch( curMatrixContext ) {
03210 case mc_start_include:
03211 gInitialBelief[i] = 1.0;
03212 break;
03213 case mc_start_exclude:
03214 gInitialBelief[i] = 0.0;
03215 break;
03216 default:
03217 ERR_enter("Parser<enterStartState>:", currentLineNumber,
03218 BAD_MATRIX_CONTEXT, "");
03219 break;
03220 }
03221 }
03222
03223 void setStartStateUniform() {
03224 int i;
03225 REAL_VALUE prob;
03226
03227 if( gProblemType != POMDP_problem_type )
03228 return;
03229
03230 prob = 1.0/gNumStates;
03231 for( i = 0; i < gNumStates; i++ )
03232 gInitialBelief[i] = prob;
03233
03234 }
03235
03236 void endStartStates() {
03237
03238
03239
03240
03241
03242 int i;
03243 REAL_VALUE prob;
03244
03245 if( gProblemType == MDP_problem_type ) {
03246 curMatrixContext = mc_none;
03247 return;
03248 }
03249
03250 switch( curMatrixContext ) {
03251 case mc_start_include:
03252 case mc_start_exclude:
03253
03254
03255
03256 prob = 0.0;
03257 for( i = 0; i < gNumStates; i++ )
03258 prob += gInitialBelief[i];
03259 if( prob <= 0.0 ) {
03260 ERR_enter("Parser<endStartStates>:", currentLineNumber,
03261 BAD_START_PROB_SUM, "" );
03262 return;
03263 }
03264 for( i = 0; i < gNumStates; i++ )
03265 gInitialBelief[i] /= prob;
03266 break;
03267
03268 default:
03269 prob = 0.0;
03270 for( i = 0; i < gNumStates; i++ )
03271 prob += gInitialBelief[i];
03272 if((prob < ( 1.0 - EPSILON)) || (prob > (1.0 + EPSILON))) {
03273 ERR_enter("Parser<endStartStates>:", NO_LINE,
03274 BAD_START_PROB_SUM, "" );
03275 }
03276 break;
03277 }
03278
03279 curMatrixContext = mc_none;
03280
03281 }
03282
03283 void verifyPreamble() {
03284
03285
03286
03287
03288
03289
03290
03291 if( discountDefined == 0 )
03292 ERR_enter("Parser<verifyPreamble>:", currentLineNumber,
03293 MISSING_DISCOUNT, "" );
03294 if( valuesDefined == 0 )
03295 ERR_enter("Parser<verifyPreamble>:", currentLineNumber,
03296 MISSING_VALUES, "" );
03297 if( statesDefined == 0 ) {
03298 ERR_enter("Parser<verifyPreamble>:", currentLineNumber,
03299 MISSING_STATES, "" );
03300 gNumStates = 1;
03301 }
03302 if( actionsDefined == 0 ) {
03303 ERR_enter("Parser<verifyPreamble>:", currentLineNumber,
03304 MISSING_ACTIONS, "" );
03305 gNumActions = 1;
03306 }
03307
03308
03309 if( observationsDefined == 0 ) {
03310 gNumObservations = 0;
03311 gProblemType = MDP_problem_type;
03312 }
03313
03314 else
03315 gProblemType = POMDP_problem_type;
03316
03317 }
03318
03319 void checkProbs() {
03320 int a,i,j;
03321 REAL_VALUE sum;
03322 char str[40];
03323
03324
03325 for( a = 0; a < gNumActions; a++ )
03326 for( i = 0; i < gNumStates; i++ ) {
03327 sum = sumIMatrixRowValues( IP[a], i );
03328 if((sum < ( 1.0 - EPSILON)) || (sum > (1.0 + EPSILON))) {
03329 sprintf( str, "action=%d, state=%d (%.5lf)", a, i, sum );
03330 ERR_enter("Parser<checkProbs>:", NO_LINE,
03331 BAD_TRANS_PROB_SUM, str );
03332 }
03333 }
03334
03335 if( gProblemType == POMDP_problem_type )
03336 for( a = 0; a < gNumActions; a++ )
03337 for( j = 0; j < gNumStates; j++ ) {
03338 sum = sumIMatrixRowValues( IR[a], j );
03339 if((sum < ( 1.0 - EPSILON)) || (sum > (1.0 + EPSILON))) {
03340 sprintf( str, "action=%d, state=%d (%.5lf)", a, j, sum );
03341 ERR_enter("Parser<checkProbs>:", NO_LINE,
03342 BAD_OBS_PROB_SUM, str );
03343 }
03344 }
03345
03346
03347
03348 if( observationSpecDefined && (gProblemType == MDP_problem_type))
03349 ERR_enter("Parser<checkProbs>:", NO_LINE,
03350 OBS_IN_MDP_PROBLEM, "" );
03351
03352 }
03353
03354 void initParser() {
03355
03356
03357
03358
03359 observationSpecDefined = 0;
03360 discountDefined = 0;
03361 valuesDefined = 0;
03362 statesDefined = 0;
03363 actionsDefined = 0;
03364 observationsDefined = 0;
03365 observationSpecDefined = 0;
03366 currentLineNumber = 1;
03367 curMnemonic = nt_unknown;
03368 curMatrixContext = mc_none;
03369
03370 }
03371
03372 int readMDPFile( FILE *file ) {
03373 int returnValue;
03374 extern FILE *yyin;
03375
03376 initParser();
03377
03378 ERR_initialize();
03379 H_create();
03380 yyin = file;
03381
03382 returnValue = yyparse();
03383 #if USE_DEBUG_PRINT
03384 printf("pomdp_spec: done parsing, beginning conversion to sparse-matrix\n");
03385 #endif
03386
03387
03388
03389
03390
03391
03392
03393
03394
03395
03396 if (returnValue != 0) {
03397 printf("\nERROR: POMDP model file contains syntax errors!\n");
03398 }
03399
03400 if (ERR_dump() || returnValue )
03401 return( 0 );
03402
03403 ERR_cleanUp();
03404 H_destroy();
03405
03406
03407
03408 convertMatrices();
03409
03410 return( 1 );
03411 }
03412
03413 #if 0
03414 int yywrap()
03415 {
03416 return 1;
03417 }
03418 #endif
03419
03420