00001
00002
00003
00004
00005 #define YYBISON 1
00006
00007 #define yyparse cfparse
00008 #define yylex cflex
00009 #define yyerror cferror
00010 #define yylval cflval
00011 #define yychar cfchar
00012 #define yydebug cfdebug
00013 #define yynerrs cfnerrs
00014 #define ADD_ASSIGN 257
00015 #define ASSIGN 258
00016 #define VARIABLE 259
00017 #define STRING 260
00018 #define SEMICOLON 261
00019 #define PLUS 262
00020 #define MINUS 263
00021 #define MULT 264
00022 #define DIVIDE 265
00023 #define RPAREN 266
00024 #define LPAREN 267
00025 #define RBRACE 268
00026 #define LBRACE 269
00027 #define COMMA 270
00028 #define INTEGER 271
00029 #define REAL 272
00030 #define FILELINE 273
00031
00032 #line 1 "cf_gramatical.yxx"
00033
00034
00035
00036
00037 #ifdef NL_OS_WINDOWS
00038 #pragma warning (disable : 4786)
00039 #endif // NL_OS_WINDOWS
00040
00041
00042 #include "nel/misc/config_file.h"
00043 #include "nel/misc/common.h"
00044 #include "nel/misc/debug.h"
00045
00046 #include <cstdio>
00047 #include <vector>
00048 #include <string>
00049
00050 using namespace std;
00051 using namespace NLMISC;
00052
00053
00054
00055 #define YYPARSE_PARAM pvararray
00056
00057
00058
00059
00060
00061
00062
00063 #define DEBUG_PRINT(a)
00064 #ifdef __GNUC__
00065 #define DEBUG_PRINTF(format, args...)
00066 #else // __GNUC__
00067 #define DEBUG_PRINTF // InfoLog->displayRaw
00068 #endif // __GNUC__
00069
00070
00071
00072
00073 enum cf_operation { OP_PLUS, OP_MINUS, OP_MULT, OP_DIVIDE, OP_NEG };
00074
00075 struct cf_value
00076 {
00077 NLMISC::CConfigFile::CVar::TVarType Type;
00078 int Int;
00079 double Real;
00080 char String[1024];
00081 };
00082
00083
00084
00085 extern bool cf_Ignore;
00086
00087 extern bool LoadRoot;
00088
00089 extern FILE *yyin;
00090
00091
00092
00093 NLMISC::CConfigFile::CVar cf_CurrentVar;
00094
00095 int cf_CurrentLine;
00096 char *cf_CurrentFile;
00097
00098 bool cf_OverwriteExistingVariable;
00099
00100
00101
00102
00103
00104 int yylex (void);
00105
00106 cf_value cf_op (cf_value a, cf_value b, cf_operation op);
00107
00108 void cf_print (cf_value Val);
00109
00110 void cf_setVar (NLMISC::CConfigFile::CVar &Var, cf_value Val);
00111
00112 int yyerror (const char *);
00113
00114
00115 #line 85 "cf_gramatical.yxx"
00116 typedef union {
00117 cf_value Val;
00118 } YYSTYPE;
00119 #include <cstdio>
00120
00121 #ifndef __cplusplus
00122 #ifndef __STDC__
00123 #define const
00124 #endif
00125 #endif
00126
00127
00128
00129 #define YYFINAL 47
00130 #define YYFLAG -32768
00131 #define YYNTBASE 20
00132
00133 #define YYTRANSLATE(x) ((unsigned)(x) <= 273 ? yytranslate[x] : 29)
00134
00135 static const char yytranslate[] = { 0,
00136 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00137 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00138 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00139 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00141 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00142 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00143 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00144 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00145 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00146 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00147 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00148 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00149 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00150 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00153 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00154 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00155 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00156 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00157 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00158 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00159 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00161 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
00162 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
00163 17, 18, 19
00164 };
00165
00166 #if YYDEBUG != 0
00167 static const short yyprhs[] = { 0,
00168 0, 2, 3, 6, 8, 12, 17, 22, 24, 28,
00169 33, 36, 38, 42, 44, 48, 52, 54, 58, 62,
00170 65, 68, 72, 74, 76, 78, 80
00171 };
00172
00173 static const short yyrhs[] = { 21,
00174 0, 0, 21, 22, 0, 22, 0, 19, 6, 17,
00175 0, 5, 4, 23, 7, 0, 5, 3, 23, 7,
00176 0, 25, 0, 15, 24, 14, 0, 15, 24, 16,
00177 14, 0, 15, 14, 0, 25, 0, 24, 16, 25,
00178 0, 26, 0, 25, 8, 26, 0, 25, 9, 26,
00179 0, 27, 0, 26, 10, 27, 0, 26, 11, 27,
00180 0, 8, 27, 0, 9, 27, 0, 13, 23, 12,
00181 0, 17, 0, 18, 0, 6, 0, 28, 0, 5,
00182 0
00183 };
00184
00185 #endif
00186
00187 #if YYDEBUG != 0
00188 static const short yyrline[] = { 0,
00189 104, 104, 107, 108, 111, 123, 185, 245, 246, 247,
00190 248, 251, 252, 255, 256, 257, 260, 261, 262, 265,
00191 266, 267, 268, 269, 270, 271, 274
00192 };
00193 #endif
00194
00195
00196 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
00197
00198 static const char * const yytname[] = { "$","error","$undefined.","ADD_ASSIGN",
00199 "ASSIGN","VARIABLE","STRING","SEMICOLON","PLUS","MINUS","MULT","DIVIDE","RPAREN",
00200 "LPAREN","RBRACE","LBRACE","COMMA","INTEGER","REAL","FILELINE","ROOT","instlist",
00201 "inst","expression","exprbrace","expr2","expr3","expr4","variable", NULL
00202 };
00203 #endif
00204
00205 static const short yyr1[] = { 0,
00206 20, 20, 21, 21, 22, 22, 22, 23, 23, 23,
00207 23, 24, 24, 25, 25, 25, 26, 26, 26, 27,
00208 27, 27, 27, 27, 27, 27, 28
00209 };
00210
00211 static const short yyr2[] = { 0,
00212 1, 0, 2, 1, 3, 4, 4, 1, 3, 4,
00213 2, 1, 3, 1, 3, 3, 1, 3, 3, 2,
00214 2, 3, 1, 1, 1, 1, 1
00215 };
00216
00217 static const short yydefact[] = { 2,
00218 0, 0, 1, 4, 0, 0, 0, 3, 27, 25,
00219 0, 0, 0, 0, 23, 24, 0, 8, 14, 17,
00220 26, 0, 5, 20, 21, 0, 11, 0, 12, 7,
00221 0, 0, 0, 0, 6, 22, 9, 0, 15, 16,
00222 18, 19, 10, 13, 0, 0, 0
00223 };
00224
00225 static const short yydefgoto[] = { 45,
00226 3, 4, 17, 28, 18, 19, 20, 21
00227 };
00228
00229 static const short yypact[] = { -4,
00230 17, 2, -4,-32768, 1, 1, -15,-32768,-32768,-32768,
00231 50, 50, 1, 22,-32768,-32768, 10, 14, 23,-32768,
00232 -32768, 25,-32768,-32768,-32768, 31,-32768, -3, 14,-32768,
00233 50, 50, 50, 50,-32768,-32768,-32768, 36, 23, 23,
00234 -32768,-32768,-32768, 14, 29, 46,-32768
00235 };
00236
00237 static const short yypgoto[] = {-32768,
00238 -32768, 44, -1,-32768, -14, 6, -8,-32768
00239 };
00240
00241
00242 #define YYLAST 68
00243
00244
00245 static const short yytable[] = { 29,
00246 1, 23, 24, 25, 22, 9, 10, 7, 11, 12,
00247 37, 26, 38, 13, 2, 14, 30, 15, 16, 5,
00248 6, 31, 32, 44, 41, 42, 9, 10, 46, 11,
00249 12, 35, 33, 34, 13, 27, 39, 40, 15, 16,
00250 9, 10, 36, 11, 12, 47, 8, 0, 13, 43,
00251 0, 0, 15, 16, 9, 10, 0, 11, 12, 0,
00252 0, 0, 13, 0, 0, 0, 15, 16
00253 };
00254
00255 static const short yycheck[] = { 14,
00256 5, 17, 11, 12, 6, 5, 6, 6, 8, 9,
00257 14, 13, 16, 13, 19, 15, 7, 17, 18, 3,
00258 4, 8, 9, 38, 33, 34, 5, 6, 0, 8,
00259 9, 7, 10, 11, 13, 14, 31, 32, 17, 18,
00260 5, 6, 12, 8, 9, 0, 3, -1, 13, 14,
00261 -1, -1, 17, 18, 5, 6, -1, 8, 9, -1,
00262 -1, -1, 13, -1, -1, -1, 17, 18
00263 };
00264
00265 #line 3 "cfbison.simple"
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 #ifndef YYSTACK_USE_ALLOCA
00297 #ifdef alloca
00298 #define YYSTACK_USE_ALLOCA
00299 #else
00300 #ifdef __GNUC__
00301 #define YYSTACK_USE_ALLOCA
00302 #define alloca __builtin_alloca
00303 #else
00304 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
00305 #define YYSTACK_USE_ALLOCA
00306 #include <alloca.h>
00307 #else
00308
00309
00310
00311 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
00312 #if 0
00313
00314 #include <malloc.h>
00315 #endif
00316 #else
00317 #if defined(_AIX)
00318
00319
00320
00321 #pragma alloca
00322 #define YYSTACK_USE_ALLOCA
00323 #else
00324 #if 0
00325 #ifdef __hpux
00326
00327 #define YYSTACK_USE_ALLOCA
00328 #define alloca __builtin_alloca
00329 #endif
00330 #endif
00331 #endif
00332 #endif
00333 #endif
00334 #endif
00335 #endif
00336 #endif
00337
00338 #ifdef YYSTACK_USE_ALLOCA
00339 #define YYSTACK_ALLOC alloca
00340 #else
00341 #define YYSTACK_ALLOC malloc
00342 #endif
00343
00344
00345
00346
00347
00348 #define yyerrok (yyerrstatus = 0)
00349 #define yyclearin (yychar = YYEMPTY)
00350 #define YYEMPTY -2
00351 #define YYEOF 0
00352 #define YYACCEPT goto yyacceptlab
00353 #define YYABORT goto yyabortlab
00354 #define YYERROR goto yyerrlab1
00355
00356
00357
00358
00359 #define YYFAIL goto yyerrlab
00360 #define YYRECOVERING() (!!yyerrstatus)
00361 #define YYBACKUP(token, value) \
00362 do \
00363 if (yychar == YYEMPTY && yylen == 1) \
00364 { yychar = (token), yylval = (value); \
00365 yychar1 = YYTRANSLATE (yychar); \
00366 YYPOPSTACK; \
00367 goto yybackup; \
00368 } \
00369 else \
00370 { yyerror ("syntax error: cannot back up"); YYERROR; } \
00371 while (0)
00372
00373 #define YYTERROR 1
00374 #define YYERRCODE 256
00375
00376 #ifndef YYPURE
00377 #define YYLEX yylex()
00378 #endif
00379
00380 #ifdef YYPURE
00381 #ifdef YYLSP_NEEDED
00382 #ifdef YYLEX_PARAM
00383 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
00384 #else
00385 #define YYLEX yylex(&yylval, &yylloc)
00386 #endif
00387 #else
00388 #ifdef YYLEX_PARAM
00389 #define YYLEX yylex(&yylval, YYLEX_PARAM)
00390 #else
00391 #define YYLEX yylex(&yylval)
00392 #endif
00393 #endif
00394 #endif
00395
00396
00397
00398 #ifndef YYPURE
00399
00400 int yychar;
00401 YYSTYPE yylval;
00402
00403
00404 #ifdef YYLSP_NEEDED
00405 YYLTYPE yylloc;
00406
00407 #endif
00408
00409 int yynerrs;
00410 #endif
00411
00412 #if YYDEBUG != 0
00413 int yydebug;
00414
00415
00416 #endif
00417
00418
00419
00420 #ifndef YYINITDEPTH
00421 #define YYINITDEPTH 200
00422 #endif
00423
00424
00425
00426
00427 #if YYMAXDEPTH == 0
00428 #undef YYMAXDEPTH
00429 #endif
00430
00431 #ifndef YYMAXDEPTH
00432 #define YYMAXDEPTH 10000
00433 #endif
00434
00435
00436
00437
00438
00439
00440 #if __GNUC__ > 1
00441 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
00442 #else
00443 #ifndef __cplusplus
00444
00445
00446
00447 static void
00448 __yy_memcpy (to, from, count)
00449 char *to;
00450 char *from;
00451 unsigned int count;
00452 {
00453 register char *f = from;
00454 register char *t = to;
00455 register int i = count;
00456
00457 while (i-- > 0)
00458 *t++ = *f++;
00459 }
00460
00461 #else
00462
00463
00464
00465 static void
00466 __yy_memcpy (char *to, char *from, unsigned int count)
00467 {
00468 register char *t = to;
00469 register char *f = from;
00470 register int i = count;
00471
00472 while (i-- > 0)
00473 *t++ = *f++;
00474 }
00475
00476 #endif
00477 #endif
00478
00479 #line 217 "cfbison.simple"
00480
00481
00482
00483
00484
00485
00486
00487 #ifdef YYPARSE_PARAM
00488 #ifdef __cplusplus
00489 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
00490 #define YYPARSE_PARAM_DECL
00491 #else
00492 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
00493 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
00494 #endif
00495 #else
00496 #define YYPARSE_PARAM_ARG
00497 #define YYPARSE_PARAM_DECL
00498 #endif
00499
00500
00501 #ifdef __GNUC__
00502 #ifdef YYPARSE_PARAM
00503 int yyparse (void *);
00504 #else
00505 int yyparse (void);
00506 #endif
00507 #endif
00508
00509 int
00510 yyparse(YYPARSE_PARAM_ARG)
00511 YYPARSE_PARAM_DECL
00512 {
00513 register int yystate;
00514 register int yyn;
00515 register short *yyssp;
00516 register YYSTYPE *yyvsp;
00517 int yyerrstatus;
00518 int yychar1 = 0;
00519
00520 short yyssa[YYINITDEPTH];
00521 YYSTYPE yyvsa[YYINITDEPTH];
00522
00523 short *yyss = yyssa;
00524 YYSTYPE *yyvs = yyvsa;
00525
00526 #ifdef YYLSP_NEEDED
00527 YYLTYPE yylsa[YYINITDEPTH];
00528 YYLTYPE *yyls = yylsa;
00529 YYLTYPE *yylsp;
00530
00531 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
00532 #else
00533 #define YYPOPSTACK (yyvsp--, yyssp--)
00534 #endif
00535
00536 int yystacksize = YYINITDEPTH;
00537 int yyfree_stacks = 0;
00538
00539 #ifdef YYPURE
00540 int yychar;
00541 YYSTYPE yylval;
00542 int yynerrs;
00543 #ifdef YYLSP_NEEDED
00544 YYLTYPE yylloc;
00545 #endif
00546 #endif
00547
00548 YYSTYPE yyval;
00549
00550
00551
00552 yyval.Val.Int = 0;
00553 int yylen;
00554
00555 #if YYDEBUG != 0
00556 if (yydebug)
00557 fprintf(stderr, "Starting parse\n");
00558 #endif
00559
00560 yystate = 0;
00561 yyerrstatus = 0;
00562 yynerrs = 0;
00563 yychar = YYEMPTY;
00564
00565
00566
00567
00568
00569
00570 yyssp = yyss - 1;
00571 yyvsp = yyvs;
00572 #ifdef YYLSP_NEEDED
00573 yylsp = yyls;
00574 #endif
00575
00576
00577
00578
00579 yynewstate:
00580
00581 *++yyssp = yystate;
00582
00583 if (yyssp >= yyss + yystacksize - 1)
00584 {
00585
00586
00587 YYSTYPE *yyvs1 = yyvs;
00588 short *yyss1 = yyss;
00589 #ifdef YYLSP_NEEDED
00590 YYLTYPE *yyls1 = yyls;
00591 #endif
00592
00593
00594 int size = yyssp - yyss + 1;
00595
00596 #ifdef yyoverflow
00597
00598
00599 #ifdef YYLSP_NEEDED
00600
00601
00602 yyoverflow("parser stack overflow",
00603 &yyss1, size * sizeof (*yyssp),
00604 &yyvs1, size * sizeof (*yyvsp),
00605 &yyls1, size * sizeof (*yylsp),
00606 &yystacksize);
00607 #else
00608 yyoverflow("parser stack overflow",
00609 &yyss1, size * sizeof (*yyssp),
00610 &yyvs1, size * sizeof (*yyvsp),
00611 &yystacksize);
00612 #endif
00613
00614 yyss = yyss1; yyvs = yyvs1;
00615 #ifdef YYLSP_NEEDED
00616 yyls = yyls1;
00617 #endif
00618 #else
00619
00620 if (yystacksize >= YYMAXDEPTH)
00621 {
00622 yyerror("parser stack overflow");
00623 if (yyfree_stacks)
00624 {
00625 free (yyss);
00626 free (yyvs);
00627 #ifdef YYLSP_NEEDED
00628 free (yyls);
00629 #endif
00630 }
00631 return 2;
00632 }
00633 yystacksize *= 2;
00634 if (yystacksize > YYMAXDEPTH)
00635 yystacksize = YYMAXDEPTH;
00636 #ifndef YYSTACK_USE_ALLOCA
00637 yyfree_stacks = 1;
00638 #endif
00639 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
00640 __yy_memcpy ((char *)yyss, (char *)yyss1,
00641 size * (unsigned int) sizeof (*yyssp));
00642 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
00643 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
00644 size * (unsigned int) sizeof (*yyvsp));
00645 #ifdef YYLSP_NEEDED
00646 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
00647 __yy_memcpy ((char *)yyls, (char *)yyls1,
00648 size * (unsigned int) sizeof (*yylsp));
00649 #endif
00650 #endif
00651
00652 yyssp = yyss + size - 1;
00653 yyvsp = yyvs + size - 1;
00654 #ifdef YYLSP_NEEDED
00655 yylsp = yyls + size - 1;
00656 #endif
00657
00658 #if YYDEBUG != 0
00659 if (yydebug)
00660 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
00661 #endif
00662
00663 if (yyssp >= yyss + yystacksize - 1)
00664 YYABORT;
00665 }
00666
00667 #if YYDEBUG != 0
00668 if (yydebug)
00669 fprintf(stderr, "Entering state %d\n", yystate);
00670 #endif
00671
00672 goto yybackup;
00673 yybackup:
00674
00675
00676
00677
00678
00679
00680
00681 yyn = yypact[yystate];
00682 if (yyn == YYFLAG)
00683 goto yydefault;
00684
00685
00686
00687
00688
00689
00690 if (yychar == YYEMPTY)
00691 {
00692 #if YYDEBUG != 0
00693 if (yydebug)
00694 fprintf(stderr, "Reading a token: ");
00695 #endif
00696 yychar = YYLEX;
00697 }
00698
00699
00700
00701 if (yychar <= 0)
00702 {
00703 yychar1 = 0;
00704 yychar = YYEOF;
00705
00706 #if YYDEBUG != 0
00707 if (yydebug)
00708 fprintf(stderr, "Now at end of input.\n");
00709 #endif
00710 }
00711 else
00712 {
00713 yychar1 = YYTRANSLATE(yychar);
00714
00715 #if YYDEBUG != 0
00716 if (yydebug)
00717 {
00718 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
00719
00720
00721 #ifdef YYPRINT
00722 YYPRINT (stderr, yychar, yylval);
00723 #endif
00724 fprintf (stderr, ")\n");
00725 }
00726 #endif
00727 }
00728
00729 yyn += yychar1;
00730 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
00731 goto yydefault;
00732
00733 yyn = yytable[yyn];
00734
00735
00736
00737
00738
00739
00740
00741
00742 if (yyn < 0)
00743 {
00744 if (yyn == YYFLAG)
00745 goto yyerrlab;
00746 yyn = -yyn;
00747 goto yyreduce;
00748 }
00749 else if (yyn == 0)
00750 goto yyerrlab;
00751
00752 if (yyn == YYFINAL)
00753 YYACCEPT;
00754
00755
00756
00757 #if YYDEBUG != 0
00758 if (yydebug)
00759 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
00760 #endif
00761
00762
00763 if (yychar != YYEOF)
00764 yychar = YYEMPTY;
00765
00766 *++yyvsp = yylval;
00767 #ifdef YYLSP_NEEDED
00768 *++yylsp = yylloc;
00769 #endif
00770
00771
00772 if (yyerrstatus) yyerrstatus--;
00773
00774 yystate = yyn;
00775 goto yynewstate;
00776
00777
00778 yydefault:
00779
00780 yyn = yydefact[yystate];
00781 if (yyn == 0)
00782 goto yyerrlab;
00783
00784
00785 yyreduce:
00786 yylen = yyr2[yyn];
00787 if (yylen > 0)
00788 yyval = yyvsp[1-yylen];
00789
00790 #if YYDEBUG != 0
00791 if (yydebug)
00792 {
00793 int i;
00794
00795 fprintf (stderr, "Reducing via rule %d (line %d), ",
00796 yyn, yyrline[yyn]);
00797
00798
00799 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
00800 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
00801 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
00802 }
00803 #endif
00804
00805
00806 switch (yyn) {
00807
00808 case 2:
00809 #line 104 "cf_gramatical.yxx"
00810 { ;
00811 break;}
00812 case 3:
00813 #line 107 "cf_gramatical.yxx"
00814 { ;
00815 break;}
00816 case 4:
00817 #line 108 "cf_gramatical.yxx"
00818 { ;
00819 break;}
00820 case 5:
00821 #line 112 "cf_gramatical.yxx"
00822 {
00823 DEBUG_PRINTF("Forcing current file %s and line %u\n", yyvsp[-1].Val.String, yyvsp[0].Val.Int-1);
00824
00825 if (cf_CurrentFile != NULL)
00826 free(cf_CurrentFile);
00827
00828 cf_CurrentFile = strdup(yyvsp[-1].Val.String);
00829
00830 cf_CurrentLine = yyvsp[0].Val.Int-1;
00831 ;
00832 break;}
00833 case 6:
00834 #line 124 "cf_gramatical.yxx"
00835 {
00836 DEBUG_PRINTF(" (TYPE %d VARIABLE=", yyvsp[-3].Val.Type);
00837 cf_print (yyvsp[-3].Val);
00838 DEBUG_PRINTF("), (TYPE %d VALUE=", yyvsp[-1].Val.Type);
00839 cf_print (yyvsp[-1].Val);
00840 DEBUG_PRINT(")\n");
00841 int i;
00842
00843 for(i = 0; i < (int)((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM))).size()); i++)
00844 {
00845 if ((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].Name == yyvsp[-3].Val.String)
00846 {
00847 if (cf_OverwriteExistingVariable || (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].Root || !strcmp(yyvsp[-3].Val.String,"RootConfigFilename"))
00848 {
00849 DEBUG_PRINTF("Variable '%s' existe deja, ecrasement\n", yyvsp[-3].Val.String);
00850 }
00851 break;
00852 }
00853 }
00854 NLMISC::CConfigFile::CVar Var;
00855 Var.Comp = false;
00856 Var.Callback = NULL;
00857 if (cf_CurrentVar.Comp)
00858 {
00859 DEBUG_PRINTF ("yacc: new assign complex variable '%s'\n", yyvsp[-3].Val.String);
00860 Var = cf_CurrentVar;
00861 }
00862 else
00863 {
00864 DEBUG_PRINTF ("yacc: new assign normal variable '%s'\n", yyvsp[-3].Val.String);
00865 cf_setVar (Var, yyvsp[-1].Val);
00866 }
00867 Var.Name = yyvsp[-3].Val.String;
00868 if (i == (int)((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM))).size ()))
00869 {
00870
00871 DEBUG_PRINTF ("yacc: new assign var '%s'\n", yyvsp[-3].Val.String);
00872 (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM))).push_back (Var);
00873 }
00874 else if (cf_OverwriteExistingVariable || (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].Root || !strcmp(yyvsp[-3].Val.String,"RootConfigFilename"))
00875 {
00876
00877 Var.Callback = (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].Callback;
00878 DEBUG_PRINTF ("yacc: reassign var name '%s' type %d\n", Var.Name.c_str(), Var.Type);
00879 if (Var != (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i] && Var.Callback != NULL)
00880 (Var.Callback)(Var);
00881 (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i] = Var;
00882 }
00883 else
00884 {
00885 DEBUG_PRINTF ("yacc: don't reassign var '%s' because the variable already exists\n", yyvsp[-3].Val.String);
00886 }
00887
00888 cf_CurrentVar.IntValues.clear ();
00889 cf_CurrentVar.RealValues.clear ();
00890 cf_CurrentVar.StrValues.clear ();
00891 cf_CurrentVar.Comp = false;
00892 cf_CurrentVar.Type = NLMISC::CConfigFile::CVar::T_UNKNOWN;
00893 ;
00894 break;}
00895 case 7:
00896 #line 186 "cf_gramatical.yxx"
00897 {
00898 DEBUG_PRINT(" (VARIABLE+=");
00899 cf_print (yyvsp[-3].Val);
00900 DEBUG_PRINT("), (VALUE=");
00901 cf_print (yyvsp[-1].Val);
00902 DEBUG_PRINT(")\n");
00903 int i;
00904
00905 for(i = 0; i < (int)((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM))).size()); i++)
00906 {
00907 if ((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].Name == yyvsp[-3].Val.String)
00908 {
00909 DEBUG_PRINTF("Variable '%s' existe deja, ajout\n", yyvsp[-3].Val.String);
00910 break;
00911 }
00912 }
00913 NLMISC::CConfigFile::CVar Var;
00914 Var.Comp = false;
00915 Var.Callback = NULL;
00916 if (cf_CurrentVar.Comp) Var = cf_CurrentVar;
00917 else cf_setVar (Var, yyvsp[-1].Val);
00918 Var.Name = yyvsp[-3].Val.String;
00919 if (i == (int)((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM))).size ()))
00920 {
00921
00922 DEBUG_PRINTF ("yacc: new add assign var '%s'\n", yyvsp[-3].Val.String);
00923 (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM))).push_back (Var);
00924 }
00925 else
00926 {
00927
00928 Var.Callback = (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].Callback;
00929 DEBUG_PRINTF ("yacc: add assign var '%s'\n", yyvsp[-3].Val.String);
00930 if ((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].FromLocalFile)
00931 {
00932
00933 (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].add(Var);
00934
00935 if (Var.size() > 0 && Var.Callback != NULL)
00936 (Var.Callback)((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i]);
00937 }
00938 else
00939 {
00940
00941 Var.add ((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i]);
00942 if (Var != (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i] && Var.Callback != NULL)
00943 (Var.Callback)(Var);
00944 (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i] = Var;
00945 }
00946 }
00947
00948 cf_CurrentVar.IntValues.clear ();
00949 cf_CurrentVar.RealValues.clear ();
00950 cf_CurrentVar.StrValues.clear ();
00951 cf_CurrentVar.Comp = false;
00952 cf_CurrentVar.Type = NLMISC::CConfigFile::CVar::T_UNKNOWN;
00953 ;
00954 break;}
00955 case 8:
00956 #line 245 "cf_gramatical.yxx"
00957 { yyval.Val = yyvsp[0].Val; cf_CurrentVar.Comp = false; DEBUG_PRINT("false\n"); ;
00958 break;}
00959 case 9:
00960 #line 246 "cf_gramatical.yxx"
00961 { yyval.Val = yyvsp[-1].Val; cf_CurrentVar.Comp = true; DEBUG_PRINT("true\n"); ;
00962 break;}
00963 case 10:
00964 #line 247 "cf_gramatical.yxx"
00965 { yyval.Val = yyvsp[-2].Val; cf_CurrentVar.Comp = true; DEBUG_PRINT("true\n"); ;
00966 break;}
00967 case 11:
00968 #line 248 "cf_gramatical.yxx"
00969 { yyval.Val = yyvsp[0].Val; cf_CurrentVar.Comp = true; DEBUG_PRINT("true\n"); ;
00970 break;}
00971 case 12:
00972 #line 251 "cf_gramatical.yxx"
00973 { yyval.Val = yyvsp[0].Val; cf_setVar (cf_CurrentVar, yyvsp[0].Val); ;
00974 break;}
00975 case 13:
00976 #line 252 "cf_gramatical.yxx"
00977 { yyval.Val = yyvsp[0].Val; cf_setVar (cf_CurrentVar, yyvsp[0].Val); ;
00978 break;}
00979 case 14:
00980 #line 255 "cf_gramatical.yxx"
00981 { yyval.Val = yyvsp[0].Val; ;
00982 break;}
00983 case 15:
00984 #line 256 "cf_gramatical.yxx"
00985 { yyval.Val = cf_op(yyvsp[-2].Val, yyvsp[0].Val, OP_PLUS); ;
00986 break;}
00987 case 16:
00988 #line 257 "cf_gramatical.yxx"
00989 { yyval.Val = cf_op(yyvsp[-2].Val, yyvsp[0].Val, OP_MINUS); ;
00990 break;}
00991 case 17:
00992 #line 260 "cf_gramatical.yxx"
00993 { yyval.Val = yyvsp[0].Val; ;
00994 break;}
00995 case 18:
00996 #line 261 "cf_gramatical.yxx"
00997 { yyval.Val = cf_op(yyvsp[-2].Val, yyvsp[0].Val, OP_MULT); ;
00998 break;}
00999 case 19:
01000 #line 262 "cf_gramatical.yxx"
01001 { yyval.Val = cf_op (yyvsp[-2].Val, yyvsp[0].Val, OP_DIVIDE); ;
01002 break;}
01003 case 20:
01004 #line 265 "cf_gramatical.yxx"
01005 { yyval.Val = yyvsp[0].Val; ;
01006 break;}
01007 case 21:
01008 #line 266 "cf_gramatical.yxx"
01009 { cf_value v; v.Type=NLMISC::CConfigFile::CVar::T_INT; yyval.Val = cf_op(yyvsp[0].Val,v,OP_NEG); ;
01010 break;}
01011 case 22:
01012 #line 267 "cf_gramatical.yxx"
01013 { yyval.Val = yyvsp[-1].Val; ;
01014 break;}
01015 case 23:
01016 #line 268 "cf_gramatical.yxx"
01017 { yyval.Val = yylval.Val; ;
01018 break;}
01019 case 24:
01020 #line 269 "cf_gramatical.yxx"
01021 { yyval.Val = yylval.Val; ;
01022 break;}
01023 case 25:
01024 #line 270 "cf_gramatical.yxx"
01025 { yyval.Val = yylval.Val; ;
01026 break;}
01027 case 26:
01028 #line 271 "cf_gramatical.yxx"
01029 { yyval.Val = yyvsp[0].Val; ;
01030 break;}
01031 case 27:
01032 #line 275 "cf_gramatical.yxx"
01033 {
01034 DEBUG_PRINT("yacc: cont\n");
01035 bool ok=false;
01036 int i;
01037 for(i = 0; i < (int)((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM))).size()); i++)
01038 {
01039 if ((*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].Name == yyvsp[0].Val.String)
01040 {
01041 ok = true;
01042 break;
01043 }
01044 }
01045 if (ok)
01046 {
01047 cf_value Var;
01048 Var.Type = (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].Type;
01049 DEBUG_PRINTF("vart %d\n", Var.Type);
01050 switch (Var.Type)
01051 {
01052 case NLMISC::CConfigFile::CVar::T_INT: Var.Int = (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].IntValues[0]; break;
01053 case NLMISC::CConfigFile::CVar::T_REAL: Var.Real = (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].RealValues[0]; break;
01054 case NLMISC::CConfigFile::CVar::T_STRING: strcpy (Var.String, (*((vector<NLMISC::CConfigFile::CVar>*)(YYPARSE_PARAM)))[i].StrValues[0].c_str()); break;
01055 default: DEBUG_PRINT("*** CAN T DO THAT!!!\n"); break;
01056 }
01057 yyval.Val = Var;
01058 }
01059 else
01060 {
01061 DEBUG_PRINT("var existe pas\n");
01062 }
01063 ;
01064 break;}
01065 }
01066
01067 #line 543 "cfbison.simple"
01068
01069 yyvsp -= yylen;
01070 yyssp -= yylen;
01071 #ifdef YYLSP_NEEDED
01072 yylsp -= yylen;
01073 #endif
01074
01075 #if YYDEBUG != 0
01076 if (yydebug)
01077 {
01078 short *ssp1 = yyss - 1;
01079 fprintf (stderr, "state stack now");
01080 while (ssp1 != yyssp)
01081 fprintf (stderr, " %d", *++ssp1);
01082 fprintf (stderr, "\n");
01083 }
01084 #endif
01085
01086 *++yyvsp = yyval;
01087
01088 #ifdef YYLSP_NEEDED
01089 yylsp++;
01090 if (yylen == 0)
01091 {
01092 yylsp->first_line = yylloc.first_line;
01093 yylsp->first_column = yylloc.first_column;
01094 yylsp->last_line = (yylsp-1)->last_line;
01095 yylsp->last_column = (yylsp-1)->last_column;
01096 yylsp->text = 0;
01097 }
01098 else
01099 {
01100 yylsp->last_line = (yylsp+yylen-1)->last_line;
01101 yylsp->last_column = (yylsp+yylen-1)->last_column;
01102 }
01103 #endif
01104
01105
01106
01107
01108
01109
01110 yyn = yyr1[yyn];
01111
01112 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
01113 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
01114 yystate = yytable[yystate];
01115 else
01116 yystate = yydefgoto[yyn - YYNTBASE];
01117
01118 goto yynewstate;
01119
01120 yyerrlab:
01121
01122 if (! yyerrstatus)
01123
01124 {
01125 ++yynerrs;
01126
01127 #ifdef YYERROR_VERBOSE
01128 yyn = yypact[yystate];
01129
01130 if (yyn > YYFLAG && yyn < YYLAST)
01131 {
01132 int size = 0;
01133 char *msg;
01134 int x, count;
01135
01136 count = 0;
01137
01138 for (x = (yyn < 0 ? -yyn : 0);
01139 x < (sizeof(yytname) / sizeof(char *)); x++)
01140 if (yycheck[x + yyn] == x)
01141 size += strlen(yytname[x]) + 15, count++;
01142 msg = (char *) malloc(size + 15);
01143 if (msg != 0)
01144 {
01145 strcpy(msg, "parse error");
01146
01147 if (count < 5)
01148 {
01149 count = 0;
01150 for (x = (yyn < 0 ? -yyn : 0);
01151 x < (sizeof(yytname) / sizeof(char *)); x++)
01152 if (yycheck[x + yyn] == x)
01153 {
01154 strcat(msg, count == 0 ? ", expecting `" : " or `");
01155 strcat(msg, yytname[x]);
01156 strcat(msg, "'");
01157 count++;
01158 }
01159 }
01160 yyerror(msg);
01161 free(msg);
01162 }
01163 else
01164 yyerror ("parse error; also virtual memory exceeded");
01165 }
01166 else
01167 #endif
01168 yyerror("parse error");
01169 }
01170
01171 goto yyerrlab1;
01172 yyerrlab1:
01173
01174 if (yyerrstatus == 3)
01175 {
01176
01177
01178
01179 if (yychar == YYEOF)
01180 YYABORT;
01181
01182 #if YYDEBUG != 0
01183 if (yydebug)
01184 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
01185 #endif
01186
01187 yychar = YYEMPTY;
01188 }
01189
01190
01191
01192
01193 yyerrstatus = 3;
01194
01195 goto yyerrhandle;
01196
01197 yyerrdefault:
01198
01199 #if 0
01200
01201
01202 yyn = yydefact[yystate];
01203 if (yyn) goto yydefault;
01204 #endif
01205
01206 yyerrpop:
01207
01208 if (yyssp == yyss) YYABORT;
01209 yyvsp--;
01210 yystate = *--yyssp;
01211 #ifdef YYLSP_NEEDED
01212 yylsp--;
01213 #endif
01214
01215 #if YYDEBUG != 0
01216 if (yydebug)
01217 {
01218 short *ssp1 = yyss - 1;
01219 fprintf (stderr, "Error: state stack now");
01220 while (ssp1 != yyssp)
01221 fprintf (stderr, " %d", *++ssp1);
01222 fprintf (stderr, "\n");
01223 }
01224 #endif
01225
01226 yyerrhandle:
01227
01228 yyn = yypact[yystate];
01229 if (yyn == YYFLAG)
01230 goto yyerrdefault;
01231
01232 yyn += YYTERROR;
01233 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
01234 goto yyerrdefault;
01235
01236 yyn = yytable[yyn];
01237 if (yyn < 0)
01238 {
01239 if (yyn == YYFLAG)
01240 goto yyerrpop;
01241 yyn = -yyn;
01242 goto yyreduce;
01243 }
01244 else if (yyn == 0)
01245 goto yyerrpop;
01246
01247 if (yyn == YYFINAL)
01248 YYACCEPT;
01249
01250 #if YYDEBUG != 0
01251 if (yydebug)
01252 fprintf(stderr, "Shifting error token, ");
01253 #endif
01254
01255 *++yyvsp = yylval;
01256 #ifdef YYLSP_NEEDED
01257 *++yylsp = yylloc;
01258 #endif
01259
01260 yystate = yyn;
01261 goto yynewstate;
01262
01263 yyacceptlab:
01264
01265 if (yyfree_stacks)
01266 {
01267 free (yyss);
01268 free (yyvs);
01269 #ifdef YYLSP_NEEDED
01270 free (yyls);
01271 #endif
01272 }
01273 return 0;
01274
01275 yyabortlab:
01276
01277 if (yyfree_stacks)
01278 {
01279 free (yyss);
01280 free (yyvs);
01281 #ifdef YYLSP_NEEDED
01282 free (yyls);
01283 #endif
01284 }
01285 return 1;
01286 }
01287 #line 307 "cf_gramatical.yxx"
01288
01289
01290
01291 cf_value cf_op (cf_value a, cf_value b, cf_operation op)
01292 {
01293 DEBUG_PRINTF("[OP:%d; ", op);
01294 cf_print(a);
01295 DEBUG_PRINT("; ");
01296 cf_print(b);
01297 DEBUG_PRINT("; ");
01298
01299 switch (op)
01300 {
01301 case OP_MULT:
01302 switch (a.Type)
01303 {
01304 case NLMISC::CConfigFile::CVar::T_INT:
01305 switch (b.Type)
01306 {
01307 case NLMISC::CConfigFile::CVar::T_INT: a.Int *= b.Int; break;
01308 case NLMISC::CConfigFile::CVar::T_REAL: a.Int *= (int)b.Real; break;
01309 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: int*str\n"); break;
01310 default: break;
01311 }
01312 break;
01313 case NLMISC::CConfigFile::CVar::T_REAL:
01314 switch (b.Type)
01315 {
01316 case NLMISC::CConfigFile::CVar::T_INT: a.Real *= (double)b.Int; break;
01317 case NLMISC::CConfigFile::CVar::T_REAL: a.Real *= b.Real; break;
01318 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: real*str\n"); break;
01319 default: break;
01320 }
01321 break;
01322 case NLMISC::CConfigFile::CVar::T_STRING:
01323 switch (b.Type)
01324 {
01325 case NLMISC::CConfigFile::CVar::T_INT: DEBUG_PRINT("ERROR: str*int\n"); break;
01326 case NLMISC::CConfigFile::CVar::T_REAL: DEBUG_PRINT("ERROR: str*real\n"); break;
01327 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: str*str\n"); break;
01328 default: break;
01329 }
01330 break;
01331 default: break;
01332 }
01333 break;
01334 case OP_DIVIDE:
01335 switch (a.Type)
01336 {
01337 case NLMISC::CConfigFile::CVar::T_INT:
01338 switch (b.Type)
01339 {
01340 case NLMISC::CConfigFile::CVar::T_INT: a.Int /= b.Int; break;
01341 case NLMISC::CConfigFile::CVar::T_REAL: a.Int /= (int)b.Real; break;
01342 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: int/str\n"); break;
01343 default: break;
01344 }
01345 break;
01346 case NLMISC::CConfigFile::CVar::T_REAL:
01347 switch (b.Type)
01348 {
01349 case NLMISC::CConfigFile::CVar::T_INT: a.Real /= (double)b.Int; break;
01350 case NLMISC::CConfigFile::CVar::T_REAL: a.Real /= b.Real; break;
01351 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: real/str\n"); break;
01352 default: break;
01353 }
01354 break;
01355 case NLMISC::CConfigFile::CVar::T_STRING:
01356 switch (b.Type)
01357 {
01358 case NLMISC::CConfigFile::CVar::T_INT: DEBUG_PRINT("ERROR: str/int\n"); break;
01359 case NLMISC::CConfigFile::CVar::T_REAL: DEBUG_PRINT("ERROR: str/real\n"); break;
01360 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: str/str\n"); break;
01361 default: break;
01362 }
01363 break;
01364 default: break;
01365 }
01366 break;
01367 case OP_PLUS:
01368 switch (a.Type)
01369 {
01370 case NLMISC::CConfigFile::CVar::T_INT:
01371 switch (b.Type)
01372 {
01373 case NLMISC::CConfigFile::CVar::T_INT: a.Int += b.Int; break;
01374 case NLMISC::CConfigFile::CVar::T_REAL: a.Int += (int)b.Real; break;
01375 case NLMISC::CConfigFile::CVar::T_STRING: a.Int += atoi(b.String); break;
01376 default: break;
01377 }
01378 break;
01379 case NLMISC::CConfigFile::CVar::T_REAL:
01380 switch (b.Type)
01381 {
01382 case NLMISC::CConfigFile::CVar::T_INT: a.Real += (double)b.Int; break;
01383 case NLMISC::CConfigFile::CVar::T_REAL: a.Real += b.Real; break;
01384 case NLMISC::CConfigFile::CVar::T_STRING: a.Real += atof (b.String); break;
01385 default: break;
01386 }
01387 break;
01388 case NLMISC::CConfigFile::CVar::T_STRING:
01389 switch (b.Type)
01390 {
01391 case NLMISC::CConfigFile::CVar::T_INT: { char str2[60]; NLMISC::smprintf(str2, 60, "%d", b.Int); strcat(a.String, str2); break; }
01392 case NLMISC::CConfigFile::CVar::T_REAL: { char str2[60]; NLMISC::smprintf(str2, 60, "%f", b.Real); strcat(a.String, str2); break; }
01393 case NLMISC::CConfigFile::CVar::T_STRING: strcat (a.String, b.String); break;
01394 default: break;
01395 }
01396 break;
01397 default: break;
01398 }
01399 break;
01400 case OP_MINUS:
01401 switch (a.Type)
01402 {
01403 case NLMISC::CConfigFile::CVar::T_INT:
01404 switch (b.Type)
01405 {
01406 case NLMISC::CConfigFile::CVar::T_INT: a.Int -= b.Int; break;
01407 case NLMISC::CConfigFile::CVar::T_REAL: a.Int -= (int)b.Real; break;
01408 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: int-str\n"); break;
01409 default: break;
01410 }
01411 break;
01412 case NLMISC::CConfigFile::CVar::T_REAL:
01413 switch (b.Type)
01414 {
01415 case NLMISC::CConfigFile::CVar::T_INT: a.Real -= (double)b.Int; break;
01416 case NLMISC::CConfigFile::CVar::T_REAL: a.Real -= b.Real; break;
01417 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: real-str\n"); break;
01418 default: break;
01419 }
01420 break;
01421 case NLMISC::CConfigFile::CVar::T_STRING:
01422 switch (b.Type)
01423 {
01424 case NLMISC::CConfigFile::CVar::T_INT: DEBUG_PRINT("ERROR: str-int\n"); break;
01425 case NLMISC::CConfigFile::CVar::T_REAL: DEBUG_PRINT("ERROR: str-real\n"); break;
01426 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: str-str\n"); break;
01427 default: break;
01428 }
01429 break;
01430 default: break;
01431 }
01432 break;
01433 case OP_NEG:
01434 switch (a.Type)
01435 {
01436 case NLMISC::CConfigFile::CVar::T_INT: a.Int = -a.Int; break;
01437 case NLMISC::CConfigFile::CVar::T_REAL: a.Real = -a.Real; break;
01438 case NLMISC::CConfigFile::CVar::T_STRING: DEBUG_PRINT("ERROR: -str\n"); break;
01439 default: break;
01440 }
01441 break;
01442 }
01443 cf_print(a);
01444 DEBUG_PRINT("]\n");
01445 return a;
01446 }
01447
01448
01449 void cf_print (cf_value Val)
01450 {
01451 switch (Val.Type)
01452 {
01453 case NLMISC::CConfigFile::CVar::T_INT:
01454 DEBUG_PRINTF("'%d'", Val.Int);
01455 break;
01456 case NLMISC::CConfigFile::CVar::T_REAL:
01457 DEBUG_PRINTF("`%f`", Val.Real);
01458 break;
01459 case NLMISC::CConfigFile::CVar::T_STRING:
01460 DEBUG_PRINTF("\"%s\"", Val.String);
01461 break;
01462 default: break;
01463 }
01464 }
01465
01466
01467 void cf_setVar (NLMISC::CConfigFile::CVar &Var, cf_value Val)
01468 {
01469 DEBUG_PRINTF("Set var (type %d var name '%s') with new var type %d with value : ", Var.Type, Var.Name.c_str(), Val.Type);
01470 cf_print(Val);
01471 DEBUG_PRINTF("\n");
01472 Var.Root = LoadRoot;
01473 if (Var.Type == NLMISC::CConfigFile::CVar::T_UNKNOWN || Var.Type == Val.Type)
01474 {
01475 if (Var.Type == NLMISC::CConfigFile::CVar::T_UNKNOWN)
01476 {
01477 DEBUG_PRINTF("var type is unknown, set to the val type\n");
01478 }
01479 else
01480 {
01481 DEBUG_PRINTF("val type is same var type, just add\n");
01482 }
01483
01484 Var.Type = Val.Type;
01485 switch (Val.Type)
01486 {
01487 case NLMISC::CConfigFile::CVar::T_INT: Var.IntValues.push_back (Val.Int); break;
01488 case NLMISC::CConfigFile::CVar::T_REAL: Var.RealValues.push_back (Val.Real); break;
01489 case NLMISC::CConfigFile::CVar::T_STRING: Var.StrValues.push_back(Val.String); break;
01490 default: break;
01491 }
01492 }
01493 else
01494 {
01495
01496 switch (Var.Type)
01497 {
01498 case NLMISC::CConfigFile::CVar::T_INT:
01499 switch (Val.Type)
01500 {
01501 case NLMISC::CConfigFile::CVar::T_REAL: Var.IntValues.push_back ((int)Val.Real); break;
01502 case NLMISC::CConfigFile::CVar::T_STRING: Var.IntValues.push_back (atoi(Val.String)); break;
01503 default: break;
01504 }
01505 break;
01506 case NLMISC::CConfigFile::CVar::T_REAL:
01507 switch (Val.Type)
01508 {
01509 case NLMISC::CConfigFile::CVar::T_INT: Var.RealValues.push_back ((double)Val.Int); break;
01510 case NLMISC::CConfigFile::CVar::T_STRING: Var.RealValues.push_back (atof(Val.String)); break;
01511 default: break;
01512 }
01513 break;
01514 case NLMISC::CConfigFile::CVar::T_STRING:
01515 switch (Val.Type)
01516 {
01517 case NLMISC::CConfigFile::CVar::T_INT: Var.StrValues.push_back(toString(Val.Int)); break;
01518 case NLMISC::CConfigFile::CVar::T_REAL: Var.StrValues.push_back(toString(Val.Real)); break;
01519 default: break;
01520 }
01521 break;
01522 default: break;
01523 }
01524 }
01525 }
01526
01527 int yyerror (const char *s)
01528 {
01529 DEBUG_PRINTF("%s\n",s);
01530 return 1;
01531 }
01532
01533