Reverted latest changes.
[reactos.git] / reactos / tools / wmc / y_tab.c
1
2 /* A Bison parser, made from ./mcy.y
3 by GNU Bison version 1.25
4 */
5
6 #define YYBISON 1 /* Identify Bison output. */
7
8 #define tSEVNAMES 258
9 #define tFACNAMES 259
10 #define tLANNAMES 260
11 #define tBASE 261
12 #define tCODEPAGE 262
13 #define tTYPEDEF 263
14 #define tNL 264
15 #define tSYMNAME 265
16 #define tMSGEND 266
17 #define tSEVERITY 267
18 #define tFACILITY 268
19 #define tLANGUAGE 269
20 #define tMSGID 270
21 #define tIDENT 271
22 #define tLINE 272
23 #define tFILE 273
24 #define tCOMMENT 274
25 #define tNUMBER 275
26 #define tTOKEN 276
27
28 #line 23 "./mcy.y"
29
30
31 #include <windows.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <assert.h>
35
36 #include "config.h"
37
38 #include "utils.h"
39 #include "wmc.h"
40 #include "lang.h"
41
42 static const char err_syntax[] = "Syntax error";
43 static const char err_number[] = "Number expected";
44 static const char err_ident[] = "Identifier expected";
45 static const char err_assign[] = "'=' expected";
46 static const char err_popen[] = "'(' expected";
47 static const char err_pclose[] = "')' expected";
48 static const char err_colon[] = "':' expected";
49 static const char err_msg[] = "Message expected";
50
51 /* Scanner switches */
52 int want_nl = 0; /* Request next newlinw */
53 int want_line = 0; /* Request next complete line */
54 int want_file = 0; /* Request next ident as filename */
55
56 node_t *nodehead = NULL; /* The list of all parsed elements */
57 static node_t *nodetail = NULL;
58 lan_blk_t *lanblockhead; /* List of parsed elements transposed */
59
60 static int base = 16; /* Current printout base to use (8, 10 or 16) */
61 static WCHAR *cast = NULL; /* Current typecast to use */
62
63 static int last_id = 0; /* The last message ID parsed */
64 static int last_sev = 0; /* Last severity code parsed */
65 static int last_fac = 0; /* Last facility code parsed */
66 static WCHAR *last_sym = NULL;/* Last alias symbol parsed */
67 static int have_sev; /* Set if severity parsed for current message */
68 static int have_fac; /* Set if facility parsed for current message */
69 static int have_sym; /* Set is symbol parsed for current message */
70
71 static cp_xlat_t *cpxlattab = NULL; /* Codepage translation table */
72 static int ncpxlattab = 0;
73
74 /* Prototypes */
75 static WCHAR *merge(WCHAR *s1, WCHAR *s2);
76 static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg);
77 static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg);
78 static msg_t *complete_msg(msg_t *msg, int id);
79 static void add_node(node_e type, void *p);
80 static void do_add_token(tok_e type, token_t *tok, const char *code);
81 static void test_id(int id);
82 static int check_languages(node_t *head);
83 static lan_blk_t *block_messages(node_t *head);
84 static void add_cpxlat(int lan, int cpin, int cpout);
85 static cp_xlat_t *find_cpxlat(int lan);
86
87
88 #line 83 "./mcy.y"
89 typedef union {
90 WCHAR *str;
91 unsigned num;
92 token_t *tok;
93 lanmsg_t *lmp;
94 msg_t *msg;
95 lan_cp_t lcp;
96 } YYSTYPE;
97 #ifndef YYDEBUG
98 #define YYDEBUG 1
99 #endif
100
101 #include <stdio.h>
102
103 #ifndef __cplusplus
104 #ifndef __STDC__
105 #define const
106 #endif
107 #endif
108
109
110
111 #define YYFINAL 155
112 #define YYFLAG -32768
113 #define YYNTBASE 27
114
115 #define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 58)
116
117 static const char yytranslate[] = { 0,
118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
120 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
121 2, 2, 2, 2, 2, 2, 2, 2, 2, 23,
122 24, 2, 26, 2, 2, 2, 2, 2, 2, 2,
123 2, 2, 2, 2, 2, 2, 2, 25, 2, 2,
124 22, 2, 2, 2, 2, 2, 2, 2, 2, 2,
125 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
126 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
127 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
128 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
131 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
132 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
134 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
136 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
137 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
138 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
139 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
142 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
143 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
144 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
145 16, 17, 18, 19, 20, 21
146 };
147
148 #if YYDEBUG != 0
149 static const short yyprhs[] = { 0,
150 0, 2, 4, 7, 9, 11, 13, 15, 21, 27,
151 31, 34, 40, 46, 50, 53, 59, 65, 69, 72,
152 78, 84, 88, 91, 95, 99, 102, 106, 110, 113,
153 115, 118, 120, 125, 129, 132, 134, 137, 139, 144,
154 148, 151, 152, 155, 158, 160, 163, 165, 173, 180,
155 185, 189, 192, 193, 196, 199, 201, 204, 206, 212,
156 218, 223, 227, 230, 232, 234, 235, 240, 244, 247,
157 248, 250, 253, 256, 257, 260, 263, 266, 270, 274,
158 277, 281, 285, 288, 292, 296, 299, 301, 304, 306,
159 311, 317, 323, 328, 331, 333, 336, 338, 341, 343,
160 345, 346, 347
161 };
162
163 static const short yyrhs[] = { 28,
164 0, 29, 0, 28, 29, 0, 30, 0, 42, 0,
165 19, 0, 1, 0, 3, 22, 23, 31, 24, 0,
166 3, 22, 23, 31, 1, 0, 3, 22, 1, 0,
167 3, 1, 0, 4, 22, 23, 33, 24, 0, 4,
168 22, 23, 33, 1, 0, 4, 22, 1, 0, 4,
169 1, 0, 5, 22, 23, 36, 24, 0, 5, 22,
170 23, 36, 1, 0, 5, 22, 1, 0, 5, 1,
171 0, 7, 22, 23, 39, 24, 0, 7, 22, 23,
172 39, 1, 0, 7, 22, 1, 0, 7, 1, 0,
173 8, 22, 16, 0, 8, 22, 1, 0, 8, 1,
174 0, 6, 22, 20, 0, 6, 22, 1, 0, 6,
175 1, 0, 32, 0, 31, 32, 0, 1, 0, 54,
176 22, 20, 35, 0, 54, 22, 1, 0, 54, 1,
177 0, 34, 0, 33, 34, 0, 1, 0, 54, 22,
178 20, 35, 0, 54, 22, 1, 0, 54, 1, 0,
179 0, 25, 16, 0, 25, 1, 0, 37, 0, 36,
180 37, 0, 1, 0, 54, 22, 20, 57, 25, 18,
181 38, 0, 54, 22, 20, 57, 25, 1, 0, 54,
182 22, 20, 1, 0, 54, 22, 1, 0, 54, 1,
183 0, 0, 25, 20, 0, 25, 1, 0, 40, 0,
184 39, 40, 0, 1, 0, 41, 22, 20, 25, 20,
185 0, 41, 22, 20, 25, 1, 0, 41, 22, 20,
186 1, 0, 41, 22, 1, 0, 41, 1, 0, 20,
187 0, 21, 0, 0, 44, 46, 43, 50, 0, 15,
188 22, 45, 0, 15, 1, 0, 0, 20, 0, 26,
189 20, 0, 26, 1, 0, 0, 46, 48, 0, 46,
190 49, 0, 46, 47, 0, 10, 22, 16, 0, 10,
191 22, 1, 0, 10, 1, 0, 12, 22, 54, 0,
192 12, 22, 1, 0, 12, 1, 0, 13, 22, 54,
193 0, 13, 22, 1, 0, 13, 1, 0, 51, 0,
194 50, 51, 0, 1, 0, 52, 56, 53, 11, 0,
195 14, 55, 22, 54, 9, 0, 14, 55, 22, 54,
196 1, 0, 14, 55, 22, 1, 0, 14, 1, 0,
197 17, 0, 53, 17, 0, 1, 0, 53, 1, 0,
198 16, 0, 21, 0, 0, 0, 0
199 };
200
201 #endif
202
203 #if YYDEBUG != 0
204 static const short yyrline[] = { 0,
205 108, 115, 116, 119, 120, 121, 122, 125, 126, 127,
206 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
207 138, 139, 140, 141, 142, 143, 144, 156, 157, 163,
208 164, 165, 168, 175, 176, 182, 183, 184, 187, 194,
209 195, 198, 199, 200, 206, 207, 208, 211, 219, 220,
210 221, 222, 225, 226, 227, 233, 234, 235, 238, 248,
211 249, 250, 251, 254, 255, 265, 265, 268, 273, 276,
212 277, 278, 279, 282, 283, 284, 285, 288, 289, 290,
213 293, 301, 302, 305, 313, 314, 320, 321, 322, 325,
214 333, 362, 363, 364, 367, 368, 369, 370, 376, 377,
215 380, 383, 386
216 };
217 #endif
218
219
220 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
221
222 static const char * const yytname[] = { "$","error","$undefined.","tSEVNAMES",
223 "tFACNAMES","tLANNAMES","tBASE","tCODEPAGE","tTYPEDEF","tNL","tSYMNAME","tMSGEND",
224 "tSEVERITY","tFACILITY","tLANGUAGE","tMSGID","tIDENT","tLINE","tFILE","tCOMMENT",
225 "tNUMBER","tTOKEN","'='","'('","')'","':'","'+'","file","items","decl","global",
226 "smaps","smap","fmaps","fmap","alias","lmaps","lmap","optcp","cmaps","cmap",
227 "clan","msg","@1","msgid","id","sevfacsym","sym","sev","fac","bodies","body",
228 "lang","lines","token","setnl","setline","setfile", NULL
229 };
230 #endif
231
232 static const short yyr1[] = { 0,
233 27, 28, 28, 29, 29, 29, 29, 30, 30, 30,
234 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
235 30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
236 31, 31, 32, 32, 32, 33, 33, 33, 34, 34,
237 34, 35, 35, 35, 36, 36, 36, 37, 37, 37,
238 37, 37, 38, 38, 38, 39, 39, 39, 40, 40,
239 40, 40, 40, 41, 41, 43, 42, 44, 44, 45,
240 45, 45, 45, 46, 46, 46, 46, 47, 47, 47,
241 48, 48, 48, 49, 49, 49, 50, 50, 50, 51,
242 52, 52, 52, 52, 53, 53, 53, 53, 54, 54,
243 55, 56, 57
244 };
245
246 static const short yyr2[] = { 0,
247 1, 1, 2, 1, 1, 1, 1, 5, 5, 3,
248 2, 5, 5, 3, 2, 5, 5, 3, 2, 5,
249 5, 3, 2, 3, 3, 2, 3, 3, 2, 1,
250 2, 1, 4, 3, 2, 1, 2, 1, 4, 3,
251 2, 0, 2, 2, 1, 2, 1, 7, 6, 4,
252 3, 2, 0, 2, 2, 1, 2, 1, 5, 5,
253 4, 3, 2, 1, 1, 0, 4, 3, 2, 0,
254 1, 2, 2, 0, 2, 2, 2, 3, 3, 2,
255 3, 3, 2, 3, 3, 2, 1, 2, 1, 4,
256 5, 5, 4, 2, 1, 2, 1, 2, 1, 1,
257 0, 0, 0
258 };
259
260 static const short yydefact[] = { 0,
261 7, 0, 0, 0, 0, 0, 0, 0, 6, 0,
262 2, 4, 5, 74, 11, 0, 15, 0, 19, 0,
263 29, 0, 23, 0, 26, 0, 69, 70, 3, 66,
264 10, 0, 14, 0, 18, 0, 28, 27, 22, 0,
265 25, 24, 71, 0, 68, 0, 0, 0, 0, 77,
266 75, 76, 32, 99, 100, 0, 30, 0, 38, 0,
267 36, 0, 47, 0, 45, 0, 58, 64, 65, 0,
268 56, 0, 73, 72, 80, 0, 83, 0, 86, 0,
269 89, 0, 67, 87, 102, 9, 8, 31, 35, 0,
270 13, 12, 37, 41, 0, 17, 16, 46, 52, 0,
271 21, 20, 57, 63, 0, 79, 78, 82, 81, 85,
272 84, 94, 0, 88, 0, 34, 42, 40, 42, 51,
273 0, 62, 0, 0, 97, 95, 0, 0, 33, 39,
274 50, 0, 61, 0, 93, 0, 98, 90, 96, 44,
275 43, 0, 60, 59, 92, 91, 49, 53, 0, 48,
276 55, 54, 0, 0, 0
277 };
278
279 static const short yydefgoto[] = { 153,
280 10, 11, 12, 56, 57, 60, 61, 129, 64, 65,
281 150, 70, 71, 72, 13, 49, 14, 45, 30, 50,
282 51, 52, 83, 84, 85, 127, 58, 113, 115, 132
283 };
284
285 static const short yypact[] = { 132,
286 -32768, 18, 44, 46, 47, 48, 49, 50,-32768, 113,
287 -32768,-32768,-32768,-32768,-32768, 11,-32768, 14,-32768, 19,
288 -32768, 85,-32768, 20,-32768, 147,-32768, -13,-32768, 87,
289 -32768, 66,-32768, 80,-32768, 82,-32768,-32768,-32768, 64,
290 -32768,-32768,-32768, 107,-32768, 51, 52, 53, 3,-32768,
291 -32768,-32768,-32768,-32768,-32768, 7,-32768, 54,-32768, 8,
292 -32768, 55,-32768, 17,-32768, 56,-32768,-32768,-32768, 15,
293 -32768, 57,-32768,-32768,-32768, 148,-32768, 88,-32768, 90,
294 -32768, 58, -4,-32768,-32768,-32768,-32768,-32768,-32768, 109,
295 -32768,-32768,-32768,-32768, 114,-32768,-32768,-32768,-32768, 121,
296 -32768,-32768,-32768,-32768, 122,-32768,-32768,-32768,-32768,-32768,
297 -32768,-32768, -11,-32768, 129,-32768, 35,-32768, 35,-32768,
298 0,-32768, 2, 91,-32768,-32768, 144, 149,-32768,-32768,
299 -32768, 36,-32768, 123,-32768, 5,-32768,-32768,-32768,-32768,
300 -32768, 4,-32768,-32768,-32768,-32768,-32768, 37, 124,-32768,
301 -32768,-32768, 63, 93,-32768
302 };
303
304 static const short yypgoto[] = {-32768,
305 -32768, 78,-32768,-32768, 38,-32768, 42, -55,-32768, 31,
306 -32768,-32768, 61,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
307 -32768,-32768,-32768, 43,-32768,-32768, -34,-32768,-32768,-32768
308 };
309
310
311 #define YYLAST 165
312
313
314 static const short yytable[] = { 62,
315 131, 66, 133, 81, 147, 145, 43, 86, 91, 82,
316 124, 31, 44, 146, 33, 101, 82, 96, 15, 35,
317 39, 148, 54, 54, -103, 62, 134, 55, 55, 66,
318 87, 92, 54, 32, 68, 69, 34, 55, 102, 16,
319 97, 36, 40, 109, 17, 111, 19, 21, 23, 25,
320 27, 75, 77, 79, 89, 94, 99, 104, 112, 128,
321 142, 149, 154, 130, 67, 18, 53, 20, 22, 24,
322 26, 28, 76, 78, 80, 90, 95, 100, 105, -101,
323 59, 54, 63, 68, 69, 37, 55, 29, 108, 136,
324 110, 135, 155, 88, 98, 54, 46, 54, 47, 48,
325 55, 93, 55, 54, 38, 54, 54, 73, 55, 116,
326 55, 55, -1, 1, 118, 2, 3, 4, 5, 6,
327 7, 120, 122, 143, 151, 114, 74, 8, 117, 125,
328 103, 9, 1, 119, 2, 3, 4, 5, 6, 7,
329 121, 123, 144, 152, 137, 126, 8, 41, 106, 140,
330 9, 0, 0, 0, 138, 0, 0, 0, 0, 0,
331 139, 0, 42, 107, 141
332 };
333
334 static const short yycheck[] = { 34,
335 1, 36, 1, 1, 1, 1, 20, 1, 1, 14,
336 22, 1, 26, 9, 1, 1, 14, 1, 1, 1,
337 1, 18, 16, 16, 25, 60, 25, 21, 21, 64,
338 24, 24, 16, 23, 20, 21, 23, 21, 24, 22,
339 24, 23, 23, 78, 1, 80, 1, 1, 1, 1,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 25,
341 25, 25, 0, 119, 1, 22, 1, 22, 22, 22,
342 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
343 1, 16, 1, 20, 21, 1, 21, 10, 1, 124,
344 1, 1, 0, 56, 64, 16, 10, 16, 12, 13,
345 21, 60, 21, 16, 20, 16, 16, 1, 21, 1,
346 21, 21, 0, 1, 1, 3, 4, 5, 6, 7,
347 8, 1, 1, 1, 1, 83, 20, 15, 20, 1,
348 70, 19, 1, 20, 3, 4, 5, 6, 7, 8,
349 20, 20, 20, 20, 1, 17, 15, 1, 1, 1,
350 19, -1, -1, -1, 11, -1, -1, -1, -1, -1,
351 17, -1, 16, 16, 16
352 };
353 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
354 #line 3 "/usr/share/bison.simple"
355
356 /* Skeleton output parser for bison,
357 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
358
359 This program is free software; you can redistribute it and/or modify
360 it under the terms of the GNU General Public License as published by
361 the Free Software Foundation; either version 2, or (at your option)
362 any later version.
363
364 This program is distributed in the hope that it will be useful,
365 but WITHOUT ANY WARRANTY; without even the implied warranty of
366 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
367 GNU General Public License for more details.
368
369 You should have received a copy of the GNU General Public License
370 along with this program; if not, write to the Free Software
371 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
372
373 /* As a special exception, when this file is copied by Bison into a
374 Bison output file, you may use that output file without restriction.
375 This special exception was added by the Free Software Foundation
376 in version 1.24 of Bison. */
377
378 #ifndef alloca
379 #ifdef __GNUC__
380 #define alloca __builtin_alloca
381 #else /* not GNU C. */
382 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
383 #include <alloca.h>
384 #else /* not sparc */
385 #if defined (MSDOS) && !defined (__TURBOC__)
386 #include <malloc.h>
387 #else /* not MSDOS, or __TURBOC__ */
388 #if defined(_AIX)
389 #include <malloc.h>
390 #pragma alloca
391 #else /* not MSDOS, __TURBOC__, or _AIX */
392 #ifdef __hpux
393 #ifdef __cplusplus
394 extern "C" {
395 void *alloca (unsigned int);
396 };
397 #else /* not __cplusplus */
398 void *alloca ();
399 #endif /* not __cplusplus */
400 #endif /* __hpux */
401 #endif /* not _AIX */
402 #endif /* not MSDOS, or __TURBOC__ */
403 #endif /* not sparc. */
404 #endif /* not GNU C. */
405 #endif /* alloca not defined. */
406
407 /* This is the parser code that is written into each bison parser
408 when the %semantic_parser declaration is not specified in the grammar.
409 It was written by Richard Stallman by simplifying the hairy parser
410 used when %semantic_parser is specified. */
411
412 /* Note: there must be only one dollar sign in this file.
413 It is replaced by the list of actions, each action
414 as one case of the switch. */
415
416 #define yyerrok (yyerrstatus = 0)
417 #define yyclearin (yychar = YYEMPTY)
418 #define YYEMPTY -2
419 #define YYEOF 0
420 #define YYACCEPT return(0)
421 #define YYABORT return(1)
422 #define YYERROR goto yyerrlab1
423 /* Like YYERROR except do call yyerror.
424 This remains here temporarily to ease the
425 transition to the new meaning of YYERROR, for GCC.
426 Once GCC version 2 has supplanted version 1, this can go. */
427 #define YYFAIL goto yyerrlab
428 #define YYRECOVERING() (!!yyerrstatus)
429 #define YYBACKUP(token, value) \
430 do \
431 if (yychar == YYEMPTY && yylen == 1) \
432 { yychar = (token), yylval = (value); \
433 yychar1 = YYTRANSLATE (yychar); \
434 YYPOPSTACK; \
435 goto yybackup; \
436 } \
437 else \
438 { yyerror ("syntax error: cannot back up"); YYERROR; } \
439 while (0)
440
441 #define YYTERROR 1
442 #define YYERRCODE 256
443
444 #ifndef YYPURE
445 #define YYLEX yylex()
446 #endif
447
448 #ifdef YYPURE
449 #ifdef YYLSP_NEEDED
450 #ifdef YYLEX_PARAM
451 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
452 #else
453 #define YYLEX yylex(&yylval, &yylloc)
454 #endif
455 #else /* not YYLSP_NEEDED */
456 #ifdef YYLEX_PARAM
457 #define YYLEX yylex(&yylval, YYLEX_PARAM)
458 #else
459 #define YYLEX yylex(&yylval)
460 #endif
461 #endif /* not YYLSP_NEEDED */
462 #endif
463
464 /* If nonreentrant, generate the variables here */
465
466 #ifndef YYPURE
467
468 int yychar; /* the lookahead symbol */
469 YYSTYPE yylval; /* the semantic value of the */
470 /* lookahead symbol */
471
472 #ifdef YYLSP_NEEDED
473 YYLTYPE yylloc; /* location data for the lookahead */
474 /* symbol */
475 #endif
476
477 int yynerrs; /* number of parse errors so far */
478 #endif /* not YYPURE */
479
480 #if YYDEBUG != 0
481 int yydebug; /* nonzero means print parse trace */
482 /* Since this is uninitialized, it does not stop multiple parsers
483 from coexisting. */
484 #endif
485
486 /* YYINITDEPTH indicates the initial size of the parser's stacks */
487
488 #ifndef YYINITDEPTH
489 #define YYINITDEPTH 200
490 #endif
491
492 /* YYMAXDEPTH is the maximum size the stacks can grow to
493 (effective only if the built-in stack extension method is used). */
494
495 #if YYMAXDEPTH == 0
496 #undef YYMAXDEPTH
497 #endif
498
499 #ifndef YYMAXDEPTH
500 #define YYMAXDEPTH 10000
501 #endif
502
503 #ifndef YYPARSE_RETURN_TYPE
504 #define YYPARSE_RETURN_TYPE int
505 #endif
506
507 /* Prevent warning if -Wstrict-prototypes. */
508 #ifdef __GNUC__
509 YYPARSE_RETURN_TYPE yyparse (void);
510 #endif
511 \f
512 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
513 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
514 #else /* not GNU C or C++ */
515 #ifndef __cplusplus
516
517 /* This is the most reliable way to avoid incompatibilities
518 in available built-in functions on various systems. */
519 static void
520 __yy_memcpy (to, from, count)
521 char *to;
522 char *from;
523 int count;
524 {
525 register char *f = from;
526 register char *t = to;
527 register int i = count;
528
529 while (i-- > 0)
530 *t++ = *f++;
531 }
532
533 #else /* __cplusplus */
534
535 /* This is the most reliable way to avoid incompatibilities
536 in available built-in functions on various systems. */
537 static void
538 __yy_memcpy (char *to, char *from, int count)
539 {
540 register char *f = from;
541 register char *t = to;
542 register int i = count;
543
544 while (i-- > 0)
545 *t++ = *f++;
546 }
547
548 #endif
549 #endif
550 \f
551 #line 196 "/usr/share/bison.simple"
552
553 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
554 into yyparse. The argument should have type void *.
555 It should actually point to an object.
556 Grammar actions can access the variable by casting it
557 to the proper pointer type. */
558
559 #ifdef YYPARSE_PARAM
560 #ifdef __cplusplus
561 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
562 #define YYPARSE_PARAM_DECL
563 #else /* not __cplusplus */
564 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
565 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
566 #endif /* not __cplusplus */
567 #else /* not YYPARSE_PARAM */
568 #define YYPARSE_PARAM_ARG
569 #define YYPARSE_PARAM_DECL
570 #endif /* not YYPARSE_PARAM */
571
572 YYPARSE_RETURN_TYPE
573 yyparse(YYPARSE_PARAM_ARG)
574 YYPARSE_PARAM_DECL
575 {
576 register int yystate;
577 register int yyn;
578 register short *yyssp;
579 register YYSTYPE *yyvsp;
580 int yyerrstatus; /* number of tokens to shift before error messages enabled */
581 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
582
583 short yyssa[YYINITDEPTH]; /* the state stack */
584 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
585
586 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
587 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
588
589 #ifdef YYLSP_NEEDED
590 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
591 YYLTYPE *yyls = yylsa;
592 YYLTYPE *yylsp;
593
594 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
595 #else
596 #define YYPOPSTACK (yyvsp--, yyssp--)
597 #endif
598
599 int yystacksize = YYINITDEPTH;
600
601 #ifdef YYPURE
602 int yychar;
603 YYSTYPE yylval;
604 int yynerrs;
605 #ifdef YYLSP_NEEDED
606 YYLTYPE yylloc;
607 #endif
608 #endif
609
610 YYSTYPE yyval; /* the variable used to return */
611 /* semantic values from the action */
612 /* routines */
613
614 int yylen;
615
616 #if YYDEBUG != 0
617 if (yydebug)
618 fprintf(stderr, "Starting parse\n");
619 #endif
620
621 yystate = 0;
622 yyerrstatus = 0;
623 yynerrs = 0;
624 yychar = YYEMPTY; /* Cause a token to be read. */
625
626 /* Initialize stack pointers.
627 Waste one element of value and location stack
628 so that they stay on the same level as the state stack.
629 The wasted elements are never initialized. */
630
631 yyssp = yyss - 1;
632 yyvsp = yyvs;
633 #ifdef YYLSP_NEEDED
634 yylsp = yyls;
635 #endif
636
637 /* Push a new state, which is found in yystate . */
638 /* In all cases, when you get here, the value and location stacks
639 have just been pushed. so pushing a state here evens the stacks. */
640 yynewstate:
641
642 *++yyssp = yystate;
643
644 if (yyssp >= yyss + yystacksize - 1)
645 {
646 /* Give user a chance to reallocate the stack */
647 /* Use copies of these so that the &'s don't force the real ones into memory. */
648 YYSTYPE *yyvs1 = yyvs;
649 short *yyss1 = yyss;
650 #ifdef YYLSP_NEEDED
651 YYLTYPE *yyls1 = yyls;
652 #endif
653
654 /* Get the current used size of the three stacks, in elements. */
655 int size = yyssp - yyss + 1;
656
657 #ifdef yyoverflow
658 /* Each stack pointer address is followed by the size of
659 the data in use in that stack, in bytes. */
660 #ifdef YYLSP_NEEDED
661 /* This used to be a conditional around just the two extra args,
662 but that might be undefined if yyoverflow is a macro. */
663 yyoverflow("parser stack overflow",
664 &yyss1, size * sizeof (*yyssp),
665 &yyvs1, size * sizeof (*yyvsp),
666 &yyls1, size * sizeof (*yylsp),
667 &yystacksize);
668 #else
669 yyoverflow("parser stack overflow",
670 &yyss1, size * sizeof (*yyssp),
671 &yyvs1, size * sizeof (*yyvsp),
672 &yystacksize);
673 #endif
674
675 yyss = yyss1; yyvs = yyvs1;
676 #ifdef YYLSP_NEEDED
677 yyls = yyls1;
678 #endif
679 #else /* no yyoverflow */
680 /* Extend the stack our own way. */
681 if (yystacksize >= YYMAXDEPTH)
682 {
683 yyerror("parser stack overflow");
684 return 2;
685 }
686 yystacksize *= 2;
687 if (yystacksize > YYMAXDEPTH)
688 yystacksize = YYMAXDEPTH;
689 yyss = (short *) _alloca (yystacksize * sizeof (*yyssp));
690 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
691 yyvs = (YYSTYPE *) _alloca (yystacksize * sizeof (*yyvsp));
692 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
693 #ifdef YYLSP_NEEDED
694 yyls = (YYLTYPE *) _alloca (yystacksize * sizeof (*yylsp));
695 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
696 #endif
697 #endif /* no yyoverflow */
698
699 yyssp = yyss + size - 1;
700 yyvsp = yyvs + size - 1;
701 #ifdef YYLSP_NEEDED
702 yylsp = yyls + size - 1;
703 #endif
704
705 #if YYDEBUG != 0
706 if (yydebug)
707 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
708 #endif
709
710 if (yyssp >= yyss + yystacksize - 1)
711 YYABORT;
712 }
713
714 #if YYDEBUG != 0
715 if (yydebug)
716 fprintf(stderr, "Entering state %d\n", yystate);
717 #endif
718
719 goto yybackup;
720 yybackup:
721
722 /* Do appropriate processing given the current state. */
723 /* Read a lookahead token if we need one and don't already have one. */
724 /* yyresume: */
725
726 /* First try to decide what to do without reference to lookahead token. */
727
728 yyn = yypact[yystate];
729 if (yyn == YYFLAG)
730 goto yydefault;
731
732 /* Not known => get a lookahead token if don't already have one. */
733
734 /* yychar is either YYEMPTY or YYEOF
735 or a valid token in external form. */
736
737 if (yychar == YYEMPTY)
738 {
739 #if YYDEBUG != 0
740 if (yydebug)
741 fprintf(stderr, "Reading a token: ");
742 #endif
743 yychar = YYLEX;
744 }
745
746 /* Convert token to internal form (in yychar1) for indexing tables with */
747
748 if (yychar <= 0) /* This means end of input. */
749 {
750 yychar1 = 0;
751 yychar = YYEOF; /* Don't call YYLEX any more */
752
753 #if YYDEBUG != 0
754 if (yydebug)
755 fprintf(stderr, "Now at end of input.\n");
756 #endif
757 }
758 else
759 {
760 yychar1 = YYTRANSLATE(yychar);
761
762 #if YYDEBUG != 0
763 if (yydebug)
764 {
765 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
766 /* Give the individual parser a way to print the precise meaning
767 of a token, for further debugging info. */
768 #ifdef YYPRINT
769 YYPRINT (stderr, yychar, yylval);
770 #endif
771 fprintf (stderr, ")\n");
772 }
773 #endif
774 }
775
776 yyn += yychar1;
777 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
778 goto yydefault;
779
780 yyn = yytable[yyn];
781
782 /* yyn is what to do for this token type in this state.
783 Negative => reduce, -yyn is rule number.
784 Positive => shift, yyn is new state.
785 New state is final state => don't bother to shift,
786 just return success.
787 0, or most negative number => error. */
788
789 if (yyn < 0)
790 {
791 if (yyn == YYFLAG)
792 goto yyerrlab;
793 yyn = -yyn;
794 goto yyreduce;
795 }
796 else if (yyn == 0)
797 goto yyerrlab;
798
799 if (yyn == YYFINAL)
800 YYACCEPT;
801
802 /* Shift the lookahead token. */
803
804 #if YYDEBUG != 0
805 if (yydebug)
806 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
807 #endif
808
809 /* Discard the token being shifted unless it is eof. */
810 if (yychar != YYEOF)
811 yychar = YYEMPTY;
812
813 *++yyvsp = yylval;
814 #ifdef YYLSP_NEEDED
815 *++yylsp = yylloc;
816 #endif
817
818 /* count tokens shifted since error; after three, turn off error status. */
819 if (yyerrstatus) yyerrstatus--;
820
821 yystate = yyn;
822 goto yynewstate;
823
824 /* Do the default action for the current state. */
825 yydefault:
826
827 yyn = yydefact[yystate];
828 if (yyn == 0)
829 goto yyerrlab;
830
831 /* Do a reduction. yyn is the number of a rule to reduce with. */
832 yyreduce:
833 yylen = yyr2[yyn];
834 if (yylen > 0)
835 yyval = yyvsp[1-yylen]; /* implement default value of the action */
836
837 #if YYDEBUG != 0
838 if (yydebug)
839 {
840 int i;
841
842 fprintf (stderr, "Reducing via rule %d (line %d), ",
843 yyn, yyrline[yyn]);
844
845 /* Print the symbols being reduced, and their result. */
846 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
847 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
848 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
849 }
850 #endif
851
852
853 switch (yyn) {
854
855 case 1:
856 #line 108 "./mcy.y"
857 {
858 if(!check_languages(nodehead))
859 xyyerror("No messages defined");
860 lanblockhead = block_messages(nodehead);
861 ;
862 break;}
863 case 5:
864 #line 120 "./mcy.y"
865 { add_node(nd_msg, yyvsp[0].msg); ;
866 break;}
867 case 6:
868 #line 121 "./mcy.y"
869 { add_node(nd_comment, yyvsp[0].str); ;
870 break;}
871 case 7:
872 #line 122 "./mcy.y"
873 { xyyerror(err_syntax); /* `Catch all' error */ ;
874 break;}
875 case 9:
876 #line 126 "./mcy.y"
877 { xyyerror(err_pclose); ;
878 break;}
879 case 10:
880 #line 127 "./mcy.y"
881 { xyyerror(err_popen); ;
882 break;}
883 case 11:
884 #line 128 "./mcy.y"
885 { xyyerror(err_assign); ;
886 break;}
887 case 13:
888 #line 130 "./mcy.y"
889 { xyyerror(err_pclose); ;
890 break;}
891 case 14:
892 #line 131 "./mcy.y"
893 { xyyerror(err_popen); ;
894 break;}
895 case 15:
896 #line 132 "./mcy.y"
897 { xyyerror(err_assign); ;
898 break;}
899 case 17:
900 #line 134 "./mcy.y"
901 { xyyerror(err_pclose); ;
902 break;}
903 case 18:
904 #line 135 "./mcy.y"
905 { xyyerror(err_popen); ;
906 break;}
907 case 19:
908 #line 136 "./mcy.y"
909 { xyyerror(err_assign); ;
910 break;}
911 case 21:
912 #line 138 "./mcy.y"
913 { xyyerror(err_pclose); ;
914 break;}
915 case 22:
916 #line 139 "./mcy.y"
917 { xyyerror(err_popen); ;
918 break;}
919 case 23:
920 #line 140 "./mcy.y"
921 { xyyerror(err_assign); ;
922 break;}
923 case 24:
924 #line 141 "./mcy.y"
925 { cast = yyvsp[0].str; ;
926 break;}
927 case 25:
928 #line 142 "./mcy.y"
929 { xyyerror(err_number); ;
930 break;}
931 case 26:
932 #line 143 "./mcy.y"
933 { xyyerror(err_assign); ;
934 break;}
935 case 27:
936 #line 144 "./mcy.y"
937 {
938 switch(base)
939 {
940 case 8:
941 case 10:
942 case 16:
943 base = yyvsp[0].num;
944 break;
945 default:
946 xyyerror("Numberbase must be 8, 10 or 16");
947 }
948 ;
949 break;}
950 case 28:
951 #line 156 "./mcy.y"
952 { xyyerror(err_number); ;
953 break;}
954 case 29:
955 #line 157 "./mcy.y"
956 { xyyerror(err_assign); ;
957 break;}
958 case 32:
959 #line 165 "./mcy.y"
960 { xyyerror(err_ident); ;
961 break;}
962 case 33:
963 #line 168 "./mcy.y"
964 {
965 yyvsp[-3].tok->token = yyvsp[-1].num;
966 yyvsp[-3].tok->alias = yyvsp[0].str;
967 if(yyvsp[-1].num & (~0x3))
968 xyyerror("Severity value out of range (0x%08x > 0x3)", yyvsp[-1].num);
969 do_add_token(tok_severity, yyvsp[-3].tok, "severity");
970 ;
971 break;}
972 case 34:
973 #line 175 "./mcy.y"
974 { xyyerror(err_number); ;
975 break;}
976 case 35:
977 #line 176 "./mcy.y"
978 { xyyerror(err_assign); ;
979 break;}
980 case 38:
981 #line 184 "./mcy.y"
982 { xyyerror(err_ident); ;
983 break;}
984 case 39:
985 #line 187 "./mcy.y"
986 {
987 yyvsp[-3].tok->token = yyvsp[-1].num;
988 yyvsp[-3].tok->alias = yyvsp[0].str;
989 if(yyvsp[-1].num & (~0xfff))
990 xyyerror("Facility value out of range (0x%08x > 0xfff)", yyvsp[-1].num);
991 do_add_token(tok_facility, yyvsp[-3].tok, "facility");
992 ;
993 break;}
994 case 40:
995 #line 194 "./mcy.y"
996 { xyyerror(err_number); ;
997 break;}
998 case 41:
999 #line 195 "./mcy.y"
1000 { xyyerror(err_assign); ;
1001 break;}
1002 case 42:
1003 #line 198 "./mcy.y"
1004 { yyval.str = NULL; ;
1005 break;}
1006 case 43:
1007 #line 199 "./mcy.y"
1008 { yyval.str = yyvsp[0].str; ;
1009 break;}
1010 case 44:
1011 #line 200 "./mcy.y"
1012 { xyyerror(err_ident); ;
1013 break;}
1014 case 47:
1015 #line 208 "./mcy.y"
1016 { xyyerror(err_ident); ;
1017 break;}
1018 case 48:
1019 #line 211 "./mcy.y"
1020 {
1021 yyvsp[-6].tok->token = yyvsp[-4].num;
1022 yyvsp[-6].tok->alias = yyvsp[-1].str;
1023 yyvsp[-6].tok->codepage = yyvsp[0].num;
1024 do_add_token(tok_language, yyvsp[-6].tok, "language");
1025 if(!find_language(yyvsp[-6].tok->token) && !find_cpxlat(yyvsp[-6].tok->token))
1026 yywarning("Language 0x%x not built-in, using codepage %d; use explicit codepage to override", yyvsp[-6].tok->token, WMC_DEFAULT_CODEPAGE);
1027 ;
1028 break;}
1029 case 49:
1030 #line 219 "./mcy.y"
1031 { xyyerror("Filename expected"); ;
1032 break;}
1033 case 50:
1034 #line 220 "./mcy.y"
1035 { xyyerror(err_colon); ;
1036 break;}
1037 case 51:
1038 #line 221 "./mcy.y"
1039 { xyyerror(err_number); ;
1040 break;}
1041 case 52:
1042 #line 222 "./mcy.y"
1043 { xyyerror(err_assign); ;
1044 break;}
1045 case 53:
1046 #line 225 "./mcy.y"
1047 { yyval.num = 0; ;
1048 break;}
1049 case 54:
1050 #line 226 "./mcy.y"
1051 { yyval.num = yyvsp[0].num; ;
1052 break;}
1053 case 55:
1054 #line 227 "./mcy.y"
1055 { xyyerror("Codepage-number expected"); ;
1056 break;}
1057 case 58:
1058 #line 235 "./mcy.y"
1059 { xyyerror(err_ident); ;
1060 break;}
1061 case 59:
1062 #line 238 "./mcy.y"
1063 {
1064 static const char err_nocp[] = "Codepage %d not builtin; cannot convert";
1065 if(find_cpxlat(yyvsp[-4].num))
1066 xyyerror("Codepage translation already defined for language 0x%x", yyvsp[-4].num);
1067 // if(yyvsp[-2].num && !find_codepage(yyvsp[-2].num))
1068 if(yyvsp[-2].num)
1069 xyyerror(err_nocp, yyvsp[-2].num);
1070 // if(yyvsp[0].num && !find_codepage(yyvsp[0].num))
1071 if(yyvsp[0].num)
1072 xyyerror(err_nocp, yyvsp[0].num);
1073 add_cpxlat(yyvsp[-4].num, yyvsp[-2].num, yyvsp[0].num);
1074 ;
1075 break;}
1076 case 60:
1077 #line 248 "./mcy.y"
1078 { xyyerror(err_number); ;
1079 break;}
1080 case 61:
1081 #line 249 "./mcy.y"
1082 { xyyerror(err_colon); ;
1083 break;}
1084 case 62:
1085 #line 250 "./mcy.y"
1086 { xyyerror(err_number); ;
1087 break;}
1088 case 63:
1089 #line 251 "./mcy.y"
1090 { xyyerror(err_assign); ;
1091 break;}
1092 case 64:
1093 #line 254 "./mcy.y"
1094 { yyval.num = yyvsp[0].num; ;
1095 break;}
1096 case 65:
1097 #line 255 "./mcy.y"
1098 {
1099 if(yyvsp[0].tok->type != tok_language)
1100 xyyerror("Language name or code expected");
1101 yyval.num = yyvsp[0].tok->token;
1102 ;
1103 break;}
1104 case 66:
1105 #line 265 "./mcy.y"
1106 { test_id(yyvsp[-1].num); ;
1107 break;}
1108 case 67:
1109 #line 265 "./mcy.y"
1110 { yyval.msg = complete_msg(yyvsp[0].msg, yyvsp[-3].num); ;
1111 break;}
1112 case 68:
1113 #line 268 "./mcy.y"
1114 {
1115 if(yyvsp[0].num & (~0xffff))
1116 xyyerror("Message ID value out of range (0x%08x > 0xffff)", yyvsp[0].num);
1117 yyval.num = yyvsp[0].num;
1118 ;
1119 break;}
1120 case 69:
1121 #line 273 "./mcy.y"
1122 { xyyerror(err_assign); ;
1123 break;}
1124 case 70:
1125 #line 276 "./mcy.y"
1126 { yyval.num = ++last_id; ;
1127 break;}
1128 case 71:
1129 #line 277 "./mcy.y"
1130 { yyval.num = last_id = yyvsp[0].num; ;
1131 break;}
1132 case 72:
1133 #line 278 "./mcy.y"
1134 { yyval.num = last_id += yyvsp[0].num; ;
1135 break;}
1136 case 73:
1137 #line 279 "./mcy.y"
1138 { xyyerror(err_number); ;
1139 break;}
1140 case 74:
1141 #line 282 "./mcy.y"
1142 { have_sev = have_fac = have_sym = 0; ;
1143 break;}
1144 case 75:
1145 #line 283 "./mcy.y"
1146 { if(have_sev) xyyerror("Severity already defined"); have_sev = 1; ;
1147 break;}
1148 case 76:
1149 #line 284 "./mcy.y"
1150 { if(have_fac) xyyerror("Facility already defined"); have_fac = 1; ;
1151 break;}
1152 case 77:
1153 #line 285 "./mcy.y"
1154 { if(have_sym) xyyerror("Symbolname already defined"); have_sym = 1; ;
1155 break;}
1156 case 78:
1157 #line 288 "./mcy.y"
1158 { last_sym = yyvsp[0].str; ;
1159 break;}
1160 case 79:
1161 #line 289 "./mcy.y"
1162 { xyyerror(err_ident); ;
1163 break;}
1164 case 80:
1165 #line 290 "./mcy.y"
1166 { xyyerror(err_assign); ;
1167 break;}
1168 case 81:
1169 #line 293 "./mcy.y"
1170 {
1171 token_t *tok = lookup_token(yyvsp[0].tok->name);
1172 if(!tok)
1173 xyyerror("Undefined severityname");
1174 if(tok->type != tok_severity)
1175 xyyerror("Identifier is not of class 'severity'");
1176 last_sev = tok->token;
1177 ;
1178 break;}
1179 case 82:
1180 #line 301 "./mcy.y"
1181 { xyyerror(err_ident); ;
1182 break;}
1183 case 83:
1184 #line 302 "./mcy.y"
1185 { xyyerror(err_assign); ;
1186 break;}
1187 case 84:
1188 #line 305 "./mcy.y"
1189 {
1190 token_t *tok = lookup_token(yyvsp[0].tok->name);
1191 if(!tok)
1192 xyyerror("Undefined facilityname");
1193 if(tok->type != tok_facility)
1194 xyyerror("Identifier is not of class 'facility'");
1195 last_fac = tok->token;
1196 ;
1197 break;}
1198 case 85:
1199 #line 313 "./mcy.y"
1200 { xyyerror(err_ident); ;
1201 break;}
1202 case 86:
1203 #line 314 "./mcy.y"
1204 { xyyerror(err_assign); ;
1205 break;}
1206 case 87:
1207 #line 320 "./mcy.y"
1208 { yyval.msg = add_lanmsg(NULL, yyvsp[0].lmp); ;
1209 break;}
1210 case 88:
1211 #line 321 "./mcy.y"
1212 { yyval.msg = add_lanmsg(yyvsp[-1].msg, yyvsp[0].lmp); ;
1213 break;}
1214 case 89:
1215 #line 322 "./mcy.y"
1216 { xyyerror("'Language=...' (start of message text-definition) expected"); ;
1217 break;}
1218 case 90:
1219 #line 325 "./mcy.y"
1220 { yyval.lmp = new_lanmsg(&yyvsp[-3].lcp, yyvsp[-1].str); ;
1221 break;}
1222 case 91:
1223 #line 333 "./mcy.y"
1224 {
1225 token_t *tok = lookup_token(yyvsp[-1].tok->name);
1226 cp_xlat_t *cpx;
1227 if(!tok)
1228 xyyerror("Undefined language");
1229 if(tok->type != tok_language)
1230 xyyerror("Identifier is not of class 'language'");
1231 if((cpx = find_cpxlat(tok->token)))
1232 {
1233 set_codepage(yyval.lcp.codepage = cpx->cpin);
1234 }
1235 else if(!tok->codepage)
1236 {
1237 const language_t *lan = find_language(tok->token);
1238 if(!lan)
1239 {
1240 /* Just set default; warning was given while parsing languagenames */
1241 set_codepage(yyval.lcp.codepage = WMC_DEFAULT_CODEPAGE);
1242 }
1243 else
1244 {
1245 /* The default seems to be to use the DOS codepage... */
1246 set_codepage(yyval.lcp.codepage = lan->doscp);
1247 }
1248 }
1249 else
1250 set_codepage(yyval.lcp.codepage = tok->codepage);
1251 yyval.lcp.language = tok->token;
1252 ;
1253 break;}
1254 case 92:
1255 #line 362 "./mcy.y"
1256 { xyyerror("Missing newline"); ;
1257 break;}
1258 case 93:
1259 #line 363 "./mcy.y"
1260 { xyyerror(err_ident); ;
1261 break;}
1262 case 94:
1263 #line 364 "./mcy.y"
1264 { xyyerror(err_assign); ;
1265 break;}
1266 case 95:
1267 #line 367 "./mcy.y"
1268 { yyval.str = yyvsp[0].str; ;
1269 break;}
1270 case 96:
1271 #line 368 "./mcy.y"
1272 { yyval.str = merge(yyvsp[-1].str, yyvsp[0].str); ;
1273 break;}
1274 case 97:
1275 #line 369 "./mcy.y"
1276 { xyyerror(err_msg); ;
1277 break;}
1278 case 98:
1279 #line 370 "./mcy.y"
1280 { xyyerror(err_msg); ;
1281 break;}
1282 case 99:
1283 #line 376 "./mcy.y"
1284 { yyval.tok = xmalloc(sizeof(token_t)); yyval.tok->name = yyvsp[0].str; ;
1285 break;}
1286 case 100:
1287 #line 377 "./mcy.y"
1288 { yyval.tok = yyvsp[0].tok; ;
1289 break;}
1290 case 101:
1291 #line 380 "./mcy.y"
1292 { want_nl = 1; ;
1293 break;}
1294 case 102:
1295 #line 383 "./mcy.y"
1296 { want_line = 1; ;
1297 break;}
1298 case 103:
1299 #line 386 "./mcy.y"
1300 { want_file = 1; ;
1301 break;}
1302 }
1303 /* the action file gets copied in in place of this dollarsign */
1304 #line 498 "/usr/share/bison.simple"
1305
1306 yyvsp -= yylen;
1307 yyssp -= yylen;
1308 #ifdef YYLSP_NEEDED
1309 yylsp -= yylen;
1310 #endif
1311
1312 #if YYDEBUG != 0
1313 if (yydebug)
1314 {
1315 short *ssp1 = yyss - 1;
1316 fprintf (stderr, "state stack now");
1317 while (ssp1 != yyssp)
1318 fprintf (stderr, " %d", *++ssp1);
1319 fprintf (stderr, "\n");
1320 }
1321 #endif
1322
1323 *++yyvsp = yyval;
1324
1325 #ifdef YYLSP_NEEDED
1326 yylsp++;
1327 if (yylen == 0)
1328 {
1329 yylsp->first_line = yylloc.first_line;
1330 yylsp->first_column = yylloc.first_column;
1331 yylsp->last_line = (yylsp-1)->last_line;
1332 yylsp->last_column = (yylsp-1)->last_column;
1333 yylsp->text = 0;
1334 }
1335 else
1336 {
1337 yylsp->last_line = (yylsp+yylen-1)->last_line;
1338 yylsp->last_column = (yylsp+yylen-1)->last_column;
1339 }
1340 #endif
1341
1342 /* Now "shift" the result of the reduction.
1343 Determine what state that goes to,
1344 based on the state we popped back to
1345 and the rule number reduced by. */
1346
1347 yyn = yyr1[yyn];
1348
1349 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1350 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1351 yystate = yytable[yystate];
1352 else
1353 yystate = yydefgoto[yyn - YYNTBASE];
1354
1355 goto yynewstate;
1356
1357 yyerrlab: /* here on detecting error */
1358
1359 if (! yyerrstatus)
1360 /* If not already recovering from an error, report this error. */
1361 {
1362 ++yynerrs;
1363
1364 #ifdef YYERROR_VERBOSE
1365 yyn = yypact[yystate];
1366
1367 if (yyn > YYFLAG && yyn < YYLAST)
1368 {
1369 int size = 0;
1370 char *msg;
1371 int x, count;
1372
1373 count = 0;
1374 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1375 for (x = (yyn < 0 ? -yyn : 0);
1376 x < (sizeof(yytname) / sizeof(char *)); x++)
1377 if (yycheck[x + yyn] == x)
1378 size += strlen(yytname[x]) + 15, count++;
1379 msg = (char *) malloc(size + 15);
1380 if (msg != 0)
1381 {
1382 strcpy(msg, "parse error");
1383
1384 if (count < 5)
1385 {
1386 count = 0;
1387 for (x = (yyn < 0 ? -yyn : 0);
1388 x < (sizeof(yytname) / sizeof(char *)); x++)
1389 if (yycheck[x + yyn] == x)
1390 {
1391 strcat(msg, count == 0 ? ", expecting `" : " or `");
1392 strcat(msg, yytname[x]);
1393 strcat(msg, "'");
1394 count++;
1395 }
1396 }
1397 yyerror(msg);
1398 free(msg);
1399 }
1400 else
1401 yyerror ("parse error; also virtual memory exceeded");
1402 }
1403 else
1404 #endif /* YYERROR_VERBOSE */
1405 yyerror("parse error");
1406 }
1407
1408 goto yyerrlab1;
1409 yyerrlab1: /* here on error raised explicitly by an action */
1410
1411 if (yyerrstatus == 3)
1412 {
1413 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1414
1415 /* return failure if at end of input */
1416 if (yychar == YYEOF)
1417 YYABORT;
1418
1419 #if YYDEBUG != 0
1420 if (yydebug)
1421 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1422 #endif
1423
1424 yychar = YYEMPTY;
1425 }
1426
1427 /* Else will try to reuse lookahead token
1428 after shifting the error token. */
1429
1430 yyerrstatus = 3; /* Each real token shifted decrements this */
1431
1432 goto yyerrhandle;
1433
1434 yyerrdefault: /* current state does not do anything special for the error token. */
1435
1436 #if 0
1437 /* This is wrong; only states that explicitly want error tokens
1438 should shift them. */
1439 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1440 if (yyn) goto yydefault;
1441 #endif
1442
1443 yyerrpop: /* pop the current state because it cannot handle the error token */
1444
1445 if (yyssp == yyss) YYABORT;
1446 yyvsp--;
1447 yystate = *--yyssp;
1448 #ifdef YYLSP_NEEDED
1449 yylsp--;
1450 #endif
1451
1452 #if YYDEBUG != 0
1453 if (yydebug)
1454 {
1455 short *ssp1 = yyss - 1;
1456 fprintf (stderr, "Error: state stack now");
1457 while (ssp1 != yyssp)
1458 fprintf (stderr, " %d", *++ssp1);
1459 fprintf (stderr, "\n");
1460 }
1461 #endif
1462
1463 yyerrhandle:
1464
1465 yyn = yypact[yystate];
1466 if (yyn == YYFLAG)
1467 goto yyerrdefault;
1468
1469 yyn += YYTERROR;
1470 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1471 goto yyerrdefault;
1472
1473 yyn = yytable[yyn];
1474 if (yyn < 0)
1475 {
1476 if (yyn == YYFLAG)
1477 goto yyerrpop;
1478 yyn = -yyn;
1479 goto yyreduce;
1480 }
1481 else if (yyn == 0)
1482 goto yyerrpop;
1483
1484 if (yyn == YYFINAL)
1485 YYACCEPT;
1486
1487 #if YYDEBUG != 0
1488 if (yydebug)
1489 fprintf(stderr, "Shifting error token, ");
1490 #endif
1491
1492 *++yyvsp = yylval;
1493 #ifdef YYLSP_NEEDED
1494 *++yylsp = yylloc;
1495 #endif
1496
1497 yystate = yyn;
1498 goto yynewstate;
1499 }
1500 #line 389 "./mcy.y"
1501
1502
1503 static WCHAR *merge(WCHAR *s1, WCHAR *s2)
1504 {
1505 int l1 = unistrlen(s1);
1506 int l2 = unistrlen(s2);
1507 s1 = xrealloc(s1, (l1 + l2 + 1) * sizeof(*s1));
1508 unistrcpy(s1+l1, s2);
1509 free(s2);
1510 return s1;
1511 }
1512
1513 static void do_add_token(tok_e type, token_t *tok, const char *code)
1514 {
1515 token_t *tp = lookup_token(tok->name);
1516 if(tp)
1517 {
1518 if(tok->type != type)
1519 yywarning("Type change in token");
1520 if(tp != tok)
1521 xyyerror("Overlapping token not the same");
1522 /* else its already defined and changed */
1523 if(tok->fixed)
1524 xyyerror("Redefinition of %s", code);
1525 tok->fixed = 1;
1526 }
1527 else
1528 {
1529 add_token(type, tok->name, tok->token, tok->codepage, tok->alias, 1);
1530 free(tok);
1531 }
1532 }
1533
1534 static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg)
1535 {
1536 lanmsg_t *lmp = (lanmsg_t *)xmalloc(sizeof(lanmsg_t));
1537 lmp->lan = lcp->language;
1538 lmp->cp = lcp->codepage;
1539 lmp->msg = msg;
1540 lmp->len = unistrlen(msg) + 1; /* Include termination */
1541 if(lmp->len > 4096)
1542 yywarning("Message exceptionally long; might be a missing termination");
1543 return lmp;
1544 }
1545
1546 static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg)
1547 {
1548 int i;
1549 if(!msg)
1550 msg = xmalloc(sizeof(msg_t));
1551 msg->msgs = xrealloc(msg->msgs, (msg->nmsgs+1) * sizeof(*(msg->msgs)));
1552 msg->msgs[msg->nmsgs] = lanmsg;
1553 msg->nmsgs++;
1554 for(i = 0; i < msg->nmsgs-1; i++)
1555 {
1556 if(msg->msgs[i]->lan == lanmsg->lan)
1557 xyyerror("Message for language 0x%x already defined", lanmsg->lan);
1558 }
1559 return msg;
1560 }
1561
1562 static int sort_lanmsg(const void *p1, const void *p2)
1563 {
1564 return (*(lanmsg_t **)p1)->lan - (*(lanmsg_t **)p2)->lan;
1565 }
1566
1567 static msg_t *complete_msg(msg_t *mp, int id)
1568 {
1569 assert(mp != NULL);
1570 mp->id = id;
1571 if(have_sym)
1572 mp->sym = last_sym;
1573 else
1574 xyyerror("No symbolic name defined for message id %d", id);
1575 mp->sev = last_sev;
1576 mp->fac = last_fac;
1577 qsort(mp->msgs, mp->nmsgs, sizeof(*(mp->msgs)), sort_lanmsg);
1578 mp->realid = id | (last_sev << 30) | (last_fac << 16);
1579 if(custombit)
1580 mp->realid |= 1 << 29;
1581 mp->base = base;
1582 mp->cast = cast;
1583 return mp;
1584 }
1585
1586 static void add_node(node_e type, void *p)
1587 {
1588 node_t *ndp = (node_t *)xmalloc(sizeof(node_t));
1589 ndp->type = type;
1590 ndp->u.all = p;
1591
1592 if(nodetail)
1593 {
1594 ndp->prev = nodetail;
1595 nodetail->next = ndp;
1596 nodetail = ndp;
1597 }
1598 else
1599 {
1600 nodehead = nodetail = ndp;
1601 }
1602 }
1603
1604 static void test_id(int id)
1605 {
1606 node_t *ndp;
1607 for(ndp = nodehead; ndp; ndp = ndp->next)
1608 {
1609 if(ndp->type != nd_msg)
1610 continue;
1611 if(ndp->u.msg->id == id && ndp->u.msg->sev == last_sev && ndp->u.msg->fac == last_fac)
1612 xyyerror("MessageId %d with facility 0x%x and severity 0x%x already defined", id, last_fac, last_sev);
1613 }
1614 }
1615
1616 static int check_languages(node_t *head)
1617 {
1618 static char err_missing[] = "Missing definition for language 0x%x; MessageID %d, facility 0x%x, severity 0x%x";
1619 node_t *ndp;
1620 int nm = 0;
1621 msg_t *msg = NULL;
1622
1623 for(ndp = head; ndp; ndp = ndp->next)
1624 {
1625 if(ndp->type != nd_msg)
1626 continue;
1627 if(!nm)
1628 {
1629 msg = ndp->u.msg;
1630 }
1631 else
1632 {
1633 int i;
1634 msg_t *m1;
1635 msg_t *m2;
1636 if(ndp->u.msg->nmsgs > msg->nmsgs)
1637 {
1638 m1 = ndp->u.msg;
1639 m2 = msg;
1640 }
1641 else
1642 {
1643 m1 = msg;
1644 m2 = ndp->u.msg;
1645 }
1646
1647 for(i = 0; i < m1->nmsgs; i++)
1648 {
1649 if(i > m2->nmsgs)
1650 error(err_missing, m1->msgs[i]->lan, m2->id, m2->fac, m2->sev);
1651 else if(m1->msgs[i]->lan < m2->msgs[i]->lan)
1652 error(err_missing, m1->msgs[i]->lan, m2->id, m2->fac, m2->sev);
1653 else if(m1->msgs[i]->lan > m2->msgs[i]->lan)
1654 error(err_missing, m2->msgs[i]->lan, m1->id, m1->fac, m1->sev);
1655 }
1656 }
1657 nm++;
1658 }
1659 return nm;
1660 }
1661
1662 #define MSGRID(x) ((*(msg_t **)(x))->realid)
1663 static int sort_msg(const void *p1, const void *p2)
1664 {
1665 return MSGRID(p1) > MSGRID(p2) ? 1 : (MSGRID(p1) == MSGRID(p2) ? 0 : -1);
1666 /* return (*(msg_t **)p1)->realid - (*(msg_t **)p1)->realid; */
1667 }
1668
1669 /*
1670 * block_messages() basically transposes the messages
1671 * from ID/language based list to a language/ID
1672 * based list.
1673 */
1674 static lan_blk_t *block_messages(node_t *head)
1675 {
1676 lan_blk_t *lbp;
1677 lan_blk_t *lblktail = NULL;
1678 lan_blk_t *lblkhead = NULL;
1679 msg_t **msgtab = NULL;
1680 node_t *ndp;
1681 int nmsg = 0;
1682 int i;
1683 int nl;
1684 int factor = unicodeout ? 2 : 1;
1685
1686 for(ndp = head; ndp; ndp = ndp->next)
1687 {
1688 if(ndp->type != nd_msg)
1689 continue;
1690 msgtab = xrealloc(msgtab, (nmsg+1) * sizeof(*msgtab));
1691 msgtab[nmsg++] = ndp->u.msg;
1692 }
1693
1694 assert(nmsg != 0);
1695 qsort(msgtab, nmsg, sizeof(*msgtab), sort_msg);
1696
1697 for(nl = 0; nl < msgtab[0]->nmsgs; nl++) /* This should be equal for all after check_languages() */
1698 {
1699 lbp = xmalloc(sizeof(lan_blk_t));
1700
1701 if(!lblktail)
1702 {
1703 lblkhead = lblktail = lbp;
1704 }
1705 else
1706 {
1707 lblktail->next = lbp;
1708 lbp->prev = lblktail;
1709 lblktail = lbp;
1710 }
1711 lbp->nblk = 1;
1712 lbp->blks = xmalloc(sizeof(*lbp->blks));
1713 lbp->blks[0].idlo = msgtab[0]->realid;
1714 lbp->blks[0].idhi = msgtab[0]->realid;
1715 /* The plus 4 is the entry header; (+3)&~3 is DWORD alignment */
1716 lbp->blks[0].size = ((factor * msgtab[0]->msgs[nl]->len + 3) & ~3) + 4;
1717 lbp->blks[0].msgs = xmalloc(sizeof(*lbp->blks[0].msgs));
1718 lbp->blks[0].nmsg = 1;
1719 lbp->blks[0].msgs[0] = msgtab[0]->msgs[nl];
1720 lbp->lan = msgtab[0]->msgs[nl]->lan;
1721
1722 for(i = 1; i < nmsg; i++)
1723 {
1724 block_t *blk = &(lbp->blks[lbp->nblk-1]);
1725 if(msgtab[i]->realid == blk->idhi+1)
1726 {
1727 blk->size += ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
1728 blk->idhi++;
1729 blk->msgs = xrealloc(blk->msgs, (blk->nmsg+1) * sizeof(*blk->msgs));
1730 blk->msgs[blk->nmsg++] = msgtab[i]->msgs[nl];
1731 }
1732 else
1733 {
1734 lbp->nblk++;
1735 lbp->blks = xrealloc(lbp->blks, lbp->nblk * sizeof(*lbp->blks));
1736 blk = &(lbp->blks[lbp->nblk-1]);
1737 blk->idlo = msgtab[i]->realid;
1738 blk->idhi = msgtab[i]->realid;
1739 blk->size = ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
1740 blk->msgs = xmalloc(sizeof(*blk->msgs));
1741 blk->nmsg = 1;
1742 blk->msgs[0] = msgtab[i]->msgs[nl];
1743 }
1744 }
1745 }
1746 free(msgtab);
1747 return lblkhead;
1748 }
1749
1750 static int sc_xlat(const void *p1, const void *p2)
1751 {
1752 return ((cp_xlat_t *)p1)->lan - ((cp_xlat_t *)p2)->lan;
1753 }
1754
1755 static void add_cpxlat(int lan, int cpin, int cpout)
1756 {
1757 cpxlattab = xrealloc(cpxlattab, (ncpxlattab+1) * sizeof(*cpxlattab));
1758 cpxlattab[ncpxlattab].lan = lan;
1759 cpxlattab[ncpxlattab].cpin = cpin;
1760 cpxlattab[ncpxlattab].cpout = cpout;
1761 ncpxlattab++;
1762 qsort(cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
1763 }
1764
1765 static cp_xlat_t *find_cpxlat(int lan)
1766 {
1767 cp_xlat_t t;
1768
1769 if(!cpxlattab) return NULL;
1770
1771 t.lan = lan;
1772 return (cp_xlat_t *)bsearch(&t, cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
1773 }
1774