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 SL_BISON 1
00048
00049
00050 #define SL_BISON_VERSION "2.3"
00051
00052
00053 #define SL_SKELETON_NAME "yacc.c"
00054
00055
00056 #define SL_PURE 0
00057
00058
00059 #define SL_LSP_NEEDED 0
00060
00061
00062
00063
00064 #ifndef SL_TOKENTYPE
00065 # define SL_TOKENTYPE
00066
00067
00068 enum slx_tokentype {
00069 ACCFERM = 1,
00070 ACCOUVR = 2,
00071 CONSTANTE = 3,
00072 EGAL = 4,
00073 IDENT = 5,
00074 INF = 6,
00075 INFEGAL = 7,
00076 MOINS = 8,
00077 PLUS = 9,
00078 SUP = 10,
00079 SUPEGAL = 11,
00080 VAR = 12,
00081 VIRG = 13
00082 };
00083 #endif
00084
00085 #define ACCFERM 1
00086 #define ACCOUVR 2
00087 #define CONSTANTE 3
00088 #define EGAL 4
00089 #define IDENT 5
00090 #define INF 6
00091 #define INFEGAL 7
00092 #define MOINS 8
00093 #define PLUS 9
00094 #define SUP 10
00095 #define SUPEGAL 11
00096 #define VAR 12
00097 #define VIRG 13
00098
00099
00100
00101
00102
00103 #line 7 "sl_gram.y"
00104
00105
00106 #include <stdio.h>
00107 #include <stdlib.h>
00108 #include <string.h>
00109
00110 #include "boolean.h"
00111 #include "arithmetique.h"
00112 #include "vecteur.h"
00113 #include "contrainte.h"
00114 #include "sc.h"
00115 #include "malloc.h"
00116 #include "union.h"
00117
00118
00119 extern char slx_text[];
00120 Psysteme ps_yacc;
00121 boolean syntax_error;
00122 Value valcst;
00123 Value fac;
00124
00125 int sens;
00126
00127
00128 short int cote;
00129 Value b1, b2;
00130
00131 Pcontrainte eq;
00132 Pvecteur cp ;
00133 short int operat;
00134
00135 extern Pcontrainte p_eg_fin;
00136 extern Pcontrainte p_ineg_fin;
00137 extern Pvecteur p_pred;
00138 extern Pvecteur p_membre_courant;
00139 extern Pvecteur cp;
00140 Psyslist sl_yacc; Pbase ba_yacc; Variable va_yacc;
00141
00142
00143 #define OPINF 1
00144 #define OPINFEGAL 2
00145 #define OPEGAL 3
00146 #define OPSUPEGAL 4
00147 #define OPSUP 5
00148 #define DROIT 1
00149 #define GAUCHE 2
00150
00151
00152
00153
00154
00155 #ifndef SL_DEBUG
00156 # define SL_DEBUG 0
00157 #endif
00158
00159
00160 #ifdef SL_ERROR_VERBOSE
00161 # undef SL_ERROR_VERBOSE
00162 # define SL_ERROR_VERBOSE 1
00163 #else
00164 # define SL_ERROR_VERBOSE 0
00165 #endif
00166
00167
00168 #ifndef SL_TOKEN_TABLE
00169 # define SL_TOKEN_TABLE 0
00170 #endif
00171
00172 #if ! defined SL_STYPE && ! defined SL_STYPE_IS_DECLARED
00173 typedef union SL_STYPE
00174 #line 74 "sl_gram.y"
00175 {
00176 Value Value;
00177 Variable Variable;
00178 }
00179
00180 #line 181 "y.tab.c"
00181 SL_STYPE;
00182 # define slx_stype SL_STYPE
00183 # define SL_STYPE_IS_DECLARED 1
00184 # define SL_STYPE_IS_TRIVIAL 1
00185 #endif
00186
00187
00188
00189
00190
00191
00192
00193 #line 194 "y.tab.c"
00194
00195 #ifdef short
00196 # undef short
00197 #endif
00198
00199 #ifdef SL_TYPE_UINT8
00200 typedef SL_TYPE_UINT8 slx_type_uint8;
00201 #else
00202 typedef unsigned char slx_type_uint8;
00203 #endif
00204
00205 #ifdef SL_TYPE_INT8
00206 typedef SL_TYPE_INT8 slx_type_int8;
00207 #elif (defined __STDC__ || defined __C99__FUNC__ \
00208 || defined __cplusplus || defined _MSC_VER)
00209 typedef signed char slx_type_int8;
00210 #else
00211 typedef short int slx_type_int8;
00212 #endif
00213
00214 #ifdef SL_TYPE_UINT16
00215 typedef SL_TYPE_UINT16 slx_type_uint16;
00216 #else
00217 typedef unsigned short int slx_type_uint16;
00218 #endif
00219
00220 #ifdef SL_TYPE_INT16
00221 typedef SL_TYPE_INT16 slx_type_int16;
00222 #else
00223 typedef short int slx_type_int16;
00224 #endif
00225
00226 #ifndef SL_SIZE_T
00227 # ifdef __SIZE_TYPE__
00228 # define SL_SIZE_T __SIZE_TYPE__
00229 # elif defined size_t
00230 # define SL_SIZE_T size_t
00231 # elif ! defined SL_SIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
00232 || defined __cplusplus || defined _MSC_VER)
00233 # include <stddef.h>
00234 # define SL_SIZE_T size_t
00235 # else
00236 # define SL_SIZE_T unsigned int
00237 # endif
00238 #endif
00239
00240 #define SL_SIZE_MAXIMUM ((SL_SIZE_T) -1)
00241
00242 #ifndef SL__
00243 # if SL_ENABLE_NLS
00244 # if ENABLE_NLS
00245 # include <libintl.h>
00246 # define SL__(msgid) dgettext ("bison-runtime", msgid)
00247 # endif
00248 # endif
00249 # ifndef SL__
00250 # define SL__(msgid) msgid
00251 # endif
00252 #endif
00253
00254
00255 #if ! defined lint || defined __GNUC__
00256 # define SL_USE(e) ((void) (e))
00257 #else
00258 # define SL_USE(e)
00259 #endif
00260
00261
00262 #ifndef lint
00263 # define SL_ID(n) (n)
00264 #else
00265 #if (defined __STDC__ || defined __C99__FUNC__ \
00266 || defined __cplusplus || defined _MSC_VER)
00267 static int
00268 SL_ID (int i)
00269 #else
00270 static int
00271 SL_ID (i)
00272 int i;
00273 #endif
00274 {
00275 return i;
00276 }
00277 #endif
00278
00279 #if ! defined slx_overflow || SL_ERROR_VERBOSE
00280
00281
00282
00283 # ifdef SL_STACK_USE_ALLOCA
00284 # if SL_STACK_USE_ALLOCA
00285 # ifdef __GNUC__
00286 # define SL_STACK_ALLOC __builtin_alloca
00287 # elif defined __BUILTIN_VA_ARG_INCR
00288 # include <alloca.h>
00289 # elif defined _AIX
00290 # define SL_STACK_ALLOC __alloca
00291 # elif defined _MSC_VER
00292 # include <malloc.h>
00293 # define alloca _alloca
00294 # else
00295 # define SL_STACK_ALLOC alloca
00296 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00297 || defined __cplusplus || defined _MSC_VER)
00298 # include <stdlib.h>
00299 # ifndef _STDLIB_H
00300 # define _STDLIB_H 1
00301 # endif
00302 # endif
00303 # endif
00304 # endif
00305 # endif
00306
00307 # ifdef SL_STACK_ALLOC
00308
00309 # define SL_STACK_FREE(Ptr) do { ; } while (SL_ID (0))
00310 # ifndef SL_STACK_ALLOC_MAXIMUM
00311
00312
00313
00314
00315 # define SL_STACK_ALLOC_MAXIMUM 4032
00316 # endif
00317 # else
00318 # define SL_STACK_ALLOC SL_MALLOC
00319 # define SL_STACK_FREE SL_FREE
00320 # ifndef SL_STACK_ALLOC_MAXIMUM
00321 # define SL_STACK_ALLOC_MAXIMUM SL_SIZE_MAXIMUM
00322 # endif
00323 # if (defined __cplusplus && ! defined _STDLIB_H \
00324 && ! ((defined SL_MALLOC || defined malloc) \
00325 && (defined SL_FREE || defined free)))
00326 # include <stdlib.h>
00327 # ifndef _STDLIB_H
00328 # define _STDLIB_H 1
00329 # endif
00330 # endif
00331 # ifndef SL_MALLOC
00332 # define SL_MALLOC malloc
00333 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00334 || defined __cplusplus || defined _MSC_VER)
00335 void *malloc (SL_SIZE_T);
00336 # endif
00337 # endif
00338 # ifndef SL_FREE
00339 # define SL_FREE free
00340 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00341 || defined __cplusplus || defined _MSC_VER)
00342 void free (void *);
00343 # endif
00344 # endif
00345 # endif
00346 #endif
00347
00348
00349 #if (! defined slx_overflow \
00350 && (! defined __cplusplus \
00351 || (defined SL_STYPE_IS_TRIVIAL && SL_STYPE_IS_TRIVIAL)))
00352
00353
00354 union slx_alloc
00355 {
00356 slx_type_int16 slx_ss;
00357 SL_STYPE slx_vs;
00358 };
00359
00360
00361 # define SL_STACK_GAP_MAXIMUM (sizeof (union slx_alloc) - 1)
00362
00363
00364
00365 # define SL_STACK_BYTES(N) \
00366 ((N) * (sizeof (slx_type_int16) + sizeof (SL_STYPE)) \
00367 + SL_STACK_GAP_MAXIMUM)
00368
00369
00370
00371 # ifndef SL_COPY
00372 # if defined __GNUC__ && 1 < __GNUC__
00373 # define SL_COPY(To, From, Count) \
00374 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
00375 # else
00376 # define SL_COPY(To, From, Count) \
00377 do \
00378 { \
00379 SL_SIZE_T slx_i; \
00380 for (slx_i = 0; slx_i < (Count); slx_i++) \
00381 (To)[slx_i] = (From)[slx_i]; \
00382 } \
00383 while (SL_ID (0))
00384 # endif
00385 # endif
00386
00387
00388
00389
00390
00391
00392 # define SL_STACK_RELOCATE(Stack) \
00393 do \
00394 { \
00395 SL_SIZE_T slx_newbytes; \
00396 SL_COPY (&slx_ptr->Stack, Stack, slx_size); \
00397 Stack = &slx_ptr->Stack; \
00398 slx_newbytes = slx_stacksize * sizeof (*Stack) + SL_STACK_GAP_MAXIMUM; \
00399 slx_ptr += slx_newbytes / sizeof (*slx_ptr); \
00400 } \
00401 while (SL_ID (0))
00402
00403 #endif
00404
00405
00406 #define SL_FINAL 3
00407
00408 #define SL_LAST 31
00409
00410
00411 #define SL_NTOKENS 16
00412
00413 #define SL_NNTS 25
00414
00415 #define SL_NRULES 40
00416
00417 #define SL_NSTATES 49
00418
00419
00420 #define SL_UNDEFTOK 2
00421 #define SL_MAXUTOK 257
00422
00423 #define SL_TRANSLATE(SL_X) \
00424 ((unsigned int) (SL_X) <= SL_MAXUTOK ? slx_translate[SL_X] : SL_UNDEFTOK)
00425
00426
00427 static const slx_type_uint8 slx_translate[] =
00428 {
00429 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00430 12, 13, 14, 15, 2, 2, 2, 2, 2, 2,
00431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00442 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
00454 2, 2, 2, 2, 2, 2, 1, 2
00455 };
00456
00457 #if SL_DEBUG
00458
00459
00460 static const slx_type_uint8 slx_prhs[] =
00461 {
00462 0, 0, 3, 8, 9, 10, 13, 15, 19, 21,
00463 23, 26, 33, 34, 35, 37, 41, 42, 49, 50,
00464 51, 54, 55, 58, 62, 65, 67, 69, 71, 73,
00465 75, 77, 79, 81, 83, 85, 87, 89, 94, 95,
00466 97
00467 };
00468
00469
00470 static const slx_type_int8 slx_rhs[] =
00471 {
00472 17, 0, -1, 18, 20, 23, 19, -1, -1, -1,
00473 14, 21, -1, 22, -1, 21, 15, 22, -1, 7,
00474 -1, 24, -1, 24, 23, -1, 25, 4, 27, 40,
00475 3, 26, -1, -1, -1, 28, -1, 27, 15, 28,
00476 -1, -1, 29, 38, 36, 31, 39, 30, -1, -1,
00477 -1, 37, 33, -1, -1, 32, 33, -1, 31, 37,
00478 33, -1, 35, 34, -1, 35, -1, 34, -1, 7,
00479 -1, 5, -1, 8, -1, 9, -1, 6, -1, 12,
00480 -1, 13, -1, 11, -1, 10, -1, 31, -1, 38,
00481 36, 31, 39, -1, -1, 15, -1, -1
00482 };
00483
00484
00485 static const slx_type_uint16 slx_rline[] =
00486 {
00487 0, 82, 82, 86, 93, 98, 101, 102, 105, 112,
00488 113, 116, 120, 128, 139, 140, 141, 144, 148, 161,
00489 166, 167, 167, 168, 171, 183, 195, 206, 221, 227,
00490 235, 243, 251, 259, 268, 270, 274, 275, 279, 307,
00491 308
00492 };
00493 #endif
00494
00495 #if SL_DEBUG || SL_ERROR_VERBOSE || SL_TOKEN_TABLE
00496
00497
00498 static const char *const slx_tname[] =
00499 {
00500 "$end", "error", "$undefined", "ACCFERM", "ACCOUVR", "CONSTANTE",
00501 "EGAL", "IDENT", "INF", "INFEGAL", "MOINS", "PLUS", "SUP", "SUPEGAL",
00502 "VAR", "VIRG", "$accept", "s_list", "inisl", "endsl", "defvar", "l_var",
00503 "newid", "l_sys", "system", "inisys", "endsys", "l_eq", "eq", "debeq",
00504 "feq", "membre", "@1", "terme", "ident", "const", "op", "addop",
00505 "multi_membre", "fin_mult_membre", "virg_opt", 0
00506 };
00507 #endif
00508
00509 # ifdef SL_PRINT
00510
00511
00512 static const slx_type_uint16 slx_toknum[] =
00513 {
00514 0, 256, 257, 1, 2, 3, 4, 5, 6, 7,
00515 8, 9, 10, 11, 12, 13
00516 };
00517 # endif
00518
00519
00520 static const slx_type_uint8 slx_r1[] =
00521 {
00522 0, 16, 17, 18, 19, 20, 21, 21, 22, 23,
00523 23, 24, 25, 26, 27, 27, 27, 28, 29, 30,
00524 31, 32, 31, 31, 33, 33, 33, 34, 35, 36,
00525 36, 36, 36, 36, 37, 37, 38, 38, 39, 40,
00526 40
00527 };
00528
00529
00530 static const slx_type_uint8 slx_r2[] =
00531 {
00532 0, 2, 4, 0, 0, 2, 1, 3, 1, 1,
00533 2, 6, 0, 0, 1, 3, 0, 6, 0, 0,
00534 2, 0, 2, 3, 2, 1, 1, 1, 1, 1,
00535 1, 1, 1, 1, 1, 1, 1, 4, 0, 1,
00536 0
00537 };
00538
00539
00540
00541
00542 static const slx_type_uint8 slx_defact[] =
00543 {
00544 3, 0, 0, 1, 0, 12, 8, 5, 6, 4,
00545 9, 0, 0, 2, 10, 18, 7, 40, 14, 21,
00546 18, 0, 35, 34, 36, 0, 0, 0, 15, 13,
00547 0, 28, 27, 22, 26, 25, 20, 31, 29, 30,
00548 32, 33, 21, 11, 23, 24, 38, 37, 17
00549 };
00550
00551
00552 static const slx_type_int8 slx_defgoto[] =
00553 {
00554 -1, 1, 2, 13, 5, 7, 8, 9, 10, 11,
00555 43, 17, 18, 19, 48, 24, 25, 33, 34, 35,
00556 42, 26, 27, 47, 21
00557 };
00558
00559
00560
00561 #define SL_PACT_NINF -25
00562 static const slx_type_int8 slx_pact[] =
00563 {
00564 -25, 7, 2, -25, 11, -25, -25, 4, -25, -25,
00565 16, 17, 11, -25, -25, -2, -25, 8, -25, 1,
00566 21, 22, -25, -25, 1, 10, 10, -3, -25, -25,
00567 10, -25, -25, -25, -25, 19, -25, -25, -25, -25,
00568 -25, -25, 1, -25, -25, -25, 1, -1, -25
00569 };
00570
00571
00572 static const slx_type_int8 slx_pgoto[] =
00573 {
00574 -25, -25, -25, -25, -25, -25, 15, 18, -25, -25,
00575 -25, -25, 9, -25, -25, -12, -25, -22, -4, -25,
00576 -25, -24, -25, -25, -25
00577 };
00578
00579
00580
00581
00582
00583 #define SL_TABLE_NINF -40
00584 static const slx_type_int8 slx_table[] =
00585 {
00586 30, -16, -19, 37, 36, 38, 39, 3, 44, 40,
00587 41, 22, 23, -16, -19, 31, 4, 32, 6, 12,
00588 -12, 15, 30, 20, -39, 29, 32, 16, 14, 28,
00589 46, 45
00590 };
00591
00592 static const slx_type_uint8 slx_check[] =
00593 {
00594 24, 3, 3, 6, 26, 8, 9, 0, 30, 12,
00595 13, 10, 11, 15, 15, 5, 14, 7, 7, 15,
00596 4, 4, 46, 15, 3, 3, 7, 12, 10, 20,
00597 42, 35
00598 };
00599
00600
00601
00602 static const slx_type_uint8 slx_stos[] =
00603 {
00604 0, 17, 18, 0, 14, 20, 7, 21, 22, 23,
00605 24, 25, 15, 19, 23, 4, 22, 27, 28, 29,
00606 15, 40, 10, 11, 31, 32, 37, 38, 28, 3,
00607 37, 5, 7, 33, 34, 35, 33, 6, 8, 9,
00608 12, 13, 36, 26, 33, 34, 31, 39, 30
00609 };
00610
00611 #define slx_errok (slx_errstatus = 0)
00612 #define slx_clearin (slx_char = SL_EMPTY)
00613 #define SL_EMPTY (-2)
00614 #define SL_EOF 0
00615
00616 #define SL_ACCEPT goto slx_acceptlab
00617 #define SL_ABORT goto slx_abortlab
00618 #define SL_ERROR goto slx_errorlab
00619
00620
00621
00622
00623
00624
00625 #define SL_FAIL goto slx_errlab
00626
00627 #define SL_RECOVERING() (!!slx_errstatus)
00628
00629 #define SL_BACKUP(Token, Value) \
00630 do \
00631 if (slx_char == SL_EMPTY && slx_len == 1) \
00632 { \
00633 slx_char = (Token); \
00634 slx_lval = (Value); \
00635 slx_token = SL_TRANSLATE (slx_char); \
00636 SL_POPSTACK (1); \
00637 goto slx_backup; \
00638 } \
00639 else \
00640 { \
00641 slx_error (SL__("syntax error: cannot back up")); \
00642 SL_ERROR; \
00643 } \
00644 while (SL_ID (0))
00645
00646
00647 #define SL_TERROR 1
00648 #define SL_ERRCODE 256
00649
00650
00651
00652
00653
00654
00655 #define SL_RHSLOC(Rhs, K) ((Rhs)[K])
00656 #ifndef SL_LLOC_DEFAULT
00657 # define SL_LLOC_DEFAULT(Current, Rhs, N) \
00658 do \
00659 if (SL_ID (N)) \
00660 { \
00661 (Current).first_line = SL_RHSLOC (Rhs, 1).first_line; \
00662 (Current).first_column = SL_RHSLOC (Rhs, 1).first_column; \
00663 (Current).last_line = SL_RHSLOC (Rhs, N).last_line; \
00664 (Current).last_column = SL_RHSLOC (Rhs, N).last_column; \
00665 } \
00666 else \
00667 { \
00668 (Current).first_line = (Current).last_line = \
00669 SL_RHSLOC (Rhs, 0).last_line; \
00670 (Current).first_column = (Current).last_column = \
00671 SL_RHSLOC (Rhs, 0).last_column; \
00672 } \
00673 while (SL_ID (0))
00674 #endif
00675
00676
00677
00678
00679
00680
00681 #ifndef SL__LOCATION_PRINT
00682 # if SL_LTYPE_IS_TRIVIAL
00683 # define SL__LOCATION_PRINT(File, Loc) \
00684 fprintf (File, "%d.%d-%d.%d", \
00685 (Loc).first_line, (Loc).first_column, \
00686 (Loc).last_line, (Loc).last_column)
00687 # else
00688 # define SL__LOCATION_PRINT(File, Loc) ((void) 0)
00689 # endif
00690 #endif
00691
00692
00693
00694
00695 #ifdef SL_LEX_PARAM
00696 # define SL_LEX slx_lex (SL_LEX_PARAM)
00697 #else
00698 # define SL_LEX slx_lex ()
00699 #endif
00700
00701
00702 #if SL_DEBUG
00703
00704 # ifndef SL_FPRINTF
00705 # include <stdio.h>
00706 # define SL_FPRINTF fprintf
00707 # endif
00708
00709 # define SL_DPRINTF(Args) \
00710 do { \
00711 if (slx_debug) \
00712 SL_FPRINTF Args; \
00713 } while (SL_ID (0))
00714
00715 # define SL__SYMBOL_PRINT(Title, Type, Value, Location) \
00716 do { \
00717 if (slx_debug) \
00718 { \
00719 SL_FPRINTF (stderr, "%s ", Title); \
00720 slx__symbol_print (stderr, \
00721 Type, Value); \
00722 SL_FPRINTF (stderr, "\n"); \
00723 } \
00724 } while (SL_ID (0))
00725
00726
00727
00728
00729
00730
00731
00732 #if (defined __STDC__ || defined __C99__FUNC__ \
00733 || defined __cplusplus || defined _MSC_VER)
00734 static void
00735 slx__symbol_value_print (FILE *slx_output, int slx_type, SL_STYPE const * const slx_valuep)
00736 #else
00737 static void
00738 slx__symbol_value_print (slx_output, slx_type, slx_valuep)
00739 FILE *slx_output;
00740 int slx_type;
00741 SL_STYPE const * const slx_valuep;
00742 #endif
00743 {
00744 if (!slx_valuep)
00745 return;
00746 # ifdef SL_PRINT
00747 if (slx_type < SL_NTOKENS)
00748 SL_PRINT (slx_output, slx_toknum[slx_type], *slx_valuep);
00749 # else
00750 SL_USE (slx_output);
00751 # endif
00752 switch (slx_type)
00753 {
00754 default:
00755 break;
00756 }
00757 }
00758
00759
00760
00761
00762
00763
00764 #if (defined __STDC__ || defined __C99__FUNC__ \
00765 || defined __cplusplus || defined _MSC_VER)
00766 static void
00767 slx__symbol_print (FILE *slx_output, int slx_type, SL_STYPE const * const slx_valuep)
00768 #else
00769 static void
00770 slx__symbol_print (slx_output, slx_type, slx_valuep)
00771 FILE *slx_output;
00772 int slx_type;
00773 SL_STYPE const * const slx_valuep;
00774 #endif
00775 {
00776 if (slx_type < SL_NTOKENS)
00777 SL_FPRINTF (slx_output, "token %s (", slx_tname[slx_type]);
00778 else
00779 SL_FPRINTF (slx_output, "nterm %s (", slx_tname[slx_type]);
00780
00781 slx__symbol_value_print (slx_output, slx_type, slx_valuep);
00782 SL_FPRINTF (slx_output, ")");
00783 }
00784
00785
00786
00787
00788
00789
00790 #if (defined __STDC__ || defined __C99__FUNC__ \
00791 || defined __cplusplus || defined _MSC_VER)
00792 static void
00793 slx__stack_print (slx_type_int16 *bottom, slx_type_int16 *top)
00794 #else
00795 static void
00796 slx__stack_print (bottom, top)
00797 slx_type_int16 *bottom;
00798 slx_type_int16 *top;
00799 #endif
00800 {
00801 SL_FPRINTF (stderr, "Stack now");
00802 for (; bottom <= top; ++bottom)
00803 SL_FPRINTF (stderr, " %d", *bottom);
00804 SL_FPRINTF (stderr, "\n");
00805 }
00806
00807 # define SL__STACK_PRINT(Bottom, Top) \
00808 do { \
00809 if (slx_debug) \
00810 slx__stack_print ((Bottom), (Top)); \
00811 } while (SL_ID (0))
00812
00813
00814
00815
00816
00817
00818 #if (defined __STDC__ || defined __C99__FUNC__ \
00819 || defined __cplusplus || defined _MSC_VER)
00820 static void
00821 slx__reduce_print (SL_STYPE *slx_vsp, int slx_rule)
00822 #else
00823 static void
00824 slx__reduce_print (slx_vsp, slx_rule)
00825 SL_STYPE *slx_vsp;
00826 int slx_rule;
00827 #endif
00828 {
00829 int slx_nrhs = slx_r2[slx_rule];
00830 int slx_i;
00831 unsigned long int slx_lno = slx_rline[slx_rule];
00832 SL_FPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
00833 slx_rule - 1, slx_lno);
00834
00835 for (slx_i = 0; slx_i < slx_nrhs; slx_i++)
00836 {
00837 fprintf (stderr, " $%d = ", slx_i + 1);
00838 slx__symbol_print (stderr, slx_rhs[slx_prhs[slx_rule] + slx_i],
00839 &(slx_vsp[(slx_i + 1) - (slx_nrhs)])
00840 );
00841 fprintf (stderr, "\n");
00842 }
00843 }
00844
00845 # define SL__REDUCE_PRINT(Rule) \
00846 do { \
00847 if (slx_debug) \
00848 slx__reduce_print (slx_vsp, Rule); \
00849 } while (SL_ID (0))
00850
00851
00852
00853 int slx_debug;
00854 #else
00855 # define SL_DPRINTF(Args)
00856 # define SL__SYMBOL_PRINT(Title, Type, Value, Location)
00857 # define SL__STACK_PRINT(Bottom, Top)
00858 # define SL__REDUCE_PRINT(Rule)
00859 #endif
00860
00861
00862
00863 #ifndef SL_INITDEPTH
00864 # define SL_INITDEPTH 200
00865 #endif
00866
00867
00868
00869
00870
00871
00872
00873
00874 #ifndef SL_MAXDEPTH
00875 # define SL_MAXDEPTH 10000
00876 #endif
00877
00878
00879
00880 #if SL_ERROR_VERBOSE
00881
00882 # ifndef slx_strlen
00883 # if defined __GLIBC__ && defined _STRING_H
00884 # define slx_strlen strlen
00885 # else
00886
00887 #if (defined __STDC__ || defined __C99__FUNC__ \
00888 || defined __cplusplus || defined _MSC_VER)
00889 static SL_SIZE_T
00890 slx_strlen (const char *slx_str)
00891 #else
00892 static SL_SIZE_T
00893 slx_strlen (slx_str)
00894 const char *slx_str;
00895 #endif
00896 {
00897 SL_SIZE_T slx_len;
00898 for (slx_len = 0; slx_str[slx_len]; slx_len++)
00899 continue;
00900 return slx_len;
00901 }
00902 # endif
00903 # endif
00904
00905 # ifndef slx_stpcpy
00906 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
00907 # define slx_stpcpy stpcpy
00908 # else
00909
00910
00911 #if (defined __STDC__ || defined __C99__FUNC__ \
00912 || defined __cplusplus || defined _MSC_VER)
00913 static char *
00914 slx_stpcpy (char *slx_dest, const char *slx_src)
00915 #else
00916 static char *
00917 slx_stpcpy (slx_dest, slx_src)
00918 char *slx_dest;
00919 const char *slx_src;
00920 #endif
00921 {
00922 char *slx_d = slx_dest;
00923 const char *slx_s = slx_src;
00924
00925 while ((*slx_d++ = *slx_s++) != '\0')
00926 continue;
00927
00928 return slx_d - 1;
00929 }
00930 # endif
00931 # endif
00932
00933 # ifndef slx_tnamerr
00934
00935
00936
00937
00938
00939
00940
00941 static SL_SIZE_T
00942 slx_tnamerr (char *slx_res, const char *slx_str)
00943 {
00944 if (*slx_str == '"')
00945 {
00946 SL_SIZE_T slx_n = 0;
00947 char const *slx_p = slx_str;
00948
00949 for (;;)
00950 switch (*++slx_p)
00951 {
00952 case '\'':
00953 case ',':
00954 goto do_not_strip_quotes;
00955
00956 case '\\':
00957 if (*++slx_p != '\\')
00958 goto do_not_strip_quotes;
00959
00960 default:
00961 if (slx_res)
00962 slx_res[slx_n] = *slx_p;
00963 slx_n++;
00964 break;
00965
00966 case '"':
00967 if (slx_res)
00968 slx_res[slx_n] = '\0';
00969 return slx_n;
00970 }
00971 do_not_strip_quotes: ;
00972 }
00973
00974 if (! slx_res)
00975 return slx_strlen (slx_str);
00976
00977 return slx_stpcpy (slx_res, slx_str) - slx_res;
00978 }
00979 # endif
00980
00981
00982
00983
00984
00985
00986
00987
00988 static SL_SIZE_T
00989 slx_syntax_error (char *slx_result, int slx_state, int slx_char)
00990 {
00991 int slx_n = slx_pact[slx_state];
00992
00993 if (! (SL_PACT_NINF < slx_n && slx_n <= SL_LAST))
00994 return 0;
00995 else
00996 {
00997 int slx_type = SL_TRANSLATE (slx_char);
00998 SL_SIZE_T slx_size0 = slx_tnamerr (0, slx_tname[slx_type]);
00999 SL_SIZE_T slx_size = slx_size0;
01000 SL_SIZE_T slx_size1;
01001 int slx_size_overflow = 0;
01002 enum { SL_ERROR_VERBOSE_ARGS_MAXIMUM = 5 };
01003 char const *slx_arg[SL_ERROR_VERBOSE_ARGS_MAXIMUM];
01004 int slx_x;
01005
01006 # if 0
01007
01008
01009 SL__("syntax error, unexpected %s");
01010 SL__("syntax error, unexpected %s, expecting %s");
01011 SL__("syntax error, unexpected %s, expecting %s or %s");
01012 SL__("syntax error, unexpected %s, expecting %s or %s or %s");
01013 SL__("syntax error, unexpected %s, expecting %s or %s or %s or %s");
01014 # endif
01015 char *slx_fmt;
01016 char const *slx_f;
01017 static char const slx_unexpected[] = "syntax error, unexpected %s";
01018 static char const slx_expecting[] = ", expecting %s";
01019 static char const slx_or[] = " or %s";
01020 char slx_format[sizeof slx_unexpected
01021 + sizeof slx_expecting - 1
01022 + ((SL_ERROR_VERBOSE_ARGS_MAXIMUM - 2)
01023 * (sizeof slx_or - 1))];
01024 char const *slx_prefix = slx_expecting;
01025
01026
01027
01028 int slx_xbegin = slx_n < 0 ? -slx_n : 0;
01029
01030
01031 int slx_checklim = SL_LAST - slx_n + 1;
01032 int slx_xend = slx_checklim < SL_NTOKENS ? slx_checklim : SL_NTOKENS;
01033 int slx_count = 1;
01034
01035 slx_arg[0] = slx_tname[slx_type];
01036 slx_fmt = slx_stpcpy (slx_format, slx_unexpected);
01037
01038 for (slx_x = slx_xbegin; slx_x < slx_xend; ++slx_x)
01039 if (slx_check[slx_x + slx_n] == slx_x && slx_x != SL_TERROR)
01040 {
01041 if (slx_count == SL_ERROR_VERBOSE_ARGS_MAXIMUM)
01042 {
01043 slx_count = 1;
01044 slx_size = slx_size0;
01045 slx_format[sizeof slx_unexpected - 1] = '\0';
01046 break;
01047 }
01048 slx_arg[slx_count++] = slx_tname[slx_x];
01049 slx_size1 = slx_size + slx_tnamerr (0, slx_tname[slx_x]);
01050 slx_size_overflow |= (slx_size1 < slx_size);
01051 slx_size = slx_size1;
01052 slx_fmt = slx_stpcpy (slx_fmt, slx_prefix);
01053 slx_prefix = slx_or;
01054 }
01055
01056 slx_f = SL__(slx_format);
01057 slx_size1 = slx_size + slx_strlen (slx_f);
01058 slx_size_overflow |= (slx_size1 < slx_size);
01059 slx_size = slx_size1;
01060
01061 if (slx_size_overflow)
01062 return SL_SIZE_MAXIMUM;
01063
01064 if (slx_result)
01065 {
01066
01067
01068
01069 char *slx_p = slx_result;
01070