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