Sync to trunk head(r38096)
[reactos.git] / reactos / tools / wmc / mcy.tab.c
1 /* A Bison parser, made by GNU Bison 2.1. */
2
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36 /* Identify Bison output. */
37 #define YYBISON 1
38
39 /* Bison version. */
40 #define YYBISON_VERSION "2.1"
41
42 /* Skeleton name. */
43 #define YYSKELETON_NAME "yacc.c"
44
45 /* Pure parsers. */
46 #define YYPURE 0
47
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
50
51 /* Substitute the variable and function names. */
52 #define yyparse mcy_parse
53 #define yylex mcy_lex
54 #define yyerror mcy_error
55 #define yylval mcy_lval
56 #define yychar mcy_char
57 #define yydebug mcy_debug
58 #define yynerrs mcy_nerrs
59
60
61 /* Tokens. */
62 #ifndef YYTOKENTYPE
63 # define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 tSEVNAMES = 258,
68 tFACNAMES = 259,
69 tLANNAMES = 260,
70 tBASE = 261,
71 tCODEPAGE = 262,
72 tTYPEDEF = 263,
73 tNL = 264,
74 tSYMNAME = 265,
75 tMSGEND = 266,
76 tSEVERITY = 267,
77 tFACILITY = 268,
78 tLANGUAGE = 269,
79 tMSGID = 270,
80 tIDENT = 271,
81 tLINE = 272,
82 tFILE = 273,
83 tCOMMENT = 274,
84 tNUMBER = 275,
85 tTOKEN = 276
86 };
87 #endif
88 /* Tokens. */
89 #define tSEVNAMES 258
90 #define tFACNAMES 259
91 #define tLANNAMES 260
92 #define tBASE 261
93 #define tCODEPAGE 262
94 #define tTYPEDEF 263
95 #define tNL 264
96 #define tSYMNAME 265
97 #define tMSGEND 266
98 #define tSEVERITY 267
99 #define tFACILITY 268
100 #define tLANGUAGE 269
101 #define tMSGID 270
102 #define tIDENT 271
103 #define tLINE 272
104 #define tFILE 273
105 #define tCOMMENT 274
106 #define tNUMBER 275
107 #define tTOKEN 276
108
109
110
111
112 /* Copy the first part of user declarations. */
113 #line 39 "tools/wmc/mcy.y"
114
115
116 #include "config.h"
117
118 #include <stdio.h>
119 #include <stdlib.h>
120 #include <assert.h>
121 #include <string.h>
122 #include "utils.h"
123 #include "wmc.h"
124 #include "lang.h"
125
126 static const char err_syntax[] = "Syntax error";
127 static const char err_number[] = "Number expected";
128 static const char err_ident[] = "Identifier expected";
129 static const char err_assign[] = "'=' expected";
130 static const char err_popen[] = "'(' expected";
131 static const char err_pclose[] = "')' expected";
132 static const char err_colon[] = "':' expected";
133 static const char err_msg[] = "Message expected";
134
135 /* Scanner switches */
136 int want_nl = 0; /* Request next newlinw */
137 int want_line = 0; /* Request next complete line */
138 int want_file = 0; /* Request next ident as filename */
139
140 node_t *nodehead = NULL; /* The list of all parsed elements */
141 static node_t *nodetail = NULL;
142 lan_blk_t *lanblockhead; /* List of parsed elements transposed */
143
144 static int base = 16; /* Current printout base to use (8, 10 or 16) */
145 static WCHAR *cast = NULL; /* Current typecast to use */
146
147 static int last_id = 0; /* The last message ID parsed */
148 static int last_sev = 0; /* Last severity code parsed */
149 static int last_fac = 0; /* Last facility code parsed */
150 static WCHAR *last_sym = NULL;/* Last alias symbol parsed */
151 static int have_sev; /* Set if severity parsed for current message */
152 static int have_fac; /* Set if facility parsed for current message */
153 static int have_sym; /* Set is symbol parsed for current message */
154
155 static cp_xlat_t *cpxlattab = NULL; /* Codepage translation table */
156 static int ncpxlattab = 0;
157
158 /* Prototypes */
159 static WCHAR *merge(WCHAR *s1, WCHAR *s2);
160 static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg);
161 static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg);
162 static msg_t *complete_msg(msg_t *msg, int id);
163 static void add_node(node_e type, void *p);
164 static void do_add_token(tok_e type, token_t *tok, const char *code);
165 static void test_id(int id);
166 static int check_languages(node_t *head);
167 static lan_blk_t *block_messages(node_t *head);
168 static void add_cpxlat(int lan, int cpin, int cpout);
169 static cp_xlat_t *find_cpxlat(int lan);
170
171
172
173 /* Enabling traces. */
174 #ifndef YYDEBUG
175 # define YYDEBUG 0
176 #endif
177
178 /* Enabling verbose error messages. */
179 #ifdef YYERROR_VERBOSE
180 # undef YYERROR_VERBOSE
181 # define YYERROR_VERBOSE 1
182 #else
183 # define YYERROR_VERBOSE 0
184 #endif
185
186 /* Enabling the token table. */
187 #ifndef YYTOKEN_TABLE
188 # define YYTOKEN_TABLE 0
189 #endif
190
191 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
192 #line 98 "tools/wmc/mcy.y"
193 typedef union YYSTYPE {
194 WCHAR *str;
195 unsigned num;
196 token_t *tok;
197 lanmsg_t *lmp;
198 msg_t *msg;
199 lan_cp_t lcp;
200 } YYSTYPE;
201 /* Line 196 of yacc.c. */
202 #line 203 "mcy.tab.c"
203 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
204 # define YYSTYPE_IS_DECLARED 1
205 # define YYSTYPE_IS_TRIVIAL 1
206 #endif
207
208
209
210 /* Copy the second part of user declarations. */
211
212
213 /* Line 219 of yacc.c. */
214 #line 215 "mcy.tab.c"
215
216 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
217 # define YYSIZE_T __SIZE_TYPE__
218 #endif
219 #if ! defined (YYSIZE_T) && defined (size_t)
220 # define YYSIZE_T size_t
221 #endif
222 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
223 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
224 # define YYSIZE_T size_t
225 #endif
226 #if ! defined (YYSIZE_T)
227 # define YYSIZE_T unsigned int
228 #endif
229
230 #ifndef YY_
231 # if YYENABLE_NLS
232 # if ENABLE_NLS
233 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
234 # define YY_(msgid) dgettext ("bison-runtime", msgid)
235 # endif
236 # endif
237 # ifndef YY_
238 # define YY_(msgid) msgid
239 # endif
240 #endif
241
242 #if ! defined (yyoverflow) || YYERROR_VERBOSE
243
244 /* The parser invokes alloca or malloc; define the necessary symbols. */
245
246 # ifdef YYSTACK_USE_ALLOCA
247 # if YYSTACK_USE_ALLOCA
248 # ifdef __GNUC__
249 # define YYSTACK_ALLOC __builtin_alloca
250 # else
251 # define YYSTACK_ALLOC alloca
252 # if defined (__STDC__) || defined (__cplusplus)
253 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
254 # define YYINCLUDED_STDLIB_H
255 # endif
256 # endif
257 # endif
258 # endif
259
260 # ifdef YYSTACK_ALLOC
261 /* Pacify GCC's `empty if-body' warning. */
262 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
263 # ifndef YYSTACK_ALLOC_MAXIMUM
264 /* The OS might guarantee only one guard page at the bottom of the stack,
265 and a page size can be as small as 4096 bytes. So we cannot safely
266 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
267 to allow for a few compiler-allocated temporary stack slots. */
268 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
269 # endif
270 # else
271 # define YYSTACK_ALLOC YYMALLOC
272 # define YYSTACK_FREE YYFREE
273 # ifndef YYSTACK_ALLOC_MAXIMUM
274 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
275 # endif
276 # ifdef __cplusplus
277 extern "C" {
278 # endif
279 # ifndef YYMALLOC
280 # define YYMALLOC malloc
281 # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
282 && (defined (__STDC__) || defined (__cplusplus)))
283 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
284 # endif
285 # endif
286 # ifndef YYFREE
287 # define YYFREE free
288 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
289 && (defined (__STDC__) || defined (__cplusplus)))
290 void free (void *); /* INFRINGES ON USER NAME SPACE */
291 # endif
292 # endif
293 # ifdef __cplusplus
294 }
295 # endif
296 # endif
297 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
298
299
300 #if (! defined (yyoverflow) \
301 && (! defined (__cplusplus) \
302 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
303
304 /* A type that is properly aligned for any stack member. */
305 union yyalloc
306 {
307 short int yyss;
308 YYSTYPE yyvs;
309 };
310
311 /* The size of the maximum gap between one aligned stack and the next. */
312 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
313
314 /* The size of an array large to enough to hold all stacks, each with
315 N elements. */
316 # define YYSTACK_BYTES(N) \
317 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
318 + YYSTACK_GAP_MAXIMUM)
319
320 /* Copy COUNT objects from FROM to TO. The source and destination do
321 not overlap. */
322 # ifndef YYCOPY
323 # if defined (__GNUC__) && 1 < __GNUC__
324 # define YYCOPY(To, From, Count) \
325 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
326 # else
327 # define YYCOPY(To, From, Count) \
328 do \
329 { \
330 YYSIZE_T yyi; \
331 for (yyi = 0; yyi < (Count); yyi++) \
332 (To)[yyi] = (From)[yyi]; \
333 } \
334 while (0)
335 # endif
336 # endif
337
338 /* Relocate STACK from its old location to the new one. The
339 local variables YYSIZE and YYSTACKSIZE give the old and new number of
340 elements in the stack, and YYPTR gives the new location of the
341 stack. Advance YYPTR to a properly aligned location for the next
342 stack. */
343 # define YYSTACK_RELOCATE(Stack) \
344 do \
345 { \
346 YYSIZE_T yynewbytes; \
347 YYCOPY (&yyptr->Stack, Stack, yysize); \
348 Stack = &yyptr->Stack; \
349 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
350 yyptr += yynewbytes / sizeof (*yyptr); \
351 } \
352 while (0)
353
354 #endif
355
356 #if defined (__STDC__) || defined (__cplusplus)
357 typedef signed char yysigned_char;
358 #else
359 typedef short int yysigned_char;
360 #endif
361
362 /* YYFINAL -- State number of the termination state. */
363 #define YYFINAL 30
364 /* YYLAST -- Last index in YYTABLE. */
365 #define YYLAST 165
366
367 /* YYNTOKENS -- Number of terminals. */
368 #define YYNTOKENS 27
369 /* YYNNTS -- Number of nonterminals. */
370 #define YYNNTS 32
371 /* YYNRULES -- Number of rules. */
372 #define YYNRULES 104
373 /* YYNRULES -- Number of states. */
374 #define YYNSTATES 155
375
376 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
377 #define YYUNDEFTOK 2
378 #define YYMAXUTOK 276
379
380 #define YYTRANSLATE(YYX) \
381 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
382
383 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
384 static const unsigned char yytranslate[] =
385 {
386 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
387 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
388 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
389 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
390 23, 24, 2, 26, 2, 2, 2, 2, 2, 2,
391 2, 2, 2, 2, 2, 2, 2, 2, 25, 2,
392 2, 22, 2, 2, 2, 2, 2, 2, 2, 2,
393 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
394 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
395 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
396 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
397 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
398 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
399 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
401 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
402 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
404 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
410 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
412 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
413 15, 16, 17, 18, 19, 20, 21
414 };
415
416 #if YYDEBUG
417 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
418 YYRHS. */
419 static const unsigned short int yyprhs[] =
420 {
421 0, 0, 3, 5, 7, 10, 12, 14, 16, 18,
422 24, 30, 34, 37, 43, 49, 53, 56, 62, 68,
423 72, 75, 81, 87, 91, 94, 98, 102, 105, 109,
424 113, 116, 118, 121, 123, 128, 132, 135, 137, 140,
425 142, 147, 151, 154, 155, 158, 161, 163, 166, 168,
426 176, 183, 188, 192, 195, 196, 199, 202, 204, 207,
427 209, 215, 221, 226, 230, 233, 235, 237, 238, 243,
428 247, 250, 251, 253, 256, 259, 260, 263, 266, 269,
429 273, 277, 280, 284, 288, 291, 295, 299, 302, 304,
430 307, 309, 314, 320, 326, 331, 334, 336, 339, 341,
431 344, 346, 348, 349, 350
432 };
433
434 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
435 static const yysigned_char yyrhs[] =
436 {
437 28, 0, -1, 29, -1, 30, -1, 29, 30, -1,
438 31, -1, 43, -1, 19, -1, 1, -1, 3, 22,
439 23, 32, 24, -1, 3, 22, 23, 32, 1, -1,
440 3, 22, 1, -1, 3, 1, -1, 4, 22, 23,
441 34, 24, -1, 4, 22, 23, 34, 1, -1, 4,
442 22, 1, -1, 4, 1, -1, 5, 22, 23, 37,
443 24, -1, 5, 22, 23, 37, 1, -1, 5, 22,
444 1, -1, 5, 1, -1, 7, 22, 23, 40, 24,
445 -1, 7, 22, 23, 40, 1, -1, 7, 22, 1,
446 -1, 7, 1, -1, 8, 22, 16, -1, 8, 22,
447 1, -1, 8, 1, -1, 6, 22, 20, -1, 6,
448 22, 1, -1, 6, 1, -1, 33, -1, 32, 33,
449 -1, 1, -1, 55, 22, 20, 36, -1, 55, 22,
450 1, -1, 55, 1, -1, 35, -1, 34, 35, -1,
451 1, -1, 55, 22, 20, 36, -1, 55, 22, 1,
452 -1, 55, 1, -1, -1, 25, 16, -1, 25, 1,
453 -1, 38, -1, 37, 38, -1, 1, -1, 55, 22,
454 20, 58, 25, 18, 39, -1, 55, 22, 20, 58,
455 25, 1, -1, 55, 22, 20, 1, -1, 55, 22,
456 1, -1, 55, 1, -1, -1, 25, 20, -1, 25,
457 1, -1, 41, -1, 40, 41, -1, 1, -1, 42,
458 22, 20, 25, 20, -1, 42, 22, 20, 25, 1,
459 -1, 42, 22, 20, 1, -1, 42, 22, 1, -1,
460 42, 1, -1, 20, -1, 21, -1, -1, 45, 47,
461 44, 51, -1, 15, 22, 46, -1, 15, 1, -1,
462 -1, 20, -1, 26, 20, -1, 26, 1, -1, -1,
463 47, 49, -1, 47, 50, -1, 47, 48, -1, 10,
464 22, 16, -1, 10, 22, 1, -1, 10, 1, -1,
465 12, 22, 55, -1, 12, 22, 1, -1, 12, 1,
466 -1, 13, 22, 55, -1, 13, 22, 1, -1, 13,
467 1, -1, 52, -1, 51, 52, -1, 1, -1, 53,
468 57, 54, 11, -1, 14, 56, 22, 55, 9, -1,
469 14, 56, 22, 55, 1, -1, 14, 56, 22, 1,
470 -1, 14, 1, -1, 17, -1, 54, 17, -1, 1,
471 -1, 54, 1, -1, 16, -1, 21, -1, -1, -1,
472 -1
473 };
474
475 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
476 static const unsigned short int yyrline[] =
477 {
478 0, 123, 123, 130, 131, 134, 135, 136, 137, 140,
479 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
480 151, 152, 153, 154, 155, 156, 157, 158, 159, 171,
481 172, 178, 179, 180, 183, 190, 191, 197, 198, 199,
482 202, 209, 210, 213, 214, 215, 221, 222, 223, 226,
483 234, 235, 236, 237, 240, 241, 242, 248, 249, 250,
484 253, 263, 264, 265, 266, 269, 270, 280, 280, 283,
485 288, 291, 292, 293, 294, 297, 298, 299, 300, 303,
486 304, 305, 308, 316, 317, 320, 328, 329, 335, 336,
487 337, 340, 348, 377, 378, 379, 382, 383, 384, 385,
488 391, 392, 395, 398, 401
489 };
490 #endif
491
492 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
493 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
494 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
495 static const char *const yytname[] =
496 {
497 "$end", "error", "$undefined", "tSEVNAMES", "tFACNAMES", "tLANNAMES",
498 "tBASE", "tCODEPAGE", "tTYPEDEF", "tNL", "tSYMNAME", "tMSGEND",
499 "tSEVERITY", "tFACILITY", "tLANGUAGE", "tMSGID", "tIDENT", "tLINE",
500 "tFILE", "tCOMMENT", "tNUMBER", "tTOKEN", "'='", "'('", "')'", "':'",
501 "'+'", "$accept", "file", "items", "decl", "global", "smaps", "smap",
502 "fmaps", "fmap", "alias", "lmaps", "lmap", "optcp", "cmaps", "cmap",
503 "clan", "msg", "@1", "msgid", "id", "sevfacsym", "sym", "sev", "fac",
504 "bodies", "body", "lang", "lines", "token", "setnl", "setline",
505 "setfile", 0
506 };
507 #endif
508
509 # ifdef YYPRINT
510 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
511 token YYLEX-NUM. */
512 static const unsigned short int yytoknum[] =
513 {
514 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
515 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
516 275, 276, 61, 40, 41, 58, 43
517 };
518 # endif
519
520 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
521 static const unsigned char yyr1[] =
522 {
523 0, 27, 28, 29, 29, 30, 30, 30, 30, 31,
524 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
525 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
526 31, 32, 32, 32, 33, 33, 33, 34, 34, 34,
527 35, 35, 35, 36, 36, 36, 37, 37, 37, 38,
528 38, 38, 38, 38, 39, 39, 39, 40, 40, 40,
529 41, 41, 41, 41, 41, 42, 42, 44, 43, 45,
530 45, 46, 46, 46, 46, 47, 47, 47, 47, 48,
531 48, 48, 49, 49, 49, 50, 50, 50, 51, 51,
532 51, 52, 53, 53, 53, 53, 54, 54, 54, 54,
533 55, 55, 56, 57, 58
534 };
535
536 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
537 static const unsigned char yyr2[] =
538 {
539 0, 2, 1, 1, 2, 1, 1, 1, 1, 5,
540 5, 3, 2, 5, 5, 3, 2, 5, 5, 3,
541 2, 5, 5, 3, 2, 3, 3, 2, 3, 3,
542 2, 1, 2, 1, 4, 3, 2, 1, 2, 1,
543 4, 3, 2, 0, 2, 2, 1, 2, 1, 7,
544 6, 4, 3, 2, 0, 2, 2, 1, 2, 1,
545 5, 5, 4, 3, 2, 1, 1, 0, 4, 3,
546 2, 0, 1, 2, 2, 0, 2, 2, 2, 3,
547 3, 2, 3, 3, 2, 3, 3, 2, 1, 2,
548 1, 4, 5, 5, 4, 2, 1, 2, 1, 2,
549 1, 1, 0, 0, 0
550 };
551
552 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
553 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
554 means the default is an error. */
555 static const unsigned char yydefact[] =
556 {
557 0, 8, 0, 0, 0, 0, 0, 0, 0, 7,
558 0, 0, 3, 5, 6, 75, 12, 0, 16, 0,
559 20, 0, 30, 0, 24, 0, 27, 0, 70, 71,
560 1, 4, 67, 11, 0, 15, 0, 19, 0, 29,
561 28, 23, 0, 26, 25, 72, 0, 69, 0, 0,
562 0, 0, 78, 76, 77, 33, 100, 101, 0, 31,
563 0, 39, 0, 37, 0, 48, 0, 46, 0, 59,
564 65, 66, 0, 57, 0, 74, 73, 81, 0, 84,
565 0, 87, 0, 90, 0, 68, 88, 103, 10, 9,
566 32, 36, 0, 14, 13, 38, 42, 0, 18, 17,
567 47, 53, 0, 22, 21, 58, 64, 0, 80, 79,
568 83, 82, 86, 85, 95, 0, 89, 0, 35, 43,
569 41, 43, 52, 0, 63, 0, 0, 98, 96, 0,
570 0, 34, 40, 51, 0, 62, 0, 94, 0, 99,
571 91, 97, 45, 44, 0, 61, 60, 93, 92, 50,
572 54, 0, 49, 56, 55
573 };
574
575 /* YYDEFGOTO[NTERM-NUM]. */
576 static const short int yydefgoto[] =
577 {
578 -1, 10, 11, 12, 13, 58, 59, 62, 63, 131,
579 66, 67, 152, 72, 73, 74, 14, 51, 15, 47,
580 32, 52, 53, 54, 85, 86, 87, 129, 60, 115,
581 117, 134
582 };
583
584 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
585 STATE-NUM. */
586 #define YYPACT_NINF -37
587 static const short int yypact[] =
588 {
589 132, -37, 18, 44, 46, 47, 48, 49, 50, -37,
590 10, 113, -37, -37, -37, -37, -37, 11, -37, 14,
591 -37, 19, -37, 85, -37, 20, -37, 147, -37, -13,
592 -37, -37, 87, -37, 66, -37, 80, -37, 82, -37,
593 -37, -37, 64, -37, -37, -37, 107, -37, 51, 52,
594 53, 3, -37, -37, -37, -37, -37, -37, 7, -37,
595 54, -37, 8, -37, 55, -37, 17, -37, 56, -37,
596 -37, -37, 15, -37, 57, -37, -37, -37, 148, -37,
597 88, -37, 90, -37, 58, -3, -37, -37, -37, -37,
598 -37, -37, 109, -37, -37, -37, -37, 114, -37, -37,
599 -37, -37, 121, -37, -37, -37, -37, 122, -37, -37,
600 -37, -37, -37, -37, -37, 38, -37, 129, -37, 36,
601 -37, 36, -37, 0, -37, 2, 91, -37, -37, 144,
602 149, -37, -37, -37, 37, -37, 123, -37, 5, -37,
603 -37, -37, -37, -37, 4, -37, -37, -37, -37, -37,
604 39, 124, -37, -37, -37
605 };
606
607 /* YYPGOTO[NTERM-NUM]. */
608 static const yysigned_char yypgoto[] =
609 {
610 -37, -37, -37, 77, -37, -37, 35, -37, 1, -27,
611 -37, 29, -37, -37, 30, -37, -37, -37, -37, -37,
612 -37, -37, -37, -37, -37, 41, -37, -37, -36, -37,
613 -37, -37
614 };
615
616 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
617 positive, shift that token. If negative, reduce the rule which
618 number is the opposite. If zero, do what YYDEFACT says.
619 If YYTABLE_NINF, syntax error. */
620 #define YYTABLE_NINF -105
621 static const short int yytable[] =
622 {
623 64, 133, 68, 135, 83, 149, 147, 45, 88, 93,
624 30, 84, 33, 46, 148, 35, 103, 84, 98, 16,
625 37, 41, 150, 56, 56, -104, 64, 136, 57, 57,
626 68, 89, 94, 56, 34, 70, 71, 36, 57, 104,
627 17, 99, 38, 42, 111, 18, 113, 20, 22, 24,
628 26, 28, 77, 79, 81, 91, 96, 101, 106, 114,
629 126, 130, 144, 95, 151, 69, 19, 55, 21, 23,
630 25, 27, 29, 78, 80, 82, 92, 97, 102, 107,
631 -102, 61, 56, 65, 70, 71, 39, 57, 31, 110,
632 138, 112, 137, 90, 132, 100, 56, 48, 56, 49,
633 50, 57, 105, 57, 56, 40, 56, 56, 75, 57,
634 118, 57, 57, -2, 1, 120, 2, 3, 4, 5,
635 6, 7, 122, 124, 145, 153, 116, 76, 8, 119,
636 127, 0, 9, 1, 121, 2, 3, 4, 5, 6,
637 7, 123, 125, 146, 154, 139, 128, 8, 43, 108,
638 142, 9, 0, 0, 0, 140, 0, 0, 0, 0,
639 0, 141, 0, 44, 109, 143
640 };
641
642 static const yysigned_char yycheck[] =
643 {
644 36, 1, 38, 1, 1, 1, 1, 20, 1, 1,
645 0, 14, 1, 26, 9, 1, 1, 14, 1, 1,
646 1, 1, 18, 16, 16, 25, 62, 25, 21, 21,
647 66, 24, 24, 16, 23, 20, 21, 23, 21, 24,
648 22, 24, 23, 23, 80, 1, 82, 1, 1, 1,
649 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
650 22, 25, 25, 62, 25, 1, 22, 1, 22, 22,
651 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
652 22, 1, 16, 1, 20, 21, 1, 21, 11, 1,
653 126, 1, 1, 58, 121, 66, 16, 10, 16, 12,
654 13, 21, 72, 21, 16, 20, 16, 16, 1, 21,
655 1, 21, 21, 0, 1, 1, 3, 4, 5, 6,
656 7, 8, 1, 1, 1, 1, 85, 20, 15, 20,
657 1, -1, 19, 1, 20, 3, 4, 5, 6, 7,
658 8, 20, 20, 20, 20, 1, 17, 15, 1, 1,
659 1, 19, -1, -1, -1, 11, -1, -1, -1, -1,
660 -1, 17, -1, 16, 16, 16
661 };
662
663 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
664 symbol of state STATE-NUM. */
665 static const unsigned char yystos[] =
666 {
667 0, 1, 3, 4, 5, 6, 7, 8, 15, 19,
668 28, 29, 30, 31, 43, 45, 1, 22, 1, 22,
669 1, 22, 1, 22, 1, 22, 1, 22, 1, 22,
670 0, 30, 47, 1, 23, 1, 23, 1, 23, 1,
671 20, 1, 23, 1, 16, 20, 26, 46, 10, 12,
672 13, 44, 48, 49, 50, 1, 16, 21, 32, 33,
673 55, 1, 34, 35, 55, 1, 37, 38, 55, 1,
674 20, 21, 40, 41, 42, 1, 20, 1, 22, 1,
675 22, 1, 22, 1, 14, 51, 52, 53, 1, 24,
676 33, 1, 22, 1, 24, 35, 1, 22, 1, 24,
677 38, 1, 22, 1, 24, 41, 1, 22, 1, 16,
678 1, 55, 1, 55, 1, 56, 52, 57, 1, 20,
679 1, 20, 1, 20, 1, 20, 22, 1, 17, 54,
680 25, 36, 36, 1, 58, 1, 25, 1, 55, 1,
681 11, 17, 1, 16, 25, 1, 20, 1, 9, 1,
682 18, 25, 39, 1, 20
683 };
684
685 #define yyerrok (yyerrstatus = 0)
686 #define yyclearin (yychar = YYEMPTY)
687 #define YYEMPTY (-2)
688 #define YYEOF 0
689
690 #define YYACCEPT goto yyacceptlab
691 #define YYABORT goto yyabortlab
692 #define YYERROR goto yyerrorlab
693
694
695 /* Like YYERROR except do call yyerror. This remains here temporarily
696 to ease the transition to the new meaning of YYERROR, for GCC.
697 Once GCC version 2 has supplanted version 1, this can go. */
698
699 #define YYFAIL goto yyerrlab
700
701 #define YYRECOVERING() (!!yyerrstatus)
702
703 #define YYBACKUP(Token, Value) \
704 do \
705 if (yychar == YYEMPTY && yylen == 1) \
706 { \
707 yychar = (Token); \
708 yylval = (Value); \
709 yytoken = YYTRANSLATE (yychar); \
710 YYPOPSTACK; \
711 goto yybackup; \
712 } \
713 else \
714 { \
715 yyerror (YY_("syntax error: cannot back up")); \
716 YYERROR; \
717 } \
718 while (0)
719
720
721 #define YYTERROR 1
722 #define YYERRCODE 256
723
724
725 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
726 If N is 0, then set CURRENT to the empty location which ends
727 the previous symbol: RHS[0] (always defined). */
728
729 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
730 #ifndef YYLLOC_DEFAULT
731 # define YYLLOC_DEFAULT(Current, Rhs, N) \
732 do \
733 if (N) \
734 { \
735 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
736 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
737 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
738 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
739 } \
740 else \
741 { \
742 (Current).first_line = (Current).last_line = \
743 YYRHSLOC (Rhs, 0).last_line; \
744 (Current).first_column = (Current).last_column = \
745 YYRHSLOC (Rhs, 0).last_column; \
746 } \
747 while (0)
748 #endif
749
750
751 /* YY_LOCATION_PRINT -- Print the location on the stream.
752 This macro was not mandated originally: define only if we know
753 we won't break user code: when these are the locations we know. */
754
755 #ifndef YY_LOCATION_PRINT
756 # if YYLTYPE_IS_TRIVIAL
757 # define YY_LOCATION_PRINT(File, Loc) \
758 fprintf (File, "%d.%d-%d.%d", \
759 (Loc).first_line, (Loc).first_column, \
760 (Loc).last_line, (Loc).last_column)
761 # else
762 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
763 # endif
764 #endif
765
766
767 /* YYLEX -- calling `yylex' with the right arguments. */
768
769 #ifdef YYLEX_PARAM
770 # define YYLEX yylex (YYLEX_PARAM)
771 #else
772 # define YYLEX yylex ()
773 #endif
774
775 /* Enable debugging if requested. */
776 #if YYDEBUG
777
778 # ifndef YYFPRINTF
779 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
780 # define YYFPRINTF fprintf
781 # endif
782
783 # define YYDPRINTF(Args) \
784 do { \
785 if (yydebug) \
786 YYFPRINTF Args; \
787 } while (0)
788
789 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
790 do { \
791 if (yydebug) \
792 { \
793 YYFPRINTF (stderr, "%s ", Title); \
794 yysymprint (stderr, \
795 Type, Value); \
796 YYFPRINTF (stderr, "\n"); \
797 } \
798 } while (0)
799
800 /*------------------------------------------------------------------.
801 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
802 | TOP (included). |
803 `------------------------------------------------------------------*/
804
805 #if defined (__STDC__) || defined (__cplusplus)
806 static void
807 yy_stack_print (short int *bottom, short int *top)
808 #else
809 static void
810 yy_stack_print (bottom, top)
811 short int *bottom;
812 short int *top;
813 #endif
814 {
815 YYFPRINTF (stderr, "Stack now");
816 for (/* Nothing. */; bottom <= top; ++bottom)
817 YYFPRINTF (stderr, " %d", *bottom);
818 YYFPRINTF (stderr, "\n");
819 }
820
821 # define YY_STACK_PRINT(Bottom, Top) \
822 do { \
823 if (yydebug) \
824 yy_stack_print ((Bottom), (Top)); \
825 } while (0)
826
827
828 /*------------------------------------------------.
829 | Report that the YYRULE is going to be reduced. |
830 `------------------------------------------------*/
831
832 #if defined (__STDC__) || defined (__cplusplus)
833 static void
834 yy_reduce_print (int yyrule)
835 #else
836 static void
837 yy_reduce_print (yyrule)
838 int yyrule;
839 #endif
840 {
841 int yyi;
842 unsigned long int yylno = yyrline[yyrule];
843 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
844 yyrule - 1, yylno);
845 /* Print the symbols being reduced, and their result. */
846 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
847 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
848 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
849 }
850
851 # define YY_REDUCE_PRINT(Rule) \
852 do { \
853 if (yydebug) \
854 yy_reduce_print (Rule); \
855 } while (0)
856
857 /* Nonzero means print parse trace. It is left uninitialized so that
858 multiple parsers can coexist. */
859 int yydebug;
860 #else /* !YYDEBUG */
861 # define YYDPRINTF(Args)
862 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
863 # define YY_STACK_PRINT(Bottom, Top)
864 # define YY_REDUCE_PRINT(Rule)
865 #endif /* !YYDEBUG */
866
867
868 /* YYINITDEPTH -- initial size of the parser's stacks. */
869 #ifndef YYINITDEPTH
870 # define YYINITDEPTH 200
871 #endif
872
873 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
874 if the built-in stack extension method is used).
875
876 Do not make this value too large; the results are undefined if
877 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
878 evaluated with infinite-precision integer arithmetic. */
879
880 #ifndef YYMAXDEPTH
881 # define YYMAXDEPTH 10000
882 #endif
883
884 \f
885
886 #if YYERROR_VERBOSE
887
888 # ifndef yystrlen
889 # if defined (__GLIBC__) && defined (_STRING_H)
890 # define yystrlen strlen
891 # else
892 /* Return the length of YYSTR. */
893 static YYSIZE_T
894 # if defined (__STDC__) || defined (__cplusplus)
895 yystrlen (const char *yystr)
896 # else
897 yystrlen (yystr)
898 const char *yystr;
899 # endif
900 {
901 const char *yys = yystr;
902
903 while (*yys++ != '\0')
904 continue;
905
906 return yys - yystr - 1;
907 }
908 # endif
909 # endif
910
911 # ifndef yystpcpy
912 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
913 # define yystpcpy stpcpy
914 # else
915 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
916 YYDEST. */
917 static char *
918 # if defined (__STDC__) || defined (__cplusplus)
919 yystpcpy (char *yydest, const char *yysrc)
920 # else
921 yystpcpy (yydest, yysrc)
922 char *yydest;
923 const char *yysrc;
924 # endif
925 {
926 char *yyd = yydest;
927 const char *yys = yysrc;
928
929 while ((*yyd++ = *yys++) != '\0')
930 continue;
931
932 return yyd - 1;
933 }
934 # endif
935 # endif
936
937 # ifndef yytnamerr
938 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
939 quotes and backslashes, so that it's suitable for yyerror. The
940 heuristic is that double-quoting is unnecessary unless the string
941 contains an apostrophe, a comma, or backslash (other than
942 backslash-backslash). YYSTR is taken from yytname. If YYRES is
943 null, do not copy; instead, return the length of what the result
944 would have been. */
945 static YYSIZE_T
946 yytnamerr (char *yyres, const char *yystr)
947 {
948 if (*yystr == '"')
949 {
950 size_t yyn = 0;
951 char const *yyp = yystr;
952
953 for (;;)
954 switch (*++yyp)
955 {
956 case '\'':
957 case ',':
958 goto do_not_strip_quotes;
959
960 case '\\':
961 if (*++yyp != '\\')
962 goto do_not_strip_quotes;
963 /* Fall through. */
964 default:
965 if (yyres)
966 yyres[yyn] = *yyp;
967 yyn++;
968 break;
969
970 case '"':
971 if (yyres)
972 yyres[yyn] = '\0';
973 return yyn;
974 }
975 do_not_strip_quotes: ;
976 }
977
978 if (! yyres)
979 return yystrlen (yystr);
980
981 return yystpcpy (yyres, yystr) - yyres;
982 }
983 # endif
984
985 #endif /* YYERROR_VERBOSE */
986
987 \f
988
989 #if YYDEBUG
990 /*--------------------------------.
991 | Print this symbol on YYOUTPUT. |
992 `--------------------------------*/
993
994 #if defined (__STDC__) || defined (__cplusplus)
995 static void
996 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
997 #else
998 static void
999 yysymprint (yyoutput, yytype, yyvaluep)
1000 FILE *yyoutput;
1001 int yytype;
1002 YYSTYPE *yyvaluep;
1003 #endif
1004 {
1005 /* Pacify ``unused variable'' warnings. */
1006 (void) yyvaluep;
1007
1008 if (yytype < YYNTOKENS)
1009 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1010 else
1011 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1012
1013
1014 # ifdef YYPRINT
1015 if (yytype < YYNTOKENS)
1016 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1017 # endif
1018 switch (yytype)
1019 {
1020 default:
1021 break;
1022 }
1023 YYFPRINTF (yyoutput, ")");
1024 }
1025
1026 #endif /* ! YYDEBUG */
1027 /*-----------------------------------------------.
1028 | Release the memory associated to this symbol. |
1029 `-----------------------------------------------*/
1030
1031 #if defined (__STDC__) || defined (__cplusplus)
1032 static void
1033 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1034 #else
1035 static void
1036 yydestruct (yymsg, yytype, yyvaluep)
1037 const char *yymsg;
1038 int yytype;
1039 YYSTYPE *yyvaluep;
1040 #endif
1041 {
1042 /* Pacify ``unused variable'' warnings. */
1043 (void) yyvaluep;
1044
1045 if (!yymsg)
1046 yymsg = "Deleting";
1047 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1048
1049 switch (yytype)
1050 {
1051
1052 default:
1053 break;
1054 }
1055 }
1056 \f
1057
1058 /* Prevent warnings from -Wmissing-prototypes. */
1059
1060 #ifdef YYPARSE_PARAM
1061 # if defined (__STDC__) || defined (__cplusplus)
1062 int yyparse (void *YYPARSE_PARAM);
1063 # else
1064 int yyparse ();
1065 # endif
1066 #else /* ! YYPARSE_PARAM */
1067 #if defined (__STDC__) || defined (__cplusplus)
1068 int yyparse (void);
1069 #else
1070 int yyparse ();
1071 #endif
1072 #endif /* ! YYPARSE_PARAM */
1073
1074
1075
1076 /* The look-ahead symbol. */
1077 int yychar;
1078
1079 /* The semantic value of the look-ahead symbol. */
1080 YYSTYPE yylval;
1081
1082 /* Number of syntax errors so far. */
1083 int yynerrs;
1084
1085
1086
1087 /*----------.
1088 | yyparse. |
1089 `----------*/
1090
1091 #ifdef YYPARSE_PARAM
1092 # if defined (__STDC__) || defined (__cplusplus)
1093 int yyparse (void *YYPARSE_PARAM)
1094 # else
1095 int yyparse (YYPARSE_PARAM)
1096 void *YYPARSE_PARAM;
1097 # endif
1098 #else /* ! YYPARSE_PARAM */
1099 #if defined (__STDC__) || defined (__cplusplus)
1100 int
1101 yyparse (void)
1102 #else
1103 int
1104 yyparse ()
1105 ;
1106 #endif
1107 #endif
1108 {
1109
1110 int yystate;
1111 int yyn;
1112 int yyresult;
1113 /* Number of tokens to shift before error messages enabled. */
1114 int yyerrstatus;
1115 /* Look-ahead token as an internal (translated) token number. */
1116 int yytoken = 0;
1117
1118 /* Three stacks and their tools:
1119 `yyss': related to states,
1120 `yyvs': related to semantic values,
1121 `yyls': related to locations.
1122
1123 Refer to the stacks thru separate pointers, to allow yyoverflow
1124 to reallocate them elsewhere. */
1125
1126 /* The state stack. */
1127 short int yyssa[YYINITDEPTH];
1128 short int *yyss = yyssa;
1129 short int *yyssp;
1130
1131 /* The semantic value stack. */
1132 YYSTYPE yyvsa[YYINITDEPTH];
1133 YYSTYPE *yyvs = yyvsa;
1134 YYSTYPE *yyvsp;
1135
1136
1137
1138 #define YYPOPSTACK (yyvsp--, yyssp--)
1139
1140 YYSIZE_T yystacksize = YYINITDEPTH;
1141
1142 /* The variables used to return semantic value and location from the
1143 action routines. */
1144 YYSTYPE yyval;
1145
1146
1147 /* When reducing, the number of symbols on the RHS of the reduced
1148 rule. */
1149 int yylen;
1150
1151 YYDPRINTF ((stderr, "Starting parse\n"));
1152
1153 yystate = 0;
1154 yyerrstatus = 0;
1155 yynerrs = 0;
1156 yychar = YYEMPTY; /* Cause a token to be read. */
1157
1158 /* Initialize stack pointers.
1159 Waste one element of value and location stack
1160 so that they stay on the same level as the state stack.
1161 The wasted elements are never initialized. */
1162
1163 yyssp = yyss;
1164 yyvsp = yyvs;
1165
1166 goto yysetstate;
1167
1168 /*------------------------------------------------------------.
1169 | yynewstate -- Push a new state, which is found in yystate. |
1170 `------------------------------------------------------------*/
1171 yynewstate:
1172 /* In all cases, when you get here, the value and location stacks
1173 have just been pushed. so pushing a state here evens the stacks.
1174 */
1175 yyssp++;
1176
1177 yysetstate:
1178 *yyssp = yystate;
1179
1180 if (yyss + yystacksize - 1 <= yyssp)
1181 {
1182 /* Get the current used size of the three stacks, in elements. */
1183 YYSIZE_T yysize = yyssp - yyss + 1;
1184
1185 #ifdef yyoverflow
1186 {
1187 /* Give user a chance to reallocate the stack. Use copies of
1188 these so that the &'s don't force the real ones into
1189 memory. */
1190 YYSTYPE *yyvs1 = yyvs;
1191 short int *yyss1 = yyss;
1192
1193
1194 /* Each stack pointer address is followed by the size of the
1195 data in use in that stack, in bytes. This used to be a
1196 conditional around just the two extra args, but that might
1197 be undefined if yyoverflow is a macro. */
1198 yyoverflow (YY_("memory exhausted"),
1199 &yyss1, yysize * sizeof (*yyssp),
1200 &yyvs1, yysize * sizeof (*yyvsp),
1201
1202 &yystacksize);
1203
1204 yyss = yyss1;
1205 yyvs = yyvs1;
1206 }
1207 #else /* no yyoverflow */
1208 # ifndef YYSTACK_RELOCATE
1209 goto yyexhaustedlab;
1210 # else
1211 /* Extend the stack our own way. */
1212 if (YYMAXDEPTH <= yystacksize)
1213 goto yyexhaustedlab;
1214 yystacksize *= 2;
1215 if (YYMAXDEPTH < yystacksize)
1216 yystacksize = YYMAXDEPTH;
1217
1218 {
1219 short int *yyss1 = yyss;
1220 union yyalloc *yyptr =
1221 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1222 if (! yyptr)
1223 goto yyexhaustedlab;
1224 YYSTACK_RELOCATE (yyss);
1225 YYSTACK_RELOCATE (yyvs);
1226
1227 # undef YYSTACK_RELOCATE
1228 if (yyss1 != yyssa)
1229 YYSTACK_FREE (yyss1);
1230 }
1231 # endif
1232 #endif /* no yyoverflow */
1233
1234 yyssp = yyss + yysize - 1;
1235 yyvsp = yyvs + yysize - 1;
1236
1237
1238 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1239 (unsigned long int) yystacksize));
1240
1241 if (yyss + yystacksize - 1 <= yyssp)
1242 YYABORT;
1243 }
1244
1245 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1246
1247 goto yybackup;
1248
1249 /*-----------.
1250 | yybackup. |
1251 `-----------*/
1252 yybackup:
1253
1254 /* Do appropriate processing given the current state. */
1255 /* Read a look-ahead token if we need one and don't already have one. */
1256 /* yyresume: */
1257
1258 /* First try to decide what to do without reference to look-ahead token. */
1259
1260 yyn = yypact[yystate];
1261 if (yyn == YYPACT_NINF)
1262 goto yydefault;
1263
1264 /* Not known => get a look-ahead token if don't already have one. */
1265
1266 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1267 if (yychar == YYEMPTY)
1268 {
1269 YYDPRINTF ((stderr, "Reading a token: "));
1270 yychar = YYLEX;
1271 }
1272
1273 if (yychar <= YYEOF)
1274 {
1275 yychar = yytoken = YYEOF;
1276 YYDPRINTF ((stderr, "Now at end of input.\n"));
1277 }
1278 else
1279 {
1280 yytoken = YYTRANSLATE (yychar);
1281 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1282 }
1283
1284 /* If the proper action on seeing token YYTOKEN is to reduce or to
1285 detect an error, take that action. */
1286 yyn += yytoken;
1287 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1288 goto yydefault;
1289 yyn = yytable[yyn];
1290 if (yyn <= 0)
1291 {
1292 if (yyn == 0 || yyn == YYTABLE_NINF)
1293 goto yyerrlab;
1294 yyn = -yyn;
1295 goto yyreduce;
1296 }
1297
1298 if (yyn == YYFINAL)
1299 YYACCEPT;
1300
1301 /* Shift the look-ahead token. */
1302 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1303
1304 /* Discard the token being shifted unless it is eof. */
1305 if (yychar != YYEOF)
1306 yychar = YYEMPTY;
1307
1308 *++yyvsp = yylval;
1309
1310
1311 /* Count tokens shifted since error; after three, turn off error
1312 status. */
1313 if (yyerrstatus)
1314 yyerrstatus--;
1315
1316 yystate = yyn;
1317 goto yynewstate;
1318
1319
1320 /*-----------------------------------------------------------.
1321 | yydefault -- do the default action for the current state. |
1322 `-----------------------------------------------------------*/
1323 yydefault:
1324 yyn = yydefact[yystate];
1325 if (yyn == 0)
1326 goto yyerrlab;
1327 goto yyreduce;
1328
1329
1330 /*-----------------------------.
1331 | yyreduce -- Do a reduction. |
1332 `-----------------------------*/
1333 yyreduce:
1334 /* yyn is the number of a rule to reduce with. */
1335 yylen = yyr2[yyn];
1336
1337 /* If YYLEN is nonzero, implement the default value of the action:
1338 `$$ = $1'.
1339
1340 Otherwise, the following line sets YYVAL to garbage.
1341 This behavior is undocumented and Bison
1342 users should not rely upon it. Assigning to YYVAL
1343 unconditionally makes the parser a bit smaller, and it avoids a
1344 GCC warning that YYVAL may be used uninitialized. */
1345 yyval = yyvsp[1-yylen];
1346
1347
1348 YY_REDUCE_PRINT (yyn);
1349 switch (yyn)
1350 {
1351 case 2:
1352 #line 123 "tools/wmc/mcy.y"
1353 {
1354 if(!check_languages(nodehead))
1355 xyyerror("No messages defined\n");
1356 lanblockhead = block_messages(nodehead);
1357 ;}
1358 break;
1359
1360 case 6:
1361 #line 135 "tools/wmc/mcy.y"
1362 { add_node(nd_msg, (yyvsp[0].msg)); ;}
1363 break;
1364
1365 case 7:
1366 #line 136 "tools/wmc/mcy.y"
1367 { add_node(nd_comment, (yyvsp[0].str)); ;}
1368 break;
1369
1370 case 8:
1371 #line 137 "tools/wmc/mcy.y"
1372 { xyyerror(err_syntax); /* `Catch all' error */ ;}
1373 break;
1374
1375 case 10:
1376 #line 141 "tools/wmc/mcy.y"
1377 { xyyerror(err_pclose); ;}
1378 break;
1379
1380 case 11:
1381 #line 142 "tools/wmc/mcy.y"
1382 { xyyerror(err_popen); ;}
1383 break;
1384
1385 case 12:
1386 #line 143 "tools/wmc/mcy.y"
1387 { xyyerror(err_assign); ;}
1388 break;
1389
1390 case 14:
1391 #line 145 "tools/wmc/mcy.y"
1392 { xyyerror(err_pclose); ;}
1393 break;
1394
1395 case 15:
1396 #line 146 "tools/wmc/mcy.y"
1397 { xyyerror(err_popen); ;}
1398 break;
1399
1400 case 16:
1401 #line 147 "tools/wmc/mcy.y"
1402 { xyyerror(err_assign); ;}
1403 break;
1404
1405 case 18:
1406 #line 149 "tools/wmc/mcy.y"
1407 { xyyerror(err_pclose); ;}
1408 break;
1409
1410 case 19:
1411 #line 150 "tools/wmc/mcy.y"
1412 { xyyerror(err_popen); ;}
1413 break;
1414
1415 case 20:
1416 #line 151 "tools/wmc/mcy.y"
1417 { xyyerror(err_assign); ;}
1418 break;
1419
1420 case 22:
1421 #line 153 "tools/wmc/mcy.y"
1422 { xyyerror(err_pclose); ;}
1423 break;
1424
1425 case 23:
1426 #line 154 "tools/wmc/mcy.y"
1427 { xyyerror(err_popen); ;}
1428 break;
1429
1430 case 24:
1431 #line 155 "tools/wmc/mcy.y"
1432 { xyyerror(err_assign); ;}
1433 break;
1434
1435 case 25:
1436 #line 156 "tools/wmc/mcy.y"
1437 { cast = (yyvsp[0].str); ;}
1438 break;
1439
1440 case 26:
1441 #line 157 "tools/wmc/mcy.y"
1442 { xyyerror(err_number); ;}
1443 break;
1444
1445 case 27:
1446 #line 158 "tools/wmc/mcy.y"
1447 { xyyerror(err_assign); ;}
1448 break;
1449
1450 case 28:
1451 #line 159 "tools/wmc/mcy.y"
1452 {
1453 switch(base)
1454 {
1455 case 8:
1456 case 10:
1457 case 16:
1458 base = (yyvsp[0].num);
1459 break;
1460 default:
1461 xyyerror("Numberbase must be 8, 10 or 16\n");
1462 }
1463 ;}
1464 break;
1465
1466 case 29:
1467 #line 171 "tools/wmc/mcy.y"
1468 { xyyerror(err_number); ;}
1469 break;
1470
1471 case 30:
1472 #line 172 "tools/wmc/mcy.y"
1473 { xyyerror(err_assign); ;}
1474 break;
1475
1476 case 33:
1477 #line 180 "tools/wmc/mcy.y"
1478 { xyyerror(err_ident); ;}
1479 break;
1480
1481 case 34:
1482 #line 183 "tools/wmc/mcy.y"
1483 {
1484 (yyvsp[-3].tok)->token = (yyvsp[-1].num);
1485 (yyvsp[-3].tok)->alias = (yyvsp[0].str);
1486 if((yyvsp[-1].num) & (~0x3))
1487 xyyerror("Severity value out of range (0x%08x > 0x3)\n", (yyvsp[-1].num));
1488 do_add_token(tok_severity, (yyvsp[-3].tok), "severity");
1489 ;}
1490 break;
1491
1492 case 35:
1493 #line 190 "tools/wmc/mcy.y"
1494 { xyyerror(err_number); ;}
1495 break;
1496
1497 case 36:
1498 #line 191 "tools/wmc/mcy.y"
1499 { xyyerror(err_assign); ;}
1500 break;
1501
1502 case 39:
1503 #line 199 "tools/wmc/mcy.y"
1504 { xyyerror(err_ident); ;}
1505 break;
1506
1507 case 40:
1508 #line 202 "tools/wmc/mcy.y"
1509 {
1510 (yyvsp[-3].tok)->token = (yyvsp[-1].num);
1511 (yyvsp[-3].tok)->alias = (yyvsp[0].str);
1512 if((yyvsp[-1].num) & (~0xfff))
1513 xyyerror("Facility value out of range (0x%08x > 0xfff)\n", (yyvsp[-1].num));
1514 do_add_token(tok_facility, (yyvsp[-3].tok), "facility");
1515 ;}
1516 break;
1517
1518 case 41:
1519 #line 209 "tools/wmc/mcy.y"
1520 { xyyerror(err_number); ;}
1521 break;
1522
1523 case 42:
1524 #line 210 "tools/wmc/mcy.y"
1525 { xyyerror(err_assign); ;}
1526 break;
1527
1528 case 43:
1529 #line 213 "tools/wmc/mcy.y"
1530 { (yyval.str) = NULL; ;}
1531 break;
1532
1533 case 44:
1534 #line 214 "tools/wmc/mcy.y"
1535 { (yyval.str) = (yyvsp[0].str); ;}
1536 break;
1537
1538 case 45:
1539 #line 215 "tools/wmc/mcy.y"
1540 { xyyerror(err_ident); ;}
1541 break;
1542
1543 case 48:
1544 #line 223 "tools/wmc/mcy.y"
1545 { xyyerror(err_ident); ;}
1546 break;
1547
1548 case 49:
1549 #line 226 "tools/wmc/mcy.y"
1550 {
1551 (yyvsp[-6].tok)->token = (yyvsp[-4].num);
1552 (yyvsp[-6].tok)->alias = (yyvsp[-1].str);
1553 (yyvsp[-6].tok)->codepage = (yyvsp[0].num);
1554 do_add_token(tok_language, (yyvsp[-6].tok), "language");
1555 if(!find_language((yyvsp[-4].num)) && !find_cpxlat((yyvsp[-4].num)))
1556 mcy_warning("Language 0x%x not built-in, using codepage %d; use explicit codepage to override\n", (yyvsp[-4].num), WMC_DEFAULT_CODEPAGE);
1557 ;}
1558 break;
1559
1560 case 50:
1561 #line 234 "tools/wmc/mcy.y"
1562 { xyyerror("Filename expected\n"); ;}
1563 break;
1564
1565 case 51:
1566 #line 235 "tools/wmc/mcy.y"
1567 { xyyerror(err_colon); ;}
1568 break;
1569
1570 case 52:
1571 #line 236 "tools/wmc/mcy.y"
1572 { xyyerror(err_number); ;}
1573 break;
1574
1575 case 53:
1576 #line 237 "tools/wmc/mcy.y"
1577 { xyyerror(err_assign); ;}
1578 break;
1579
1580 case 54:
1581 #line 240 "tools/wmc/mcy.y"
1582 { (yyval.num) = 0; ;}
1583 break;
1584
1585 case 55:
1586 #line 241 "tools/wmc/mcy.y"
1587 { (yyval.num) = (yyvsp[0].num); ;}
1588 break;
1589
1590 case 56:
1591 #line 242 "tools/wmc/mcy.y"
1592 { xyyerror("Codepage-number expected\n"); ;}
1593 break;
1594
1595 case 59:
1596 #line 250 "tools/wmc/mcy.y"
1597 { xyyerror(err_ident); ;}
1598 break;
1599
1600 case 60:
1601 #line 253 "tools/wmc/mcy.y"
1602 {
1603 static const char err_nocp[] = "Codepage %d not builtin; cannot convert";
1604 if(find_cpxlat((yyvsp[-4].num)))
1605 xyyerror("Codepage translation already defined for language 0x%x\n", (yyvsp[-4].num));
1606 if((yyvsp[-2].num) && !find_codepage((yyvsp[-2].num)))
1607 xyyerror(err_nocp, (yyvsp[-2].num));
1608 if((yyvsp[0].num) && !find_codepage((yyvsp[0].num)))
1609 xyyerror(err_nocp, (yyvsp[0].num));
1610 add_cpxlat((yyvsp[-4].num), (yyvsp[-2].num), (yyvsp[0].num));
1611 ;}
1612 break;
1613
1614 case 61:
1615 #line 263 "tools/wmc/mcy.y"
1616 { xyyerror(err_number); ;}
1617 break;
1618
1619 case 62:
1620 #line 264 "tools/wmc/mcy.y"
1621 { xyyerror(err_colon); ;}
1622 break;
1623
1624 case 63:
1625 #line 265 "tools/wmc/mcy.y"
1626 { xyyerror(err_number); ;}
1627 break;
1628
1629 case 64:
1630 #line 266 "tools/wmc/mcy.y"
1631 { xyyerror(err_assign); ;}
1632 break;
1633
1634 case 65:
1635 #line 269 "tools/wmc/mcy.y"
1636 { (yyval.num) = (yyvsp[0].num); ;}
1637 break;
1638
1639 case 66:
1640 #line 270 "tools/wmc/mcy.y"
1641 {
1642 if((yyvsp[0].tok)->type != tok_language)
1643 xyyerror("Language name or code expected\n");
1644 (yyval.num) = (yyvsp[0].tok)->token;
1645 ;}
1646 break;
1647
1648 case 67:
1649 #line 280 "tools/wmc/mcy.y"
1650 { test_id((yyvsp[-1].num)); ;}
1651 break;
1652
1653 case 68:
1654 #line 280 "tools/wmc/mcy.y"
1655 { (yyval.msg) = complete_msg((yyvsp[0].msg), (yyvsp[-3].num)); ;}
1656 break;
1657
1658 case 69:
1659 #line 283 "tools/wmc/mcy.y"
1660 {
1661 if((yyvsp[0].num) & (~0xffff))
1662 xyyerror("Message ID value out of range (0x%08x > 0xffff)\n", (yyvsp[0].num));
1663 (yyval.num) = (yyvsp[0].num);
1664 ;}
1665 break;
1666
1667 case 70:
1668 #line 288 "tools/wmc/mcy.y"
1669 { xyyerror(err_assign); ;}
1670 break;
1671
1672 case 71:
1673 #line 291 "tools/wmc/mcy.y"
1674 { (yyval.num) = ++last_id; ;}
1675 break;
1676
1677 case 72:
1678 #line 292 "tools/wmc/mcy.y"
1679 { (yyval.num) = last_id = (yyvsp[0].num); ;}
1680 break;
1681
1682 case 73:
1683 #line 293 "tools/wmc/mcy.y"
1684 { (yyval.num) = last_id += (yyvsp[0].num); ;}
1685 break;
1686
1687 case 74:
1688 #line 294 "tools/wmc/mcy.y"
1689 { xyyerror(err_number); ;}
1690 break;
1691
1692 case 75:
1693 #line 297 "tools/wmc/mcy.y"
1694 { have_sev = have_fac = have_sym = 0; ;}
1695 break;
1696
1697 case 76:
1698 #line 298 "tools/wmc/mcy.y"
1699 { if(have_sev) xyyerror("Severity already defined\n"); have_sev = 1; ;}
1700 break;
1701
1702 case 77:
1703 #line 299 "tools/wmc/mcy.y"
1704 { if(have_fac) xyyerror("Facility already defined\n"); have_fac = 1; ;}
1705 break;
1706
1707 case 78:
1708 #line 300 "tools/wmc/mcy.y"
1709 { if(have_sym) xyyerror("Symbolname already defined\n"); have_sym = 1; ;}
1710 break;
1711
1712 case 79:
1713 #line 303 "tools/wmc/mcy.y"
1714 { last_sym = (yyvsp[0].str); ;}
1715 break;
1716
1717 case 80:
1718 #line 304 "tools/wmc/mcy.y"
1719 { xyyerror(err_ident); ;}
1720 break;
1721
1722 case 81:
1723 #line 305 "tools/wmc/mcy.y"
1724 { xyyerror(err_assign); ;}
1725 break;
1726
1727 case 82:
1728 #line 308 "tools/wmc/mcy.y"
1729 {
1730 token_t *tok = lookup_token((yyvsp[0].tok)->name);
1731 if(!tok)
1732 xyyerror("Undefined severityname\n");
1733 if(tok->type != tok_severity)
1734 xyyerror("Identifier is not of class 'severity'\n");
1735 last_sev = tok->token;
1736 ;}
1737 break;
1738
1739 case 83:
1740 #line 316 "tools/wmc/mcy.y"
1741 { xyyerror(err_ident); ;}
1742 break;
1743
1744 case 84:
1745 #line 317 "tools/wmc/mcy.y"
1746 { xyyerror(err_assign); ;}
1747 break;
1748
1749 case 85:
1750 #line 320 "tools/wmc/mcy.y"
1751 {
1752 token_t *tok = lookup_token((yyvsp[0].tok)->name);
1753 if(!tok)
1754 xyyerror("Undefined facilityname\n");
1755 if(tok->type != tok_facility)
1756 xyyerror("Identifier is not of class 'facility'\n");
1757 last_fac = tok->token;
1758 ;}
1759 break;
1760
1761 case 86:
1762 #line 328 "tools/wmc/mcy.y"
1763 { xyyerror(err_ident); ;}
1764 break;
1765
1766 case 87:
1767 #line 329 "tools/wmc/mcy.y"
1768 { xyyerror(err_assign); ;}
1769 break;
1770
1771 case 88:
1772 #line 335 "tools/wmc/mcy.y"
1773 { (yyval.msg) = add_lanmsg(NULL, (yyvsp[0].lmp)); ;}
1774 break;
1775
1776 case 89:
1777 #line 336 "tools/wmc/mcy.y"
1778 { (yyval.msg) = add_lanmsg((yyvsp[-1].msg), (yyvsp[0].lmp)); ;}
1779 break;
1780
1781 case 90:
1782 #line 337 "tools/wmc/mcy.y"
1783 { xyyerror("'Language=...' (start of message text-definition) expected\n"); ;}
1784 break;
1785
1786 case 91:
1787 #line 340 "tools/wmc/mcy.y"
1788 { (yyval.lmp) = new_lanmsg(&(yyvsp[-3].lcp), (yyvsp[-1].str)); ;}
1789 break;
1790
1791 case 92:
1792 #line 348 "tools/wmc/mcy.y"
1793 {
1794 token_t *tok = lookup_token((yyvsp[-1].tok)->name);
1795 cp_xlat_t *cpx;
1796 if(!tok)
1797 xyyerror("Undefined language\n");
1798 if(tok->type != tok_language)
1799 xyyerror("Identifier is not of class 'language'\n");
1800 if((cpx = find_cpxlat(tok->token)))
1801 {
1802 set_codepage((yyval.lcp).codepage = cpx->cpin);
1803 }
1804 else if(!tok->codepage)
1805 {
1806 const language_t *lan = find_language(tok->token);
1807 if(!lan)
1808 {
1809 /* Just set default; warning was given while parsing languagenames */
1810 set_codepage((yyval.lcp).codepage = WMC_DEFAULT_CODEPAGE);
1811 }
1812 else
1813 {
1814 /* The default seems to be to use the DOS codepage... */
1815 set_codepage((yyval.lcp).codepage = lan->doscp);
1816 }
1817 }
1818 else
1819 set_codepage((yyval.lcp).codepage = tok->codepage);
1820 (yyval.lcp).language = tok->token;
1821 ;}
1822 break;
1823
1824 case 93:
1825 #line 377 "tools/wmc/mcy.y"
1826 { xyyerror("Missing newline\n"); ;}
1827 break;
1828
1829 case 94:
1830 #line 378 "tools/wmc/mcy.y"
1831 { xyyerror(err_ident); ;}
1832 break;
1833
1834 case 95:
1835 #line 379 "tools/wmc/mcy.y"
1836 { xyyerror(err_assign); ;}
1837 break;
1838
1839 case 96:
1840 #line 382 "tools/wmc/mcy.y"
1841 { (yyval.str) = (yyvsp[0].str); ;}
1842 break;
1843
1844 case 97:
1845 #line 383 "tools/wmc/mcy.y"
1846 { (yyval.str) = merge((yyvsp[-1].str), (yyvsp[0].str)); ;}
1847 break;
1848
1849 case 98:
1850 #line 384 "tools/wmc/mcy.y"
1851 { xyyerror(err_msg); ;}
1852 break;
1853
1854 case 99:
1855 #line 385 "tools/wmc/mcy.y"
1856 { xyyerror(err_msg); ;}
1857 break;
1858
1859 case 100:
1860 #line 391 "tools/wmc/mcy.y"
1861 { (yyval.tok) = xmalloc(sizeof(token_t)); memset((yyval.tok),0,sizeof(*(yyval.tok))); (yyval.tok)->name = (yyvsp[0].str); ;}
1862 break;
1863
1864 case 101:
1865 #line 392 "tools/wmc/mcy.y"
1866 { (yyval.tok) = (yyvsp[0].tok); ;}
1867 break;
1868
1869 case 102:
1870 #line 395 "tools/wmc/mcy.y"
1871 { want_nl = 1; ;}
1872 break;
1873
1874 case 103:
1875 #line 398 "tools/wmc/mcy.y"
1876 { want_line = 1; ;}
1877 break;
1878
1879 case 104:
1880 #line 401 "tools/wmc/mcy.y"
1881 { want_file = 1; ;}
1882 break;
1883
1884
1885 default: break;
1886 }
1887
1888 /* Line 1126 of yacc.c. */
1889 #line 1890 "mcy.tab.c"
1890 \f
1891 yyvsp -= yylen;
1892 yyssp -= yylen;
1893
1894
1895 YY_STACK_PRINT (yyss, yyssp);
1896
1897 *++yyvsp = yyval;
1898
1899
1900 /* Now `shift' the result of the reduction. Determine what state
1901 that goes to, based on the state we popped back to and the rule
1902 number reduced by. */
1903
1904 yyn = yyr1[yyn];
1905
1906 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1907 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1908 yystate = yytable[yystate];
1909 else
1910 yystate = yydefgoto[yyn - YYNTOKENS];
1911
1912 goto yynewstate;
1913
1914
1915 /*------------------------------------.
1916 | yyerrlab -- here on detecting error |
1917 `------------------------------------*/
1918 yyerrlab:
1919 /* If not already recovering from an error, report this error. */
1920 if (!yyerrstatus)
1921 {
1922 ++yynerrs;
1923 #if YYERROR_VERBOSE
1924 yyn = yypact[yystate];
1925
1926 if (YYPACT_NINF < yyn && yyn < YYLAST)
1927 {
1928 int yytype = YYTRANSLATE (yychar);
1929 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1930 YYSIZE_T yysize = yysize0;
1931 YYSIZE_T yysize1;
1932 int yysize_overflow = 0;
1933 char *yymsg = 0;
1934 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
1935 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1936 int yyx;
1937
1938 #if 0
1939 /* This is so xgettext sees the translatable formats that are
1940 constructed on the fly. */
1941 YY_("syntax error, unexpected %s");
1942 YY_("syntax error, unexpected %s, expecting %s");
1943 YY_("syntax error, unexpected %s, expecting %s or %s");
1944 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1945 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1946 #endif
1947 char *yyfmt;
1948 char const *yyf;
1949 static char const yyunexpected[] = "syntax error, unexpected %s";
1950 static char const yyexpecting[] = ", expecting %s";
1951 static char const yyor[] = " or %s";
1952 char yyformat[sizeof yyunexpected
1953 + sizeof yyexpecting - 1
1954 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1955 * (sizeof yyor - 1))];
1956 char const *yyprefix = yyexpecting;
1957
1958 /* Start YYX at -YYN if negative to avoid negative indexes in
1959 YYCHECK. */
1960 int yyxbegin = yyn < 0 ? -yyn : 0;
1961
1962 /* Stay within bounds of both yycheck and yytname. */
1963 int yychecklim = YYLAST - yyn;
1964 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1965 int yycount = 1;
1966
1967 yyarg[0] = yytname[yytype];
1968 yyfmt = yystpcpy (yyformat, yyunexpected);
1969
1970 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1971 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1972 {
1973 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1974 {
1975 yycount = 1;
1976 yysize = yysize0;
1977 yyformat[sizeof yyunexpected - 1] = '\0';
1978 break;
1979 }
1980 yyarg[yycount++] = yytname[yyx];
1981 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1982 yysize_overflow |= yysize1 < yysize;
1983 yysize = yysize1;
1984 yyfmt = yystpcpy (yyfmt, yyprefix);
1985 yyprefix = yyor;
1986 }
1987
1988 yyf = YY_(yyformat);
1989 yysize1 = yysize + yystrlen (yyf);
1990 yysize_overflow |= yysize1 < yysize;
1991 yysize = yysize1;
1992
1993 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
1994 yymsg = (char *) YYSTACK_ALLOC (yysize);
1995 if (yymsg)
1996 {
1997 /* Avoid sprintf, as that infringes on the user's name space.
1998 Don't have undefined behavior even if the translation
1999 produced a string with the wrong number of "%s"s. */
2000 char *yyp = yymsg;
2001 int yyi = 0;
2002 while ((*yyp = *yyf))
2003 {
2004 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2005 {
2006 yyp += yytnamerr (yyp, yyarg[yyi++]);
2007 yyf += 2;
2008 }
2009 else
2010 {
2011 yyp++;
2012 yyf++;
2013 }
2014 }
2015 yyerror (yymsg);
2016 YYSTACK_FREE (yymsg);
2017 }
2018 else
2019 {
2020 yyerror (YY_("syntax error"));
2021 goto yyexhaustedlab;
2022 }
2023 }
2024 else
2025 #endif /* YYERROR_VERBOSE */
2026 yyerror (YY_("syntax error"));
2027 }
2028
2029
2030
2031 if (yyerrstatus == 3)
2032 {
2033 /* If just tried and failed to reuse look-ahead token after an
2034 error, discard it. */
2035
2036 if (yychar <= YYEOF)
2037 {
2038 /* Return failure if at end of input. */
2039 if (yychar == YYEOF)
2040 YYABORT;
2041 }
2042 else
2043 {
2044 yydestruct ("Error: discarding", yytoken, &yylval);
2045 yychar = YYEMPTY;
2046 }
2047 }
2048
2049 /* Else will try to reuse look-ahead token after shifting the error
2050 token. */
2051 goto yyerrlab1;
2052
2053
2054 /*---------------------------------------------------.
2055 | yyerrorlab -- error raised explicitly by YYERROR. |
2056 `---------------------------------------------------*/
2057 yyerrorlab:
2058
2059 /* Pacify compilers like GCC when the user code never invokes
2060 YYERROR and the label yyerrorlab therefore never appears in user
2061 code. */
2062 if (0)
2063 goto yyerrorlab;
2064
2065 yyvsp -= yylen;
2066 yyssp -= yylen;
2067 yystate = *yyssp;
2068 goto yyerrlab1;
2069
2070
2071 /*-------------------------------------------------------------.
2072 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2073 `-------------------------------------------------------------*/
2074 yyerrlab1:
2075 yyerrstatus = 3; /* Each real token shifted decrements this. */
2076
2077 for (;;)
2078 {
2079 yyn = yypact[yystate];
2080 if (yyn != YYPACT_NINF)
2081 {
2082 yyn += YYTERROR;
2083 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2084 {
2085 yyn = yytable[yyn];
2086 if (0 < yyn)
2087 break;
2088 }
2089 }
2090
2091 /* Pop the current state because it cannot handle the error token. */
2092 if (yyssp == yyss)
2093 YYABORT;
2094
2095
2096 yydestruct ("Error: popping", yystos[yystate], yyvsp);
2097 YYPOPSTACK;
2098 yystate = *yyssp;
2099 YY_STACK_PRINT (yyss, yyssp);
2100 }
2101
2102 if (yyn == YYFINAL)
2103 YYACCEPT;
2104
2105 *++yyvsp = yylval;
2106
2107
2108 /* Shift the error token. */
2109 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2110
2111 yystate = yyn;
2112 goto yynewstate;
2113
2114
2115 /*-------------------------------------.
2116 | yyacceptlab -- YYACCEPT comes here. |
2117 `-------------------------------------*/
2118 yyacceptlab:
2119 yyresult = 0;
2120 goto yyreturn;
2121
2122 /*-----------------------------------.
2123 | yyabortlab -- YYABORT comes here. |
2124 `-----------------------------------*/
2125 yyabortlab:
2126 yyresult = 1;
2127 goto yyreturn;
2128
2129 #ifndef yyoverflow
2130 /*-------------------------------------------------.
2131 | yyexhaustedlab -- memory exhaustion comes here. |
2132 `-------------------------------------------------*/
2133 yyexhaustedlab:
2134 yyerror (YY_("memory exhausted"));
2135 yyresult = 2;
2136 /* Fall through. */
2137 #endif
2138
2139 yyreturn:
2140 if (yychar != YYEOF && yychar != YYEMPTY)
2141 yydestruct ("Cleanup: discarding lookahead",
2142 yytoken, &yylval);
2143 while (yyssp != yyss)
2144 {
2145 yydestruct ("Cleanup: popping",
2146 yystos[*yyssp], yyvsp);
2147 YYPOPSTACK;
2148 }
2149 #ifndef yyoverflow
2150 if (yyss != yyssa)
2151 YYSTACK_FREE (yyss);
2152 #endif
2153 return yyresult;
2154 }
2155
2156
2157 #line 404 "tools/wmc/mcy.y"
2158
2159
2160 static WCHAR *merge(WCHAR *s1, WCHAR *s2)
2161 {
2162 int l1 = unistrlen(s1);
2163 int l2 = unistrlen(s2);
2164 s1 = xrealloc(s1, (l1 + l2 + 1) * sizeof(*s1));
2165 unistrcpy(s1+l1, s2);
2166 free(s2);
2167 return s1;
2168 }
2169
2170 static void do_add_token(tok_e type, token_t *tok, const char *code)
2171 {
2172 token_t *tp = lookup_token(tok->name);
2173 if(tp)
2174 {
2175 if(tok->type != type)
2176 mcy_warning("Type change in token\n");
2177 if(tp != tok)
2178 xyyerror("Overlapping token not the same\n");
2179 /* else its already defined and changed */
2180 if(tok->fixed)
2181 xyyerror("Redefinition of %s\n", code);
2182 tok->fixed = 1;
2183 }
2184 else
2185 {
2186 add_token(type, tok->name, tok->token, tok->codepage, tok->alias, 1);
2187 free(tok);
2188 }
2189 }
2190
2191 static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg)
2192 {
2193 lanmsg_t *lmp = xmalloc(sizeof(lanmsg_t));
2194 lmp->lan = lcp->language;
2195 lmp->cp = lcp->codepage;
2196 lmp->msg = msg;
2197 lmp->len = unistrlen(msg) + 1; /* Include termination */
2198 if(lmp->len > 4096)
2199 mcy_warning("Message exceptionally long; might be a missing termination\n");
2200 return lmp;
2201 }
2202
2203 static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg)
2204 {
2205 int i;
2206 if(!msg)
2207 {
2208 msg = xmalloc(sizeof(msg_t));
2209 memset( msg, 0, sizeof(*msg) );
2210 }
2211 msg->msgs = xrealloc(msg->msgs, (msg->nmsgs+1) * sizeof(*(msg->msgs)));
2212 msg->msgs[msg->nmsgs] = lanmsg;
2213 msg->nmsgs++;
2214 for(i = 0; i < msg->nmsgs-1; i++)
2215 {
2216 if(msg->msgs[i]->lan == lanmsg->lan)
2217 xyyerror("Message for language 0x%x already defined\n", lanmsg->lan);
2218 }
2219 return msg;
2220 }
2221
2222 static int sort_lanmsg(const void *p1, const void *p2)
2223 {
2224 return (*(const lanmsg_t * const *)p1)->lan - (*(const lanmsg_t * const*)p2)->lan;
2225 }
2226
2227 static msg_t *complete_msg(msg_t *mp, int id)
2228 {
2229 assert(mp != NULL);
2230 mp->id = id;
2231 if(have_sym)
2232 mp->sym = last_sym;
2233 else
2234 xyyerror("No symbolic name defined for message id %d\n", id);
2235 mp->sev = last_sev;
2236 mp->fac = last_fac;
2237 qsort(mp->msgs, mp->nmsgs, sizeof(*(mp->msgs)), sort_lanmsg);
2238 mp->realid = id | (last_sev << 30) | (last_fac << 16);
2239 if(custombit)
2240 mp->realid |= 1 << 29;
2241 mp->base = base;
2242 mp->cast = cast;
2243 return mp;
2244 }
2245
2246 static void add_node(node_e type, void *p)
2247 {
2248 node_t *ndp = xmalloc(sizeof(node_t));
2249 memset( ndp, 0, sizeof(*ndp) );
2250 ndp->type = type;
2251 ndp->u.all = p;
2252
2253 if(nodetail)
2254 {
2255 ndp->prev = nodetail;
2256 nodetail->next = ndp;
2257 nodetail = ndp;
2258 }
2259 else
2260 {
2261 nodehead = nodetail = ndp;
2262 }
2263 }
2264
2265 static void test_id(int id)
2266 {
2267 node_t *ndp;
2268 for(ndp = nodehead; ndp; ndp = ndp->next)
2269 {
2270 if(ndp->type != nd_msg)
2271 continue;
2272 if(ndp->u.msg->id == id && ndp->u.msg->sev == last_sev && ndp->u.msg->fac == last_fac)
2273 xyyerror("MessageId %d with facility 0x%x and severity 0x%x already defined\n", id, last_fac, last_sev);
2274 }
2275 }
2276
2277 static int check_languages(node_t *head)
2278 {
2279 static const char err_missing[] = "Missing definition for language 0x%x; MessageID %d, facility 0x%x, severity 0x%x";
2280 node_t *ndp;
2281 int nm = 0;
2282 msg_t *msg = NULL;
2283
2284 for(ndp = head; ndp; ndp = ndp->next)
2285 {
2286 if(ndp->type != nd_msg)
2287 continue;
2288 if(!nm)
2289 {
2290 msg = ndp->u.msg;
2291 }
2292 else
2293 {
2294 int i;
2295 msg_t *m1;
2296 msg_t *m2;
2297 if(ndp->u.msg->nmsgs > msg->nmsgs)
2298 {
2299 m1 = ndp->u.msg;
2300 m2 = msg;
2301 }
2302 else
2303 {
2304 m1 = msg;
2305 m2 = ndp->u.msg;
2306 }
2307
2308 for(i = 0; i < m1->nmsgs; i++)
2309 {
2310 if(i > m2->nmsgs)
2311 error(err_missing, m1->msgs[i]->lan, m2->id, m2->fac, m2->sev);
2312 else if(m1->msgs[i]->lan < m2->msgs[i]->lan)
2313 error(err_missing, m1->msgs[i]->lan, m2->id, m2->fac, m2->sev);
2314 else if(m1->msgs[i]->lan > m2->msgs[i]->lan)
2315 error(err_missing, m2->msgs[i]->lan, m1->id, m1->fac, m1->sev);
2316 }
2317 }
2318 nm++;
2319 }
2320 return nm;
2321 }
2322
2323 #define MSGRID(x) ((*(const msg_t * const*)(x))->realid)
2324 static int sort_msg(const void *p1, const void *p2)
2325 {
2326 return MSGRID(p1) > MSGRID(p2) ? 1 : (MSGRID(p1) == MSGRID(p2) ? 0 : -1);
2327 /* return (*(msg_t **)p1)->realid - (*(msg_t **)p1)->realid; */
2328 }
2329
2330 /*
2331 * block_messages() basically transposes the messages
2332 * from ID/language based list to a language/ID
2333 * based list.
2334 */
2335 static lan_blk_t *block_messages(node_t *head)
2336 {
2337 lan_blk_t *lbp;
2338 lan_blk_t *lblktail = NULL;
2339 lan_blk_t *lblkhead = NULL;
2340 msg_t **msgtab = NULL;
2341 node_t *ndp;
2342 int nmsg = 0;
2343 int i;
2344 int nl;
2345 int factor = unicodeout ? 2 : 1;
2346
2347 for(ndp = head; ndp; ndp = ndp->next)
2348 {
2349 if(ndp->type != nd_msg)
2350 continue;
2351 msgtab = xrealloc(msgtab, (nmsg+1) * sizeof(*msgtab));
2352 msgtab[nmsg++] = ndp->u.msg;
2353 }
2354
2355 assert(nmsg != 0);
2356 qsort(msgtab, nmsg, sizeof(*msgtab), sort_msg);
2357
2358 for(nl = 0; nl < msgtab[0]->nmsgs; nl++) /* This should be equal for all after check_languages() */
2359 {
2360 lbp = xmalloc(sizeof(lan_blk_t));
2361 memset( lbp, 0, sizeof(*lbp) );
2362 if(!lblktail)
2363 {
2364 lblkhead = lblktail = lbp;
2365 }
2366 else
2367 {
2368 lblktail->next = lbp;
2369 lbp->prev = lblktail;
2370 lblktail = lbp;
2371 }
2372 lbp->nblk = 1;
2373 lbp->blks = xmalloc(sizeof(*lbp->blks));
2374 lbp->blks[0].idlo = msgtab[0]->realid;
2375 lbp->blks[0].idhi = msgtab[0]->realid;
2376 /* The plus 4 is the entry header; (+3)&~3 is DWORD alignment */
2377 lbp->blks[0].size = ((factor * msgtab[0]->msgs[nl]->len + 3) & ~3) + 4;
2378 lbp->blks[0].msgs = xmalloc(sizeof(*lbp->blks[0].msgs));
2379 lbp->blks[0].nmsg = 1;
2380 lbp->blks[0].msgs[0] = msgtab[0]->msgs[nl];
2381 lbp->lan = msgtab[0]->msgs[nl]->lan;
2382
2383 for(i = 1; i < nmsg; i++)
2384 {
2385 block_t *blk = &(lbp->blks[lbp->nblk-1]);
2386 if(msgtab[i]->realid == blk->idhi+1)
2387 {
2388 blk->size += ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
2389 blk->idhi++;
2390 blk->msgs = xrealloc(blk->msgs, (blk->nmsg+1) * sizeof(*blk->msgs));
2391 blk->msgs[blk->nmsg++] = msgtab[i]->msgs[nl];
2392 }
2393 else
2394 {
2395 lbp->nblk++;
2396 lbp->blks = xrealloc(lbp->blks, lbp->nblk * sizeof(*lbp->blks));
2397 blk = &(lbp->blks[lbp->nblk-1]);
2398 blk->idlo = msgtab[i]->realid;
2399 blk->idhi = msgtab[i]->realid;
2400 blk->size = ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
2401 blk->msgs = xmalloc(sizeof(*blk->msgs));
2402 blk->nmsg = 1;
2403 blk->msgs[0] = msgtab[i]->msgs[nl];
2404 }
2405 }
2406 }
2407 free(msgtab);
2408 return lblkhead;
2409 }
2410
2411 static int sc_xlat(const void *p1, const void *p2)
2412 {
2413 return ((const cp_xlat_t *)p1)->lan - ((const cp_xlat_t *)p2)->lan;
2414 }
2415
2416 static void add_cpxlat(int lan, int cpin, int cpout)
2417 {
2418 cpxlattab = xrealloc(cpxlattab, (ncpxlattab+1) * sizeof(*cpxlattab));
2419 cpxlattab[ncpxlattab].lan = lan;
2420 cpxlattab[ncpxlattab].cpin = cpin;
2421 cpxlattab[ncpxlattab].cpout = cpout;
2422 ncpxlattab++;
2423 qsort(cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
2424 }
2425
2426 static cp_xlat_t *find_cpxlat(int lan)
2427 {
2428 cp_xlat_t t;
2429
2430 if(!cpxlattab) return NULL;
2431
2432 t.lan = lan;
2433 return (cp_xlat_t *)bsearch(&t, cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
2434 }
2435