1 /* A Bison parser, made by GNU Bison 2.1. */
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.
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)
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.
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. */
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. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
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. */
36 /* Identify Bison output. */
40 #define YYBISON_VERSION "2.1"
43 #define YYSKELETON_NAME "yacc.c"
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
51 /* Substitute the variable and function names. */
52 #define yyparse mcy_parse
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
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
100 #define tLANGUAGE 269
112 /* Copy the first part of user declarations. */
113 #line 39 "tools/wmc/mcy.y"
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";
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 */
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 */
144 static int base
= 16; /* Current printout base to use (8, 10 or 16) */
145 static WCHAR
*cast
= NULL
; /* Current typecast to use */
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 */
155 static cp_xlat_t
*cpxlattab
= NULL
; /* Codepage translation table */
156 static int ncpxlattab
= 0;
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
);
173 /* Enabling traces. */
178 /* Enabling verbose error messages. */
179 #ifdef YYERROR_VERBOSE
180 # undef YYERROR_VERBOSE
181 # define YYERROR_VERBOSE 1
183 # define YYERROR_VERBOSE 0
186 /* Enabling the token table. */
187 #ifndef YYTOKEN_TABLE
188 # define YYTOKEN_TABLE 0
191 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
192 #line 98 "tools/wmc/mcy.y"
193 typedef union 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
210 /* Copy the second part of user declarations. */
213 /* Line 219 of yacc.c. */
214 #line 215 "mcy.tab.c"
216 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
217 # define YYSIZE_T __SIZE_TYPE__
219 #if ! defined (YYSIZE_T) && defined (size_t)
220 # define YYSIZE_T size_t
222 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
223 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
224 # define YYSIZE_T size_t
226 #if ! defined (YYSIZE_T)
227 # define YYSIZE_T unsigned int
233 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
234 # define YY_(msgid) dgettext ("bison-runtime", msgid)
238 # define YY_(msgid) msgid
242 #if ! defined (yyoverflow) || YYERROR_VERBOSE
244 /* The parser invokes alloca or malloc; define the necessary symbols. */
246 # ifdef YYSTACK_USE_ALLOCA
247 # if YYSTACK_USE_ALLOCA
249 # define YYSTACK_ALLOC __builtin_alloca
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
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 */
271 # define YYSTACK_ALLOC YYMALLOC
272 # define YYSTACK_FREE YYFREE
273 # ifndef YYSTACK_ALLOC_MAXIMUM
274 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
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 */
288 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
289 && (defined (__STDC__) || defined (__cplusplus)))
290 void free (void *); /* INFRINGES ON USER NAME SPACE */
297 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
300 #if (! defined (yyoverflow) \
301 && (! defined (__cplusplus) \
302 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
304 /* A type that is properly aligned for any stack member. */
311 /* The size of the maximum gap between one aligned stack and the next. */
312 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
314 /* The size of an array large to enough to hold all stacks, each with
316 # define YYSTACK_BYTES(N) \
317 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
318 + YYSTACK_GAP_MAXIMUM)
320 /* Copy COUNT objects from FROM to TO. The source and destination do
323 # if defined (__GNUC__) && 1 < __GNUC__
324 # define YYCOPY(To, From, Count) \
325 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
327 # define YYCOPY(To, From, Count) \
331 for (yyi = 0; yyi < (Count); yyi++) \
332 (To)[yyi] = (From)[yyi]; \
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
343 # define YYSTACK_RELOCATE(Stack) \
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); \
356 #if defined (__STDC__) || defined (__cplusplus)
357 typedef signed char yysigned_char
;
359 typedef short int yysigned_char
;
362 /* YYFINAL -- State number of the termination state. */
364 /* YYLAST -- Last index in YYTABLE. */
367 /* YYNTOKENS -- Number of terminals. */
369 /* YYNNTS -- Number of nonterminals. */
371 /* YYNRULES -- Number of rules. */
373 /* YYNRULES -- Number of states. */
374 #define YYNSTATES 155
376 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
378 #define YYMAXUTOK 276
380 #define YYTRANSLATE(YYX) \
381 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
383 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
384 static const unsigned char yytranslate
[] =
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
417 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
419 static const unsigned short int yyprhs
[] =
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
434 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
435 static const yysigned_char yyrhs
[] =
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,
475 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
476 static const unsigned short int yyrline
[] =
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
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
[] =
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",
510 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
512 static const unsigned short int yytoknum
[] =
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
520 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
521 static const unsigned char yyr1
[] =
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,
536 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
537 static const unsigned char yyr2
[] =
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,
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
[] =
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,
575 /* YYDEFGOTO[NTERM-NUM]. */
576 static const short int yydefgoto
[] =
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,
584 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
586 #define YYPACT_NINF -37
587 static const short int yypact
[] =
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
607 /* YYPGOTO[NTERM-NUM]. */
608 static const yysigned_char yypgoto
[] =
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,
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
[] =
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
642 static const yysigned_char yycheck
[] =
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
663 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
664 symbol of state STATE-NUM. */
665 static const unsigned char yystos
[] =
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,
685 #define yyerrok (yyerrstatus = 0)
686 #define yyclearin (yychar = YYEMPTY)
690 #define YYACCEPT goto yyacceptlab
691 #define YYABORT goto yyabortlab
692 #define YYERROR goto yyerrorlab
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. */
699 #define YYFAIL goto yyerrlab
701 #define YYRECOVERING() (!!yyerrstatus)
703 #define YYBACKUP(Token, Value) \
705 if (yychar == YYEMPTY && yylen == 1) \
709 yytoken = YYTRANSLATE (yychar); \
715 yyerror (YY_("syntax error: cannot back up")); \
722 #define YYERRCODE 256
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). */
729 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
730 #ifndef YYLLOC_DEFAULT
731 # define YYLLOC_DEFAULT(Current, Rhs, N) \
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; \
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; \
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. */
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)
762 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
767 /* YYLEX -- calling `yylex' with the right arguments. */
770 # define YYLEX yylex (YYLEX_PARAM)
772 # define YYLEX yylex ()
775 /* Enable debugging if requested. */
779 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
780 # define YYFPRINTF fprintf
783 # define YYDPRINTF(Args) \
789 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
793 YYFPRINTF (stderr, "%s ", Title); \
794 yysymprint (stderr, \
796 YYFPRINTF (stderr, "\n"); \
800 /*------------------------------------------------------------------.
801 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
803 `------------------------------------------------------------------*/
805 #if defined (__STDC__) || defined (__cplusplus)
807 yy_stack_print (short int *bottom
, short int *top
)
810 yy_stack_print (bottom
, top
)
815 YYFPRINTF (stderr
, "Stack now");
816 for (/* Nothing. */; bottom
<= top
; ++bottom
)
817 YYFPRINTF (stderr
, " %d", *bottom
);
818 YYFPRINTF (stderr
, "\n");
821 # define YY_STACK_PRINT(Bottom, Top) \
824 yy_stack_print ((Bottom), (Top)); \
828 /*------------------------------------------------.
829 | Report that the YYRULE is going to be reduced. |
830 `------------------------------------------------*/
832 #if defined (__STDC__) || defined (__cplusplus)
834 yy_reduce_print (int yyrule
)
837 yy_reduce_print (yyrule
)
842 unsigned long int yylno
= yyrline
[yyrule
];
843 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu), ",
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
]]);
851 # define YY_REDUCE_PRINT(Rule) \
854 yy_reduce_print (Rule); \
857 /* Nonzero means print parse trace. It is left uninitialized so that
858 multiple parsers can coexist. */
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 */
868 /* YYINITDEPTH -- initial size of the parser's stacks. */
870 # define YYINITDEPTH 200
873 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
874 if the built-in stack extension method is used).
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. */
881 # define YYMAXDEPTH 10000
889 # if defined (__GLIBC__) && defined (_STRING_H)
890 # define yystrlen strlen
892 /* Return the length of YYSTR. */
894 # if defined (__STDC__) || defined (__cplusplus)
895 yystrlen (const char *yystr
)
901 const char *yys
= yystr
;
903 while (*yys
++ != '\0')
906 return yys
- yystr
- 1;
912 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
913 # define yystpcpy stpcpy
915 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
918 # if defined (__STDC__) || defined (__cplusplus)
919 yystpcpy (char *yydest
, const char *yysrc
)
921 yystpcpy (yydest
, yysrc
)
927 const char *yys
= yysrc
;
929 while ((*yyd
++ = *yys
++) != '\0')
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
946 yytnamerr (char *yyres
, const char *yystr
)
951 char const *yyp
= yystr
;
958 goto do_not_strip_quotes
;
962 goto do_not_strip_quotes
;
975 do_not_strip_quotes
: ;
979 return yystrlen (yystr
);
981 return yystpcpy (yyres
, yystr
) - yyres
;
985 #endif /* YYERROR_VERBOSE */
990 /*--------------------------------.
991 | Print this symbol on YYOUTPUT. |
992 `--------------------------------*/
994 #if defined (__STDC__) || defined (__cplusplus)
996 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
999 yysymprint (yyoutput
, yytype
, yyvaluep
)
1005 /* Pacify ``unused variable'' warnings. */
1008 if (yytype
< YYNTOKENS
)
1009 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1011 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1015 if (yytype
< YYNTOKENS
)
1016 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1023 YYFPRINTF (yyoutput
, ")");
1026 #endif /* ! YYDEBUG */
1027 /*-----------------------------------------------.
1028 | Release the memory associated to this symbol. |
1029 `-----------------------------------------------*/
1031 #if defined (__STDC__) || defined (__cplusplus)
1033 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1036 yydestruct (yymsg
, yytype
, yyvaluep
)
1042 /* Pacify ``unused variable'' warnings. */
1047 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1058 /* Prevent warnings from -Wmissing-prototypes. */
1060 #ifdef YYPARSE_PARAM
1061 # if defined (__STDC__) || defined (__cplusplus)
1062 int yyparse (void *YYPARSE_PARAM
);
1066 #else /* ! YYPARSE_PARAM */
1067 #if defined (__STDC__) || defined (__cplusplus)
1072 #endif /* ! YYPARSE_PARAM */
1076 /* The look-ahead symbol. */
1079 /* The semantic value of the look-ahead symbol. */
1082 /* Number of syntax errors so far. */
1091 #ifdef YYPARSE_PARAM
1092 # if defined (__STDC__) || defined (__cplusplus)
1093 int yyparse (void *YYPARSE_PARAM
)
1095 int yyparse (YYPARSE_PARAM
)
1096 void *YYPARSE_PARAM
;
1098 #else /* ! YYPARSE_PARAM */
1099 #if defined (__STDC__) || defined (__cplusplus)
1113 /* Number of tokens to shift before error messages enabled. */
1115 /* Look-ahead token as an internal (translated) token number. */
1118 /* Three stacks and their tools:
1119 `yyss': related to states,
1120 `yyvs': related to semantic values,
1121 `yyls': related to locations.
1123 Refer to the stacks thru separate pointers, to allow yyoverflow
1124 to reallocate them elsewhere. */
1126 /* The state stack. */
1127 short int yyssa
[YYINITDEPTH
];
1128 short int *yyss
= yyssa
;
1131 /* The semantic value stack. */
1132 YYSTYPE yyvsa
[YYINITDEPTH
];
1133 YYSTYPE
*yyvs
= yyvsa
;
1138 #define YYPOPSTACK (yyvsp--, yyssp--)
1140 YYSIZE_T yystacksize
= YYINITDEPTH
;
1142 /* The variables used to return semantic value and location from the
1147 /* When reducing, the number of symbols on the RHS of the reduced
1151 YYDPRINTF ((stderr
, "Starting parse\n"));
1156 yychar
= YYEMPTY
; /* Cause a token to be read. */
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. */
1168 /*------------------------------------------------------------.
1169 | yynewstate -- Push a new state, which is found in yystate. |
1170 `------------------------------------------------------------*/
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.
1180 if (yyss
+ yystacksize
- 1 <= yyssp
)
1182 /* Get the current used size of the three stacks, in elements. */
1183 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
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
1190 YYSTYPE
*yyvs1
= yyvs
;
1191 short int *yyss1
= yyss
;
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
),
1207 #else /* no yyoverflow */
1208 # ifndef YYSTACK_RELOCATE
1209 goto yyexhaustedlab
;
1211 /* Extend the stack our own way. */
1212 if (YYMAXDEPTH
<= yystacksize
)
1213 goto yyexhaustedlab
;
1215 if (YYMAXDEPTH
< yystacksize
)
1216 yystacksize
= YYMAXDEPTH
;
1219 short int *yyss1
= yyss
;
1220 union yyalloc
*yyptr
=
1221 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1223 goto yyexhaustedlab
;
1224 YYSTACK_RELOCATE (yyss
);
1225 YYSTACK_RELOCATE (yyvs
);
1227 # undef YYSTACK_RELOCATE
1229 YYSTACK_FREE (yyss1
);
1232 #endif /* no yyoverflow */
1234 yyssp
= yyss
+ yysize
- 1;
1235 yyvsp
= yyvs
+ yysize
- 1;
1238 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1239 (unsigned long int) yystacksize
));
1241 if (yyss
+ yystacksize
- 1 <= yyssp
)
1245 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1254 /* Do appropriate processing given the current state. */
1255 /* Read a look-ahead token if we need one and don't already have one. */
1258 /* First try to decide what to do without reference to look-ahead token. */
1260 yyn
= yypact
[yystate
];
1261 if (yyn
== YYPACT_NINF
)
1264 /* Not known => get a look-ahead token if don't already have one. */
1266 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1267 if (yychar
== YYEMPTY
)
1269 YYDPRINTF ((stderr
, "Reading a token: "));
1273 if (yychar
<= YYEOF
)
1275 yychar
= yytoken
= YYEOF
;
1276 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1280 yytoken
= YYTRANSLATE (yychar
);
1281 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1284 /* If the proper action on seeing token YYTOKEN is to reduce or to
1285 detect an error, take that action. */
1287 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1292 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1301 /* Shift the look-ahead token. */
1302 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1304 /* Discard the token being shifted unless it is eof. */
1305 if (yychar
!= YYEOF
)
1311 /* Count tokens shifted since error; after three, turn off error
1320 /*-----------------------------------------------------------.
1321 | yydefault -- do the default action for the current state. |
1322 `-----------------------------------------------------------*/
1324 yyn
= yydefact
[yystate
];
1330 /*-----------------------------.
1331 | yyreduce -- Do a reduction. |
1332 `-----------------------------*/
1334 /* yyn is the number of a rule to reduce with. */
1337 /* If YYLEN is nonzero, implement the default value of the action:
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
];
1348 YY_REDUCE_PRINT (yyn
);
1352 #line 123 "tools/wmc/mcy.y"
1354 if(!check_languages(nodehead
))
1355 xyyerror("No messages defined\n");
1356 lanblockhead
= block_messages(nodehead
);
1361 #line 135 "tools/wmc/mcy.y"
1362 { add_node(nd_msg
, (yyvsp
[0].msg
)); ;}
1366 #line 136 "tools/wmc/mcy.y"
1367 { add_node(nd_comment
, (yyvsp
[0].str
)); ;}
1371 #line 137 "tools/wmc/mcy.y"
1372 { xyyerror(err_syntax
); /* `Catch all' error */ ;}
1376 #line 141 "tools/wmc/mcy.y"
1377 { xyyerror(err_pclose
); ;}
1381 #line 142 "tools/wmc/mcy.y"
1382 { xyyerror(err_popen
); ;}
1386 #line 143 "tools/wmc/mcy.y"
1387 { xyyerror(err_assign
); ;}
1391 #line 145 "tools/wmc/mcy.y"
1392 { xyyerror(err_pclose
); ;}
1396 #line 146 "tools/wmc/mcy.y"
1397 { xyyerror(err_popen
); ;}
1401 #line 147 "tools/wmc/mcy.y"
1402 { xyyerror(err_assign
); ;}
1406 #line 149 "tools/wmc/mcy.y"
1407 { xyyerror(err_pclose
); ;}
1411 #line 150 "tools/wmc/mcy.y"
1412 { xyyerror(err_popen
); ;}
1416 #line 151 "tools/wmc/mcy.y"
1417 { xyyerror(err_assign
); ;}
1421 #line 153 "tools/wmc/mcy.y"
1422 { xyyerror(err_pclose
); ;}
1426 #line 154 "tools/wmc/mcy.y"
1427 { xyyerror(err_popen
); ;}
1431 #line 155 "tools/wmc/mcy.y"
1432 { xyyerror(err_assign
); ;}
1436 #line 156 "tools/wmc/mcy.y"
1437 { cast
= (yyvsp
[0].str
); ;}
1441 #line 157 "tools/wmc/mcy.y"
1442 { xyyerror(err_number
); ;}
1446 #line 158 "tools/wmc/mcy.y"
1447 { xyyerror(err_assign
); ;}
1451 #line 159 "tools/wmc/mcy.y"
1458 base
= (yyvsp
[0].num
);
1461 xyyerror("Numberbase must be 8, 10 or 16\n");
1467 #line 171 "tools/wmc/mcy.y"
1468 { xyyerror(err_number
); ;}
1472 #line 172 "tools/wmc/mcy.y"
1473 { xyyerror(err_assign
); ;}
1477 #line 180 "tools/wmc/mcy.y"
1478 { xyyerror(err_ident
); ;}
1482 #line 183 "tools/wmc/mcy.y"
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");
1493 #line 190 "tools/wmc/mcy.y"
1494 { xyyerror(err_number
); ;}
1498 #line 191 "tools/wmc/mcy.y"
1499 { xyyerror(err_assign
); ;}
1503 #line 199 "tools/wmc/mcy.y"
1504 { xyyerror(err_ident
); ;}
1508 #line 202 "tools/wmc/mcy.y"
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");
1519 #line 209 "tools/wmc/mcy.y"
1520 { xyyerror(err_number
); ;}
1524 #line 210 "tools/wmc/mcy.y"
1525 { xyyerror(err_assign
); ;}
1529 #line 213 "tools/wmc/mcy.y"
1530 { (yyval
.str
) = NULL
; ;}
1534 #line 214 "tools/wmc/mcy.y"
1535 { (yyval
.str
) = (yyvsp
[0].str
); ;}
1539 #line 215 "tools/wmc/mcy.y"
1540 { xyyerror(err_ident
); ;}
1544 #line 223 "tools/wmc/mcy.y"
1545 { xyyerror(err_ident
); ;}
1549 #line 226 "tools/wmc/mcy.y"
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
);
1561 #line 234 "tools/wmc/mcy.y"
1562 { xyyerror("Filename expected\n"); ;}
1566 #line 235 "tools/wmc/mcy.y"
1567 { xyyerror(err_colon
); ;}
1571 #line 236 "tools/wmc/mcy.y"
1572 { xyyerror(err_number
); ;}
1576 #line 237 "tools/wmc/mcy.y"
1577 { xyyerror(err_assign
); ;}
1581 #line 240 "tools/wmc/mcy.y"
1582 { (yyval
.num
) = 0; ;}
1586 #line 241 "tools/wmc/mcy.y"
1587 { (yyval
.num
) = (yyvsp
[0].num
); ;}
1591 #line 242 "tools/wmc/mcy.y"
1592 { xyyerror("Codepage-number expected\n"); ;}
1596 #line 250 "tools/wmc/mcy.y"
1597 { xyyerror(err_ident
); ;}
1601 #line 253 "tools/wmc/mcy.y"
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
));
1615 #line 263 "tools/wmc/mcy.y"
1616 { xyyerror(err_number
); ;}
1620 #line 264 "tools/wmc/mcy.y"
1621 { xyyerror(err_colon
); ;}
1625 #line 265 "tools/wmc/mcy.y"
1626 { xyyerror(err_number
); ;}
1630 #line 266 "tools/wmc/mcy.y"
1631 { xyyerror(err_assign
); ;}
1635 #line 269 "tools/wmc/mcy.y"
1636 { (yyval
.num
) = (yyvsp
[0].num
); ;}
1640 #line 270 "tools/wmc/mcy.y"
1642 if((yyvsp
[0].tok
)->type
!= tok_language
)
1643 xyyerror("Language name or code expected\n");
1644 (yyval
.num
) = (yyvsp
[0].tok
)->token
;
1649 #line 280 "tools/wmc/mcy.y"
1650 { test_id((yyvsp
[-1].num
)); ;}
1654 #line 280 "tools/wmc/mcy.y"
1655 { (yyval
.msg
) = complete_msg((yyvsp
[0].msg
), (yyvsp
[-3].num
)); ;}
1659 #line 283 "tools/wmc/mcy.y"
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
);
1668 #line 288 "tools/wmc/mcy.y"
1669 { xyyerror(err_assign
); ;}
1673 #line 291 "tools/wmc/mcy.y"
1674 { (yyval
.num
) = ++last_id
; ;}
1678 #line 292 "tools/wmc/mcy.y"
1679 { (yyval
.num
) = last_id
= (yyvsp
[0].num
); ;}
1683 #line 293 "tools/wmc/mcy.y"
1684 { (yyval
.num
) = last_id
+= (yyvsp
[0].num
); ;}
1688 #line 294 "tools/wmc/mcy.y"
1689 { xyyerror(err_number
); ;}
1693 #line 297 "tools/wmc/mcy.y"
1694 { have_sev
= have_fac
= have_sym
= 0; ;}
1698 #line 298 "tools/wmc/mcy.y"
1699 { if(have_sev
) xyyerror("Severity already defined\n"); have_sev
= 1; ;}
1703 #line 299 "tools/wmc/mcy.y"
1704 { if(have_fac
) xyyerror("Facility already defined\n"); have_fac
= 1; ;}
1708 #line 300 "tools/wmc/mcy.y"
1709 { if(have_sym
) xyyerror("Symbolname already defined\n"); have_sym
= 1; ;}
1713 #line 303 "tools/wmc/mcy.y"
1714 { last_sym
= (yyvsp
[0].str
); ;}
1718 #line 304 "tools/wmc/mcy.y"
1719 { xyyerror(err_ident
); ;}
1723 #line 305 "tools/wmc/mcy.y"
1724 { xyyerror(err_assign
); ;}
1728 #line 308 "tools/wmc/mcy.y"
1730 token_t
*tok
= lookup_token((yyvsp
[0].tok
)->name
);
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
;
1740 #line 316 "tools/wmc/mcy.y"
1741 { xyyerror(err_ident
); ;}
1745 #line 317 "tools/wmc/mcy.y"
1746 { xyyerror(err_assign
); ;}
1750 #line 320 "tools/wmc/mcy.y"
1752 token_t
*tok
= lookup_token((yyvsp
[0].tok
)->name
);
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
;
1762 #line 328 "tools/wmc/mcy.y"
1763 { xyyerror(err_ident
); ;}
1767 #line 329 "tools/wmc/mcy.y"
1768 { xyyerror(err_assign
); ;}
1772 #line 335 "tools/wmc/mcy.y"
1773 { (yyval
.msg
) = add_lanmsg(NULL
, (yyvsp
[0].lmp
)); ;}
1777 #line 336 "tools/wmc/mcy.y"
1778 { (yyval
.msg
) = add_lanmsg((yyvsp
[-1].msg
), (yyvsp
[0].lmp
)); ;}
1782 #line 337 "tools/wmc/mcy.y"
1783 { xyyerror("'Language=...' (start of message text-definition) expected\n"); ;}
1787 #line 340 "tools/wmc/mcy.y"
1788 { (yyval
.lmp
) = new_lanmsg(&(yyvsp
[-3].lcp
), (yyvsp
[-1].str
)); ;}
1792 #line 348 "tools/wmc/mcy.y"
1794 token_t
*tok
= lookup_token((yyvsp
[-1].tok
)->name
);
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
)))
1802 set_codepage((yyval
.lcp
).codepage
= cpx
->cpin
);
1804 else if(!tok
->codepage
)
1806 const language_t
*lan
= find_language(tok
->token
);
1809 /* Just set default; warning was given while parsing languagenames */
1810 set_codepage((yyval
.lcp
).codepage
= WMC_DEFAULT_CODEPAGE
);
1814 /* The default seems to be to use the DOS codepage... */
1815 set_codepage((yyval
.lcp
).codepage
= lan
->doscp
);
1819 set_codepage((yyval
.lcp
).codepage
= tok
->codepage
);
1820 (yyval
.lcp
).language
= tok
->token
;
1825 #line 377 "tools/wmc/mcy.y"
1826 { xyyerror("Missing newline\n"); ;}
1830 #line 378 "tools/wmc/mcy.y"
1831 { xyyerror(err_ident
); ;}
1835 #line 379 "tools/wmc/mcy.y"
1836 { xyyerror(err_assign
); ;}
1840 #line 382 "tools/wmc/mcy.y"
1841 { (yyval
.str
) = (yyvsp
[0].str
); ;}
1845 #line 383 "tools/wmc/mcy.y"
1846 { (yyval
.str
) = merge((yyvsp
[-1].str
), (yyvsp
[0].str
)); ;}
1850 #line 384 "tools/wmc/mcy.y"
1851 { xyyerror(err_msg
); ;}
1855 #line 385 "tools/wmc/mcy.y"
1856 { xyyerror(err_msg
); ;}
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
); ;}
1865 #line 392 "tools/wmc/mcy.y"
1866 { (yyval
.tok
) = (yyvsp
[0].tok
); ;}
1870 #line 395 "tools/wmc/mcy.y"
1875 #line 398 "tools/wmc/mcy.y"
1880 #line 401 "tools/wmc/mcy.y"
1888 /* Line 1126 of yacc.c. */
1889 #line 1890 "mcy.tab.c"
1895 YY_STACK_PRINT (yyss
, yyssp
);
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. */
1906 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1907 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1908 yystate
= yytable
[yystate
];
1910 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1915 /*------------------------------------.
1916 | yyerrlab -- here on detecting error |
1917 `------------------------------------*/
1919 /* If not already recovering from an error, report this error. */
1924 yyn
= yypact
[yystate
];
1926 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1928 int yytype
= YYTRANSLATE (yychar
);
1929 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1930 YYSIZE_T yysize
= yysize0
;
1932 int yysize_overflow
= 0;
1934 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
1935 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
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");
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
;
1958 /* Start YYX at -YYN if negative to avoid negative indexes in
1960 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1962 /* Stay within bounds of both yycheck and yytname. */
1963 int yychecklim
= YYLAST
- yyn
;
1964 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1967 yyarg
[0] = yytname
[yytype
];
1968 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1970 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1971 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1973 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1977 yyformat
[sizeof yyunexpected
- 1] = '\0';
1980 yyarg
[yycount
++] = yytname
[yyx
];
1981 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1982 yysize_overflow
|= yysize1
< yysize
;
1984 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1988 yyf
= YY_(yyformat
);
1989 yysize1
= yysize
+ yystrlen (yyf
);
1990 yysize_overflow
|= yysize1
< yysize
;
1993 if (!yysize_overflow
&& yysize
<= YYSTACK_ALLOC_MAXIMUM
)
1994 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
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. */
2002 while ((*yyp
= *yyf
))
2004 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
2006 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
2016 YYSTACK_FREE (yymsg
);
2020 yyerror (YY_("syntax error"));
2021 goto yyexhaustedlab
;
2025 #endif /* YYERROR_VERBOSE */
2026 yyerror (YY_("syntax error"));
2031 if (yyerrstatus
== 3)
2033 /* If just tried and failed to reuse look-ahead token after an
2034 error, discard it. */
2036 if (yychar
<= YYEOF
)
2038 /* Return failure if at end of input. */
2039 if (yychar
== YYEOF
)
2044 yydestruct ("Error: discarding", yytoken
, &yylval
);
2049 /* Else will try to reuse look-ahead token after shifting the error
2054 /*---------------------------------------------------.
2055 | yyerrorlab -- error raised explicitly by YYERROR. |
2056 `---------------------------------------------------*/
2059 /* Pacify compilers like GCC when the user code never invokes
2060 YYERROR and the label yyerrorlab therefore never appears in user
2071 /*-------------------------------------------------------------.
2072 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2073 `-------------------------------------------------------------*/
2075 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2079 yyn
= yypact
[yystate
];
2080 if (yyn
!= YYPACT_NINF
)
2083 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2091 /* Pop the current state because it cannot handle the error token. */
2096 yydestruct ("Error: popping", yystos
[yystate
], yyvsp
);
2099 YY_STACK_PRINT (yyss
, yyssp
);
2108 /* Shift the error token. */
2109 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2115 /*-------------------------------------.
2116 | yyacceptlab -- YYACCEPT comes here. |
2117 `-------------------------------------*/
2122 /*-----------------------------------.
2123 | yyabortlab -- YYABORT comes here. |
2124 `-----------------------------------*/
2130 /*-------------------------------------------------.
2131 | yyexhaustedlab -- memory exhaustion comes here. |
2132 `-------------------------------------------------*/
2134 yyerror (YY_("memory exhausted"));
2140 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
2141 yydestruct ("Cleanup: discarding lookahead",
2143 while (yyssp
!= yyss
)
2145 yydestruct ("Cleanup: popping",
2146 yystos
[*yyssp
], yyvsp
);
2151 YYSTACK_FREE (yyss
);
2157 #line 404 "tools/wmc/mcy.y"
2160 static WCHAR
*merge(WCHAR
*s1
, WCHAR
*s2
)
2162 int l1
= unistrlen(s1
);
2163 int l2
= unistrlen(s2
);
2164 s1
= xrealloc(s1
, (l1
+ l2
+ 1) * sizeof(*s1
));
2165 unistrcpy(s1
+l1
, s2
);
2170 static void do_add_token(tok_e type
, token_t
*tok
, const char *code
)
2172 token_t
*tp
= lookup_token(tok
->name
);
2175 if(tok
->type
!= type
)
2176 mcy_warning("Type change in token\n");
2178 xyyerror("Overlapping token not the same\n");
2179 /* else its already defined and changed */
2181 xyyerror("Redefinition of %s\n", code
);
2186 add_token(type
, tok
->name
, tok
->token
, tok
->codepage
, tok
->alias
, 1);
2191 static lanmsg_t
*new_lanmsg(lan_cp_t
*lcp
, WCHAR
*msg
)
2193 lanmsg_t
*lmp
= xmalloc(sizeof(lanmsg_t
));
2194 lmp
->lan
= lcp
->language
;
2195 lmp
->cp
= lcp
->codepage
;
2197 lmp
->len
= unistrlen(msg
) + 1; /* Include termination */
2199 mcy_warning("Message exceptionally long; might be a missing termination\n");
2203 static msg_t
*add_lanmsg(msg_t
*msg
, lanmsg_t
*lanmsg
)
2208 msg
= xmalloc(sizeof(msg_t
));
2209 memset( msg
, 0, sizeof(*msg
) );
2211 msg
->msgs
= xrealloc(msg
->msgs
, (msg
->nmsgs
+1) * sizeof(*(msg
->msgs
)));
2212 msg
->msgs
[msg
->nmsgs
] = lanmsg
;
2214 for(i
= 0; i
< msg
->nmsgs
-1; i
++)
2216 if(msg
->msgs
[i
]->lan
== lanmsg
->lan
)
2217 xyyerror("Message for language 0x%x already defined\n", lanmsg
->lan
);
2222 static int sort_lanmsg(const void *p1
, const void *p2
)
2224 return (*(const lanmsg_t
* const *)p1
)->lan
- (*(const lanmsg_t
* const*)p2
)->lan
;
2227 static msg_t
*complete_msg(msg_t
*mp
, int id
)
2234 xyyerror("No symbolic name defined for message id %d\n", id
);
2237 qsort(mp
->msgs
, mp
->nmsgs
, sizeof(*(mp
->msgs
)), sort_lanmsg
);
2238 mp
->realid
= id
| (last_sev
<< 30) | (last_fac
<< 16);
2240 mp
->realid
|= 1 << 29;
2246 static void add_node(node_e type
, void *p
)
2248 node_t
*ndp
= xmalloc(sizeof(node_t
));
2249 memset( ndp
, 0, sizeof(*ndp
) );
2255 ndp
->prev
= nodetail
;
2256 nodetail
->next
= ndp
;
2261 nodehead
= nodetail
= ndp
;
2265 static void test_id(int id
)
2268 for(ndp
= nodehead
; ndp
; ndp
= ndp
->next
)
2270 if(ndp
->type
!= nd_msg
)
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
);
2277 static int check_languages(node_t
*head
)
2279 static const char err_missing
[] = "Missing definition for language 0x%x; MessageID %d, facility 0x%x, severity 0x%x";
2284 for(ndp
= head
; ndp
; ndp
= ndp
->next
)
2286 if(ndp
->type
!= nd_msg
)
2297 if(ndp
->u
.msg
->nmsgs
> msg
->nmsgs
)
2308 for(i
= 0; i
< m1
->nmsgs
; i
++)
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
);
2323 #define MSGRID(x) ((*(const msg_t * const*)(x))->realid)
2324 static int sort_msg(const void *p1
, const void *p2
)
2326 return MSGRID(p1
) > MSGRID(p2
) ? 1 : (MSGRID(p1
) == MSGRID(p2
) ? 0 : -1);
2327 /* return (*(msg_t **)p1)->realid - (*(msg_t **)p1)->realid; */
2331 * block_messages() basically transposes the messages
2332 * from ID/language based list to a language/ID
2335 static lan_blk_t
*block_messages(node_t
*head
)
2338 lan_blk_t
*lblktail
= NULL
;
2339 lan_blk_t
*lblkhead
= NULL
;
2340 msg_t
**msgtab
= NULL
;
2345 int factor
= unicodeout
? 2 : 1;
2347 for(ndp
= head
; ndp
; ndp
= ndp
->next
)
2349 if(ndp
->type
!= nd_msg
)
2351 msgtab
= xrealloc(msgtab
, (nmsg
+1) * sizeof(*msgtab
));
2352 msgtab
[nmsg
++] = ndp
->u
.msg
;
2356 qsort(msgtab
, nmsg
, sizeof(*msgtab
), sort_msg
);
2358 for(nl
= 0; nl
< msgtab
[0]->nmsgs
; nl
++) /* This should be equal for all after check_languages() */
2360 lbp
= xmalloc(sizeof(lan_blk_t
));
2361 memset( lbp
, 0, sizeof(*lbp
) );
2364 lblkhead
= lblktail
= lbp
;
2368 lblktail
->next
= lbp
;
2369 lbp
->prev
= lblktail
;
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
;
2383 for(i
= 1; i
< nmsg
; i
++)
2385 block_t
*blk
= &(lbp
->blks
[lbp
->nblk
-1]);
2386 if(msgtab
[i
]->realid
== blk
->idhi
+1)
2388 blk
->size
+= ((factor
* msgtab
[i
]->msgs
[nl
]->len
+ 3) & ~3) + 4;
2390 blk
->msgs
= xrealloc(blk
->msgs
, (blk
->nmsg
+1) * sizeof(*blk
->msgs
));
2391 blk
->msgs
[blk
->nmsg
++] = msgtab
[i
]->msgs
[nl
];
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
));
2403 blk
->msgs
[0] = msgtab
[i
]->msgs
[nl
];
2411 static int sc_xlat(const void *p1
, const void *p2
)
2413 return ((const cp_xlat_t
*)p1
)->lan
- ((const cp_xlat_t
*)p2
)->lan
;
2416 static void add_cpxlat(int lan
, int cpin
, int cpout
)
2418 cpxlattab
= xrealloc(cpxlattab
, (ncpxlattab
+1) * sizeof(*cpxlattab
));
2419 cpxlattab
[ncpxlattab
].lan
= lan
;
2420 cpxlattab
[ncpxlattab
].cpin
= cpin
;
2421 cpxlattab
[ncpxlattab
].cpout
= cpout
;
2423 qsort(cpxlattab
, ncpxlattab
, sizeof(*cpxlattab
), sc_xlat
);
2426 static cp_xlat_t
*find_cpxlat(int lan
)
2430 if(!cpxlattab
) return NULL
;
2433 return (cp_xlat_t
*)bsearch(&t
, cpxlattab
, ncpxlattab
, sizeof(*cpxlattab
), sc_xlat
);