aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/genksyms
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /scripts/genksyms
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'scripts/genksyms')
-rw-r--r--scripts/genksyms/Makefile49
-rw-r--r--scripts/genksyms/genksyms.c591
-rw-r--r--scripts/genksyms/genksyms.h104
-rw-r--r--scripts/genksyms/keywords.c_shipped145
-rw-r--r--scripts/genksyms/keywords.gperf50
-rw-r--r--scripts/genksyms/lex.c_shipped2084
-rw-r--r--scripts/genksyms/lex.l407
-rw-r--r--scripts/genksyms/parse.c_shipped1577
-rw-r--r--scripts/genksyms/parse.h_shipped46
-rw-r--r--scripts/genksyms/parse.y469
10 files changed, 5522 insertions, 0 deletions
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
new file mode 100644
index 000000000000..5875f29a8602
--- /dev/null
+++ b/scripts/genksyms/Makefile
@@ -0,0 +1,49 @@
1
2hostprogs-y := genksyms
3always := $(hostprogs-y)
4
5genksyms-objs := genksyms.o parse.o lex.o
6
7# -I needed for generated C source (shipped source)
8HOSTCFLAGS_parse.o := -Wno-uninitialized -I$(src)
9
10# dependencies on generated files need to be listed explicitly
11$(obj)/lex.o: $(obj)/parse.h $(obj)/keywords.c
12
13# -I needed for generated C source (shipped source)
14HOSTCFLAGS_lex.o := -I$(src)
15
16ifdef GENERATE_PARSER
17
18# gperf
19
20quiet_cmd_keywords.c = GPERF $@
21 cmd_keywords.c = gperf -L ANSI-C -a -C -E -g -H is_reserved_hash \
22 -k 1,3,$$ -N is_reserved_word -p -t $< > $@
23
24$(obj)/keywords.c: $(obj)/keywords.gperf FORCE
25 $(call if_changed,keywords.c)
26
27# flex
28
29quiet_cmd_lex.c = FLEX $@
30 cmd_lex.c = flex -o$@ -d $(filter-out FORCE,$^)
31
32$(obj)/lex.c: $(obj)/lex.l $(obj)/parse.h FORCE
33 $(call if_changed,lex.c)
34
35# bison
36
37quiet_cmd_parse.c = BISON $@
38 cmd_parse.c = bison -o$@ -dtv $(filter-out FORCE,$^)
39
40$(obj)/parse.c: $(obj)/parse.y FORCE
41 $(call if_changed,parse.c)
42
43$(obj)/parse.h: $(obj)/parse.c ;
44
45clean-files += parse.output
46
47endif
48
49targets += keywords.c lex.c parse.c parse.h
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
new file mode 100644
index 000000000000..416a694b0998
--- /dev/null
+++ b/scripts/genksyms/genksyms.c
@@ -0,0 +1,591 @@
1/* Generate kernel symbol version hashes.
2 Copyright 1996, 1997 Linux International.
3
4 New implementation contributed by Richard Henderson <rth@tamu.edu>
5 Based on original work by Bjorn Ekwall <bj0rn@blox.se>
6
7 This file was part of the Linux modutils 2.4.22: moved back into the
8 kernel sources by Rusty Russell/Kai Germaschewski.
9
10 This program is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by the
12 Free Software Foundation; either version 2 of the License, or (at your
13 option) any later version.
14
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software Foundation,
22 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23
24#include <stdio.h>
25#include <string.h>
26#include <stdlib.h>
27#include <unistd.h>
28#include <assert.h>
29#include <stdarg.h>
30#ifdef __GNU_LIBRARY__
31#include <getopt.h>
32#endif /* __GNU_LIBRARY__ */
33
34#include "genksyms.h"
35
36/*----------------------------------------------------------------------*/
37
38#define HASH_BUCKETS 4096
39
40static struct symbol *symtab[HASH_BUCKETS];
41FILE *debugfile;
42
43int cur_line = 1;
44char *cur_filename, *output_directory;
45
46int flag_debug, flag_dump_defs, flag_warnings;
47
48static int errors;
49static int nsyms;
50
51static struct symbol *expansion_trail;
52
53static const char * const symbol_type_name[] = {
54 "normal", "typedef", "enum", "struct", "union"
55};
56
57/*----------------------------------------------------------------------*/
58
59static const unsigned int crctab32[] =
60{
61 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
62 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
63 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U,
64 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU,
65 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U,
66 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U,
67 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U,
68 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU,
69 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U,
70 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU,
71 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U,
72 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U,
73 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U,
74 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU,
75 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU,
76 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U,
77 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU,
78 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U,
79 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U,
80 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U,
81 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU,
82 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U,
83 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U,
84 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU,
85 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U,
86 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U,
87 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U,
88 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U,
89 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U,
90 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU,
91 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU,
92 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U,
93 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U,
94 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU,
95 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU,
96 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U,
97 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU,
98 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U,
99 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU,
100 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U,
101 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU,
102 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U,
103 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U,
104 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU,
105 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U,
106 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U,
107 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U,
108 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U,
109 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U,
110 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U,
111 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU,
112 0x2d02ef8dU
113};
114
115static inline unsigned long
116partial_crc32_one(unsigned char c, unsigned long crc)
117{
118 return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
119}
120
121static inline unsigned long
122partial_crc32(const char *s, unsigned long crc)
123{
124 while (*s)
125 crc = partial_crc32_one(*s++, crc);
126 return crc;
127}
128
129static inline unsigned long
130crc32(const char *s)
131{
132 return partial_crc32(s, 0xffffffff) ^ 0xffffffff;
133}
134
135
136/*----------------------------------------------------------------------*/
137
138static inline enum symbol_type
139map_to_ns(enum symbol_type t)
140{
141 if (t == SYM_TYPEDEF)
142 t = SYM_NORMAL;
143 else if (t == SYM_UNION)
144 t = SYM_STRUCT;
145 return t;
146}
147
148struct symbol *
149find_symbol(const char *name, enum symbol_type ns)
150{
151 unsigned long h = crc32(name) % HASH_BUCKETS;
152 struct symbol *sym;
153
154 for (sym = symtab[h]; sym ; sym = sym->hash_next)
155 if (map_to_ns(sym->type) == map_to_ns(ns) && strcmp(name, sym->name) == 0)
156 break;
157
158 return sym;
159}
160
161struct symbol *
162add_symbol(const char *name, enum symbol_type type, struct string_list *defn, int is_extern)
163{
164 unsigned long h = crc32(name) % HASH_BUCKETS;
165 struct symbol *sym;
166
167 for (sym = symtab[h]; sym ; sym = sym->hash_next)
168 if (map_to_ns(sym->type) == map_to_ns(type)
169 && strcmp(name, sym->name) == 0)
170 {
171 if (!equal_list(sym->defn, defn))
172 error_with_pos("redefinition of %s", name);
173 return sym;
174 }
175
176 sym = xmalloc(sizeof(*sym));
177 sym->name = name;
178 sym->type = type;
179 sym->defn = defn;
180 sym->expansion_trail = NULL;
181 sym->is_extern = is_extern;
182
183 sym->hash_next = symtab[h];
184 symtab[h] = sym;
185
186 if (flag_debug)
187 {
188 fprintf(debugfile, "Defn for %s %s == <", symbol_type_name[type], name);
189 if (is_extern)
190 fputs("extern ", debugfile);
191 print_list(debugfile, defn);
192 fputs(">\n", debugfile);
193 }
194
195 ++nsyms;
196 return sym;
197}
198
199
200/*----------------------------------------------------------------------*/
201
202inline void
203free_node(struct string_list *node)
204{
205 free(node->string);
206 free(node);
207}
208
209void
210free_list(struct string_list *s, struct string_list *e)
211{
212 while (s != e)
213 {
214 struct string_list *next = s->next;
215 free_node(s);
216 s = next;
217 }
218}
219
220inline struct string_list *
221copy_node(struct string_list *node)
222{
223 struct string_list *newnode;
224
225 newnode = xmalloc(sizeof(*newnode));
226 newnode->string = xstrdup(node->string);
227 newnode->tag = node->tag;
228
229 return newnode;
230}
231
232struct string_list *
233copy_list(struct string_list *s, struct string_list *e)
234{
235 struct string_list *h, *p;
236
237 if (s == e)
238 return NULL;
239
240 p = h = copy_node(s);
241 while ((s = s->next) != e)
242 p = p->next = copy_node(s);
243 p->next = NULL;
244
245 return h;
246}
247
248int
249equal_list(struct string_list *a, struct string_list *b)
250{
251 while (a && b)
252 {
253 if (a->tag != b->tag || strcmp(a->string, b->string))
254 return 0;
255 a = a->next;
256 b = b->next;
257 }
258
259 return !a && !b;
260}
261
262static inline void
263print_node(FILE *f, struct string_list *list)
264{
265 switch (list->tag)
266 {
267 case SYM_STRUCT:
268 putc('s', f);
269 goto printit;
270 case SYM_UNION:
271 putc('u', f);
272 goto printit;
273 case SYM_ENUM:
274 putc('e', f);
275 goto printit;
276 case SYM_TYPEDEF:
277 putc('t', f);
278 goto printit;
279
280 printit:
281 putc('#', f);
282 case SYM_NORMAL:
283 fputs(list->string, f);
284 break;
285 }
286}
287
288void
289print_list(FILE *f, struct string_list *list)
290{
291 struct string_list **e, **b;
292 struct string_list *tmp, **tmp2;
293 int elem = 1;
294
295 if (list == NULL)
296 {
297 fputs("(nil)", f);
298 return;
299 }
300
301 tmp = list;
302 while((tmp = tmp->next) != NULL)
303 elem++;
304
305 b = alloca(elem * sizeof(*e));
306 e = b + elem;
307 tmp2 = e - 1;
308
309 (*tmp2--) = list;
310 while((list = list->next) != NULL)
311 *(tmp2--) = list;
312
313 while (b != e)
314 {
315 print_node(f, *b++);
316 putc(' ', f);
317 }
318}
319
320static unsigned long
321expand_and_crc_list(struct string_list *list, unsigned long crc)
322{
323 struct string_list **e, **b;
324 struct string_list *tmp, **tmp2;
325 int elem = 1;
326
327 if (!list)
328 return crc;
329
330 tmp = list;
331 while((tmp = tmp->next) != NULL)
332 elem++;
333
334 b = alloca(elem * sizeof(*e));
335 e = b + elem;
336 tmp2 = e - 1;
337
338 *(tmp2--) = list;
339 while ((list = list->next) != NULL)
340 *(tmp2--) = list;
341
342 while (b != e)
343 {
344 struct string_list *cur;
345 struct symbol *subsym;
346
347 cur = *(b++);
348 switch (cur->tag)
349 {
350 case SYM_NORMAL:
351 if (flag_dump_defs)
352 fprintf(debugfile, "%s ", cur->string);
353 crc = partial_crc32(cur->string, crc);
354 crc = partial_crc32_one(' ', crc);
355 break;
356
357 case SYM_TYPEDEF:
358 subsym = find_symbol(cur->string, cur->tag);
359 if (subsym->expansion_trail)
360 {
361 if (flag_dump_defs)
362 fprintf(debugfile, "%s ", cur->string);
363 crc = partial_crc32(cur->string, crc);
364 crc = partial_crc32_one(' ', crc);
365 }
366 else
367 {
368 subsym->expansion_trail = expansion_trail;
369 expansion_trail = subsym;
370 crc = expand_and_crc_list(subsym->defn, crc);
371 }
372 break;
373
374 case SYM_STRUCT:
375 case SYM_UNION:
376 case SYM_ENUM:
377 subsym = find_symbol(cur->string, cur->tag);
378 if (!subsym)
379 {
380 struct string_list *n, *t = NULL;
381
382 error_with_pos("expand undefined %s %s",
383 symbol_type_name[cur->tag], cur->string);
384
385 n = xmalloc(sizeof(*n));
386 n->string = xstrdup(symbol_type_name[cur->tag]);
387 n->tag = SYM_NORMAL;
388 n->next = t;
389 t = n;
390
391 n = xmalloc(sizeof(*n));
392 n->string = xstrdup(cur->string);
393 n->tag = SYM_NORMAL;
394 n->next = t;
395 t = n;
396
397 n = xmalloc(sizeof(*n));
398 n->string = xstrdup("{ UNKNOWN }");
399 n->tag = SYM_NORMAL;
400 n->next = t;
401
402 subsym = add_symbol(cur->string, cur->tag, n, 0);
403 }
404 if (subsym->expansion_trail)
405 {
406 if (flag_dump_defs)
407 {
408 fprintf(debugfile, "%s %s ", symbol_type_name[cur->tag],
409 cur->string);
410 }
411
412 crc = partial_crc32(symbol_type_name[cur->tag], crc);
413 crc = partial_crc32_one(' ', crc);
414 crc = partial_crc32(cur->string, crc);
415 crc = partial_crc32_one(' ', crc);
416 }
417 else
418 {
419 subsym->expansion_trail = expansion_trail;
420 expansion_trail = subsym;
421 crc = expand_and_crc_list(subsym->defn, crc);
422 }
423 break;
424 }
425 }
426
427 return crc;
428}
429
430void
431export_symbol(const char *name)
432{
433 struct symbol *sym;
434
435 sym = find_symbol(name, SYM_NORMAL);
436 if (!sym)
437 error_with_pos("export undefined symbol %s", name);
438 else
439 {
440 unsigned long crc;
441
442 if (flag_dump_defs)
443 fprintf(debugfile, "Export %s == <", name);
444
445 expansion_trail = (struct symbol *)-1L;
446
447 crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff;
448
449 sym = expansion_trail;
450 while (sym != (struct symbol *)-1L)
451 {
452 struct symbol *n = sym->expansion_trail;
453 sym->expansion_trail = 0;
454 sym = n;
455 }
456
457 if (flag_dump_defs)
458 fputs(">\n", debugfile);
459
460 /* Used as a linker script. */
461 printf("__crc_%s = 0x%08lx ;\n", name, crc);
462 }
463}
464
465/*----------------------------------------------------------------------*/
466
467void
468error(const char *fmt, ...)
469{
470 va_list args;
471
472 if (flag_warnings)
473 {
474 va_start(args, fmt);
475 vfprintf(stderr, fmt, args);
476 va_end(args);
477 putc('\n', stderr);
478
479 errors++;
480 }
481}
482
483void
484error_with_pos(const char *fmt, ...)
485{
486 va_list args;
487
488 if (flag_warnings)
489 {
490 fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>", cur_line);
491
492 va_start(args, fmt);
493 vfprintf(stderr, fmt, args);
494 va_end(args);
495 putc('\n', stderr);
496
497 errors++;
498 }
499}
500
501
502void genksyms_usage(void)
503{
504 fputs("Usage:\n"
505 "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n"
506 "\n"
507#ifdef __GNU_LIBRARY__
508 " -d, --debug Increment the debug level (repeatable)\n"
509 " -D, --dump Dump expanded symbol defs (for debugging only)\n"
510 " -w, --warnings Enable warnings\n"
511 " -q, --quiet Disable warnings (default)\n"
512 " -h, --help Print this message\n"
513 " -V, --version Print the release version\n"
514#else /* __GNU_LIBRARY__ */
515 " -d Increment the debug level (repeatable)\n"
516 " -D Dump expanded symbol defs (for debugging only)\n"
517 " -w Enable warnings\n"
518 " -q Disable warnings (default)\n"
519 " -h Print this message\n"
520 " -V Print the release version\n"
521#endif /* __GNU_LIBRARY__ */
522 , stderr);
523}
524
525int
526main(int argc, char **argv)
527{
528 int o;
529
530#ifdef __GNU_LIBRARY__
531 struct option long_opts[] = {
532 {"debug", 0, 0, 'd'},
533 {"warnings", 0, 0, 'w'},
534 {"quiet", 0, 0, 'q'},
535 {"dump", 0, 0, 'D'},
536 {"version", 0, 0, 'V'},
537 {"help", 0, 0, 'h'},
538 {0, 0, 0, 0}
539 };
540
541 while ((o = getopt_long(argc, argv, "dwqVDk:p:",
542 &long_opts[0], NULL)) != EOF)
543#else /* __GNU_LIBRARY__ */
544 while ((o = getopt(argc, argv, "dwqVDk:p:")) != EOF)
545#endif /* __GNU_LIBRARY__ */
546 switch (o)
547 {
548 case 'd':
549 flag_debug++;
550 break;
551 case 'w':
552 flag_warnings = 1;
553 break;
554 case 'q':
555 flag_warnings = 0;
556 break;
557 case 'V':
558 fputs("genksyms version 2.5.60\n", stderr);
559 break;
560 case 'D':
561 flag_dump_defs = 1;
562 break;
563 case 'h':
564 genksyms_usage();
565 return 0;
566 default:
567 genksyms_usage();
568 return 1;
569 }
570
571 {
572 extern int yydebug;
573 extern int yy_flex_debug;
574
575 yydebug = (flag_debug > 1);
576 yy_flex_debug = (flag_debug > 2);
577
578 debugfile = stderr;
579 /* setlinebuf(debugfile); */
580 }
581
582 yyparse();
583
584 if (flag_debug)
585 {
586 fprintf(debugfile, "Hash table occupancy %d/%d = %g\n",
587 nsyms, HASH_BUCKETS, (double)nsyms / (double)HASH_BUCKETS);
588 }
589
590 return errors != 0;
591}
diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h
new file mode 100644
index 000000000000..f09af47ab281
--- /dev/null
+++ b/scripts/genksyms/genksyms.h
@@ -0,0 +1,104 @@
1/* Generate kernel symbol version hashes.
2 Copyright 1996, 1997 Linux International.
3
4 New implementation contributed by Richard Henderson <rth@tamu.edu>
5 Based on original work by Bjorn Ekwall <bj0rn@blox.se>
6
7 This file is part of the Linux modutils.
8
9 This program is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 2 of the License, or (at your
12 option) any later version.
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23
24#ifndef MODUTILS_GENKSYMS_H
25#define MODUTILS_GENKSYMS_H 1
26
27#include <stdio.h>
28
29
30enum symbol_type
31{
32 SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
33};
34
35struct string_list
36{
37 struct string_list *next;
38 enum symbol_type tag;
39 char *string;
40};
41
42struct symbol
43{
44 struct symbol *hash_next;
45 const char *name;
46 enum symbol_type type;
47 struct string_list *defn;
48 struct symbol *expansion_trail;
49 int is_extern;
50};
51
52typedef struct string_list **yystype;
53#define YYSTYPE yystype
54
55extern FILE *outfile, *debugfile;
56
57extern int cur_line;
58extern char *cur_filename, *output_directory;
59
60extern int flag_debug, flag_dump_defs, flag_warnings;
61extern int checksum_version, kernel_version;
62
63extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents;
64extern struct string_list *current_list, *next_list;
65
66
67struct symbol *find_symbol(const char *name, enum symbol_type ns);
68struct symbol *add_symbol(const char *name, enum symbol_type type,
69 struct string_list *defn, int is_extern);
70void export_symbol(const char *);
71
72struct string_list *reset_list(void);
73void free_list(struct string_list *s, struct string_list *e);
74void free_node(struct string_list *list);
75struct string_list *copy_node(struct string_list *);
76struct string_list *copy_list(struct string_list *s, struct string_list *e);
77int equal_list(struct string_list *a, struct string_list *b);
78void print_list(FILE *, struct string_list *list);
79
80int yylex(void);
81int yyparse(void);
82
83void error_with_pos(const char *, ...);
84
85#define version(a,b,c) ((a << 16) | (b << 8) | (c))
86
87/*----------------------------------------------------------------------*/
88
89#define MODUTILS_VERSION "<in-kernel>"
90
91#define xmalloc(size) ({ void *__ptr = malloc(size); \
92 if(!__ptr && size != 0) { \
93 fprintf(stderr, "out of memory\n"); \
94 exit(1); \
95 } \
96 __ptr; })
97#define xstrdup(str) ({ char *__str = strdup(str); \
98 if (!__str) { \
99 fprintf(stderr, "out of memory\n"); \
100 exit(1); \
101 } \
102 __str; })
103
104#endif /* genksyms.h */
diff --git a/scripts/genksyms/keywords.c_shipped b/scripts/genksyms/keywords.c_shipped
new file mode 100644
index 000000000000..eabaf7401cd6
--- /dev/null
+++ b/scripts/genksyms/keywords.c_shipped
@@ -0,0 +1,145 @@
1/* ANSI-C code produced by gperf version 2.7.2 */
2/* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */
3struct resword { const char *name; int token; };
4/* maximum key range = 109, duplicates = 0 */
5
6#ifdef __GNUC__
7__inline
8#else
9#ifdef __cplusplus
10inline
11#endif
12#endif
13static unsigned int
14is_reserved_hash (register const char *str, register unsigned int len)
15{
16 static const unsigned char asso_values[] =
17 {
18 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
19 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
20 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
21 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
22 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
23 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
24 113, 113, 113, 113, 113, 113, 113, 113, 113, 5,
25 113, 113, 113, 113, 113, 113, 0, 113, 113, 113,
26 0, 113, 113, 113, 113, 113, 113, 113, 113, 113,
27 113, 113, 113, 113, 113, 0, 113, 0, 113, 20,
28 25, 0, 35, 30, 113, 20, 113, 113, 40, 30,
29 30, 0, 0, 113, 0, 51, 0, 15, 5, 113,
30 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
31 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
32 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
33 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
34 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
35 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
36 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
37 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
38 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
39 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
40 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
41 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
42 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
43 113, 113, 113, 113, 113, 113
44 };
45 return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]];
46}
47
48#ifdef __GNUC__
49__inline
50#endif
51const struct resword *
52is_reserved_word (register const char *str, register unsigned int len)
53{
54 enum
55 {
56 TOTAL_KEYWORDS = 41,
57 MIN_WORD_LENGTH = 3,
58 MAX_WORD_LENGTH = 17,
59 MIN_HASH_VALUE = 4,
60 MAX_HASH_VALUE = 112
61 };
62
63 static const struct resword wordlist[] =
64 {
65 {""}, {""}, {""}, {""},
66 {"auto", AUTO_KEYW},
67 {""}, {""},
68 {"__asm__", ASM_KEYW},
69 {""},
70 {"_restrict", RESTRICT_KEYW},
71 {"__typeof__", TYPEOF_KEYW},
72 {"__attribute", ATTRIBUTE_KEYW},
73 {"__restrict__", RESTRICT_KEYW},
74 {"__attribute__", ATTRIBUTE_KEYW},
75 {""},
76 {"__volatile", VOLATILE_KEYW},
77 {""},
78 {"__volatile__", VOLATILE_KEYW},
79 {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW},
80 {""}, {""}, {""},
81 {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW},
82 {"int", INT_KEYW},
83 {"char", CHAR_KEYW},
84 {""}, {""},
85 {"__const", CONST_KEYW},
86 {"__inline", INLINE_KEYW},
87 {"__const__", CONST_KEYW},
88 {"__inline__", INLINE_KEYW},
89 {""}, {""}, {""}, {""},
90 {"__asm", ASM_KEYW},
91 {"extern", EXTERN_KEYW},
92 {""},
93 {"register", REGISTER_KEYW},
94 {""},
95 {"float", FLOAT_KEYW},
96 {"typeof", TYPEOF_KEYW},
97 {"typedef", TYPEDEF_KEYW},
98 {""}, {""},
99 {"_Bool", BOOL_KEYW},
100 {"double", DOUBLE_KEYW},
101 {""}, {""},
102 {"enum", ENUM_KEYW},
103 {""}, {""}, {""},
104 {"volatile", VOLATILE_KEYW},
105 {"void", VOID_KEYW},
106 {"const", CONST_KEYW},
107 {"short", SHORT_KEYW},
108 {"struct", STRUCT_KEYW},
109 {""},
110 {"restrict", RESTRICT_KEYW},
111 {""},
112 {"__signed__", SIGNED_KEYW},
113 {""},
114 {"asm", ASM_KEYW},
115 {""}, {""},
116 {"inline", INLINE_KEYW},
117 {""}, {""}, {""},
118 {"union", UNION_KEYW},
119 {""}, {""}, {""}, {""}, {""}, {""},
120 {"static", STATIC_KEYW},
121 {""}, {""}, {""}, {""}, {""}, {""},
122 {"__signed", SIGNED_KEYW},
123 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
124 {""}, {""}, {""}, {""}, {""},
125 {"unsigned", UNSIGNED_KEYW},
126 {""}, {""}, {""}, {""},
127 {"long", LONG_KEYW},
128 {""}, {""}, {""}, {""}, {""}, {""}, {""},
129 {"signed", SIGNED_KEYW}
130 };
131
132 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
133 {
134 register int key = is_reserved_hash (str, len);
135
136 if (key <= MAX_HASH_VALUE && key >= 0)
137 {
138 register const char *s = wordlist[key].name;
139
140 if (*str == *s && !strcmp (str + 1, s + 1))
141 return &wordlist[key];
142 }
143 }
144 return 0;
145}
diff --git a/scripts/genksyms/keywords.gperf b/scripts/genksyms/keywords.gperf
new file mode 100644
index 000000000000..b6bec765996e
--- /dev/null
+++ b/scripts/genksyms/keywords.gperf
@@ -0,0 +1,50 @@
1%{
2%}
3struct resword { const char *name; int token; }
4%%
5EXPORT_SYMBOL, EXPORT_SYMBOL_KEYW
6EXPORT_SYMBOL_GPL, EXPORT_SYMBOL_KEYW
7__asm, ASM_KEYW
8__asm__, ASM_KEYW
9__attribute, ATTRIBUTE_KEYW
10__attribute__, ATTRIBUTE_KEYW
11__const, CONST_KEYW
12__const__, CONST_KEYW
13__inline, INLINE_KEYW
14__inline__, INLINE_KEYW
15__signed, SIGNED_KEYW
16__signed__, SIGNED_KEYW
17__volatile, VOLATILE_KEYW
18__volatile__, VOLATILE_KEYW
19# According to rth, c99 defines _Bool, __restrict, __restrict__, restrict. KAO
20_Bool, BOOL_KEYW
21_restrict, RESTRICT_KEYW
22__restrict__, RESTRICT_KEYW
23restrict, RESTRICT_KEYW
24asm, ASM_KEYW
25# attribute commented out in modutils 2.4.2. People are using 'attribute' as a
26# field name which breaks the genksyms parser. It is not a gcc keyword anyway.
27# KAO.
28# attribute, ATTRIBUTE_KEYW
29auto, AUTO_KEYW
30char, CHAR_KEYW
31const, CONST_KEYW
32double, DOUBLE_KEYW
33enum, ENUM_KEYW
34extern, EXTERN_KEYW
35float, FLOAT_KEYW
36inline, INLINE_KEYW
37int, INT_KEYW
38long, LONG_KEYW
39register, REGISTER_KEYW
40short, SHORT_KEYW
41signed, SIGNED_KEYW
42static, STATIC_KEYW
43struct, STRUCT_KEYW
44typedef, TYPEDEF_KEYW
45union, UNION_KEYW
46unsigned, UNSIGNED_KEYW
47void, VOID_KEYW
48volatile, VOLATILE_KEYW
49typeof, TYPEOF_KEYW
50__typeof__, TYPEOF_KEYW
diff --git a/scripts/genksyms/lex.c_shipped b/scripts/genksyms/lex.c_shipped
new file mode 100644
index 000000000000..d9bfbb5948f2
--- /dev/null
+++ b/scripts/genksyms/lex.c_shipped
@@ -0,0 +1,2084 @@
1#line 2 "scripts/genksyms/lex.c"
2/* A lexical scanner generated by flex */
3
4/* Scanner skeleton version:
5 * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
6 */
7
8#define FLEX_SCANNER
9#define YY_FLEX_MAJOR_VERSION 2
10#define YY_FLEX_MINOR_VERSION 5
11
12#include <stdio.h>
13#include <unistd.h>
14
15
16/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
17#ifdef c_plusplus
18#ifndef __cplusplus
19#define __cplusplus
20#endif
21#endif
22
23
24#ifdef __cplusplus
25
26#include <stdlib.h>
27
28/* Use prototypes in function declarations. */
29#define YY_USE_PROTOS
30
31/* The "const" storage-class-modifier is valid. */
32#define YY_USE_CONST
33
34#else /* ! __cplusplus */
35
36#if __STDC__
37
38#define YY_USE_PROTOS
39#define YY_USE_CONST
40
41#endif /* __STDC__ */
42#endif /* ! __cplusplus */
43
44#ifdef __TURBOC__
45 #pragma warn -rch
46 #pragma warn -use
47#include <io.h>
48#include <stdlib.h>
49#define YY_USE_CONST
50#define YY_USE_PROTOS
51#endif
52
53#ifdef YY_USE_CONST
54#define yyconst const
55#else
56#define yyconst
57#endif
58
59
60#ifdef YY_USE_PROTOS
61#define YY_PROTO(proto) proto
62#else
63#define YY_PROTO(proto) ()
64#endif
65
66/* Returned upon end-of-file. */
67#define YY_NULL 0
68
69/* Promotes a possibly negative, possibly signed char to an unsigned
70 * integer for use as an array index. If the signed char is negative,
71 * we want to instead treat it as an 8-bit unsigned char, hence the
72 * double cast.
73 */
74#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
75
76/* Enter a start condition. This macro really ought to take a parameter,
77 * but we do it the disgusting crufty way forced on us by the ()-less
78 * definition of BEGIN.
79 */
80#define BEGIN yy_start = 1 + 2 *
81
82/* Translate the current start state into a value that can be later handed
83 * to BEGIN to return to the state. The YYSTATE alias is for lex
84 * compatibility.
85 */
86#define YY_START ((yy_start - 1) / 2)
87#define YYSTATE YY_START
88
89/* Action number for EOF rule of a given start state. */
90#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
91
92/* Special action meaning "start processing a new file". */
93#define YY_NEW_FILE yyrestart( yyin )
94
95#define YY_END_OF_BUFFER_CHAR 0
96
97/* Size of default input buffer. */
98#define YY_BUF_SIZE 16384
99
100typedef struct yy_buffer_state *YY_BUFFER_STATE;
101
102extern int yyleng;
103extern FILE *yyin, *yyout;
104
105#define EOB_ACT_CONTINUE_SCAN 0
106#define EOB_ACT_END_OF_FILE 1
107#define EOB_ACT_LAST_MATCH 2
108
109/* The funky do-while in the following #define is used to turn the definition
110 * int a single C statement (which needs a semi-colon terminator). This
111 * avoids problems with code like:
112 *
113 * if ( condition_holds )
114 * yyless( 5 );
115 * else
116 * do_something_else();
117 *
118 * Prior to using the do-while the compiler would get upset at the
119 * "else" because it interpreted the "if" statement as being all
120 * done when it reached the ';' after the yyless() call.
121 */
122
123/* Return all but the first 'n' matched characters back to the input stream. */
124
125#define yyless(n) \
126 do \
127 { \
128 /* Undo effects of setting up yytext. */ \
129 *yy_cp = yy_hold_char; \
130 YY_RESTORE_YY_MORE_OFFSET \
131 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
132 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
133 } \
134 while ( 0 )
135
136#define unput(c) yyunput( c, yytext_ptr )
137
138/* The following is because we cannot portably get our hands on size_t
139 * (without autoconf's help, which isn't available because we want
140 * flex-generated scanners to compile on their own).
141 */
142typedef unsigned int yy_size_t;
143
144
145struct yy_buffer_state
146 {
147 FILE *yy_input_file;
148
149 char *yy_ch_buf; /* input buffer */
150 char *yy_buf_pos; /* current position in input buffer */
151
152 /* Size of input buffer in bytes, not including room for EOB
153 * characters.
154 */
155 yy_size_t yy_buf_size;
156
157 /* Number of characters read into yy_ch_buf, not including EOB
158 * characters.
159 */
160 int yy_n_chars;
161
162 /* Whether we "own" the buffer - i.e., we know we created it,
163 * and can realloc() it to grow it, and should free() it to
164 * delete it.
165 */
166 int yy_is_our_buffer;
167
168 /* Whether this is an "interactive" input source; if so, and
169 * if we're using stdio for input, then we want to use getc()
170 * instead of fread(), to make sure we stop fetching input after
171 * each newline.
172 */
173 int yy_is_interactive;
174
175 /* Whether we're considered to be at the beginning of a line.
176 * If so, '^' rules will be active on the next match, otherwise
177 * not.
178 */
179 int yy_at_bol;
180
181 /* Whether to try to fill the input buffer when we reach the
182 * end of it.
183 */
184 int yy_fill_buffer;
185
186 int yy_buffer_status;
187#define YY_BUFFER_NEW 0
188#define YY_BUFFER_NORMAL 1
189 /* When an EOF's been seen but there's still some text to process
190 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
191 * shouldn't try reading from the input source any more. We might
192 * still have a bunch of tokens to match, though, because of
193 * possible backing-up.
194 *
195 * When we actually see the EOF, we change the status to "new"
196 * (via yyrestart()), so that the user can continue scanning by
197 * just pointing yyin at a new input file.
198 */
199#define YY_BUFFER_EOF_PENDING 2
200 };
201
202static YY_BUFFER_STATE yy_current_buffer = 0;
203
204/* We provide macros for accessing buffer states in case in the
205 * future we want to put the buffer states in a more general
206 * "scanner state".
207 */
208#define YY_CURRENT_BUFFER yy_current_buffer
209
210
211/* yy_hold_char holds the character lost when yytext is formed. */
212static char yy_hold_char;
213
214static int yy_n_chars; /* number of characters read into yy_ch_buf */
215
216
217int yyleng;
218
219/* Points to current character in buffer. */
220static char *yy_c_buf_p = (char *) 0;
221static int yy_init = 1; /* whether we need to initialize */
222static int yy_start = 0; /* start state number */
223
224/* Flag which is used to allow yywrap()'s to do buffer switches
225 * instead of setting up a fresh yyin. A bit of a hack ...
226 */
227static int yy_did_buffer_switch_on_eof;
228
229void yyrestart YY_PROTO(( FILE *input_file ));
230
231void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
232void yy_load_buffer_state YY_PROTO(( void ));
233YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
234void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
235void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
236void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
237#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
238
239YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
240YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
241YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
242
243static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
244static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
245static void yy_flex_free YY_PROTO(( void * ));
246
247#define yy_new_buffer yy_create_buffer
248
249#define yy_set_interactive(is_interactive) \
250 { \
251 if ( ! yy_current_buffer ) \
252 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
253 yy_current_buffer->yy_is_interactive = is_interactive; \
254 }
255
256#define yy_set_bol(at_bol) \
257 { \
258 if ( ! yy_current_buffer ) \
259 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
260 yy_current_buffer->yy_at_bol = at_bol; \
261 }
262
263#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
264
265
266#define yywrap() 1
267#define YY_SKIP_YYWRAP
268
269#define FLEX_DEBUG
270typedef unsigned char YY_CHAR;
271FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
272typedef int yy_state_type;
273
274#define FLEX_DEBUG
275extern char *yytext;
276#define yytext_ptr yytext
277
278static yy_state_type yy_get_previous_state YY_PROTO(( void ));
279static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
280static int yy_get_next_buffer YY_PROTO(( void ));
281static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
282
283/* Done after the current pattern has been matched and before the
284 * corresponding action - sets up yytext.
285 */
286#define YY_DO_BEFORE_ACTION \
287 yytext_ptr = yy_bp; \
288 yyleng = (int) (yy_cp - yy_bp); \
289 yy_hold_char = *yy_cp; \
290 *yy_cp = '\0'; \
291 yy_c_buf_p = yy_cp;
292
293#define YY_NUM_RULES 13
294#define YY_END_OF_BUFFER 14
295static yyconst short int yy_accept[76] =
296 { 0,
297 0, 0, 0, 0, 14, 12, 4, 3, 12, 7,
298 12, 12, 7, 12, 12, 12, 12, 12, 9, 9,
299 12, 12, 12, 4, 0, 5, 0, 7, 0, 6,
300 0, 0, 0, 0, 0, 0, 2, 8, 10, 10,
301 9, 0, 0, 9, 9, 0, 9, 0, 0, 11,
302 0, 0, 0, 10, 0, 10, 9, 9, 0, 0,
303 0, 0, 0, 0, 0, 10, 10, 0, 0, 0,
304 0, 0, 0, 1, 0
305 } ;
306
307static yyconst int yy_ec[256] =
308 { 0,
309 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
310 4, 4, 4, 1, 1, 1, 1, 1, 1, 1,
311 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
312 1, 2, 1, 5, 6, 7, 8, 9, 10, 1,
313 1, 8, 11, 1, 12, 13, 8, 14, 15, 15,
314 15, 15, 15, 15, 15, 16, 16, 1, 1, 17,
315 18, 19, 1, 1, 20, 20, 20, 20, 21, 22,
316 7, 7, 7, 7, 7, 23, 7, 7, 7, 7,
317 7, 7, 7, 7, 24, 7, 7, 25, 7, 7,
318 1, 26, 1, 8, 7, 1, 20, 20, 20, 20,
319
320 21, 22, 7, 7, 7, 7, 7, 27, 7, 7,
321 7, 7, 7, 7, 7, 7, 24, 7, 7, 25,
322 7, 7, 1, 28, 1, 8, 1, 1, 1, 1,
323 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
324 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
325 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
326 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
327 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
328 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
329 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
330
331 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
332 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
333 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
334 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
335 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
336 1, 1, 1, 1, 1
337 } ;
338
339static yyconst int yy_meta[29] =
340 { 0,
341 1, 1, 2, 1, 1, 1, 3, 1, 1, 1,
342 4, 4, 5, 6, 6, 6, 1, 1, 1, 7,
343 8, 7, 3, 3, 3, 1, 3, 1
344 } ;
345
346static yyconst short int yy_base[88] =
347 { 0,
348 0, 147, 21, 140, 145, 284, 39, 284, 26, 0,
349 32, 126, 40, 44, 115, 35, 36, 46, 50, 53,
350 39, 61, 54, 79, 65, 284, 0, 0, 66, 284,
351 0, 119, 79, 75, 123, 104, 284, 284, 107, 0,
352 79, 73, 76, 76, 66, 0, 0, 85, 86, 284,
353 133, 83, 91, 284, 99, 147, 284, 114, 122, 70,
354 107, 141, 172, 151, 135, 181, 284, 137, 114, 157,
355 149, 48, 45, 284, 284, 208, 214, 222, 230, 238,
356 246, 250, 255, 256, 261, 267, 275
357 } ;
358
359static yyconst short int yy_def[88] =
360 { 0,
361 75, 1, 1, 3, 75, 75, 75, 75, 76, 77,
362 78, 75, 77, 79, 75, 75, 75, 75, 75, 19,
363 75, 75, 75, 75, 76, 75, 80, 77, 78, 75,
364 81, 75, 76, 78, 79, 79, 75, 75, 75, 39,
365 19, 82, 83, 75, 75, 84, 20, 76, 78, 75,
366 79, 51, 85, 75, 75, 75, 75, 84, 79, 51,
367 79, 79, 79, 51, 75, 75, 75, 86, 79, 63,
368 86, 87, 87, 75, 0, 75, 75, 75, 75, 75,
369 75, 75, 75, 75, 75, 75, 75
370 } ;
371
372static yyconst short int yy_nxt[313] =
373 { 0,
374 6, 7, 8, 7, 9, 6, 10, 6, 6, 11,
375 6, 6, 12, 6, 6, 6, 6, 6, 6, 10,
376 10, 10, 13, 10, 10, 6, 10, 6, 15, 16,
377 26, 15, 17, 18, 19, 20, 20, 21, 15, 22,
378 24, 30, 24, 38, 33, 36, 37, 74, 23, 34,
379 74, 27, 38, 38, 38, 38, 38, 31, 32, 39,
380 39, 39, 40, 41, 41, 42, 47, 47, 47, 26,
381 43, 38, 44, 45, 46, 30, 44, 75, 38, 38,
382 24, 38, 24, 26, 30, 40, 55, 55, 57, 26,
383 27, 31, 57, 43, 35, 30, 64, 64, 64, 57,
384
385 31, 65, 65, 75, 27, 36, 37, 35, 59, 37,
386 27, 31, 56, 56, 56, 59, 37, 51, 52, 52,
387 39, 39, 39, 59, 37, 37, 68, 53, 54, 54,
388 69, 50, 38, 54, 59, 37, 44, 45, 32, 37,
389 44, 35, 59, 37, 75, 14, 60, 60, 66, 66,
390 66, 37, 14, 72, 75, 61, 62, 63, 59, 61,
391 56, 56, 56, 69, 64, 64, 64, 69, 67, 67,
392 75, 75, 75, 67, 37, 35, 75, 75, 75, 61,
393 62, 75, 75, 61, 75, 70, 70, 70, 75, 75,
394 75, 70, 70, 70, 66, 66, 66, 75, 75, 75,
395
396 75, 75, 54, 54, 75, 75, 75, 54, 25, 25,
397 25, 25, 25, 25, 25, 25, 28, 75, 75, 28,
398 28, 28, 29, 29, 29, 29, 29, 29, 29, 29,
399 35, 35, 35, 35, 35, 35, 35, 35, 48, 75,
400 48, 48, 48, 48, 48, 48, 49, 75, 49, 49,
401 49, 49, 49, 49, 42, 42, 75, 42, 56, 75,
402 56, 58, 58, 58, 66, 75, 66, 71, 71, 71,
403 71, 71, 71, 71, 71, 73, 73, 73, 73, 73,
404 73, 73, 73, 5, 75, 75, 75, 75, 75, 75,
405 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
406
407 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
408 75, 75
409 } ;
410
411static yyconst short int yy_chk[313] =
412 { 0,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415 1, 1, 1, 1, 1, 1, 1, 1, 3, 3,
416 9, 3, 3, 3, 3, 3, 3, 3, 3, 3,
417 7, 11, 7, 16, 13, 14, 14, 73, 3, 13,
418 72, 9, 16, 17, 17, 21, 21, 11, 18, 18,
419 18, 18, 19, 19, 19, 19, 20, 20, 20, 25,
420 19, 23, 19, 19, 19, 29, 19, 20, 22, 22,
421 24, 23, 24, 33, 34, 42, 43, 43, 45, 48,
422 25, 29, 45, 42, 60, 49, 52, 52, 52, 44,
423
424 34, 53, 53, 41, 33, 36, 36, 52, 61, 61,
425 48, 49, 55, 55, 55, 69, 69, 36, 36, 36,
426 39, 39, 39, 59, 59, 35, 59, 39, 39, 39,
427 61, 32, 15, 39, 51, 51, 58, 58, 12, 68,
428 58, 68, 62, 62, 5, 4, 51, 51, 65, 65,
429 65, 71, 2, 71, 0, 51, 51, 51, 70, 51,
430 56, 56, 56, 62, 64, 64, 64, 62, 56, 56,
431 0, 0, 0, 56, 63, 64, 0, 0, 0, 70,
432 70, 0, 0, 70, 0, 63, 63, 63, 0, 0,
433 0, 63, 63, 63, 66, 66, 66, 0, 0, 0,
434
435 0, 0, 66, 66, 0, 0, 0, 66, 76, 76,
436 76, 76, 76, 76, 76, 76, 77, 0, 0, 77,
437 77, 77, 78, 78, 78, 78, 78, 78, 78, 78,
438 79, 79, 79, 79, 79, 79, 79, 79, 80, 0,
439 80, 80, 80, 80, 80, 80, 81, 0, 81, 81,
440 81, 81, 81, 81, 82, 82, 0, 82, 83, 0,
441 83, 84, 84, 84, 85, 0, 85, 86, 86, 86,
442 86, 86, 86, 86, 86, 87, 87, 87, 87, 87,
443 87, 87, 87, 75, 75, 75, 75, 75, 75, 75,
444 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
445
446 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
447 75, 75
448 } ;
449
450static yy_state_type yy_last_accepting_state;
451static char *yy_last_accepting_cpos;
452
453extern int yy_flex_debug;
454int yy_flex_debug = 1;
455
456static yyconst short int yy_rule_linenum[13] =
457 { 0,
458 69, 70, 71, 74, 77, 78, 79, 85, 86, 87,
459 89, 92
460 } ;
461
462/* The intent behind this definition is that it'll catch
463 * any uses of REJECT which flex missed.
464 */
465#define REJECT reject_used_but_not_detected
466#define yymore() yymore_used_but_not_detected
467#define YY_MORE_ADJ 0
468#define YY_RESTORE_YY_MORE_OFFSET
469char *yytext;
470#line 1 "scripts/genksyms/lex.l"
471#define INITIAL 0
472/* Lexical analysis for genksyms.
473 Copyright 1996, 1997 Linux International.
474
475 New implementation contributed by Richard Henderson <rth@tamu.edu>
476 Based on original work by Bjorn Ekwall <bj0rn@blox.se>
477
478 Taken from Linux modutils 2.4.22.
479
480 This program is free software; you can redistribute it and/or modify it
481 under the terms of the GNU General Public License as published by the
482 Free Software Foundation; either version 2 of the License, or (at your
483 option) any later version.
484
485 This program is distributed in the hope that it will be useful, but
486 WITHOUT ANY WARRANTY; without even the implied warranty of
487 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
488 General Public License for more details.
489
490 You should have received a copy of the GNU General Public License
491 along with this program; if not, write to the Free Software Foundation,
492 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
493#line 25 "scripts/genksyms/lex.l"
494
495#include <limits.h>
496#include <stdlib.h>
497#include <string.h>
498#include <ctype.h>
499
500#include "genksyms.h"
501#include "parse.h"
502
503/* We've got a two-level lexer here. We let flex do basic tokenization
504 and then we categorize those basic tokens in the second stage. */
505#define YY_DECL static int yylex1(void)
506
507/* Version 2 checksumming does proper tokenization; version 1 wasn't
508 quite so pedantic. */
509#define V2_TOKENS 1
510
511/* We don't do multiple input files. */
512#line 513 "scripts/genksyms/lex.c"
513
514/* Macros after this point can all be overridden by user definitions in
515 * section 1.
516 */
517
518#ifndef YY_SKIP_YYWRAP
519#ifdef __cplusplus
520extern "C" int yywrap YY_PROTO(( void ));
521#else
522extern int yywrap YY_PROTO(( void ));
523#endif
524#endif
525
526#ifndef YY_NO_UNPUT
527static void yyunput YY_PROTO(( int c, char *buf_ptr ));
528#endif
529
530#ifndef yytext_ptr
531static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
532#endif
533
534#ifdef YY_NEED_STRLEN
535static int yy_flex_strlen YY_PROTO(( yyconst char * ));
536#endif
537
538#ifndef YY_NO_INPUT
539#ifdef __cplusplus
540static int yyinput YY_PROTO(( void ));
541#else
542static int input YY_PROTO(( void ));
543#endif
544#endif
545
546#if YY_STACK_USED
547static int yy_start_stack_ptr = 0;
548static int yy_start_stack_depth = 0;
549static int *yy_start_stack = 0;
550#ifndef YY_NO_PUSH_STATE
551static void yy_push_state YY_PROTO(( int new_state ));
552#endif
553#ifndef YY_NO_POP_STATE
554static void yy_pop_state YY_PROTO(( void ));
555#endif
556#ifndef YY_NO_TOP_STATE
557static int yy_top_state YY_PROTO(( void ));
558#endif
559
560#else
561#define YY_NO_PUSH_STATE 1
562#define YY_NO_POP_STATE 1
563#define YY_NO_TOP_STATE 1
564#endif
565
566#ifdef YY_MALLOC_DECL
567YY_MALLOC_DECL
568#else
569#if __STDC__
570#ifndef __cplusplus
571#include <stdlib.h>
572#endif
573#else
574/* Just try to get by without declaring the routines. This will fail
575 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
576 * or sizeof(void*) != sizeof(int).
577 */
578#endif
579#endif
580
581/* Amount of stuff to slurp up with each read. */
582#ifndef YY_READ_BUF_SIZE
583#define YY_READ_BUF_SIZE 8192
584#endif
585
586/* Copy whatever the last rule matched to the standard output. */
587
588#ifndef ECHO
589/* This used to be an fputs(), but since the string might contain NUL's,
590 * we now use fwrite().
591 */
592#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
593#endif
594
595/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
596 * is returned in "result".
597 */
598#ifndef YY_INPUT
599#define YY_INPUT(buf,result,max_size) \
600 if ( yy_current_buffer->yy_is_interactive ) \
601 { \
602 int c = '*', n; \
603 for ( n = 0; n < max_size && \
604 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
605 buf[n] = (char) c; \
606 if ( c == '\n' ) \
607 buf[n++] = (char) c; \
608 if ( c == EOF && ferror( yyin ) ) \
609 YY_FATAL_ERROR( "input in flex scanner failed" ); \
610 result = n; \
611 } \
612 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
613 && ferror( yyin ) ) \
614 YY_FATAL_ERROR( "input in flex scanner failed" );
615#endif
616
617/* No semi-colon after return; correct usage is to write "yyterminate();" -
618 * we don't want an extra ';' after the "return" because that will cause
619 * some compilers to complain about unreachable statements.
620 */
621#ifndef yyterminate
622#define yyterminate() return YY_NULL
623#endif
624
625/* Number of entries by which start-condition stack grows. */
626#ifndef YY_START_STACK_INCR
627#define YY_START_STACK_INCR 25
628#endif
629
630/* Report a fatal error. */
631#ifndef YY_FATAL_ERROR
632#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
633#endif
634
635/* Default declaration of generated scanner - a define so the user can
636 * easily add parameters.
637 */
638#ifndef YY_DECL
639#define YY_DECL int yylex YY_PROTO(( void ))
640#endif
641
642/* Code executed at the beginning of each rule, after yytext and yyleng
643 * have been set up.
644 */
645#ifndef YY_USER_ACTION
646#define YY_USER_ACTION
647#endif
648
649/* Code executed at the end of each rule. */
650#ifndef YY_BREAK
651#define YY_BREAK break;
652#endif
653
654#define YY_RULE_SETUP \
655 if ( yyleng > 0 ) \
656 yy_current_buffer->yy_at_bol = \
657 (yytext[yyleng - 1] == '\n'); \
658 YY_USER_ACTION
659
660YY_DECL
661 {
662 register yy_state_type yy_current_state;
663 register char *yy_cp = NULL, *yy_bp = NULL;
664 register int yy_act;
665
666#line 65 "scripts/genksyms/lex.l"
667
668
669
670 /* Keep track of our location in the original source files. */
671#line 672 "scripts/genksyms/lex.c"
672
673 if ( yy_init )
674 {
675 yy_init = 0;
676
677#ifdef YY_USER_INIT
678 YY_USER_INIT;
679#endif
680
681 if ( ! yy_start )
682 yy_start = 1; /* first start state */
683
684 if ( ! yyin )
685 yyin = stdin;
686
687 if ( ! yyout )
688 yyout = stdout;
689
690 if ( ! yy_current_buffer )
691 yy_current_buffer =
692 yy_create_buffer( yyin, YY_BUF_SIZE );
693
694 yy_load_buffer_state();
695 }
696
697 while ( 1 ) /* loops until end-of-file is reached */
698 {
699 yy_cp = yy_c_buf_p;
700
701 /* Support of yytext. */
702 *yy_cp = yy_hold_char;
703
704 /* yy_bp points to the position in yy_ch_buf of the start of
705 * the current run.
706 */
707 yy_bp = yy_cp;
708
709 yy_current_state = yy_start;
710 yy_current_state += YY_AT_BOL();
711yy_match:
712 do
713 {
714 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
715 if ( yy_accept[yy_current_state] )
716 {
717 yy_last_accepting_state = yy_current_state;
718 yy_last_accepting_cpos = yy_cp;
719 }
720 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
721 {
722 yy_current_state = (int) yy_def[yy_current_state];
723 if ( yy_current_state >= 76 )
724 yy_c = yy_meta[(unsigned int) yy_c];
725 }
726 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
727 ++yy_cp;
728 }
729 while ( yy_base[yy_current_state] != 284 );
730
731yy_find_action:
732 yy_act = yy_accept[yy_current_state];
733 if ( yy_act == 0 )
734 { /* have to back up */
735 yy_cp = yy_last_accepting_cpos;
736 yy_current_state = yy_last_accepting_state;
737 yy_act = yy_accept[yy_current_state];
738 }
739
740 YY_DO_BEFORE_ACTION;
741
742
743do_action: /* This label is used only to access EOF actions. */
744
745 if ( yy_flex_debug )
746 {
747 if ( yy_act == 0 )
748 fprintf( stderr, "--scanner backing up\n" );
749 else if ( yy_act < 13 )
750 fprintf( stderr, "--accepting rule at line %d (\"%s\")\n",
751 yy_rule_linenum[yy_act], yytext );
752 else if ( yy_act == 13 )
753 fprintf( stderr, "--accepting default rule (\"%s\")\n",
754 yytext );
755 else if ( yy_act == 14 )
756 fprintf( stderr, "--(end of buffer or a NUL)\n" );
757 else
758 fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
759 }
760
761 switch ( yy_act )
762 { /* beginning of action switch */
763 case 0: /* must back up */
764 /* undo the effects of YY_DO_BEFORE_ACTION */
765 *yy_cp = yy_hold_char;
766 yy_cp = yy_last_accepting_cpos;
767 yy_current_state = yy_last_accepting_state;
768 goto yy_find_action;
769
770case 1:
771YY_RULE_SETUP
772#line 69 "scripts/genksyms/lex.l"
773return FILENAME;
774 YY_BREAK
775case 2:
776YY_RULE_SETUP
777#line 70 "scripts/genksyms/lex.l"
778cur_line++;
779 YY_BREAK
780case 3:
781YY_RULE_SETUP
782#line 71 "scripts/genksyms/lex.l"
783cur_line++;
784 YY_BREAK
785/* Ignore all other whitespace. */
786case 4:
787YY_RULE_SETUP
788#line 74 "scripts/genksyms/lex.l"
789;
790 YY_BREAK
791case 5:
792YY_RULE_SETUP
793#line 77 "scripts/genksyms/lex.l"
794return STRING;
795 YY_BREAK
796case 6:
797YY_RULE_SETUP
798#line 78 "scripts/genksyms/lex.l"
799return CHAR;
800 YY_BREAK
801case 7:
802YY_RULE_SETUP
803#line 79 "scripts/genksyms/lex.l"
804return IDENT;
805 YY_BREAK
806/* The Pedant requires that the other C multi-character tokens be
807 recognized as tokens. We don't actually use them since we don't
808 parse expressions, but we do want whitespace to be arranged
809 around them properly. */
810case 8:
811YY_RULE_SETUP
812#line 85 "scripts/genksyms/lex.l"
813return OTHER;
814 YY_BREAK
815case 9:
816YY_RULE_SETUP
817#line 86 "scripts/genksyms/lex.l"
818return INT;
819 YY_BREAK
820case 10:
821YY_RULE_SETUP
822#line 87 "scripts/genksyms/lex.l"
823return REAL;
824 YY_BREAK
825case 11:
826YY_RULE_SETUP
827#line 89 "scripts/genksyms/lex.l"
828return DOTS;
829 YY_BREAK
830/* All other tokens are single characters. */
831case 12:
832YY_RULE_SETUP
833#line 92 "scripts/genksyms/lex.l"
834return yytext[0];
835 YY_BREAK
836case 13:
837YY_RULE_SETUP
838#line 95 "scripts/genksyms/lex.l"
839ECHO;
840 YY_BREAK
841#line 842 "scripts/genksyms/lex.c"
842case YY_STATE_EOF(INITIAL):
843case YY_STATE_EOF(V2_TOKENS):
844 yyterminate();
845
846 case YY_END_OF_BUFFER:
847 {
848 /* Amount of text matched not including the EOB char. */
849 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
850
851 /* Undo the effects of YY_DO_BEFORE_ACTION. */
852 *yy_cp = yy_hold_char;
853 YY_RESTORE_YY_MORE_OFFSET
854
855 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
856 {
857 /* We're scanning a new file or input source. It's
858 * possible that this happened because the user
859 * just pointed yyin at a new source and called
860 * yylex(). If so, then we have to assure
861 * consistency between yy_current_buffer and our
862 * globals. Here is the right place to do so, because
863 * this is the first action (other than possibly a
864 * back-up) that will match for the new input source.
865 */
866 yy_n_chars = yy_current_buffer->yy_n_chars;
867 yy_current_buffer->yy_input_file = yyin;
868 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
869 }
870
871 /* Note that here we test for yy_c_buf_p "<=" to the position
872 * of the first EOB in the buffer, since yy_c_buf_p will
873 * already have been incremented past the NUL character
874 * (since all states make transitions on EOB to the
875 * end-of-buffer state). Contrast this with the test
876 * in input().
877 */
878 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
879 { /* This was really a NUL. */
880 yy_state_type yy_next_state;
881
882 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
883
884 yy_current_state = yy_get_previous_state();
885
886 /* Okay, we're now positioned to make the NUL
887 * transition. We couldn't have
888 * yy_get_previous_state() go ahead and do it
889 * for us because it doesn't know how to deal
890 * with the possibility of jamming (and we don't
891 * want to build jamming into it because then it
892 * will run more slowly).
893 */
894
895 yy_next_state = yy_try_NUL_trans( yy_current_state );
896
897 yy_bp = yytext_ptr + YY_MORE_ADJ;
898
899 if ( yy_next_state )
900 {
901 /* Consume the NUL. */
902 yy_cp = ++yy_c_buf_p;
903 yy_current_state = yy_next_state;
904 goto yy_match;
905 }
906
907 else
908 {
909 yy_cp = yy_c_buf_p;
910 goto yy_find_action;
911 }
912 }
913
914 else switch ( yy_get_next_buffer() )
915 {
916 case EOB_ACT_END_OF_FILE:
917 {
918 yy_did_buffer_switch_on_eof = 0;
919
920 if ( yywrap() )
921 {
922 /* Note: because we've taken care in
923 * yy_get_next_buffer() to have set up
924 * yytext, we can now set up
925 * yy_c_buf_p so that if some total
926 * hoser (like flex itself) wants to
927 * call the scanner after we return the
928 * YY_NULL, it'll still work - another
929 * YY_NULL will get returned.
930 */
931 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
932
933 yy_act = YY_STATE_EOF(YY_START);
934 goto do_action;
935 }
936
937 else
938 {
939 if ( ! yy_did_buffer_switch_on_eof )
940 YY_NEW_FILE;
941 }
942 break;
943 }
944
945 case EOB_ACT_CONTINUE_SCAN:
946 yy_c_buf_p =
947 yytext_ptr + yy_amount_of_matched_text;
948
949 yy_current_state = yy_get_previous_state();
950
951 yy_cp = yy_c_buf_p;
952 yy_bp = yytext_ptr + YY_MORE_ADJ;
953 goto yy_match;
954
955 case EOB_ACT_LAST_MATCH:
956 yy_c_buf_p =
957 &yy_current_buffer->yy_ch_buf[yy_n_chars];
958
959 yy_current_state = yy_get_previous_state();
960
961 yy_cp = yy_c_buf_p;
962 yy_bp = yytext_ptr + YY_MORE_ADJ;
963 goto yy_find_action;
964 }
965 break;
966 }
967
968 default:
969 YY_FATAL_ERROR(
970 "fatal flex scanner internal error--no action found" );
971 } /* end of action switch */
972 } /* end of scanning one token */
973 } /* end of yylex */
974
975
976/* yy_get_next_buffer - try to read in a new buffer
977 *
978 * Returns a code representing an action:
979 * EOB_ACT_LAST_MATCH -
980 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
981 * EOB_ACT_END_OF_FILE - end of file
982 */
983
984static int yy_get_next_buffer()
985 {
986 register char *dest = yy_current_buffer->yy_ch_buf;
987 register char *source = yytext_ptr;
988 register int number_to_move, i;
989 int ret_val;
990
991 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
992 YY_FATAL_ERROR(
993 "fatal flex scanner internal error--end of buffer missed" );
994
995 if ( yy_current_buffer->yy_fill_buffer == 0 )
996 { /* Don't try to fill the buffer, so this is an EOF. */
997 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
998 {
999 /* We matched a single character, the EOB, so
1000 * treat this as a final EOF.
1001 */
1002 return EOB_ACT_END_OF_FILE;
1003 }
1004
1005 else
1006 {
1007 /* We matched some text prior to the EOB, first
1008 * process it.
1009 */
1010 return EOB_ACT_LAST_MATCH;
1011 }
1012 }
1013
1014 /* Try to read more data. */
1015
1016 /* First move last chars to start of buffer. */
1017 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1018
1019 for ( i = 0; i < number_to_move; ++i )
1020 *(dest++) = *(source++);
1021
1022 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1023 /* don't do the read, it's not guaranteed to return an EOF,
1024 * just force an EOF
1025 */
1026 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1027
1028 else
1029 {
1030 int num_to_read =
1031 yy_current_buffer->yy_buf_size - number_to_move - 1;
1032
1033 while ( num_to_read <= 0 )
1034 { /* Not enough room in the buffer - grow it. */
1035#ifdef YY_USES_REJECT
1036 YY_FATAL_ERROR(
1037"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1038#else
1039
1040 /* just a shorter name for the current buffer */
1041 YY_BUFFER_STATE b = yy_current_buffer;
1042
1043 int yy_c_buf_p_offset =
1044 (int) (yy_c_buf_p - b->yy_ch_buf);
1045
1046 if ( b->yy_is_our_buffer )
1047 {
1048 int new_size = b->yy_buf_size * 2;
1049
1050 if ( new_size <= 0 )
1051 b->yy_buf_size += b->yy_buf_size / 8;
1052 else
1053 b->yy_buf_size *= 2;
1054
1055 b->yy_ch_buf = (char *)
1056 /* Include room in for 2 EOB chars. */
1057 yy_flex_realloc( (void *) b->yy_ch_buf,
1058 b->yy_buf_size + 2 );
1059 }
1060 else
1061 /* Can't grow it, we don't own it. */
1062 b->yy_ch_buf = 0;
1063
1064 if ( ! b->yy_ch_buf )
1065 YY_FATAL_ERROR(
1066 "fatal error - scanner input buffer overflow" );
1067
1068 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1069
1070 num_to_read = yy_current_buffer->yy_buf_size -
1071 number_to_move - 1;
1072#endif
1073 }
1074
1075 if ( num_to_read > YY_READ_BUF_SIZE )
1076 num_to_read = YY_READ_BUF_SIZE;
1077
1078 /* Read in more data. */
1079 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1080 yy_n_chars, num_to_read );
1081
1082 yy_current_buffer->yy_n_chars = yy_n_chars;
1083 }
1084
1085 if ( yy_n_chars == 0 )
1086 {
1087 if ( number_to_move == YY_MORE_ADJ )
1088 {
1089 ret_val = EOB_ACT_END_OF_FILE;
1090 yyrestart( yyin );
1091 }
1092
1093 else
1094 {
1095 ret_val = EOB_ACT_LAST_MATCH;
1096 yy_current_buffer->yy_buffer_status =
1097 YY_BUFFER_EOF_PENDING;
1098 }
1099 }
1100
1101 else
1102 ret_val = EOB_ACT_CONTINUE_SCAN;
1103
1104 yy_n_chars += number_to_move;
1105 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1106 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1107
1108 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1109
1110 return ret_val;
1111 }
1112
1113
1114/* yy_get_previous_state - get the state just before the EOB char was reached */
1115
1116static yy_state_type yy_get_previous_state()
1117 {
1118 register yy_state_type yy_current_state;
1119 register char *yy_cp;
1120
1121 yy_current_state = yy_start;
1122 yy_current_state += YY_AT_BOL();
1123
1124 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1125 {
1126 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1127 if ( yy_accept[yy_current_state] )
1128 {
1129 yy_last_accepting_state = yy_current_state;
1130 yy_last_accepting_cpos = yy_cp;
1131 }
1132 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1133 {
1134 yy_current_state = (int) yy_def[yy_current_state];
1135 if ( yy_current_state >= 76 )
1136 yy_c = yy_meta[(unsigned int) yy_c];
1137 }
1138 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1139 }
1140
1141 return yy_current_state;
1142 }
1143
1144
1145/* yy_try_NUL_trans - try to make a transition on the NUL character
1146 *
1147 * synopsis
1148 * next_state = yy_try_NUL_trans( current_state );
1149 */
1150
1151#ifdef YY_USE_PROTOS
1152static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1153#else
1154static yy_state_type yy_try_NUL_trans( yy_current_state )
1155yy_state_type yy_current_state;
1156#endif
1157 {
1158 register int yy_is_jam;
1159 register char *yy_cp = yy_c_buf_p;
1160
1161 register YY_CHAR yy_c = 1;
1162 if ( yy_accept[yy_current_state] )
1163 {
1164 yy_last_accepting_state = yy_current_state;
1165 yy_last_accepting_cpos = yy_cp;
1166 }
1167 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1168 {
1169 yy_current_state = (int) yy_def[yy_current_state];
1170 if ( yy_current_state >= 76 )
1171 yy_c = yy_meta[(unsigned int) yy_c];
1172 }
1173 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1174 yy_is_jam = (yy_current_state == 75);
1175
1176 return yy_is_jam ? 0 : yy_current_state;
1177 }
1178
1179
1180#ifndef YY_NO_UNPUT
1181#ifdef YY_USE_PROTOS
1182static void yyunput( int c, register char *yy_bp )
1183#else
1184static void yyunput( c, yy_bp )
1185int c;
1186register char *yy_bp;
1187#endif
1188 {
1189 register char *yy_cp = yy_c_buf_p;
1190
1191 /* undo effects of setting up yytext */
1192 *yy_cp = yy_hold_char;
1193
1194 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1195 { /* need to shift things up to make room */
1196 /* +2 for EOB chars. */
1197 register int number_to_move = yy_n_chars + 2;
1198 register char *dest = &yy_current_buffer->yy_ch_buf[
1199 yy_current_buffer->yy_buf_size + 2];
1200 register char *source =
1201 &yy_current_buffer->yy_ch_buf[number_to_move];
1202
1203 while ( source > yy_current_buffer->yy_ch_buf )
1204 *--dest = *--source;
1205
1206 yy_cp += (int) (dest - source);
1207 yy_bp += (int) (dest - source);
1208 yy_current_buffer->yy_n_chars =
1209 yy_n_chars = yy_current_buffer->yy_buf_size;
1210
1211 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1212 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1213 }
1214
1215 *--yy_cp = (char) c;
1216
1217
1218 yytext_ptr = yy_bp;
1219 yy_hold_char = *yy_cp;
1220 yy_c_buf_p = yy_cp;
1221 }
1222#endif /* ifndef YY_NO_UNPUT */
1223
1224
1225#ifdef __cplusplus
1226static int yyinput()
1227#else
1228static int input()
1229#endif
1230 {
1231 int c;
1232
1233 *yy_c_buf_p = yy_hold_char;
1234
1235 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1236 {
1237 /* yy_c_buf_p now points to the character we want to return.
1238 * If this occurs *before* the EOB characters, then it's a
1239 * valid NUL; if not, then we've hit the end of the buffer.
1240 */
1241 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1242 /* This was really a NUL. */
1243 *yy_c_buf_p = '\0';
1244
1245 else
1246 { /* need more input */
1247 int offset = yy_c_buf_p - yytext_ptr;
1248 ++yy_c_buf_p;
1249
1250 switch ( yy_get_next_buffer() )
1251 {
1252 case EOB_ACT_LAST_MATCH:
1253 /* This happens because yy_g_n_b()
1254 * sees that we've accumulated a
1255 * token and flags that we need to
1256 * try matching the token before
1257 * proceeding. But for input(),
1258 * there's no matching to consider.
1259 * So convert the EOB_ACT_LAST_MATCH
1260 * to EOB_ACT_END_OF_FILE.
1261 */
1262
1263 /* Reset buffer status. */
1264 yyrestart( yyin );
1265
1266 /* fall through */
1267
1268 case EOB_ACT_END_OF_FILE:
1269 {
1270 if ( yywrap() )
1271 return EOF;
1272
1273 if ( ! yy_did_buffer_switch_on_eof )
1274 YY_NEW_FILE;
1275#ifdef __cplusplus
1276 return yyinput();
1277#else
1278 return input();
1279#endif
1280 }
1281
1282 case EOB_ACT_CONTINUE_SCAN:
1283 yy_c_buf_p = yytext_ptr + offset;
1284 break;
1285 }
1286 }
1287 }
1288
1289 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1290 *yy_c_buf_p = '\0'; /* preserve yytext */
1291 yy_hold_char = *++yy_c_buf_p;
1292
1293 yy_current_buffer->yy_at_bol = (c == '\n');
1294
1295 return c;
1296 }
1297
1298
1299#ifdef YY_USE_PROTOS
1300void yyrestart( FILE *input_file )
1301#else
1302void yyrestart( input_file )
1303FILE *input_file;
1304#endif
1305 {
1306 if ( ! yy_current_buffer )
1307 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1308
1309 yy_init_buffer( yy_current_buffer, input_file );
1310 yy_load_buffer_state();
1311 }
1312
1313
1314#ifdef YY_USE_PROTOS
1315void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1316#else
1317void yy_switch_to_buffer( new_buffer )
1318YY_BUFFER_STATE new_buffer;
1319#endif
1320 {
1321 if ( yy_current_buffer == new_buffer )
1322 return;
1323
1324 if ( yy_current_buffer )
1325 {
1326 /* Flush out information for old buffer. */
1327 *yy_c_buf_p = yy_hold_char;
1328 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1329 yy_current_buffer->yy_n_chars = yy_n_chars;
1330 }
1331
1332 yy_current_buffer = new_buffer;
1333 yy_load_buffer_state();
1334
1335 /* We don't actually know whether we did this switch during
1336 * EOF (yywrap()) processing, but the only time this flag
1337 * is looked at is after yywrap() is called, so it's safe
1338 * to go ahead and always set it.
1339 */
1340 yy_did_buffer_switch_on_eof = 1;
1341 }
1342
1343
1344#ifdef YY_USE_PROTOS
1345void yy_load_buffer_state( void )
1346#else
1347void yy_load_buffer_state()
1348#endif
1349 {
1350 yy_n_chars = yy_current_buffer->yy_n_chars;
1351 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1352 yyin = yy_current_buffer->yy_input_file;
1353 yy_hold_char = *yy_c_buf_p;
1354 }
1355
1356
1357#ifdef YY_USE_PROTOS
1358YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1359#else
1360YY_BUFFER_STATE yy_create_buffer( file, size )
1361FILE *file;
1362int size;
1363#endif
1364 {
1365 YY_BUFFER_STATE b;
1366
1367 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1368 if ( ! b )
1369 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1370
1371 b->yy_buf_size = size;
1372
1373 /* yy_ch_buf has to be 2 characters longer than the size given because
1374 * we need to put in 2 end-of-buffer characters.
1375 */
1376 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1377 if ( ! b->yy_ch_buf )
1378 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1379
1380 b->yy_is_our_buffer = 1;
1381
1382 yy_init_buffer( b, file );
1383
1384 return b;
1385 }
1386
1387
1388#ifdef YY_USE_PROTOS
1389void yy_delete_buffer( YY_BUFFER_STATE b )
1390#else
1391void yy_delete_buffer( b )
1392YY_BUFFER_STATE b;
1393#endif
1394 {
1395 if ( ! b )
1396 return;
1397
1398 if ( b == yy_current_buffer )
1399 yy_current_buffer = (YY_BUFFER_STATE) 0;
1400
1401 if ( b->yy_is_our_buffer )
1402 yy_flex_free( (void *) b->yy_ch_buf );
1403
1404 yy_flex_free( (void *) b );
1405 }
1406
1407
1408
1409#ifdef YY_USE_PROTOS
1410void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1411#else
1412void yy_init_buffer( b, file )
1413YY_BUFFER_STATE b;
1414FILE *file;
1415#endif
1416
1417
1418 {
1419 yy_flush_buffer( b );
1420
1421 b->yy_input_file = file;
1422 b->yy_fill_buffer = 1;
1423
1424#if YY_ALWAYS_INTERACTIVE
1425 b->yy_is_interactive = 1;
1426#else
1427#if YY_NEVER_INTERACTIVE
1428 b->yy_is_interactive = 0;
1429#else
1430 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1431#endif
1432#endif
1433 }
1434
1435
1436#ifdef YY_USE_PROTOS
1437void yy_flush_buffer( YY_BUFFER_STATE b )
1438#else
1439void yy_flush_buffer( b )
1440YY_BUFFER_STATE b;
1441#endif
1442
1443 {
1444 if ( ! b )
1445 return;
1446
1447 b->yy_n_chars = 0;
1448
1449 /* We always need two end-of-buffer characters. The first causes
1450 * a transition to the end-of-buffer state. The second causes
1451 * a jam in that state.
1452 */
1453 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1454 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1455
1456 b->yy_buf_pos = &b->yy_ch_buf[0];
1457
1458 b->yy_at_bol = 1;
1459 b->yy_buffer_status = YY_BUFFER_NEW;
1460
1461 if ( b == yy_current_buffer )
1462 yy_load_buffer_state();
1463 }
1464
1465
1466#ifndef YY_NO_SCAN_BUFFER
1467#ifdef YY_USE_PROTOS
1468YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1469#else
1470YY_BUFFER_STATE yy_scan_buffer( base, size )
1471char *base;
1472yy_size_t size;
1473#endif
1474 {
1475 YY_BUFFER_STATE b;
1476
1477 if ( size < 2 ||
1478 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1479 base[size-1] != YY_END_OF_BUFFER_CHAR )
1480 /* They forgot to leave room for the EOB's. */
1481 return 0;
1482
1483 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1484 if ( ! b )
1485 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1486
1487 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1488 b->yy_buf_pos = b->yy_ch_buf = base;
1489 b->yy_is_our_buffer = 0;
1490 b->yy_input_file = 0;
1491 b->yy_n_chars = b->yy_buf_size;
1492 b->yy_is_interactive = 0;
1493 b->yy_at_bol = 1;
1494 b->yy_fill_buffer = 0;
1495 b->yy_buffer_status = YY_BUFFER_NEW;
1496
1497 yy_switch_to_buffer( b );
1498
1499 return b;
1500 }
1501#endif
1502
1503
1504#ifndef YY_NO_SCAN_STRING
1505#ifdef YY_USE_PROTOS
1506YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1507#else
1508YY_BUFFER_STATE yy_scan_string( yy_str )
1509yyconst char *yy_str;
1510#endif
1511 {
1512 int len;
1513 for ( len = 0; yy_str[len]; ++len )
1514 ;
1515
1516 return yy_scan_bytes( yy_str, len );
1517 }
1518#endif
1519
1520
1521#ifndef YY_NO_SCAN_BYTES
1522#ifdef YY_USE_PROTOS
1523YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1524#else
1525YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1526yyconst char *bytes;
1527int len;
1528#endif
1529 {
1530 YY_BUFFER_STATE b;
1531 char *buf;
1532 yy_size_t n;
1533 int i;
1534
1535 /* Get memory for full buffer, including space for trailing EOB's. */
1536 n = len + 2;
1537 buf = (char *) yy_flex_alloc( n );
1538 if ( ! buf )
1539 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1540
1541 for ( i = 0; i < len; ++i )
1542 buf[i] = bytes[i];
1543
1544 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1545
1546 b = yy_scan_buffer( buf, n );
1547 if ( ! b )
1548 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1549
1550 /* It's okay to grow etc. this buffer, and we should throw it
1551 * away when we're done.
1552 */
1553 b->yy_is_our_buffer = 1;
1554
1555 return b;
1556 }
1557#endif
1558
1559
1560#ifndef YY_NO_PUSH_STATE
1561#ifdef YY_USE_PROTOS
1562static void yy_push_state( int new_state )
1563#else
1564static void yy_push_state( new_state )
1565int new_state;
1566#endif
1567 {
1568 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1569 {
1570 yy_size_t new_size;
1571
1572 yy_start_stack_depth += YY_START_STACK_INCR;
1573 new_size = yy_start_stack_depth * sizeof( int );
1574
1575 if ( ! yy_start_stack )
1576 yy_start_stack = (int *) yy_flex_alloc( new_size );
1577
1578 else
1579 yy_start_stack = (int *) yy_flex_realloc(
1580 (void *) yy_start_stack, new_size );
1581
1582 if ( ! yy_start_stack )
1583 YY_FATAL_ERROR(
1584 "out of memory expanding start-condition stack" );
1585 }
1586
1587 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1588
1589 BEGIN(new_state);
1590 }
1591#endif
1592
1593
1594#ifndef YY_NO_POP_STATE
1595static void yy_pop_state()
1596 {
1597 if ( --yy_start_stack_ptr < 0 )
1598 YY_FATAL_ERROR( "start-condition stack underflow" );
1599
1600 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1601 }
1602#endif
1603
1604
1605#ifndef YY_NO_TOP_STATE
1606static int yy_top_state()
1607 {
1608 return yy_start_stack[yy_start_stack_ptr - 1];
1609 }
1610#endif
1611
1612#ifndef YY_EXIT_FAILURE
1613#define YY_EXIT_FAILURE 2
1614#endif
1615
1616#ifdef YY_USE_PROTOS
1617static void yy_fatal_error( yyconst char msg[] )
1618#else
1619static void yy_fatal_error( msg )
1620char msg[];
1621#endif
1622 {
1623 (void) fprintf( stderr, "%s\n", msg );
1624 exit( YY_EXIT_FAILURE );
1625 }
1626
1627
1628
1629/* Redefine yyless() so it works in section 3 code. */
1630
1631#undef yyless
1632#define yyless(n) \
1633 do \
1634 { \
1635 /* Undo effects of setting up yytext. */ \
1636 yytext[yyleng] = yy_hold_char; \
1637 yy_c_buf_p = yytext + n; \
1638 yy_hold_char = *yy_c_buf_p; \
1639 *yy_c_buf_p = '\0'; \
1640 yyleng = n; \
1641 } \
1642 while ( 0 )
1643
1644
1645/* Internal utility routines. */
1646
1647#ifndef yytext_ptr
1648#ifdef YY_USE_PROTOS
1649static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1650#else
1651static void yy_flex_strncpy( s1, s2, n )
1652char *s1;
1653yyconst char *s2;
1654int n;
1655#endif
1656 {
1657 register int i;
1658 for ( i = 0; i < n; ++i )
1659 s1[i] = s2[i];
1660 }
1661#endif
1662
1663#ifdef YY_NEED_STRLEN
1664#ifdef YY_USE_PROTOS
1665static int yy_flex_strlen( yyconst char *s )
1666#else
1667static int yy_flex_strlen( s )
1668yyconst char *s;
1669#endif
1670 {
1671 register int n;
1672 for ( n = 0; s[n]; ++n )
1673 ;
1674
1675 return n;
1676 }
1677#endif
1678
1679
1680#ifdef YY_USE_PROTOS
1681static void *yy_flex_alloc( yy_size_t size )
1682#else
1683static void *yy_flex_alloc( size )
1684yy_size_t size;
1685#endif
1686 {
1687 return (void *) malloc( size );
1688 }
1689
1690#ifdef YY_USE_PROTOS
1691static void *yy_flex_realloc( void *ptr, yy_size_t size )
1692#else
1693static void *yy_flex_realloc( ptr, size )
1694void *ptr;
1695yy_size_t size;
1696#endif
1697 {
1698 /* The cast to (char *) in the following accommodates both
1699 * implementations that use char* generic pointers, and those
1700 * that use void* generic pointers. It works with the latter
1701 * because both ANSI C and C++ allow castless assignment from
1702 * any pointer type to void*, and deal with argument conversions
1703 * as though doing an assignment.
1704 */
1705 return (void *) realloc( (char *) ptr, size );
1706 }
1707
1708#ifdef YY_USE_PROTOS
1709static void yy_flex_free( void *ptr )
1710#else
1711static void yy_flex_free( ptr )
1712void *ptr;
1713#endif
1714 {
1715 free( ptr );
1716 }
1717
1718#if YY_MAIN
1719int main()
1720 {
1721 yylex();
1722 return 0;
1723 }
1724#endif
1725#line 95 "scripts/genksyms/lex.l"
1726
1727
1728/* Bring in the keyword recognizer. */
1729
1730#include "keywords.c"
1731
1732
1733/* Macros to append to our phrase collection list. */
1734
1735#define _APP(T,L) do { \
1736 cur_node = next_node; \
1737 next_node = xmalloc(sizeof(*next_node)); \
1738 next_node->next = cur_node; \
1739 cur_node->string = memcpy(xmalloc(L+1), T, L+1); \
1740 cur_node->tag = SYM_NORMAL; \
1741 } while (0)
1742
1743#define APP _APP(yytext, yyleng)
1744
1745
1746/* The second stage lexer. Here we incorporate knowledge of the state
1747 of the parser to tailor the tokens that are returned. */
1748
1749int
1750yylex(void)
1751{
1752 static enum {
1753 ST_NOTSTARTED, ST_NORMAL, ST_ATTRIBUTE, ST_ASM, ST_BRACKET, ST_BRACE,
1754 ST_EXPRESSION, ST_TABLE_1, ST_TABLE_2, ST_TABLE_3, ST_TABLE_4,
1755 ST_TABLE_5, ST_TABLE_6
1756 } lexstate = ST_NOTSTARTED;
1757
1758 static int suppress_type_lookup, dont_want_brace_phrase;
1759 static struct string_list *next_node;
1760
1761 int token, count = 0;
1762 struct string_list *cur_node;
1763
1764 if (lexstate == ST_NOTSTARTED)
1765 {
1766 BEGIN(V2_TOKENS);
1767 next_node = xmalloc(sizeof(*next_node));
1768 next_node->next = NULL;
1769 lexstate = ST_NORMAL;
1770 }
1771
1772repeat:
1773 token = yylex1();
1774
1775 if (token == 0)
1776 return 0;
1777 else if (token == FILENAME)
1778 {
1779 char *file, *e;
1780
1781 /* Save the filename and line number for later error messages. */
1782
1783 if (cur_filename)
1784 free(cur_filename);
1785
1786 file = strchr(yytext, '\"')+1;
1787 e = strchr(file, '\"');
1788 *e = '\0';
1789 cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1);
1790 cur_line = atoi(yytext+2);
1791
1792 goto repeat;
1793 }
1794
1795 switch (lexstate)
1796 {
1797 case ST_NORMAL:
1798 switch (token)
1799 {
1800 case IDENT:
1801 APP;
1802 {
1803 const struct resword *r = is_reserved_word(yytext, yyleng);
1804 if (r)
1805 {
1806 switch (token = r->token)
1807 {
1808 case ATTRIBUTE_KEYW:
1809 lexstate = ST_ATTRIBUTE;
1810 count = 0;
1811 goto repeat;
1812 case ASM_KEYW:
1813 lexstate = ST_ASM;
1814 count = 0;
1815 goto repeat;
1816
1817 case STRUCT_KEYW:
1818 case UNION_KEYW:
1819 dont_want_brace_phrase = 3;
1820 case ENUM_KEYW:
1821 suppress_type_lookup = 2;
1822 goto fini;
1823
1824 case EXPORT_SYMBOL_KEYW:
1825 goto fini;
1826 }
1827 }
1828 if (!suppress_type_lookup)
1829 {
1830 struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF);
1831 if (sym && sym->type == SYM_TYPEDEF)
1832 token = TYPE;
1833 }
1834 }
1835 break;
1836
1837 case '[':
1838 APP;
1839 lexstate = ST_BRACKET;
1840 count = 1;
1841 goto repeat;
1842
1843 case '{':
1844 APP;
1845 if (dont_want_brace_phrase)
1846 break;
1847 lexstate = ST_BRACE;
1848 count = 1;
1849 goto repeat;
1850
1851 case '=': case ':':
1852 APP;
1853 lexstate = ST_EXPRESSION;
1854 break;
1855
1856 case DOTS:
1857 default:
1858 APP;
1859 break;
1860 }
1861 break;
1862
1863 case ST_ATTRIBUTE:
1864 APP;
1865 switch (token)
1866 {
1867 case '(':
1868 ++count;
1869 goto repeat;
1870 case ')':
1871 if (--count == 0)
1872 {
1873 lexstate = ST_NORMAL;
1874 token = ATTRIBUTE_PHRASE;
1875 break;
1876 }
1877 goto repeat;
1878 default:
1879 goto repeat;
1880 }
1881 break;
1882
1883 case ST_ASM:
1884 APP;
1885 switch (token)
1886 {
1887 case '(':
1888 ++count;
1889 goto repeat;
1890 case ')':
1891 if (--count == 0)
1892 {
1893 lexstate = ST_NORMAL;
1894 token = ASM_PHRASE;
1895 break;
1896 }
1897 goto repeat;
1898 default:
1899 goto repeat;
1900 }
1901 break;
1902
1903 case ST_BRACKET:
1904 APP;
1905 switch (token)
1906 {
1907 case '[':
1908 ++count;
1909 goto repeat;
1910 case ']':
1911 if (--count == 0)
1912 {
1913 lexstate = ST_NORMAL;
1914 token = BRACKET_PHRASE;
1915 break;
1916 }
1917 goto repeat;
1918 default:
1919 goto repeat;
1920 }
1921 break;
1922
1923 case ST_BRACE:
1924 APP;
1925 switch (token)
1926 {
1927 case '{':
1928 ++count;
1929 goto repeat;
1930 case '}':
1931 if (--count == 0)
1932 {
1933 lexstate = ST_NORMAL;
1934 token = BRACE_PHRASE;
1935 break;
1936 }
1937 goto repeat;
1938 default:
1939 goto repeat;
1940 }
1941 break;
1942
1943 case ST_EXPRESSION:
1944 switch (token)
1945 {
1946 case '(': case '[': case '{':
1947 ++count;
1948 APP;
1949 goto repeat;
1950 case ')': case ']': case '}':
1951 --count;
1952 APP;
1953 goto repeat;
1954 case ',': case ';':
1955 if (count == 0)
1956 {
1957 /* Put back the token we just read so's we can find it again
1958 after registering the expression. */
1959 unput(token);
1960
1961 lexstate = ST_NORMAL;
1962 token = EXPRESSION_PHRASE;
1963 break;
1964 }
1965 APP;
1966 goto repeat;
1967 default:
1968 APP;
1969 goto repeat;
1970 }
1971 break;
1972
1973 case ST_TABLE_1:
1974 goto repeat;
1975
1976 case ST_TABLE_2:
1977 if (token == IDENT && yyleng == 1 && yytext[0] == 'X')
1978 {
1979 token = EXPORT_SYMBOL_KEYW;
1980 lexstate = ST_TABLE_5;
1981 APP;
1982 break;
1983 }
1984 lexstate = ST_TABLE_6;
1985 /* FALLTHRU */
1986
1987 case ST_TABLE_6:
1988 switch (token)
1989 {
1990 case '{': case '[': case '(':
1991 ++count;
1992 break;
1993 case '}': case ']': case ')':
1994 --count;
1995 break;
1996 case ',':
1997 if (count == 0)
1998 lexstate = ST_TABLE_2;
1999 break;
2000 };
2001 goto repeat;
2002
2003 case ST_TABLE_3:
2004 goto repeat;
2005
2006 case ST_TABLE_4:
2007 if (token == ';')
2008 lexstate = ST_NORMAL;
2009 goto repeat;
2010
2011 case ST_TABLE_5:
2012 switch (token)
2013 {
2014 case ',':
2015 token = ';';
2016 lexstate = ST_TABLE_2;
2017 APP;
2018 break;
2019 default:
2020 APP;
2021 break;
2022 }
2023 break;
2024
2025 default:
2026 abort();
2027 }
2028fini:
2029
2030 if (suppress_type_lookup > 0)
2031 --suppress_type_lookup;
2032 if (dont_want_brace_phrase > 0)
2033 --dont_want_brace_phrase;
2034
2035 yylval = &next_node->next;
2036
2037 return token;
2038}
2039#ifndef YYSTYPE
2040#define YYSTYPE int
2041#endif
2042#define ASM_KEYW 257
2043#define ATTRIBUTE_KEYW 258
2044#define AUTO_KEYW 259
2045#define BOOL_KEYW 260
2046#define CHAR_KEYW 261
2047#define CONST_KEYW 262
2048#define DOUBLE_KEYW 263
2049#define ENUM_KEYW 264
2050#define EXTERN_KEYW 265
2051#define FLOAT_KEYW 266
2052#define INLINE_KEYW 267
2053#define INT_KEYW 268
2054#define LONG_KEYW 269
2055#define REGISTER_KEYW 270
2056#define RESTRICT_KEYW 271
2057#define SHORT_KEYW 272
2058#define SIGNED_KEYW 273
2059#define STATIC_KEYW 274
2060#define STRUCT_KEYW 275
2061#define TYPEDEF_KEYW 276
2062#define UNION_KEYW 277
2063#define UNSIGNED_KEYW 278
2064#define VOID_KEYW 279
2065#define VOLATILE_KEYW 280
2066#define TYPEOF_KEYW 281
2067#define EXPORT_SYMBOL_KEYW 282
2068#define ASM_PHRASE 283
2069#define ATTRIBUTE_PHRASE 284
2070#define BRACE_PHRASE 285
2071#define BRACKET_PHRASE 286
2072#define EXPRESSION_PHRASE 287
2073#define CHAR 288
2074#define DOTS 289
2075#define IDENT 290
2076#define INT 291
2077#define REAL 292
2078#define STRING 293
2079#define TYPE 294
2080#define OTHER 295
2081#define FILENAME 296
2082
2083
2084extern YYSTYPE yylval;
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
new file mode 100644
index 000000000000..fe0dfeedf0ff
--- /dev/null
+++ b/scripts/genksyms/lex.l
@@ -0,0 +1,407 @@
1/* Lexical analysis for genksyms.
2 Copyright 1996, 1997 Linux International.
3
4 New implementation contributed by Richard Henderson <rth@tamu.edu>
5 Based on original work by Bjorn Ekwall <bj0rn@blox.se>
6
7 Taken from Linux modutils 2.4.22.
8
9 This program is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 2 of the License, or (at your
12 option) any later version.
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23
24%{
25
26#include <limits.h>
27#include <stdlib.h>
28#include <string.h>
29#include <ctype.h>
30
31#include "genksyms.h"
32#include "parse.h"
33
34/* We've got a two-level lexer here. We let flex do basic tokenization
35 and then we categorize those basic tokens in the second stage. */
36#define YY_DECL static int yylex1(void)
37
38%}
39
40IDENT [A-Za-z_\$][A-Za-z0-9_\$]*
41
42O_INT 0[0-7]*
43D_INT [1-9][0-9]*
44X_INT 0[Xx][0-9A-Fa-f]+
45I_SUF [Uu]|[Ll]|[Uu][Ll]|[Ll][Uu]
46INT ({O_INT}|{D_INT}|{X_INT}){I_SUF}?
47
48FRAC ([0-9]*\.[0-9]+)|([0-9]+\.)
49EXP [Ee][+-]?[0-9]+
50F_SUF [FfLl]
51REAL ({FRAC}{EXP}?{F_SUF}?)|([0-9]+{EXP}{F_SUF}?)
52
53STRING L?\"([^\\\"]*\\.)*[^\\\"]*\"
54CHAR L?\'([^\\\']*\\.)*[^\\\']*\'
55
56MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>)
57
58/* Version 2 checksumming does proper tokenization; version 1 wasn't
59 quite so pedantic. */
60%s V2_TOKENS
61
62/* We don't do multiple input files. */
63%option noyywrap
64
65%%
66
67
68 /* Keep track of our location in the original source files. */
69^#[ \t]+{INT}[ \t]+\"[^\"\n]+\".*\n return FILENAME;
70^#.*\n cur_line++;
71\n cur_line++;
72
73 /* Ignore all other whitespace. */
74[ \t\f\v\r]+ ;
75
76
77{STRING} return STRING;
78{CHAR} return CHAR;
79{IDENT} return IDENT;
80
81 /* The Pedant requires that the other C multi-character tokens be
82 recognized as tokens. We don't actually use them since we don't
83 parse expressions, but we do want whitespace to be arranged
84 around them properly. */
85<V2_TOKENS>{MC_TOKEN} return OTHER;
86<V2_TOKENS>{INT} return INT;
87<V2_TOKENS>{REAL} return REAL;
88
89"..." return DOTS;
90
91 /* All other tokens are single characters. */
92. return yytext[0];
93
94
95%%
96
97/* Bring in the keyword recognizer. */
98
99#include "keywords.c"
100
101
102/* Macros to append to our phrase collection list. */
103
104#define _APP(T,L) do { \
105 cur_node = next_node; \
106 next_node = xmalloc(sizeof(*next_node)); \
107 next_node->next = cur_node; \
108 cur_node->string = memcpy(xmalloc(L+1), T, L+1); \
109 cur_node->tag = SYM_NORMAL; \
110 } while (0)
111
112#define APP _APP(yytext, yyleng)
113
114
115/* The second stage lexer. Here we incorporate knowledge of the state
116 of the parser to tailor the tokens that are returned. */
117
118int
119yylex(void)
120{
121 static enum {
122 ST_NOTSTARTED, ST_NORMAL, ST_ATTRIBUTE, ST_ASM, ST_BRACKET, ST_BRACE,
123 ST_EXPRESSION, ST_TABLE_1, ST_TABLE_2, ST_TABLE_3, ST_TABLE_4,
124 ST_TABLE_5, ST_TABLE_6
125 } lexstate = ST_NOTSTARTED;
126
127 static int suppress_type_lookup, dont_want_brace_phrase;
128 static struct string_list *next_node;
129
130 int token, count = 0;
131 struct string_list *cur_node;
132
133 if (lexstate == ST_NOTSTARTED)
134 {
135 BEGIN(V2_TOKENS);
136 next_node = xmalloc(sizeof(*next_node));
137 next_node->next = NULL;
138 lexstate = ST_NORMAL;
139 }
140
141repeat:
142 token = yylex1();
143
144 if (token == 0)
145 return 0;
146 else if (token == FILENAME)
147 {
148 char *file, *e;
149
150 /* Save the filename and line number for later error messages. */
151
152 if (cur_filename)
153 free(cur_filename);
154
155 file = strchr(yytext, '\"')+1;
156 e = strchr(file, '\"');
157 *e = '\0';
158 cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1);
159 cur_line = atoi(yytext+2);
160
161 goto repeat;
162 }
163
164 switch (lexstate)
165 {
166 case ST_NORMAL:
167 switch (token)
168 {
169 case IDENT:
170 APP;
171 {
172 const struct resword *r = is_reserved_word(yytext, yyleng);
173 if (r)
174 {
175 switch (token = r->token)
176 {
177 case ATTRIBUTE_KEYW:
178 lexstate = ST_ATTRIBUTE;
179 count = 0;
180 goto repeat;
181 case ASM_KEYW:
182 lexstate = ST_ASM;
183 count = 0;
184 goto repeat;
185
186 case STRUCT_KEYW:
187 case UNION_KEYW:
188 dont_want_brace_phrase = 3;
189 case ENUM_KEYW:
190 suppress_type_lookup = 2;
191 goto fini;
192
193 case EXPORT_SYMBOL_KEYW:
194 goto fini;
195 }
196 }
197 if (!suppress_type_lookup)
198 {
199 struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF);
200 if (sym && sym->type == SYM_TYPEDEF)
201 token = TYPE;
202 }
203 }
204 break;
205
206 case '[':
207 APP;
208 lexstate = ST_BRACKET;
209 count = 1;
210 goto repeat;
211
212 case '{':
213 APP;
214 if (dont_want_brace_phrase)
215 break;
216 lexstate = ST_BRACE;
217 count = 1;
218 goto repeat;
219
220 case '=': case ':':
221 APP;
222 lexstate = ST_EXPRESSION;
223 break;
224
225 case DOTS:
226 default:
227 APP;
228 break;
229 }
230 break;
231
232 case ST_ATTRIBUTE:
233 APP;
234 switch (token)
235 {
236 case '(':
237 ++count;
238 goto repeat;
239 case ')':
240 if (--count == 0)
241 {
242 lexstate = ST_NORMAL;
243 token = ATTRIBUTE_PHRASE;
244 break;
245 }
246 goto repeat;
247 default:
248 goto repeat;
249 }
250 break;
251
252 case ST_ASM:
253 APP;
254 switch (token)
255 {
256 case '(':
257 ++count;
258 goto repeat;
259 case ')':
260 if (--count == 0)
261 {
262 lexstate = ST_NORMAL;
263 token = ASM_PHRASE;
264 break;
265 }
266 goto repeat;
267 default:
268 goto repeat;
269 }
270 break;
271
272 case ST_BRACKET:
273 APP;
274 switch (token)
275 {
276 case '[':
277 ++count;
278 goto repeat;
279 case ']':
280 if (--count == 0)
281 {
282 lexstate = ST_NORMAL;
283 token = BRACKET_PHRASE;
284 break;
285 }
286 goto repeat;
287 default:
288 goto repeat;
289 }
290 break;
291
292 case ST_BRACE:
293 APP;
294 switch (token)
295 {
296 case '{':
297 ++count;
298 goto repeat;
299 case '}':
300 if (--count == 0)
301 {
302 lexstate = ST_NORMAL;
303 token = BRACE_PHRASE;
304 break;
305 }
306 goto repeat;
307 default:
308 goto repeat;
309 }
310 break;
311
312 case ST_EXPRESSION:
313 switch (token)
314 {
315 case '(': case '[': case '{':
316 ++count;
317 APP;
318 goto repeat;
319 case ')': case ']': case '}':
320 --count;
321 APP;
322 goto repeat;
323 case ',': case ';':
324 if (count == 0)
325 {
326 /* Put back the token we just read so's we can find it again
327 after registering the expression. */
328 unput(token);
329
330 lexstate = ST_NORMAL;
331 token = EXPRESSION_PHRASE;
332 break;
333 }
334 APP;
335 goto repeat;
336 default:
337 APP;
338 goto repeat;
339 }
340 break;
341
342 case ST_TABLE_1:
343 goto repeat;
344
345 case ST_TABLE_2:
346 if (token == IDENT && yyleng == 1 && yytext[0] == 'X')
347 {
348 token = EXPORT_SYMBOL_KEYW;
349 lexstate = ST_TABLE_5;
350 APP;
351 break;
352 }
353 lexstate = ST_TABLE_6;
354 /* FALLTHRU */
355
356 case ST_TABLE_6:
357 switch (token)
358 {
359 case '{': case '[': case '(':
360 ++count;
361 break;
362 case '}': case ']': case ')':
363 --count;
364 break;
365 case ',':
366 if (count == 0)
367 lexstate = ST_TABLE_2;
368 break;
369 };
370 goto repeat;
371
372 case ST_TABLE_3:
373 goto repeat;
374
375 case ST_TABLE_4:
376 if (token == ';')
377 lexstate = ST_NORMAL;
378 goto repeat;
379
380 case ST_TABLE_5:
381 switch (token)
382 {
383 case ',':
384 token = ';';
385 lexstate = ST_TABLE_2;
386 APP;
387 break;
388 default:
389 APP;
390 break;
391 }
392 break;
393
394 default:
395 abort();
396 }
397fini:
398
399 if (suppress_type_lookup > 0)
400 --suppress_type_lookup;
401 if (dont_want_brace_phrase > 0)
402 --dont_want_brace_phrase;
403
404 yylval = &next_node->next;
405
406 return token;
407}
diff --git a/scripts/genksyms/parse.c_shipped b/scripts/genksyms/parse.c_shipped
new file mode 100644
index 000000000000..2c6b1286b638
--- /dev/null
+++ b/scripts/genksyms/parse.c_shipped
@@ -0,0 +1,1577 @@
1
2/* A Bison parser, made from scripts/genksyms/parse.y
3 by GNU Bison version 1.28 */
4
5#define YYBISON 1 /* Identify Bison output. */
6
7#define ASM_KEYW 257
8#define ATTRIBUTE_KEYW 258
9#define AUTO_KEYW 259
10#define BOOL_KEYW 260
11#define CHAR_KEYW 261
12#define CONST_KEYW 262
13#define DOUBLE_KEYW 263
14#define ENUM_KEYW 264
15#define EXTERN_KEYW 265
16#define FLOAT_KEYW 266
17#define INLINE_KEYW 267
18#define INT_KEYW 268
19#define LONG_KEYW 269
20#define REGISTER_KEYW 270
21#define RESTRICT_KEYW 271
22#define SHORT_KEYW 272
23#define SIGNED_KEYW 273
24#define STATIC_KEYW 274
25#define STRUCT_KEYW 275
26#define TYPEDEF_KEYW 276
27#define UNION_KEYW 277
28#define UNSIGNED_KEYW 278
29#define VOID_KEYW 279
30#define VOLATILE_KEYW 280
31#define TYPEOF_KEYW 281
32#define EXPORT_SYMBOL_KEYW 282
33#define ASM_PHRASE 283
34#define ATTRIBUTE_PHRASE 284
35#define BRACE_PHRASE 285
36#define BRACKET_PHRASE 286
37#define EXPRESSION_PHRASE 287
38#define CHAR 288
39#define DOTS 289
40#define IDENT 290
41#define INT 291
42#define REAL 292
43#define STRING 293
44#define TYPE 294
45#define OTHER 295
46#define FILENAME 296
47
48#line 24 "scripts/genksyms/parse.y"
49
50
51#include <assert.h>
52#include <malloc.h>
53#include "genksyms.h"
54
55static int is_typedef;
56static int is_extern;
57static char *current_name;
58static struct string_list *decl_spec;
59
60static void yyerror(const char *);
61
62static inline void
63remove_node(struct string_list **p)
64{
65 struct string_list *node = *p;
66 *p = node->next;
67 free_node(node);
68}
69
70static inline void
71remove_list(struct string_list **pb, struct string_list **pe)
72{
73 struct string_list *b = *pb, *e = *pe;
74 *pb = e;
75 free_list(b, e);
76}
77
78#ifndef YYSTYPE
79#define YYSTYPE int
80#endif
81#ifndef YYDEBUG
82#define YYDEBUG 1
83#endif
84
85#include <stdio.h>
86
87#ifndef __cplusplus
88#ifndef __STDC__
89#define const
90#endif
91#endif
92
93
94
95#define YYFINAL 172
96#define YYFLAG -32768
97#define YYNTBASE 52
98
99#define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 96)
100
101static const char yytranslate[] = { 0,
102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
103 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
104 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
105 2, 2, 2, 2, 2, 2, 2, 2, 2, 46,
106 47, 48, 2, 45, 2, 2, 2, 2, 2, 2,
107 2, 2, 2, 2, 2, 2, 2, 51, 43, 2,
108 49, 2, 2, 2, 2, 2, 2, 2, 2, 2,
109 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
110 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
111 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
112 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
113 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
114 2, 2, 50, 2, 44, 2, 2, 2, 2, 2,
115 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
116 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
117 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
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, 2,
122 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
123 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
124 2, 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, 1, 3, 4, 5, 6,
128 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
129 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
130 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
131 37, 38, 39, 40, 41, 42
132};
133
134#if YYDEBUG != 0
135static const short yyprhs[] = { 0,
136 0, 2, 5, 6, 9, 10, 14, 16, 18, 20,
137 22, 25, 28, 32, 33, 35, 37, 41, 46, 47,
138 49, 51, 54, 56, 58, 60, 62, 64, 66, 68,
139 70, 72, 77, 80, 83, 86, 90, 94, 98, 101,
140 104, 107, 109, 111, 113, 115, 117, 119, 121, 123,
141 125, 127, 129, 132, 133, 135, 137, 140, 142, 144,
142 146, 148, 151, 153, 155, 160, 165, 168, 172, 176,
143 179, 181, 183, 185, 190, 195, 198, 202, 206, 209,
144 211, 215, 216, 218, 220, 224, 227, 230, 232, 233,
145 235, 237, 242, 247, 250, 254, 258, 262, 263, 265,
146 268, 272, 276, 277, 279, 281, 284, 288, 291, 292,
147 294, 296, 300, 303, 306, 308, 311, 312, 314, 317,
148 318, 320
149};
150
151static const short yyrhs[] = { 53,
152 0, 52, 53, 0, 0, 54, 55, 0, 0, 22,
153 56, 57, 0, 57, 0, 81, 0, 93, 0, 95,
154 0, 1, 43, 0, 1, 44, 0, 61, 58, 43,
155 0, 0, 59, 0, 60, 0, 59, 45, 60, 0,
156 71, 94, 92, 82, 0, 0, 62, 0, 63, 0,
157 62, 63, 0, 64, 0, 65, 0, 5, 0, 16,
158 0, 20, 0, 11, 0, 13, 0, 66, 0, 70,
159 0, 27, 46, 62, 47, 0, 21, 36, 0, 23,
160 36, 0, 10, 36, 0, 21, 36, 84, 0, 23,
161 36, 84, 0, 10, 36, 31, 0, 10, 31, 0,
162 21, 84, 0, 23, 84, 0, 7, 0, 18, 0,
163 14, 0, 15, 0, 19, 0, 24, 0, 12, 0,
164 9, 0, 25, 0, 6, 0, 40, 0, 48, 68,
165 0, 0, 69, 0, 70, 0, 69, 70, 0, 8,
166 0, 26, 0, 30, 0, 17, 0, 67, 71, 0,
167 72, 0, 36, 0, 72, 46, 75, 47, 0, 72,
168 46, 1, 47, 0, 72, 32, 0, 46, 71, 47,
169 0, 46, 1, 47, 0, 67, 73, 0, 74, 0,
170 36, 0, 40, 0, 74, 46, 75, 47, 0, 74,
171 46, 1, 47, 0, 74, 32, 0, 46, 73, 47,
172 0, 46, 1, 47, 0, 76, 35, 0, 76, 0,
173 77, 45, 35, 0, 0, 77, 0, 78, 0, 77,
174 45, 78, 0, 62, 79, 0, 67, 79, 0, 80,
175 0, 0, 36, 0, 40, 0, 80, 46, 75, 47,
176 0, 80, 46, 1, 47, 0, 80, 32, 0, 46,
177 79, 47, 0, 46, 1, 47, 0, 61, 71, 31,
178 0, 0, 83, 0, 49, 33, 0, 50, 85, 44,
179 0, 50, 1, 44, 0, 0, 86, 0, 87, 0,
180 86, 87, 0, 61, 88, 43, 0, 1, 43, 0,
181 0, 89, 0, 90, 0, 89, 45, 90, 0, 73,
182 92, 0, 36, 91, 0, 91, 0, 51, 33, 0,
183 0, 30, 0, 29, 43, 0, 0, 29, 0, 28,
184 46, 36, 47, 43, 0
185};
186
187#endif
188
189#if YYDEBUG != 0
190static const short yyrline[] = { 0,
191 101, 103, 106, 109, 112, 114, 115, 116, 117, 118,
192 119, 120, 123, 137, 139, 142, 151, 163, 169, 171,
193 174, 176, 179, 186, 189, 191, 192, 193, 194, 197,
194 199, 200, 204, 206, 208, 212, 219, 226, 235, 236,
195 237, 240, 242, 243, 244, 245, 246, 247, 248, 249,
196 250, 251, 254, 259, 261, 264, 266, 269, 270, 270,
197 271, 278, 280, 283, 293, 295, 297, 299, 301, 307,
198 309, 312, 314, 315, 317, 319, 321, 323, 327, 329,
199 330, 333, 335, 338, 340, 344, 349, 352, 355, 357,
200 365, 369, 371, 373, 375, 377, 381, 390, 392, 396,
201 401, 403, 406, 408, 411, 413, 416, 419, 423, 425,
202 428, 430, 433, 435, 436, 439, 443, 445, 448, 452,
203 454, 457
204};
205#endif
206
207
208#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
209
210static const char * const yytname[] = { "$","error","$undefined.","ASM_KEYW",
211"ATTRIBUTE_KEYW","AUTO_KEYW","BOOL_KEYW","CHAR_KEYW","CONST_KEYW","DOUBLE_KEYW",
212"ENUM_KEYW","EXTERN_KEYW","FLOAT_KEYW","INLINE_KEYW","INT_KEYW","LONG_KEYW",
213"REGISTER_KEYW","RESTRICT_KEYW","SHORT_KEYW","SIGNED_KEYW","STATIC_KEYW","STRUCT_KEYW",
214"TYPEDEF_KEYW","UNION_KEYW","UNSIGNED_KEYW","VOID_KEYW","VOLATILE_KEYW","TYPEOF_KEYW",
215"EXPORT_SYMBOL_KEYW","ASM_PHRASE","ATTRIBUTE_PHRASE","BRACE_PHRASE","BRACKET_PHRASE",
216"EXPRESSION_PHRASE","CHAR","DOTS","IDENT","INT","REAL","STRING","TYPE","OTHER",
217"FILENAME","';'","'}'","','","'('","')'","'*'","'='","'{'","':'","declaration_seq",
218"declaration","@1","declaration1","@2","simple_declaration","init_declarator_list_opt",
219"init_declarator_list","init_declarator","decl_specifier_seq_opt","decl_specifier_seq",
220"decl_specifier","storage_class_specifier","type_specifier","simple_type_specifier",
221"ptr_operator","cvar_qualifier_seq_opt","cvar_qualifier_seq","cvar_qualifier",
222"declarator","direct_declarator","nested_declarator","direct_nested_declarator",
223"parameter_declaration_clause","parameter_declaration_list_opt","parameter_declaration_list",
224"parameter_declaration","m_abstract_declarator","direct_m_abstract_declarator",
225"function_definition","initializer_opt","initializer","class_body","member_specification_opt",
226"member_specification","member_declaration","member_declarator_list_opt","member_declarator_list",
227"member_declarator","member_bitfield_declarator","attribute_opt","asm_definition",
228"asm_phrase_opt","export_definition", NULL
229};
230#endif
231
232static const short yyr1[] = { 0,
233 52, 52, 54, 53, 56, 55, 55, 55, 55, 55,
234 55, 55, 57, 58, 58, 59, 59, 60, 61, 61,
235 62, 62, 63, 63, 64, 64, 64, 64, 64, 65,
236 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
237 65, 66, 66, 66, 66, 66, 66, 66, 66, 66,
238 66, 66, 67, 68, 68, 69, 69, 70, 70, 70,
239 70, 71, 71, 72, 72, 72, 72, 72, 72, 73,
240 73, 74, 74, 74, 74, 74, 74, 74, 75, 75,
241 75, 76, 76, 77, 77, 78, 79, 79, 80, 80,
242 80, 80, 80, 80, 80, 80, 81, 82, 82, 83,
243 84, 84, 85, 85, 86, 86, 87, 87, 88, 88,
244 89, 89, 90, 90, 90, 91, 92, 92, 93, 94,
245 94, 95
246};
247
248static const short yyr2[] = { 0,
249 1, 2, 0, 2, 0, 3, 1, 1, 1, 1,
250 2, 2, 3, 0, 1, 1, 3, 4, 0, 1,
251 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
252 1, 4, 2, 2, 2, 3, 3, 3, 2, 2,
253 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
254 1, 1, 2, 0, 1, 1, 2, 1, 1, 1,
255 1, 2, 1, 1, 4, 4, 2, 3, 3, 2,
256 1, 1, 1, 4, 4, 2, 3, 3, 2, 1,
257 3, 0, 1, 1, 3, 2, 2, 1, 0, 1,
258 1, 4, 4, 2, 3, 3, 3, 0, 1, 2,
259 3, 3, 0, 1, 1, 2, 3, 2, 0, 1,
260 1, 3, 2, 2, 1, 2, 0, 1, 2, 0,
261 1, 5
262};
263
264static const short yydefact[] = { 3,
265 3, 1, 0, 2, 0, 25, 51, 42, 58, 49,
266 0, 28, 48, 29, 44, 45, 26, 61, 43, 46,
267 27, 0, 5, 0, 47, 50, 59, 0, 0, 0,
268 60, 52, 4, 7, 14, 20, 21, 23, 24, 30,
269 31, 8, 9, 10, 11, 12, 39, 35, 33, 0,
270 40, 19, 34, 41, 0, 0, 119, 64, 0, 54,
271 0, 15, 16, 0, 120, 63, 22, 38, 36, 0,
272 109, 0, 0, 105, 6, 14, 37, 0, 0, 0,
273 0, 53, 55, 56, 13, 0, 62, 121, 97, 117,
274 67, 0, 108, 102, 72, 73, 0, 0, 0, 117,
275 71, 0, 110, 111, 115, 101, 0, 106, 120, 32,
276 0, 69, 68, 57, 17, 118, 98, 0, 89, 0,
277 80, 83, 84, 114, 0, 72, 0, 116, 70, 113,
278 76, 0, 107, 0, 122, 0, 18, 99, 66, 90,
279 52, 0, 89, 86, 88, 65, 79, 0, 78, 77,
280 0, 0, 112, 100, 0, 91, 0, 87, 94, 0,
281 81, 85, 75, 74, 96, 95, 0, 0, 93, 92,
282 0, 0
283};
284
285static const short yydefgoto[] = { 1,
286 2, 3, 33, 52, 34, 61, 62, 63, 71, 36,
287 37, 38, 39, 40, 64, 82, 83, 41, 109, 66,
288 100, 101, 120, 121, 122, 123, 144, 145, 42, 137,
289 138, 51, 72, 73, 74, 102, 103, 104, 105, 117,
290 43, 90, 44
291};
292
293static const short yypact[] = {-32768,
294 15,-32768, 197,-32768, 23,-32768,-32768,-32768,-32768,-32768,
295 -18,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
296-32768, -28,-32768, -25,-32768,-32768,-32768, -26, -22, -12,
297-32768,-32768,-32768,-32768, 49, 493,-32768,-32768,-32768,-32768,
298-32768,-32768,-32768,-32768,-32768,-32768,-32768, 27, -8, 101,
299-32768, 493, -8,-32768, 493, 10,-32768,-32768, 11, 9,
300 18, 26,-32768, 49, -15, -13,-32768,-32768,-32768, 25,
301 24, 48, 149,-32768,-32768, 49,-32768, 414, 39, 40,
302 47,-32768, 9,-32768,-32768, 49,-32768,-32768,-32768, 66,
303-32768, 241,-32768,-32768, 50,-32768, 5, 65, 42, 66,
304 17, 56, 55,-32768,-32768,-32768, 60,-32768, 75,-32768,
305 80,-32768,-32768,-32768,-32768,-32768, 81, 82, 370, 85,
306 98, 89,-32768,-32768, 88,-32768, 91,-32768,-32768,-32768,
307-32768, 284,-32768, 24,-32768, 103,-32768,-32768,-32768,-32768,
308-32768, 8, 43,-32768, 30,-32768,-32768, 457,-32768,-32768,
309 92, 93,-32768,-32768, 95,-32768, 96,-32768,-32768, 327,
310-32768,-32768,-32768,-32768,-32768,-32768, 99, 104,-32768,-32768,
311 148,-32768
312};
313
314static const short yypgoto[] = {-32768,
315 152,-32768,-32768,-32768, 119,-32768,-32768, 94, 0, -55,
316 -35,-32768,-32768,-32768, -69,-32768,-32768, -56, -30,-32768,
317 -76,-32768, -122,-32768,-32768, 29, -62,-32768,-32768,-32768,
318-32768, -17,-32768,-32768, 105,-32768,-32768, 52, 86, 83,
319-32768,-32768,-32768
320};
321
322
323#define YYLAST 533
324
325
326static const short yytable[] = { 78,
327 67, 99, 35, 84, 65, 125, 54, 49, 155, 152,
328 53, 80, 47, 88, 171, 89, 9, 48, 91, 55,
329 127, 50, 129, 56, 50, 18, 114, 99, 81, 99,
330 57, 69, 92, 87, 27, 77, 119, 168, 31, -89,
331 126, 50, 67, 140, 96, 79, 58, 156, 131, 143,
332 97, 76, 60, 142, -89, 60, 59, 68, 60, 95,
333 85, 159, 132, 96, 99, 45, 46, 93, 94, 97,
334 86, 60, 143, 143, 98, 160, 119, 126, 140, 157,
335 158, 96, 156, 67, 58, 111, 112, 97, 142, 60,
336 60, 106, 119, 113, 59, 116, 60, 128, 133, 134,
337 98, 70, 93, 88, 119, 6, 7, 8, 9, 10,
338 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
339 21, 22, 135, 24, 25, 26, 27, 28, 139, 136,
340 31, 146, 147, 148, 149, 154, -19, 150, 163, 164,
341 32, 165, 166, -19, -103, 169, -19, 172, -19, 107,
342 170, -19, 4, 6, 7, 8, 9, 10, 11, 12,
343 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
344 75, 24, 25, 26, 27, 28, 162, 108, 31, 115,
345 124, 0, 130, 0, -19, 153, 0, 0, 32, 0,
346 0, -19, -104, 0, -19, 0, -19, 5, 0, -19,
347 0, 6, 7, 8, 9, 10, 11, 12, 13, 14,
348 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
349 25, 26, 27, 28, 29, 30, 31, 0, 0, 0,
350 0, 0, -19, 0, 0, 0, 32, 0, 0, -19,
351 0, 118, -19, 0, -19, 6, 7, 8, 9, 10,
352 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
353 21, 22, 0, 24, 25, 26, 27, 28, 0, 0,
354 31, 0, 0, 0, 0, -82, 0, 0, 0, 0,
355 32, 0, 0, 0, 151, 0, 0, -82, 6, 7,
356 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
357 18, 19, 20, 21, 22, 0, 24, 25, 26, 27,
358 28, 0, 0, 31, 0, 0, 0, 0, -82, 0,
359 0, 0, 0, 32, 0, 0, 0, 167, 0, 0,
360 -82, 6, 7, 8, 9, 10, 11, 12, 13, 14,
361 15, 16, 17, 18, 19, 20, 21, 22, 0, 24,
362 25, 26, 27, 28, 0, 0, 31, 0, 0, 0,
363 0, -82, 0, 0, 0, 0, 32, 0, 0, 0,
364 0, 0, 0, -82, 6, 7, 8, 9, 10, 11,
365 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
366 22, 0, 24, 25, 26, 27, 28, 0, 0, 31,
367 0, 0, 0, 0, 0, 140, 0, 0, 0, 141,
368 0, 0, 0, 0, 0, 142, 0, 60, 6, 7,
369 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
370 18, 19, 20, 21, 22, 0, 24, 25, 26, 27,
371 28, 0, 0, 31, 0, 0, 0, 0, 0, 0,
372 0, 0, 0, 32, 0, 0, 0, 0, 0, 0,
373 110, 6, 7, 8, 9, 10, 11, 12, 13, 14,
374 15, 16, 17, 18, 19, 20, 21, 22, 0, 24,
375 25, 26, 27, 28, 0, 0, 31, 0, 0, 0,
376 0, 161, 0, 0, 0, 0, 32, 6, 7, 8,
377 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
378 19, 20, 21, 22, 0, 24, 25, 26, 27, 28,
379 0, 0, 31, 0, 0, 0, 0, 0, 0, 0,
380 0, 0, 32
381};
382
383static const short yycheck[] = { 55,
384 36, 71, 3, 60, 35, 1, 24, 36, 1, 132,
385 36, 1, 31, 29, 0, 31, 8, 36, 32, 46,
386 97, 50, 99, 46, 50, 17, 83, 97, 59, 99,
387 43, 49, 46, 64, 26, 53, 92, 160, 30, 32,
388 36, 50, 78, 36, 40, 36, 36, 40, 32, 119,
389 46, 52, 48, 46, 47, 48, 46, 31, 48, 36,
390 43, 32, 46, 40, 134, 43, 44, 43, 44, 46,
391 45, 48, 142, 143, 51, 46, 132, 36, 36, 142,
392 143, 40, 40, 119, 36, 47, 47, 46, 46, 48,
393 48, 44, 148, 47, 46, 30, 48, 33, 43, 45,
394 51, 1, 43, 29, 160, 5, 6, 7, 8, 9,
395 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
396 20, 21, 43, 23, 24, 25, 26, 27, 47, 49,
397 30, 47, 35, 45, 47, 33, 36, 47, 47, 47,
398 40, 47, 47, 43, 44, 47, 46, 0, 48, 1,
399 47, 51, 1, 5, 6, 7, 8, 9, 10, 11,
400 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
401 52, 23, 24, 25, 26, 27, 148, 73, 30, 86,
402 95, -1, 100, -1, 36, 134, -1, -1, 40, -1,
403 -1, 43, 44, -1, 46, -1, 48, 1, -1, 51,
404 -1, 5, 6, 7, 8, 9, 10, 11, 12, 13,
405 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
406 24, 25, 26, 27, 28, 29, 30, -1, -1, -1,
407 -1, -1, 36, -1, -1, -1, 40, -1, -1, 43,
408 -1, 1, 46, -1, 48, 5, 6, 7, 8, 9,
409 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
410 20, 21, -1, 23, 24, 25, 26, 27, -1, -1,
411 30, -1, -1, -1, -1, 35, -1, -1, -1, -1,
412 40, -1, -1, -1, 1, -1, -1, 47, 5, 6,
413 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
414 17, 18, 19, 20, 21, -1, 23, 24, 25, 26,
415 27, -1, -1, 30, -1, -1, -1, -1, 35, -1,
416 -1, -1, -1, 40, -1, -1, -1, 1, -1, -1,
417 47, 5, 6, 7, 8, 9, 10, 11, 12, 13,
418 14, 15, 16, 17, 18, 19, 20, 21, -1, 23,
419 24, 25, 26, 27, -1, -1, 30, -1, -1, -1,
420 -1, 35, -1, -1, -1, -1, 40, -1, -1, -1,
421 -1, -1, -1, 47, 5, 6, 7, 8, 9, 10,
422 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
423 21, -1, 23, 24, 25, 26, 27, -1, -1, 30,
424 -1, -1, -1, -1, -1, 36, -1, -1, -1, 40,
425 -1, -1, -1, -1, -1, 46, -1, 48, 5, 6,
426 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
427 17, 18, 19, 20, 21, -1, 23, 24, 25, 26,
428 27, -1, -1, 30, -1, -1, -1, -1, -1, -1,
429 -1, -1, -1, 40, -1, -1, -1, -1, -1, -1,
430 47, 5, 6, 7, 8, 9, 10, 11, 12, 13,
431 14, 15, 16, 17, 18, 19, 20, 21, -1, 23,
432 24, 25, 26, 27, -1, -1, 30, -1, -1, -1,
433 -1, 35, -1, -1, -1, -1, 40, 5, 6, 7,
434 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
435 18, 19, 20, 21, -1, 23, 24, 25, 26, 27,
436 -1, -1, 30, -1, -1, -1, -1, -1, -1, -1,
437 -1, -1, 40
438};
439/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
440#line 3 "/usr/lib/bison.simple"
441/* This file comes from bison-1.28. */
442
443/* Skeleton output parser for bison,
444 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
445
446 This program is free software; you can redistribute it and/or modify
447 it under the terms of the GNU General Public License as published by
448 the Free Software Foundation; either version 2, or (at your option)
449 any later version.
450
451 This program is distributed in the hope that it will be useful,
452 but WITHOUT ANY WARRANTY; without even the implied warranty of
453 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
454 GNU General Public License for more details.
455
456 You should have received a copy of the GNU General Public License
457 along with this program; if not, write to the Free Software
458 Foundation, Inc., 59 Temple Place - Suite 330,
459 Boston, MA 02111-1307, USA. */
460
461/* As a special exception, when this file is copied by Bison into a
462 Bison output file, you may use that output file without restriction.
463 This special exception was added by the Free Software Foundation
464 in version 1.24 of Bison. */
465
466/* This is the parser code that is written into each bison parser
467 when the %semantic_parser declaration is not specified in the grammar.
468 It was written by Richard Stallman by simplifying the hairy parser
469 used when %semantic_parser is specified. */
470
471#ifndef YYSTACK_USE_ALLOCA
472#ifdef alloca
473#define YYSTACK_USE_ALLOCA
474#else /* alloca not defined */
475#ifdef __GNUC__
476#define YYSTACK_USE_ALLOCA
477#define alloca __builtin_alloca
478#else /* not GNU C. */
479#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
480#define YYSTACK_USE_ALLOCA
481#include <alloca.h>
482#else /* not sparc */
483/* We think this test detects Watcom and Microsoft C. */
484/* This used to test MSDOS, but that is a bad idea
485 since that symbol is in the user namespace. */
486#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
487#if 0 /* No need for malloc.h, which pollutes the namespace;
488 instead, just don't use alloca. */
489#include <malloc.h>
490#endif
491#else /* not MSDOS, or __TURBOC__ */
492#if defined(_AIX)
493/* I don't know what this was needed for, but it pollutes the namespace.
494 So I turned it off. rms, 2 May 1997. */
495/* #include <malloc.h> */
496 #pragma alloca
497#define YYSTACK_USE_ALLOCA
498#else /* not MSDOS, or __TURBOC__, or _AIX */
499#if 0
500#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
501 and on HPUX 10. Eventually we can turn this on. */
502#define YYSTACK_USE_ALLOCA
503#define alloca __builtin_alloca
504#endif /* __hpux */
505#endif
506#endif /* not _AIX */
507#endif /* not MSDOS, or __TURBOC__ */
508#endif /* not sparc */
509#endif /* not GNU C */
510#endif /* alloca not defined */
511#endif /* YYSTACK_USE_ALLOCA not defined */
512
513#ifdef YYSTACK_USE_ALLOCA
514#define YYSTACK_ALLOC alloca
515#else
516#define YYSTACK_ALLOC malloc
517#endif
518
519/* Note: there must be only one dollar sign in this file.
520 It is replaced by the list of actions, each action
521 as one case of the switch. */
522
523#define yyerrok (yyerrstatus = 0)
524#define yyclearin (yychar = YYEMPTY)
525#define YYEMPTY -2
526#define YYEOF 0
527#define YYACCEPT goto yyacceptlab
528#define YYABORT goto yyabortlab
529#define YYERROR goto yyerrlab1
530/* Like YYERROR except do call yyerror.
531 This remains here temporarily to ease the
532 transition to the new meaning of YYERROR, for GCC.
533 Once GCC version 2 has supplanted version 1, this can go. */
534#define YYFAIL goto yyerrlab
535#define YYRECOVERING() (!!yyerrstatus)
536#define YYBACKUP(token, value) \
537do \
538 if (yychar == YYEMPTY && yylen == 1) \
539 { yychar = (token), yylval = (value); \
540 yychar1 = YYTRANSLATE (yychar); \
541 YYPOPSTACK; \
542 goto yybackup; \
543 } \
544 else \
545 { yyerror ("syntax error: cannot back up"); YYERROR; } \
546while (0)
547
548#define YYTERROR 1
549#define YYERRCODE 256
550
551#ifndef YYPURE
552#define YYLEX yylex()
553#endif
554
555#ifdef YYPURE
556#ifdef YYLSP_NEEDED
557#ifdef YYLEX_PARAM
558#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
559#else
560#define YYLEX yylex(&yylval, &yylloc)
561#endif
562#else /* not YYLSP_NEEDED */
563#ifdef YYLEX_PARAM
564#define YYLEX yylex(&yylval, YYLEX_PARAM)
565#else
566#define YYLEX yylex(&yylval)
567#endif
568#endif /* not YYLSP_NEEDED */
569#endif
570
571/* If nonreentrant, generate the variables here */
572
573#ifndef YYPURE
574
575int yychar; /* the lookahead symbol */
576YYSTYPE yylval; /* the semantic value of the */
577 /* lookahead symbol */
578
579#ifdef YYLSP_NEEDED
580YYLTYPE yylloc; /* location data for the lookahead */
581 /* symbol */
582#endif
583
584int yynerrs; /* number of parse errors so far */
585#endif /* not YYPURE */
586
587#if YYDEBUG != 0
588int yydebug; /* nonzero means print parse trace */
589/* Since this is uninitialized, it does not stop multiple parsers
590 from coexisting. */
591#endif
592
593/* YYINITDEPTH indicates the initial size of the parser's stacks */
594
595#ifndef YYINITDEPTH
596#define YYINITDEPTH 200
597#endif
598
599/* YYMAXDEPTH is the maximum size the stacks can grow to
600 (effective only if the built-in stack extension method is used). */
601
602#if YYMAXDEPTH == 0
603#undef YYMAXDEPTH
604#endif
605
606#ifndef YYMAXDEPTH
607#define YYMAXDEPTH 10000
608#endif
609
610/* Define __yy_memcpy. Note that the size argument
611 should be passed with type unsigned int, because that is what the non-GCC
612 definitions require. With GCC, __builtin_memcpy takes an arg
613 of type size_t, but it can handle unsigned int. */
614
615#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
616#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
617#else /* not GNU C or C++ */
618#ifndef __cplusplus
619
620/* This is the most reliable way to avoid incompatibilities
621 in available built-in functions on various systems. */
622static void
623__yy_memcpy (to, from, count)
624 char *to;
625 char *from;
626 unsigned int count;
627{
628 register char *f = from;
629 register char *t = to;
630 register int i = count;
631
632 while (i-- > 0)
633 *t++ = *f++;
634}
635
636#else /* __cplusplus */
637
638/* This is the most reliable way to avoid incompatibilities
639 in available built-in functions on various systems. */
640static void
641__yy_memcpy (char *to, char *from, unsigned int count)
642{
643 register char *t = to;
644 register char *f = from;
645 register int i = count;
646
647 while (i-- > 0)
648 *t++ = *f++;
649}
650
651#endif
652#endif
653
654#line 217 "/usr/lib/bison.simple"
655
656/* The user can define YYPARSE_PARAM as the name of an argument to be passed
657 into yyparse. The argument should have type void *.
658 It should actually point to an object.
659 Grammar actions can access the variable by casting it
660 to the proper pointer type. */
661
662#ifdef YYPARSE_PARAM
663#ifdef __cplusplus
664#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
665#define YYPARSE_PARAM_DECL
666#else /* not __cplusplus */
667#define YYPARSE_PARAM_ARG YYPARSE_PARAM
668#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
669#endif /* not __cplusplus */
670#else /* not YYPARSE_PARAM */
671#define YYPARSE_PARAM_ARG
672#define YYPARSE_PARAM_DECL
673#endif /* not YYPARSE_PARAM */
674
675/* Prevent warning if -Wstrict-prototypes. */
676#ifdef __GNUC__
677#ifdef YYPARSE_PARAM
678int yyparse (void *);
679#else
680int yyparse (void);
681#endif
682#endif
683
684int
685yyparse(YYPARSE_PARAM_ARG)
686 YYPARSE_PARAM_DECL
687{
688 register int yystate;
689 register int yyn;
690 register short *yyssp;
691 register YYSTYPE *yyvsp;
692 int yyerrstatus; /* number of tokens to shift before error messages enabled */
693 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
694
695 short yyssa[YYINITDEPTH]; /* the state stack */
696 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
697
698 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
699 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
700
701#ifdef YYLSP_NEEDED
702 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
703 YYLTYPE *yyls = yylsa;
704 YYLTYPE *yylsp;
705
706#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
707#else
708#define YYPOPSTACK (yyvsp--, yyssp--)
709#endif
710
711 int yystacksize = YYINITDEPTH;
712 int yyfree_stacks = 0;
713
714#ifdef YYPURE
715 int yychar;
716 YYSTYPE yylval;
717 int yynerrs;
718#ifdef YYLSP_NEEDED
719 YYLTYPE yylloc;
720#endif
721#endif
722
723 YYSTYPE yyval; /* the variable used to return */
724 /* semantic values from the action */
725 /* routines */
726
727 int yylen;
728
729#if YYDEBUG != 0
730 if (yydebug)
731 fprintf(stderr, "Starting parse\n");
732#endif
733
734 yystate = 0;
735 yyerrstatus = 0;
736 yynerrs = 0;
737 yychar = YYEMPTY; /* Cause a token to be read. */
738
739 /* Initialize stack pointers.
740 Waste one element of value and location stack
741 so that they stay on the same level as the state stack.
742 The wasted elements are never initialized. */
743
744 yyssp = yyss - 1;
745 yyvsp = yyvs;
746#ifdef YYLSP_NEEDED
747 yylsp = yyls;
748#endif
749
750/* Push a new state, which is found in yystate . */
751/* In all cases, when you get here, the value and location stacks
752 have just been pushed. so pushing a state here evens the stacks. */
753yynewstate:
754
755 *++yyssp = yystate;
756
757 if (yyssp >= yyss + yystacksize - 1)
758 {
759 /* Give user a chance to reallocate the stack */
760 /* Use copies of these so that the &'s don't force the real ones into memory. */
761 YYSTYPE *yyvs1 = yyvs;
762 short *yyss1 = yyss;
763#ifdef YYLSP_NEEDED
764 YYLTYPE *yyls1 = yyls;
765#endif
766
767 /* Get the current used size of the three stacks, in elements. */
768 int size = yyssp - yyss + 1;
769
770#ifdef yyoverflow
771 /* Each stack pointer address is followed by the size of
772 the data in use in that stack, in bytes. */
773#ifdef YYLSP_NEEDED
774 /* This used to be a conditional around just the two extra args,
775 but that might be undefined if yyoverflow is a macro. */
776 yyoverflow("parser stack overflow",
777 &yyss1, size * sizeof (*yyssp),
778 &yyvs1, size * sizeof (*yyvsp),
779 &yyls1, size * sizeof (*yylsp),
780 &yystacksize);
781#else
782 yyoverflow("parser stack overflow",
783 &yyss1, size * sizeof (*yyssp),
784 &yyvs1, size * sizeof (*yyvsp),
785 &yystacksize);
786#endif
787
788 yyss = yyss1; yyvs = yyvs1;
789#ifdef YYLSP_NEEDED
790 yyls = yyls1;
791#endif
792#else /* no yyoverflow */
793 /* Extend the stack our own way. */
794 if (yystacksize >= YYMAXDEPTH)
795 {
796 yyerror("parser stack overflow");
797 if (yyfree_stacks)
798 {
799 free (yyss);
800 free (yyvs);
801#ifdef YYLSP_NEEDED
802 free (yyls);
803#endif
804 }
805 return 2;
806 }
807 yystacksize *= 2;
808 if (yystacksize > YYMAXDEPTH)
809 yystacksize = YYMAXDEPTH;
810#ifndef YYSTACK_USE_ALLOCA
811 yyfree_stacks = 1;
812#endif
813 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
814 __yy_memcpy ((char *)yyss, (char *)yyss1,
815 size * (unsigned int) sizeof (*yyssp));
816 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
817 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
818 size * (unsigned int) sizeof (*yyvsp));
819#ifdef YYLSP_NEEDED
820 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
821 __yy_memcpy ((char *)yyls, (char *)yyls1,
822 size * (unsigned int) sizeof (*yylsp));
823#endif
824#endif /* no yyoverflow */
825
826 yyssp = yyss + size - 1;
827 yyvsp = yyvs + size - 1;
828#ifdef YYLSP_NEEDED
829 yylsp = yyls + size - 1;
830#endif
831
832#if YYDEBUG != 0
833 if (yydebug)
834 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
835#endif
836
837 if (yyssp >= yyss + yystacksize - 1)
838 YYABORT;
839 }
840
841#if YYDEBUG != 0
842 if (yydebug)
843 fprintf(stderr, "Entering state %d\n", yystate);
844#endif
845
846 goto yybackup;
847 yybackup:
848
849/* Do appropriate processing given the current state. */
850/* Read a lookahead token if we need one and don't already have one. */
851/* yyresume: */
852
853 /* First try to decide what to do without reference to lookahead token. */
854
855 yyn = yypact[yystate];
856 if (yyn == YYFLAG)
857 goto yydefault;
858
859 /* Not known => get a lookahead token if don't already have one. */
860
861 /* yychar is either YYEMPTY or YYEOF
862 or a valid token in external form. */
863
864 if (yychar == YYEMPTY)
865 {
866#if YYDEBUG != 0
867 if (yydebug)
868 fprintf(stderr, "Reading a token: ");
869#endif
870 yychar = YYLEX;
871 }
872
873 /* Convert token to internal form (in yychar1) for indexing tables with */
874
875 if (yychar <= 0) /* This means end of input. */
876 {
877 yychar1 = 0;
878 yychar = YYEOF; /* Don't call YYLEX any more */
879
880#if YYDEBUG != 0
881 if (yydebug)
882 fprintf(stderr, "Now at end of input.\n");
883#endif
884 }
885 else
886 {
887 yychar1 = YYTRANSLATE(yychar);
888
889#if YYDEBUG != 0
890 if (yydebug)
891 {
892 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
893 /* Give the individual parser a way to print the precise meaning
894 of a token, for further debugging info. */
895#ifdef YYPRINT
896 YYPRINT (stderr, yychar, yylval);
897#endif
898 fprintf (stderr, ")\n");
899 }
900#endif
901 }
902
903 yyn += yychar1;
904 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
905 goto yydefault;
906
907 yyn = yytable[yyn];
908
909 /* yyn is what to do for this token type in this state.
910 Negative => reduce, -yyn is rule number.
911 Positive => shift, yyn is new state.
912 New state is final state => don't bother to shift,
913 just return success.
914 0, or most negative number => error. */
915
916 if (yyn < 0)
917 {
918 if (yyn == YYFLAG)
919 goto yyerrlab;
920 yyn = -yyn;
921 goto yyreduce;
922 }
923 else if (yyn == 0)
924 goto yyerrlab;
925
926 if (yyn == YYFINAL)
927 YYACCEPT;
928
929 /* Shift the lookahead token. */
930
931#if YYDEBUG != 0
932 if (yydebug)
933 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
934#endif
935
936 /* Discard the token being shifted unless it is eof. */
937 if (yychar != YYEOF)
938 yychar = YYEMPTY;
939
940 *++yyvsp = yylval;
941#ifdef YYLSP_NEEDED
942 *++yylsp = yylloc;
943#endif
944
945 /* count tokens shifted since error; after three, turn off error status. */
946 if (yyerrstatus) yyerrstatus--;
947
948 yystate = yyn;
949 goto yynewstate;
950
951/* Do the default action for the current state. */
952yydefault:
953
954 yyn = yydefact[yystate];
955 if (yyn == 0)
956 goto yyerrlab;
957
958/* Do a reduction. yyn is the number of a rule to reduce with. */
959yyreduce:
960 yylen = yyr2[yyn];
961 if (yylen > 0)
962 yyval = yyvsp[1-yylen]; /* implement default value of the action */
963
964#if YYDEBUG != 0
965 if (yydebug)
966 {
967 int i;
968
969 fprintf (stderr, "Reducing via rule %d (line %d), ",
970 yyn, yyrline[yyn]);
971
972 /* Print the symbols being reduced, and their result. */
973 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
974 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
975 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
976 }
977#endif
978
979
980 switch (yyn) {
981
982case 3:
983#line 107 "scripts/genksyms/parse.y"
984{ is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ;
985 break;}
986case 4:
987#line 109 "scripts/genksyms/parse.y"
988{ free_list(*yyvsp[0], NULL); *yyvsp[0] = NULL; ;
989 break;}
990case 5:
991#line 113 "scripts/genksyms/parse.y"
992{ is_typedef = 1; ;
993 break;}
994case 6:
995#line 114 "scripts/genksyms/parse.y"
996{ yyval = yyvsp[0]; ;
997 break;}
998case 11:
999#line 119 "scripts/genksyms/parse.y"
1000{ yyval = yyvsp[0]; ;
1001 break;}
1002case 12:
1003#line 120 "scripts/genksyms/parse.y"
1004{ yyval = yyvsp[0]; ;
1005 break;}
1006case 13:
1007#line 125 "scripts/genksyms/parse.y"
1008{ if (current_name) {
1009 struct string_list *decl = (*yyvsp[0])->next;
1010 (*yyvsp[0])->next = NULL;
1011 add_symbol(current_name,
1012 is_typedef ? SYM_TYPEDEF : SYM_NORMAL,
1013 decl, is_extern);
1014 current_name = NULL;
1015 }
1016 yyval = yyvsp[0];
1017 ;
1018 break;}
1019case 14:
1020#line 138 "scripts/genksyms/parse.y"
1021{ yyval = NULL; ;
1022 break;}
1023case 16:
1024#line 144 "scripts/genksyms/parse.y"
1025{ struct string_list *decl = *yyvsp[0];
1026 *yyvsp[0] = NULL;
1027 add_symbol(current_name,
1028 is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern);
1029 current_name = NULL;
1030 yyval = yyvsp[0];
1031 ;
1032 break;}
1033case 17:
1034#line 152 "scripts/genksyms/parse.y"
1035{ struct string_list *decl = *yyvsp[0];
1036 *yyvsp[0] = NULL;
1037 free_list(*yyvsp[-1], NULL);
1038 *yyvsp[-1] = decl_spec;
1039 add_symbol(current_name,
1040 is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern);
1041 current_name = NULL;
1042 yyval = yyvsp[0];
1043 ;
1044 break;}
1045case 18:
1046#line 165 "scripts/genksyms/parse.y"
1047{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1] ? yyvsp[-1] : yyvsp[-2] ? yyvsp[-2] : yyvsp[-3]; ;
1048 break;}
1049case 19:
1050#line 170 "scripts/genksyms/parse.y"
1051{ decl_spec = NULL; ;
1052 break;}
1053case 21:
1054#line 175 "scripts/genksyms/parse.y"
1055{ decl_spec = *yyvsp[0]; ;
1056 break;}
1057case 22:
1058#line 176 "scripts/genksyms/parse.y"
1059{ decl_spec = *yyvsp[0]; ;
1060 break;}
1061case 23:
1062#line 181 "scripts/genksyms/parse.y"
1063{ /* Version 2 checksumming ignores storage class, as that
1064 is really irrelevant to the linkage. */
1065 remove_node(yyvsp[0]);
1066 yyval = yyvsp[0];
1067 ;
1068 break;}
1069case 28:
1070#line 193 "scripts/genksyms/parse.y"
1071{ is_extern = 1; yyval = yyvsp[0]; ;
1072 break;}
1073case 29:
1074#line 194 "scripts/genksyms/parse.y"
1075{ is_extern = 0; yyval = yyvsp[0]; ;
1076 break;}
1077case 33:
1078#line 205 "scripts/genksyms/parse.y"
1079{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_STRUCT; yyval = yyvsp[0]; ;
1080 break;}
1081case 34:
1082#line 207 "scripts/genksyms/parse.y"
1083{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_UNION; yyval = yyvsp[0]; ;
1084 break;}
1085case 35:
1086#line 209 "scripts/genksyms/parse.y"
1087{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_ENUM; yyval = yyvsp[0]; ;
1088 break;}
1089case 36:
1090#line 213 "scripts/genksyms/parse.y"
1091{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r;
1092 r = copy_node(i); r->tag = SYM_STRUCT;
1093 r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL;
1094 add_symbol(i->string, SYM_STRUCT, s, is_extern);
1095 yyval = yyvsp[0];
1096 ;
1097 break;}
1098case 37:
1099#line 220 "scripts/genksyms/parse.y"
1100{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r;
1101 r = copy_node(i); r->tag = SYM_UNION;
1102 r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL;
1103 add_symbol(i->string, SYM_UNION, s, is_extern);
1104 yyval = yyvsp[0];
1105 ;
1106 break;}
1107case 38:
1108#line 227 "scripts/genksyms/parse.y"
1109{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r;
1110 r = copy_node(i); r->tag = SYM_ENUM;
1111 r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL;
1112 add_symbol(i->string, SYM_ENUM, s, is_extern);
1113 yyval = yyvsp[0];
1114 ;
1115 break;}
1116case 39:
1117#line 235 "scripts/genksyms/parse.y"
1118{ yyval = yyvsp[0]; ;
1119 break;}
1120case 40:
1121#line 236 "scripts/genksyms/parse.y"
1122{ yyval = yyvsp[0]; ;
1123 break;}
1124case 41:
1125#line 237 "scripts/genksyms/parse.y"
1126{ yyval = yyvsp[0]; ;
1127 break;}
1128case 52:
1129#line 251 "scripts/genksyms/parse.y"
1130{ (*yyvsp[0])->tag = SYM_TYPEDEF; yyval = yyvsp[0]; ;
1131 break;}
1132case 53:
1133#line 256 "scripts/genksyms/parse.y"
1134{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ;
1135 break;}
1136case 54:
1137#line 260 "scripts/genksyms/parse.y"
1138{ yyval = NULL; ;
1139 break;}
1140case 57:
1141#line 266 "scripts/genksyms/parse.y"
1142{ yyval = yyvsp[0]; ;
1143 break;}
1144case 61:
1145#line 272 "scripts/genksyms/parse.y"
1146{ /* restrict has no effect in prototypes so ignore it */
1147 remove_node(yyvsp[0]);
1148 yyval = yyvsp[0];
1149 ;
1150 break;}
1151case 62:
1152#line 279 "scripts/genksyms/parse.y"
1153{ yyval = yyvsp[0]; ;
1154 break;}
1155case 64:
1156#line 285 "scripts/genksyms/parse.y"
1157{ if (current_name != NULL) {
1158 error_with_pos("unexpected second declaration name");
1159 YYERROR;
1160 } else {
1161 current_name = (*yyvsp[0])->string;
1162 yyval = yyvsp[0];
1163 }
1164 ;
1165 break;}
1166case 65:
1167#line 294 "scripts/genksyms/parse.y"
1168{ yyval = yyvsp[0]; ;
1169 break;}
1170case 66:
1171#line 296 "scripts/genksyms/parse.y"
1172{ yyval = yyvsp[0]; ;
1173 break;}
1174case 67:
1175#line 298 "scripts/genksyms/parse.y"
1176{ yyval = yyvsp[0]; ;
1177 break;}
1178case 68:
1179#line 300 "scripts/genksyms/parse.y"
1180{ yyval = yyvsp[0]; ;
1181 break;}
1182case 69:
1183#line 302 "scripts/genksyms/parse.y"
1184{ yyval = yyvsp[0]; ;
1185 break;}
1186case 70:
1187#line 308 "scripts/genksyms/parse.y"
1188{ yyval = yyvsp[0]; ;
1189 break;}
1190case 74:
1191#line 316 "scripts/genksyms/parse.y"
1192{ yyval = yyvsp[0]; ;
1193 break;}
1194case 75:
1195#line 318 "scripts/genksyms/parse.y"
1196{ yyval = yyvsp[0]; ;
1197 break;}
1198case 76:
1199#line 320 "scripts/genksyms/parse.y"
1200{ yyval = yyvsp[0]; ;
1201 break;}
1202case 77:
1203#line 322 "scripts/genksyms/parse.y"
1204{ yyval = yyvsp[0]; ;
1205 break;}
1206case 78:
1207#line 324 "scripts/genksyms/parse.y"
1208{ yyval = yyvsp[0]; ;
1209 break;}
1210case 79:
1211#line 328 "scripts/genksyms/parse.y"
1212{ yyval = yyvsp[0]; ;
1213 break;}
1214case 81:
1215#line 330 "scripts/genksyms/parse.y"
1216{ yyval = yyvsp[0]; ;
1217 break;}
1218case 82:
1219#line 334 "scripts/genksyms/parse.y"
1220{ yyval = NULL; ;
1221 break;}
1222case 85:
1223#line 341 "scripts/genksyms/parse.y"
1224{ yyval = yyvsp[0]; ;
1225 break;}
1226case 86:
1227#line 346 "scripts/genksyms/parse.y"
1228{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ;
1229 break;}
1230case 87:
1231#line 351 "scripts/genksyms/parse.y"
1232{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ;
1233 break;}
1234case 89:
1235#line 356 "scripts/genksyms/parse.y"
1236{ yyval = NULL; ;
1237 break;}
1238case 90:
1239#line 358 "scripts/genksyms/parse.y"
1240{ /* For version 2 checksums, we don't want to remember
1241 private parameter names. */
1242 remove_node(yyvsp[0]);
1243 yyval = yyvsp[0];
1244 ;
1245 break;}
1246case 91:
1247#line 366 "scripts/genksyms/parse.y"
1248{ remove_node(yyvsp[0]);
1249 yyval = yyvsp[0];
1250 ;
1251 break;}
1252case 92:
1253#line 370 "scripts/genksyms/parse.y"
1254{ yyval = yyvsp[0]; ;
1255 break;}
1256case 93:
1257#line 372 "scripts/genksyms/parse.y"
1258{ yyval = yyvsp[0]; ;
1259 break;}
1260case 94:
1261#line 374 "scripts/genksyms/parse.y"
1262{ yyval = yyvsp[0]; ;
1263 break;}
1264case 95:
1265#line 376 "scripts/genksyms/parse.y"
1266{ yyval = yyvsp[0]; ;
1267 break;}
1268case 96:
1269#line 378 "scripts/genksyms/parse.y"
1270{ yyval = yyvsp[0]; ;
1271 break;}
1272case 97:
1273#line 383 "scripts/genksyms/parse.y"
1274{ struct string_list *decl = *yyvsp[-1];
1275 *yyvsp[-1] = NULL;
1276 add_symbol(current_name, SYM_NORMAL, decl, is_extern);
1277 yyval = yyvsp[0];
1278 ;
1279 break;}
1280case 98:
1281#line 391 "scripts/genksyms/parse.y"
1282{ yyval = NULL; ;
1283 break;}
1284case 100:
1285#line 398 "scripts/genksyms/parse.y"
1286{ remove_list(yyvsp[0], &(*yyvsp[-1])->next); yyval = yyvsp[0]; ;
1287 break;}
1288case 101:
1289#line 402 "scripts/genksyms/parse.y"
1290{ yyval = yyvsp[0]; ;
1291 break;}
1292case 102:
1293#line 403 "scripts/genksyms/parse.y"
1294{ yyval = yyvsp[0]; ;
1295 break;}
1296case 103:
1297#line 407 "scripts/genksyms/parse.y"
1298{ yyval = NULL; ;
1299 break;}
1300case 106:
1301#line 413 "scripts/genksyms/parse.y"
1302{ yyval = yyvsp[0]; ;
1303 break;}
1304case 107:
1305#line 418 "scripts/genksyms/parse.y"
1306{ yyval = yyvsp[0]; ;
1307 break;}
1308case 108:
1309#line 420 "scripts/genksyms/parse.y"
1310{ yyval = yyvsp[0]; ;
1311 break;}
1312case 109:
1313#line 424 "scripts/genksyms/parse.y"
1314{ yyval = NULL; ;
1315 break;}
1316case 112:
1317#line 430 "scripts/genksyms/parse.y"
1318{ yyval = yyvsp[0]; ;
1319 break;}
1320case 113:
1321#line 434 "scripts/genksyms/parse.y"
1322{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ;
1323 break;}
1324case 114:
1325#line 435 "scripts/genksyms/parse.y"
1326{ yyval = yyvsp[0]; ;
1327 break;}
1328case 116:
1329#line 440 "scripts/genksyms/parse.y"
1330{ yyval = yyvsp[0]; ;
1331 break;}
1332case 117:
1333#line 444 "scripts/genksyms/parse.y"
1334{ yyval = NULL; ;
1335 break;}
1336case 119:
1337#line 449 "scripts/genksyms/parse.y"
1338{ yyval = yyvsp[0]; ;
1339 break;}
1340case 120:
1341#line 453 "scripts/genksyms/parse.y"
1342{ yyval = NULL; ;
1343 break;}
1344case 122:
1345#line 459 "scripts/genksyms/parse.y"
1346{ export_symbol((*yyvsp[-2])->string); yyval = yyvsp[0]; ;
1347 break;}
1348}
1349 /* the action file gets copied in in place of this dollarsign */
1350#line 543 "/usr/lib/bison.simple"
1351
1352 yyvsp -= yylen;
1353 yyssp -= yylen;
1354#ifdef YYLSP_NEEDED
1355 yylsp -= yylen;
1356#endif
1357
1358#if YYDEBUG != 0
1359 if (yydebug)
1360 {
1361 short *ssp1 = yyss - 1;
1362 fprintf (stderr, "state stack now");
1363 while (ssp1 != yyssp)
1364 fprintf (stderr, " %d", *++ssp1);
1365 fprintf (stderr, "\n");
1366 }
1367#endif
1368
1369 *++yyvsp = yyval;
1370
1371#ifdef YYLSP_NEEDED
1372 yylsp++;
1373 if (yylen == 0)
1374 {
1375 yylsp->first_line = yylloc.first_line;
1376 yylsp->first_column = yylloc.first_column;
1377 yylsp->last_line = (yylsp-1)->last_line;
1378 yylsp->last_column = (yylsp-1)->last_column;
1379 yylsp->text = 0;
1380 }
1381 else
1382 {
1383 yylsp->last_line = (yylsp+yylen-1)->last_line;
1384 yylsp->last_column = (yylsp+yylen-1)->last_column;
1385 }
1386#endif
1387
1388 /* Now "shift" the result of the reduction.
1389 Determine what state that goes to,
1390 based on the state we popped back to
1391 and the rule number reduced by. */
1392
1393 yyn = yyr1[yyn];
1394
1395 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1396 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1397 yystate = yytable[yystate];
1398 else
1399 yystate = yydefgoto[yyn - YYNTBASE];
1400
1401 goto yynewstate;
1402
1403yyerrlab: /* here on detecting error */
1404
1405 if (! yyerrstatus)
1406 /* If not already recovering from an error, report this error. */
1407 {
1408 ++yynerrs;
1409
1410#ifdef YYERROR_VERBOSE
1411 yyn = yypact[yystate];
1412
1413 if (yyn > YYFLAG && yyn < YYLAST)
1414 {
1415 int size = 0;
1416 char *msg;
1417 int x, count;
1418
1419 count = 0;
1420 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1421 for (x = (yyn < 0 ? -yyn : 0);
1422 x < (sizeof(yytname) / sizeof(char *)); x++)
1423 if (yycheck[x + yyn] == x)
1424 size += strlen(yytname[x]) + 15, count++;
1425 msg = (char *) malloc(size + 15);
1426 if (msg != 0)
1427 {
1428 strcpy(msg, "parse error");
1429
1430 if (count < 5)
1431 {
1432 count = 0;
1433 for (x = (yyn < 0 ? -yyn : 0);
1434 x < (sizeof(yytname) / sizeof(char *)); x++)
1435 if (yycheck[x + yyn] == x)
1436 {
1437 strcat(msg, count == 0 ? ", expecting `" : " or `");
1438 strcat(msg, yytname[x]);
1439 strcat(msg, "'");
1440 count++;
1441 }
1442 }
1443 yyerror(msg);
1444 free(msg);
1445 }
1446 else
1447 yyerror ("parse error; also virtual memory exceeded");
1448 }
1449 else
1450#endif /* YYERROR_VERBOSE */
1451 yyerror("parse error");
1452 }
1453
1454 goto yyerrlab1;
1455yyerrlab1: /* here on error raised explicitly by an action */
1456
1457 if (yyerrstatus == 3)
1458 {
1459 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1460
1461 /* return failure if at end of input */
1462 if (yychar == YYEOF)
1463 YYABORT;
1464
1465#if YYDEBUG != 0
1466 if (yydebug)
1467 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1468#endif
1469
1470 yychar = YYEMPTY;
1471 }
1472
1473 /* Else will try to reuse lookahead token
1474 after shifting the error token. */
1475
1476 yyerrstatus = 3; /* Each real token shifted decrements this */
1477
1478 goto yyerrhandle;
1479
1480yyerrdefault: /* current state does not do anything special for the error token. */
1481
1482#if 0
1483 /* This is wrong; only states that explicitly want error tokens
1484 should shift them. */
1485 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1486 if (yyn) goto yydefault;
1487#endif
1488
1489yyerrpop: /* pop the current state because it cannot handle the error token */
1490
1491 if (yyssp == yyss) YYABORT;
1492 yyvsp--;
1493 yystate = *--yyssp;
1494#ifdef YYLSP_NEEDED
1495 yylsp--;
1496#endif
1497
1498#if YYDEBUG != 0
1499 if (yydebug)
1500 {
1501 short *ssp1 = yyss - 1;
1502 fprintf (stderr, "Error: state stack now");
1503 while (ssp1 != yyssp)
1504 fprintf (stderr, " %d", *++ssp1);
1505 fprintf (stderr, "\n");
1506 }
1507#endif
1508
1509yyerrhandle:
1510
1511 yyn = yypact[yystate];
1512 if (yyn == YYFLAG)
1513 goto yyerrdefault;
1514
1515 yyn += YYTERROR;
1516 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1517 goto yyerrdefault;
1518
1519 yyn = yytable[yyn];
1520 if (yyn < 0)
1521 {
1522 if (yyn == YYFLAG)
1523 goto yyerrpop;
1524 yyn = -yyn;
1525 goto yyreduce;
1526 }
1527 else if (yyn == 0)
1528 goto yyerrpop;
1529
1530 if (yyn == YYFINAL)
1531 YYACCEPT;
1532
1533#if YYDEBUG != 0
1534 if (yydebug)
1535 fprintf(stderr, "Shifting error token, ");
1536#endif
1537
1538 *++yyvsp = yylval;
1539#ifdef YYLSP_NEEDED
1540 *++yylsp = yylloc;
1541#endif
1542
1543 yystate = yyn;
1544 goto yynewstate;
1545
1546 yyacceptlab:
1547 /* YYACCEPT comes here. */
1548 if (yyfree_stacks)
1549 {
1550 free (yyss);
1551 free (yyvs);
1552#ifdef YYLSP_NEEDED
1553 free (yyls);
1554#endif
1555 }
1556 return 0;
1557
1558 yyabortlab:
1559 /* YYABORT comes here. */
1560 if (yyfree_stacks)
1561 {
1562 free (yyss);
1563 free (yyvs);
1564#ifdef YYLSP_NEEDED
1565 free (yyls);
1566#endif
1567 }
1568 return 1;
1569}
1570#line 463 "scripts/genksyms/parse.y"
1571
1572
1573static void
1574yyerror(const char *e)
1575{
1576 error_with_pos("%s", e);
1577}
diff --git a/scripts/genksyms/parse.h_shipped b/scripts/genksyms/parse.h_shipped
new file mode 100644
index 000000000000..d5b27e3b20c4
--- /dev/null
+++ b/scripts/genksyms/parse.h_shipped
@@ -0,0 +1,46 @@
1#ifndef YYSTYPE
2#define YYSTYPE int
3#endif
4#define ASM_KEYW 257
5#define ATTRIBUTE_KEYW 258
6#define AUTO_KEYW 259
7#define BOOL_KEYW 260
8#define CHAR_KEYW 261
9#define CONST_KEYW 262
10#define DOUBLE_KEYW 263
11#define ENUM_KEYW 264
12#define EXTERN_KEYW 265
13#define FLOAT_KEYW 266
14#define INLINE_KEYW 267
15#define INT_KEYW 268
16#define LONG_KEYW 269
17#define REGISTER_KEYW 270
18#define RESTRICT_KEYW 271
19#define SHORT_KEYW 272
20#define SIGNED_KEYW 273
21#define STATIC_KEYW 274
22#define STRUCT_KEYW 275
23#define TYPEDEF_KEYW 276
24#define UNION_KEYW 277
25#define UNSIGNED_KEYW 278
26#define VOID_KEYW 279
27#define VOLATILE_KEYW 280
28#define TYPEOF_KEYW 281
29#define EXPORT_SYMBOL_KEYW 282
30#define ASM_PHRASE 283
31#define ATTRIBUTE_PHRASE 284
32#define BRACE_PHRASE 285
33#define BRACKET_PHRASE 286
34#define EXPRESSION_PHRASE 287
35#define CHAR 288
36#define DOTS 289
37#define IDENT 290
38#define INT 291
39#define REAL 292
40#define STRING 293
41#define TYPE 294
42#define OTHER 295
43#define FILENAME 296
44
45
46extern YYSTYPE yylval;
diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y
new file mode 100644
index 000000000000..099043713db4
--- /dev/null
+++ b/scripts/genksyms/parse.y
@@ -0,0 +1,469 @@
1/* C global declaration parser for genksyms.
2 Copyright 1996, 1997 Linux International.
3
4 New implementation contributed by Richard Henderson <rth@tamu.edu>
5 Based on original work by Bjorn Ekwall <bj0rn@blox.se>
6
7 This file is part of the Linux modutils.
8
9 This program is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 2 of the License, or (at your
12 option) any later version.
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23
24%{
25
26#include <assert.h>
27#include <malloc.h>
28#include "genksyms.h"
29
30static int is_typedef;
31static int is_extern;
32static char *current_name;
33static struct string_list *decl_spec;
34
35static void yyerror(const char *);
36
37static inline void
38remove_node(struct string_list **p)
39{
40 struct string_list *node = *p;
41 *p = node->next;
42 free_node(node);
43}
44
45static inline void
46remove_list(struct string_list **pb, struct string_list **pe)
47{
48 struct string_list *b = *pb, *e = *pe;
49 *pb = e;
50 free_list(b, e);
51}
52
53%}
54
55%token ASM_KEYW
56%token ATTRIBUTE_KEYW
57%token AUTO_KEYW
58%token BOOL_KEYW
59%token CHAR_KEYW
60%token CONST_KEYW
61%token DOUBLE_KEYW
62%token ENUM_KEYW
63%token EXTERN_KEYW
64%token FLOAT_KEYW
65%token INLINE_KEYW
66%token INT_KEYW
67%token LONG_KEYW
68%token REGISTER_KEYW
69%token RESTRICT_KEYW
70%token SHORT_KEYW
71%token SIGNED_KEYW
72%token STATIC_KEYW
73%token STRUCT_KEYW
74%token TYPEDEF_KEYW
75%token UNION_KEYW
76%token UNSIGNED_KEYW
77%token VOID_KEYW
78%token VOLATILE_KEYW
79%token TYPEOF_KEYW
80
81%token EXPORT_SYMBOL_KEYW
82
83%token ASM_PHRASE
84%token ATTRIBUTE_PHRASE
85%token BRACE_PHRASE
86%token BRACKET_PHRASE
87%token EXPRESSION_PHRASE
88
89%token CHAR
90%token DOTS
91%token IDENT
92%token INT
93%token REAL
94%token STRING
95%token TYPE
96%token OTHER
97%token FILENAME
98
99%%
100
101declaration_seq:
102 declaration
103 | declaration_seq declaration
104 ;
105
106declaration:
107 { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; }
108 declaration1
109 { free_list(*$2, NULL); *$2 = NULL; }
110 ;
111
112declaration1:
113 TYPEDEF_KEYW { is_typedef = 1; } simple_declaration
114 { $$ = $3; }
115 | simple_declaration
116 | function_definition
117 | asm_definition
118 | export_definition
119 | error ';' { $$ = $2; }
120 | error '}' { $$ = $2; }
121 ;
122
123simple_declaration:
124 decl_specifier_seq_opt init_declarator_list_opt ';'
125 { if (current_name) {
126 struct string_list *decl = (*$3)->next;
127 (*$3)->next = NULL;
128 add_symbol(current_name,
129 is_typedef ? SYM_TYPEDEF : SYM_NORMAL,
130 decl, is_extern);
131 current_name = NULL;
132 }
133 $$ = $3;
134 }
135 ;
136
137init_declarator_list_opt:
138 /* empty */ { $$ = NULL; }
139 | init_declarator_list
140 ;
141
142init_declarator_list:
143 init_declarator
144 { struct string_list *decl = *$1;
145 *$1 = NULL;
146 add_symbol(current_name,
147 is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern);
148 current_name = NULL;
149 $$ = $1;
150 }
151 | init_declarator_list ',' init_declarator
152 { struct string_list *decl = *$3;
153 *$3 = NULL;
154 free_list(*$2, NULL);
155 *$2 = decl_spec;
156 add_symbol(current_name,
157 is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern);
158 current_name = NULL;
159 $$ = $3;
160 }
161 ;
162
163init_declarator:
164 declarator asm_phrase_opt attribute_opt initializer_opt
165 { $$ = $4 ? $4 : $3 ? $3 : $2 ? $2 : $1; }
166 ;
167
168/* Hang on to the specifiers so that we can reuse them. */
169decl_specifier_seq_opt:
170 /* empty */ { decl_spec = NULL; }
171 | decl_specifier_seq
172 ;
173
174decl_specifier_seq:
175 decl_specifier { decl_spec = *$1; }
176 | decl_specifier_seq decl_specifier { decl_spec = *$2; }
177 ;
178
179decl_specifier:
180 storage_class_specifier
181 { /* Version 2 checksumming ignores storage class, as that
182 is really irrelevant to the linkage. */
183 remove_node($1);
184 $$ = $1;
185 }
186 | type_specifier
187 ;
188
189storage_class_specifier:
190 AUTO_KEYW
191 | REGISTER_KEYW
192 | STATIC_KEYW
193 | EXTERN_KEYW { is_extern = 1; $$ = $1; }
194 | INLINE_KEYW { is_extern = 0; $$ = $1; }
195 ;
196
197type_specifier:
198 simple_type_specifier
199 | cvar_qualifier
200 | TYPEOF_KEYW '(' decl_specifier_seq ')'
201
202 /* References to s/u/e's defined elsewhere. Rearrange things
203 so that it is easier to expand the definition fully later. */
204 | STRUCT_KEYW IDENT
205 { remove_node($1); (*$2)->tag = SYM_STRUCT; $$ = $2; }
206 | UNION_KEYW IDENT
207 { remove_node($1); (*$2)->tag = SYM_UNION; $$ = $2; }
208 | ENUM_KEYW IDENT
209 { remove_node($1); (*$2)->tag = SYM_ENUM; $$ = $2; }
210
211 /* Full definitions of an s/u/e. Record it. */
212 | STRUCT_KEYW IDENT class_body
213 { struct string_list *s = *$3, *i = *$2, *r;
214 r = copy_node(i); r->tag = SYM_STRUCT;
215 r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL;
216 add_symbol(i->string, SYM_STRUCT, s, is_extern);
217 $$ = $3;
218 }
219 | UNION_KEYW IDENT class_body
220 { struct string_list *s = *$3, *i = *$2, *r;
221 r = copy_node(i); r->tag = SYM_UNION;
222 r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL;
223 add_symbol(i->string, SYM_UNION, s, is_extern);
224 $$ = $3;
225 }
226 | ENUM_KEYW IDENT BRACE_PHRASE
227 { struct string_list *s = *$3, *i = *$2, *r;
228 r = copy_node(i); r->tag = SYM_ENUM;
229 r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL;
230 add_symbol(i->string, SYM_ENUM, s, is_extern);
231 $$ = $3;
232 }
233
234 /* Anonymous s/u/e definitions. Nothing needs doing. */
235 | ENUM_KEYW BRACE_PHRASE { $$ = $2; }
236 | STRUCT_KEYW class_body { $$ = $2; }
237 | UNION_KEYW class_body { $$ = $2; }
238 ;
239
240simple_type_specifier:
241 CHAR_KEYW
242 | SHORT_KEYW
243 | INT_KEYW
244 | LONG_KEYW
245 | SIGNED_KEYW
246 | UNSIGNED_KEYW
247 | FLOAT_KEYW
248 | DOUBLE_KEYW
249 | VOID_KEYW
250 | BOOL_KEYW
251 | TYPE { (*$1)->tag = SYM_TYPEDEF; $$ = $1; }
252 ;
253
254ptr_operator:
255 '*' cvar_qualifier_seq_opt
256 { $$ = $2 ? $2 : $1; }
257 ;
258
259cvar_qualifier_seq_opt:
260 /* empty */ { $$ = NULL; }
261 | cvar_qualifier_seq
262 ;
263
264cvar_qualifier_seq:
265 cvar_qualifier
266 | cvar_qualifier_seq cvar_qualifier { $$ = $2; }
267 ;
268
269cvar_qualifier:
270 CONST_KEYW | VOLATILE_KEYW | ATTRIBUTE_PHRASE
271 | RESTRICT_KEYW
272 { /* restrict has no effect in prototypes so ignore it */
273 remove_node($1);
274 $$ = $1;
275 }
276 ;
277
278declarator:
279 ptr_operator declarator { $$ = $2; }
280 | direct_declarator
281 ;
282
283direct_declarator:
284 IDENT
285 { if (current_name != NULL) {
286 error_with_pos("unexpected second declaration name");
287 YYERROR;
288 } else {
289 current_name = (*$1)->string;
290 $$ = $1;
291 }
292 }
293 | direct_declarator '(' parameter_declaration_clause ')'
294 { $$ = $4; }
295 | direct_declarator '(' error ')'
296 { $$ = $4; }
297 | direct_declarator BRACKET_PHRASE
298 { $$ = $2; }
299 | '(' declarator ')'
300 { $$ = $3; }
301 | '(' error ')'
302 { $$ = $3; }
303 ;
304
305/* Nested declarators differ from regular declarators in that they do
306 not record the symbols they find in the global symbol table. */
307nested_declarator:
308 ptr_operator nested_declarator { $$ = $2; }
309 | direct_nested_declarator
310 ;
311
312direct_nested_declarator:
313 IDENT
314 | TYPE
315 | direct_nested_declarator '(' parameter_declaration_clause ')'
316 { $$ = $4; }
317 | direct_nested_declarator '(' error ')'
318 { $$ = $4; }
319 | direct_nested_declarator BRACKET_PHRASE
320 { $$ = $2; }
321 | '(' nested_declarator ')'
322 { $$ = $3; }
323 | '(' error ')'
324 { $$ = $3; }
325 ;
326
327parameter_declaration_clause:
328 parameter_declaration_list_opt DOTS { $$ = $2; }
329 | parameter_declaration_list_opt
330 | parameter_declaration_list ',' DOTS { $$ = $3; }
331 ;
332
333parameter_declaration_list_opt:
334 /* empty */ { $$ = NULL; }
335 | parameter_declaration_list
336 ;
337
338parameter_declaration_list:
339 parameter_declaration
340 | parameter_declaration_list ',' parameter_declaration
341 { $$ = $3; }
342 ;
343
344parameter_declaration:
345 decl_specifier_seq m_abstract_declarator
346 { $$ = $2 ? $2 : $1; }
347 ;
348
349m_abstract_declarator:
350 ptr_operator m_abstract_declarator
351 { $$ = $2 ? $2 : $1; }
352 | direct_m_abstract_declarator
353 ;
354
355direct_m_abstract_declarator:
356 /* empty */ { $$ = NULL; }
357 | IDENT
358 { /* For version 2 checksums, we don't want to remember
359 private parameter names. */
360 remove_node($1);
361 $$ = $1;
362 }
363 /* This wasn't really a typedef name but an identifier that
364 shadows one. */
365 | TYPE
366 { remove_node($1);
367 $$ = $1;
368 }
369 | direct_m_abstract_declarator '(' parameter_declaration_clause ')'
370 { $$ = $4; }
371 | direct_m_abstract_declarator '(' error ')'
372 { $$ = $4; }
373 | direct_m_abstract_declarator BRACKET_PHRASE
374 { $$ = $2; }
375 | '(' m_abstract_declarator ')'
376 { $$ = $3; }
377 | '(' error ')'
378 { $$ = $3; }
379 ;
380
381function_definition:
382 decl_specifier_seq_opt declarator BRACE_PHRASE
383 { struct string_list *decl = *$2;
384 *$2 = NULL;
385 add_symbol(current_name, SYM_NORMAL, decl, is_extern);
386 $$ = $3;
387 }
388 ;
389
390initializer_opt:
391 /* empty */ { $$ = NULL; }
392 | initializer
393 ;
394
395/* We never care about the contents of an initializer. */
396initializer:
397 '=' EXPRESSION_PHRASE
398 { remove_list($2, &(*$1)->next); $$ = $2; }
399 ;
400
401class_body:
402 '{' member_specification_opt '}' { $$ = $3; }
403 | '{' error '}' { $$ = $3; }
404 ;
405
406member_specification_opt:
407 /* empty */ { $$ = NULL; }
408 | member_specification
409 ;
410
411member_specification:
412 member_declaration
413 | member_specification member_declaration { $$ = $2; }
414 ;
415
416member_declaration:
417 decl_specifier_seq_opt member_declarator_list_opt ';'
418 { $$ = $3; }
419 | error ';'
420 { $$ = $2; }
421 ;
422
423member_declarator_list_opt:
424 /* empty */ { $$ = NULL; }
425 | member_declarator_list
426 ;
427
428member_declarator_list:
429 member_declarator
430 | member_declarator_list ',' member_declarator { $$ = $3; }
431 ;
432
433member_declarator:
434 nested_declarator attribute_opt { $$ = $2 ? $2 : $1; }
435 | IDENT member_bitfield_declarator { $$ = $2; }
436 | member_bitfield_declarator
437 ;
438
439member_bitfield_declarator:
440 ':' EXPRESSION_PHRASE { $$ = $2; }
441 ;
442
443attribute_opt:
444 /* empty */ { $$ = NULL; }
445 | ATTRIBUTE_PHRASE
446 ;
447
448asm_definition:
449 ASM_PHRASE ';' { $$ = $2; }
450 ;
451
452asm_phrase_opt:
453 /* empty */ { $$ = NULL; }
454 | ASM_PHRASE
455 ;
456
457export_definition:
458 EXPORT_SYMBOL_KEYW '(' IDENT ')' ';'
459 { export_symbol((*$3)->string); $$ = $5; }
460 ;
461
462
463%%
464
465static void
466yyerror(const char *e)
467{
468 error_with_pos("%s", e);
469}