diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 15:20:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 15:20:36 -0700 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /scripts/genksyms | |
download | linux-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.tar.bz2 |
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/Makefile | 49 | ||||
-rw-r--r-- | scripts/genksyms/genksyms.c | 591 | ||||
-rw-r--r-- | scripts/genksyms/genksyms.h | 104 | ||||
-rw-r--r-- | scripts/genksyms/keywords.c_shipped | 145 | ||||
-rw-r--r-- | scripts/genksyms/keywords.gperf | 50 | ||||
-rw-r--r-- | scripts/genksyms/lex.c_shipped | 2084 | ||||
-rw-r--r-- | scripts/genksyms/lex.l | 407 | ||||
-rw-r--r-- | scripts/genksyms/parse.c_shipped | 1577 | ||||
-rw-r--r-- | scripts/genksyms/parse.h_shipped | 46 | ||||
-rw-r--r-- | scripts/genksyms/parse.y | 469 |
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 @@ + +hostprogs-y := genksyms +always := $(hostprogs-y) + +genksyms-objs := genksyms.o parse.o lex.o + +# -I needed for generated C source (shipped source) +HOSTCFLAGS_parse.o := -Wno-uninitialized -I$(src) + +# dependencies on generated files need to be listed explicitly +$(obj)/lex.o: $(obj)/parse.h $(obj)/keywords.c + +# -I needed for generated C source (shipped source) +HOSTCFLAGS_lex.o := -I$(src) + +ifdef GENERATE_PARSER + +# gperf + +quiet_cmd_keywords.c = GPERF $@ + cmd_keywords.c = gperf -L ANSI-C -a -C -E -g -H is_reserved_hash \ + -k 1,3,$$ -N is_reserved_word -p -t $< > $@ + +$(obj)/keywords.c: $(obj)/keywords.gperf FORCE + $(call if_changed,keywords.c) + +# flex + +quiet_cmd_lex.c = FLEX $@ + cmd_lex.c = flex -o$@ -d $(filter-out FORCE,$^) + +$(obj)/lex.c: $(obj)/lex.l $(obj)/parse.h FORCE + $(call if_changed,lex.c) + +# bison + +quiet_cmd_parse.c = BISON $@ + cmd_parse.c = bison -o$@ -dtv $(filter-out FORCE,$^) + +$(obj)/parse.c: $(obj)/parse.y FORCE + $(call if_changed,parse.c) + +$(obj)/parse.h: $(obj)/parse.c ; + +clean-files += parse.output + +endif + +targets += 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 @@ +/* Generate kernel symbol version hashes. + Copyright 1996, 1997 Linux International. + + New implementation contributed by Richard Henderson <rth@tamu.edu> + Based on original work by Bjorn Ekwall <bj0rn@blox.se> + + This file was part of the Linux modutils 2.4.22: moved back into the + kernel sources by Rusty Russell/Kai Germaschewski. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <assert.h> +#include <stdarg.h> +#ifdef __GNU_LIBRARY__ +#include <getopt.h> +#endif /* __GNU_LIBRARY__ */ + +#include "genksyms.h" + +/*----------------------------------------------------------------------*/ + +#define HASH_BUCKETS 4096 + +static struct symbol *symtab[HASH_BUCKETS]; +FILE *debugfile; + +int cur_line = 1; +char *cur_filename, *output_directory; + +int flag_debug, flag_dump_defs, flag_warnings; + +static int errors; +static int nsyms; + +static struct symbol *expansion_trail; + +static const char * const symbol_type_name[] = { + "normal", "typedef", "enum", "struct", "union" +}; + +/*----------------------------------------------------------------------*/ + +static const unsigned int crctab32[] = +{ + 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, + 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, + 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, + 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, + 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, + 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, + 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, + 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, + 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, + 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, + 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, + 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, + 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, + 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, + 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, + 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, + 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, + 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, + 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, + 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, + 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, + 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, + 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, + 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, + 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, + 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, + 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, + 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, + 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, + 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, + 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, + 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, + 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, + 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, + 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, + 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, + 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, + 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, + 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, + 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, + 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, + 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, + 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, + 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, + 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, + 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, + 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, + 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, + 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, + 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, + 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, + 0x2d02ef8dU +}; + +static inline unsigned long +partial_crc32_one(unsigned char c, unsigned long crc) +{ + return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8); +} + +static inline unsigned long +partial_crc32(const char *s, unsigned long crc) +{ + while (*s) + crc = partial_crc32_one(*s++, crc); + return crc; +} + +static inline unsigned long +crc32(const char *s) +{ + return partial_crc32(s, 0xffffffff) ^ 0xffffffff; +} + + +/*----------------------------------------------------------------------*/ + +static inline enum symbol_type +map_to_ns(enum symbol_type t) +{ + if (t == SYM_TYPEDEF) + t = SYM_NORMAL; + else if (t == SYM_UNION) + t = SYM_STRUCT; + return t; +} + +struct symbol * +find_symbol(const char *name, enum symbol_type ns) +{ + unsigned long h = crc32(name) % HASH_BUCKETS; + struct symbol *sym; + + for (sym = symtab[h]; sym ; sym = sym->hash_next) + if (map_to_ns(sym->type) == map_to_ns(ns) && strcmp(name, sym->name) == 0) + break; + + return sym; +} + +struct symbol * +add_symbol(const char *name, enum symbol_type type, struct string_list *defn, int is_extern) +{ + unsigned long h = crc32(name) % HASH_BUCKETS; + struct symbol *sym; + + for (sym = symtab[h]; sym ; sym = sym->hash_next) + if (map_to_ns(sym->type) == map_to_ns(type) + && strcmp(name, sym->name) == 0) + { + if (!equal_list(sym->defn, defn)) + error_with_pos("redefinition of %s", name); + return sym; + } + + sym = xmalloc(sizeof(*sym)); + sym->name = name; + sym->type = type; + sym->defn = defn; + sym->expansion_trail = NULL; + sym->is_extern = is_extern; + + sym->hash_next = symtab[h]; + symtab[h] = sym; + + if (flag_debug) + { + fprintf(debugfile, "Defn for %s %s == <", symbol_type_name[type], name); + if (is_extern) + fputs("extern ", debugfile); + print_list(debugfile, defn); + fputs(">\n", debugfile); + } + + ++nsyms; + return sym; +} + + +/*----------------------------------------------------------------------*/ + +inline void +free_node(struct string_list *node) +{ + free(node->string); + free(node); +} + +void +free_list(struct string_list *s, struct string_list *e) +{ + while (s != e) + { + struct string_list *next = s->next; + free_node(s); + s = next; + } +} + +inline struct string_list * +copy_node(struct string_list *node) +{ + struct string_list *newnode; + + newnode = xmalloc(sizeof(*newnode)); + newnode->string = xstrdup(node->string); + newnode->tag = node->tag; + + return newnode; +} + +struct string_list * +copy_list(struct string_list *s, struct string_list *e) +{ + struct string_list *h, *p; + + if (s == e) + return NULL; + + p = h = copy_node(s); + while ((s = s->next) != e) + p = p->next = copy_node(s); + p->next = NULL; + + return h; +} + +int +equal_list(struct string_list *a, struct string_list *b) +{ + while (a && b) + { + if (a->tag != b->tag || strcmp(a->string, b->string)) + return 0; + a = a->next; + b = b->next; + } + + return !a && !b; +} + +static inline void +print_node(FILE *f, struct string_list *list) +{ + switch (list->tag) + { + case SYM_STRUCT: + putc('s', f); + goto printit; + case SYM_UNION: + putc('u', f); + goto printit; + case SYM_ENUM: + putc('e', f); + goto printit; + case SYM_TYPEDEF: + putc('t', f); + goto printit; + + printit: + putc('#', f); + case SYM_NORMAL: + fputs(list->string, f); + break; + } +} + +void +print_list(FILE *f, struct string_list *list) +{ + struct string_list **e, **b; + struct string_list *tmp, **tmp2; + int elem = 1; + + if (list == NULL) + { + fputs("(nil)", f); + return; + } + + tmp = list; + while((tmp = tmp->next) != NULL) + elem++; + + b = alloca(elem * sizeof(*e)); + e = b + elem; + tmp2 = e - 1; + + (*tmp2--) = list; + while((list = list->next) != NULL) + *(tmp2--) = list; + + while (b != e) + { + print_node(f, *b++); + putc(' ', f); + } +} + +static unsigned long +expand_and_crc_list(struct string_list *list, unsigned long crc) +{ + struct string_list **e, **b; + struct string_list *tmp, **tmp2; + int elem = 1; + + if (!list) + return crc; + + tmp = list; + while((tmp = tmp->next) != NULL) + elem++; + + b = alloca(elem * sizeof(*e)); + e = b + elem; + tmp2 = e - 1; + + *(tmp2--) = list; + while ((list = list->next) != NULL) + *(tmp2--) = list; + + while (b != e) + { + struct string_list *cur; + struct symbol *subsym; + + cur = *(b++); + switch (cur->tag) + { + case SYM_NORMAL: + if (flag_dump_defs) + fprintf(debugfile, "%s ", cur->string); + crc = partial_crc32(cur->string, crc); + crc = partial_crc32_one(' ', crc); + break; + + case SYM_TYPEDEF: + subsym = find_symbol(cur->string, cur->tag); + if (subsym->expansion_trail) + { + if (flag_dump_defs) + fprintf(debugfile, "%s ", cur->string); + crc = partial_crc32(cur->string, crc); + crc = partial_crc32_one(' ', crc); + } + else + { + subsym->expansion_trail = expansion_trail; + expansion_trail = subsym; + crc = expand_and_crc_list(subsym->defn, crc); + } + break; + + case SYM_STRUCT: + case SYM_UNION: + case SYM_ENUM: + subsym = find_symbol(cur->string, cur->tag); + if (!subsym) + { + struct string_list *n, *t = NULL; + + error_with_pos("expand undefined %s %s", + symbol_type_name[cur->tag], cur->string); + + n = xmalloc(sizeof(*n)); + n->string = xstrdup(symbol_type_name[cur->tag]); + n->tag = SYM_NORMAL; + n->next = t; + t = n; + + n = xmalloc(sizeof(*n)); + n->string = xstrdup(cur->string); + n->tag = SYM_NORMAL; + n->next = t; + t = n; + + n = xmalloc(sizeof(*n)); + n->string = xstrdup("{ UNKNOWN }"); + n->tag = SYM_NORMAL; + n->next = t; + + subsym = add_symbol(cur->string, cur->tag, n, 0); + } + if (subsym->expansion_trail) + { + if (flag_dump_defs) + { + fprintf(debugfile, "%s %s ", symbol_type_name[cur->tag], + cur->string); + } + + crc = partial_crc32(symbol_type_name[cur->tag], crc); + crc = partial_crc32_one(' ', crc); + crc = partial_crc32(cur->string, crc); + crc = partial_crc32_one(' ', crc); + } + else + { + subsym->expansion_trail = expansion_trail; + expansion_trail = subsym; + crc = expand_and_crc_list(subsym->defn, crc); + } + break; + } + } + + return crc; +} + +void +export_symbol(const char *name) +{ + struct symbol *sym; + + sym = find_symbol(name, SYM_NORMAL); + if (!sym) + error_with_pos("export undefined symbol %s", name); + else + { + unsigned long crc; + + if (flag_dump_defs) + fprintf(debugfile, "Export %s == <", name); + + expansion_trail = (struct symbol *)-1L; + + crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff; + + sym = expansion_trail; + while (sym != (struct symbol *)-1L) + { + struct symbol *n = sym->expansion_trail; + sym->expansion_trail = 0; + sym = n; + } + + if (flag_dump_defs) + fputs(">\n", debugfile); + + /* Used as a linker script. */ + printf("__crc_%s = 0x%08lx ;\n", name, crc); + } +} + +/*----------------------------------------------------------------------*/ + +void +error(const char *fmt, ...) +{ + va_list args; + + if (flag_warnings) + { + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + putc('\n', stderr); + + errors++; + } +} + +void +error_with_pos(const char *fmt, ...) +{ + va_list args; + + if (flag_warnings) + { + fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>", cur_line); + + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + putc('\n', stderr); + + errors++; + } +} + + +void genksyms_usage(void) +{ + fputs("Usage:\n" + "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" + "\n" +#ifdef __GNU_LIBRARY__ + " -d, --debug Increment the debug level (repeatable)\n" + " -D, --dump Dump expanded symbol defs (for debugging only)\n" + " -w, --warnings Enable warnings\n" + " -q, --quiet Disable warnings (default)\n" + " -h, --help Print this message\n" + " -V, --version Print the release version\n" +#else /* __GNU_LIBRARY__ */ + " -d Increment the debug level (repeatable)\n" + " -D Dump expanded symbol defs (for debugging only)\n" + " -w Enable warnings\n" + " -q Disable warnings (default)\n" + " -h Print this message\n" + " -V Print the release version\n" +#endif /* __GNU_LIBRARY__ */ + , stderr); +} + +int +main(int argc, char **argv) +{ + int o; + +#ifdef __GNU_LIBRARY__ + struct option long_opts[] = { + {"debug", 0, 0, 'd'}, + {"warnings", 0, 0, 'w'}, + {"quiet", 0, 0, 'q'}, + {"dump", 0, 0, 'D'}, + {"version", 0, 0, 'V'}, + {"help", 0, 0, 'h'}, + {0, 0, 0, 0} + }; + + while ((o = getopt_long(argc, argv, "dwqVDk:p:", + &long_opts[0], NULL)) != EOF) +#else /* __GNU_LIBRARY__ */ + while ((o = getopt(argc, argv, "dwqVDk:p:")) != EOF) +#endif /* __GNU_LIBRARY__ */ + switch (o) + { + case 'd': + flag_debug++; + break; + case 'w': + flag_warnings = 1; + break; + case 'q': + flag_warnings = 0; + break; + case 'V': + fputs("genksyms version 2.5.60\n", stderr); + break; + case 'D': + flag_dump_defs = 1; + break; + case 'h': + genksyms_usage(); + return 0; + default: + genksyms_usage(); + return 1; + } + + { + extern int yydebug; + extern int yy_flex_debug; + + yydebug = (flag_debug > 1); + yy_flex_debug = (flag_debug > 2); + + debugfile = stderr; + /* setlinebuf(debugfile); */ + } + + yyparse(); + + if (flag_debug) + { + fprintf(debugfile, "Hash table occupancy %d/%d = %g\n", + nsyms, HASH_BUCKETS, (double)nsyms / (double)HASH_BUCKETS); + } + + return errors != 0; +} 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 @@ +/* Generate kernel symbol version hashes. + Copyright 1996, 1997 Linux International. + + New implementation contributed by Richard Henderson <rth@tamu.edu> + Based on original work by Bjorn Ekwall <bj0rn@blox.se> + + This file is part of the Linux modutils. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + +#ifndef MODUTILS_GENKSYMS_H +#define MODUTILS_GENKSYMS_H 1 + +#include <stdio.h> + + +enum symbol_type +{ + SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION +}; + +struct string_list +{ + struct string_list *next; + enum symbol_type tag; + char *string; +}; + +struct symbol +{ + struct symbol *hash_next; + const char *name; + enum symbol_type type; + struct string_list *defn; + struct symbol *expansion_trail; + int is_extern; +}; + +typedef struct string_list **yystype; +#define YYSTYPE yystype + +extern FILE *outfile, *debugfile; + +extern int cur_line; +extern char *cur_filename, *output_directory; + +extern int flag_debug, flag_dump_defs, flag_warnings; +extern int checksum_version, kernel_version; + +extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents; +extern struct string_list *current_list, *next_list; + + +struct symbol *find_symbol(const char *name, enum symbol_type ns); +struct symbol *add_symbol(const char *name, enum symbol_type type, + struct string_list *defn, int is_extern); +void export_symbol(const char *); + +struct string_list *reset_list(void); +void free_list(struct string_list *s, struct string_list *e); +void free_node(struct string_list *list); +struct string_list *copy_node(struct string_list *); +struct string_list *copy_list(struct string_list *s, struct string_list *e); +int equal_list(struct string_list *a, struct string_list *b); +void print_list(FILE *, struct string_list *list); + +int yylex(void); +int yyparse(void); + +void error_with_pos(const char *, ...); + +#define version(a,b,c) ((a << 16) | (b << 8) | (c)) + +/*----------------------------------------------------------------------*/ + +#define MODUTILS_VERSION "<in-kernel>" + +#define xmalloc(size) ({ void *__ptr = malloc(size); \ + if(!__ptr && size != 0) { \ + fprintf(stderr, "out of memory\n"); \ + exit(1); \ + } \ + __ptr; }) +#define xstrdup(str) ({ char *__str = strdup(str); \ + if (!__str) { \ + fprintf(stderr, "out of memory\n"); \ + exit(1); \ + } \ + __str; }) + +#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 @@ +/* ANSI-C code produced by gperf version 2.7.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 */ +struct resword { const char *name; int token; }; +/* maximum key range = 109, duplicates = 0 */ + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +is_reserved_hash (register const char *str, register unsigned int len) +{ + static const unsigned char asso_values[] = + { + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 5, + 113, 113, 113, 113, 113, 113, 0, 113, 113, 113, + 0, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 0, 113, 0, 113, 20, + 25, 0, 35, 30, 113, 20, 113, 113, 40, 30, + 30, 0, 0, 113, 0, 51, 0, 15, 5, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 113, 113 + }; + return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]]; +} + +#ifdef __GNUC__ +__inline +#endif +const struct resword * +is_reserved_word (register const char *str, register unsigned int len) +{ + enum + { + TOTAL_KEYWORDS = 41, + MIN_WORD_LENGTH = 3, + MAX_WORD_LENGTH = 17, + MIN_HASH_VALUE = 4, + MAX_HASH_VALUE = 112 + }; + + static const struct resword wordlist[] = + { + {""}, {""}, {""}, {""}, + {"auto", AUTO_KEYW}, + {""}, {""}, + {"__asm__", ASM_KEYW}, + {""}, + {"_restrict", RESTRICT_KEYW}, + {"__typeof__", TYPEOF_KEYW}, + {"__attribute", ATTRIBUTE_KEYW}, + {"__restrict__", RESTRICT_KEYW}, + {"__attribute__", ATTRIBUTE_KEYW}, + {""}, + {"__volatile", VOLATILE_KEYW}, + {""}, + {"__volatile__", VOLATILE_KEYW}, + {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW}, + {""}, {""}, {""}, + {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, + {"int", INT_KEYW}, + {"char", CHAR_KEYW}, + {""}, {""}, + {"__const", CONST_KEYW}, + {"__inline", INLINE_KEYW}, + {"__const__", CONST_KEYW}, + {"__inline__", INLINE_KEYW}, + {""}, {""}, {""}, {""}, + {"__asm", ASM_KEYW}, + {"extern", EXTERN_KEYW}, + {""}, + {"register", REGISTER_KEYW}, + {""}, + {"float", FLOAT_KEYW}, + {"typeof", TYPEOF_KEYW}, + {"typedef", TYPEDEF_KEYW}, + {""}, {""}, + {"_Bool", BOOL_KEYW}, + {"double", DOUBLE_KEYW}, + {""}, {""}, + {"enum", ENUM_KEYW}, + {""}, {""}, {""}, + {"volatile", VOLATILE_KEYW}, + {"void", VOID_KEYW}, + {"const", CONST_KEYW}, + {"short", SHORT_KEYW}, + {"struct", STRUCT_KEYW}, + {""}, + {"restrict", RESTRICT_KEYW}, + {""}, + {"__signed__", SIGNED_KEYW}, + {""}, + {"asm", ASM_KEYW}, + {""}, {""}, + {"inline", INLINE_KEYW}, + {""}, {""}, {""}, + {"union", UNION_KEYW}, + {""}, {""}, {""}, {""}, {""}, {""}, + {"static", STATIC_KEYW}, + {""}, {""}, {""}, {""}, {""}, {""}, + {"__signed", SIGNED_KEYW}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, + {"unsigned", UNSIGNED_KEYW}, + {""}, {""}, {""}, {""}, + {"long", LONG_KEYW}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {"signed", SIGNED_KEYW} + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = is_reserved_hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register const char *s = wordlist[key].name; + + if (*str == *s && !strcmp (str + 1, s + 1)) + return &wordlist[key]; + } + } + return 0; +} 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 @@ +%{ +%} +struct resword { const char *name; int token; } +%% +EXPORT_SYMBOL, EXPORT_SYMBOL_KEYW +EXPORT_SYMBOL_GPL, EXPORT_SYMBOL_KEYW +__asm, ASM_KEYW +__asm__, ASM_KEYW +__attribute, ATTRIBUTE_KEYW +__attribute__, ATTRIBUTE_KEYW +__const, CONST_KEYW +__const__, CONST_KEYW +__inline, INLINE_KEYW +__inline__, INLINE_KEYW +__signed, SIGNED_KEYW +__signed__, SIGNED_KEYW +__volatile, VOLATILE_KEYW +__volatile__, VOLATILE_KEYW +# According to rth, c99 defines _Bool, __restrict, __restrict__, restrict. KAO +_Bool, BOOL_KEYW +_restrict, RESTRICT_KEYW +__restrict__, RESTRICT_KEYW +restrict, RESTRICT_KEYW +asm, ASM_KEYW +# attribute commented out in modutils 2.4.2. People are using 'attribute' as a +# field name which breaks the genksyms parser. It is not a gcc keyword anyway. +# KAO. +# attribute, ATTRIBUTE_KEYW +auto, AUTO_KEYW +char, CHAR_KEYW +const, CONST_KEYW +double, DOUBLE_KEYW +enum, ENUM_KEYW +extern, EXTERN_KEYW +float, FLOAT_KEYW +inline, INLINE_KEYW +int, INT_KEYW +long, LONG_KEYW +register, REGISTER_KEYW +short, SHORT_KEYW +signed, SIGNED_KEYW +static, STATIC_KEYW +struct, STRUCT_KEYW +typedef, TYPEDEF_KEYW +union, UNION_KEYW +unsigned, UNSIGNED_KEYW +void, VOID_KEYW +volatile, VOLATILE_KEYW +typeof, TYPEOF_KEYW +__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 @@ +#line 2 "scripts/genksyms/lex.c" +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include <stdio.h> +#include <unistd.h> + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include <stdlib.h> + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include <io.h> +#include <stdlib.h> +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP + +#define FLEX_DEBUG +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; + +#define FLEX_DEBUG +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 13 +#define YY_END_OF_BUFFER 14 +static yyconst short int yy_accept[76] = + { 0, + 0, 0, 0, 0, 14, 12, 4, 3, 12, 7, + 12, 12, 7, 12, 12, 12, 12, 12, 9, 9, + 12, 12, 12, 4, 0, 5, 0, 7, 0, 6, + 0, 0, 0, 0, 0, 0, 2, 8, 10, 10, + 9, 0, 0, 9, 9, 0, 9, 0, 0, 11, + 0, 0, 0, 10, 0, 10, 9, 9, 0, 0, + 0, 0, 0, 0, 0, 10, 10, 0, 0, 0, + 0, 0, 0, 1, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 6, 7, 8, 9, 10, 1, + 1, 8, 11, 1, 12, 13, 8, 14, 15, 15, + 15, 15, 15, 15, 15, 16, 16, 1, 1, 17, + 18, 19, 1, 1, 20, 20, 20, 20, 21, 22, + 7, 7, 7, 7, 7, 23, 7, 7, 7, 7, + 7, 7, 7, 7, 24, 7, 7, 25, 7, 7, + 1, 26, 1, 8, 7, 1, 20, 20, 20, 20, + + 21, 22, 7, 7, 7, 7, 7, 27, 7, 7, + 7, 7, 7, 7, 7, 7, 24, 7, 7, 25, + 7, 7, 1, 28, 1, 8, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[29] = + { 0, + 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, + 4, 4, 5, 6, 6, 6, 1, 1, 1, 7, + 8, 7, 3, 3, 3, 1, 3, 1 + } ; + +static yyconst short int yy_base[88] = + { 0, + 0, 147, 21, 140, 145, 284, 39, 284, 26, 0, + 32, 126, 40, 44, 115, 35, 36, 46, 50, 53, + 39, 61, 54, 79, 65, 284, 0, 0, 66, 284, + 0, 119, 79, 75, 123, 104, 284, 284, 107, 0, + 79, 73, 76, 76, 66, 0, 0, 85, 86, 284, + 133, 83, 91, 284, 99, 147, 284, 114, 122, 70, + 107, 141, 172, 151, 135, 181, 284, 137, 114, 157, + 149, 48, 45, 284, 284, 208, 214, 222, 230, 238, + 246, 250, 255, 256, 261, 267, 275 + } ; + +static yyconst short int yy_def[88] = + { 0, + 75, 1, 1, 3, 75, 75, 75, 75, 76, 77, + 78, 75, 77, 79, 75, 75, 75, 75, 75, 19, + 75, 75, 75, 75, 76, 75, 80, 77, 78, 75, + 81, 75, 76, 78, 79, 79, 75, 75, 75, 39, + 19, 82, 83, 75, 75, 84, 20, 76, 78, 75, + 79, 51, 85, 75, 75, 75, 75, 84, 79, 51, + 79, 79, 79, 51, 75, 75, 75, 86, 79, 63, + 86, 87, 87, 75, 0, 75, 75, 75, 75, 75, + 75, 75, 75, 75, 75, 75, 75 + } ; + +static yyconst short int yy_nxt[313] = + { 0, + 6, 7, 8, 7, 9, 6, 10, 6, 6, 11, + 6, 6, 12, 6, 6, 6, 6, 6, 6, 10, + 10, 10, 13, 10, 10, 6, 10, 6, 15, 16, + 26, 15, 17, 18, 19, 20, 20, 21, 15, 22, + 24, 30, 24, 38, 33, 36, 37, 74, 23, 34, + 74, 27, 38, 38, 38, 38, 38, 31, 32, 39, + 39, 39, 40, 41, 41, 42, 47, 47, 47, 26, + 43, 38, 44, 45, 46, 30, 44, 75, 38, 38, + 24, 38, 24, 26, 30, 40, 55, 55, 57, 26, + 27, 31, 57, 43, 35, 30, 64, 64, 64, 57, + + 31, 65, 65, 75, 27, 36, 37, 35, 59, 37, + 27, 31, 56, 56, 56, 59, 37, 51, 52, 52, + 39, 39, 39, 59, 37, 37, 68, 53, 54, 54, + 69, 50, 38, 54, 59, 37, 44, 45, 32, 37, + 44, 35, 59, 37, 75, 14, 60, 60, 66, 66, + 66, 37, 14, 72, 75, 61, 62, 63, 59, 61, + 56, 56, 56, 69, 64, 64, 64, 69, 67, 67, + 75, 75, 75, 67, 37, 35, 75, 75, 75, 61, + 62, 75, 75, 61, 75, 70, 70, 70, 75, 75, + 75, 70, 70, 70, 66, 66, 66, 75, 75, 75, + + 75, 75, 54, 54, 75, 75, 75, 54, 25, 25, + 25, 25, 25, 25, 25, 25, 28, 75, 75, 28, + 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, + 35, 35, 35, 35, 35, 35, 35, 35, 48, 75, + 48, 48, 48, 48, 48, 48, 49, 75, 49, 49, + 49, 49, 49, 49, 42, 42, 75, 42, 56, 75, + 56, 58, 58, 58, 66, 75, 66, 71, 71, 71, + 71, 71, 71, 71, 71, 73, 73, 73, 73, 73, + 73, 73, 73, 5, 75, 75, 75, 75, 75, 75, + 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, + + 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, + 75, 75 + } ; + +static yyconst short int yy_chk[313] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, + 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 7, 11, 7, 16, 13, 14, 14, 73, 3, 13, + 72, 9, 16, 17, 17, 21, 21, 11, 18, 18, + 18, 18, 19, 19, 19, 19, 20, 20, 20, 25, + 19, 23, 19, 19, 19, 29, 19, 20, 22, 22, + 24, 23, 24, 33, 34, 42, 43, 43, 45, 48, + 25, 29, 45, 42, 60, 49, 52, 52, 52, 44, + + 34, 53, 53, 41, 33, 36, 36, 52, 61, 61, + 48, 49, 55, 55, 55, 69, 69, 36, 36, 36, + 39, 39, 39, 59, 59, 35, 59, 39, 39, 39, + 61, 32, 15, 39, 51, 51, 58, 58, 12, 68, + 58, 68, 62, 62, 5, 4, 51, 51, 65, 65, + 65, 71, 2, 71, 0, 51, 51, 51, 70, 51, + 56, 56, 56, 62, 64, 64, 64, 62, 56, 56, + 0, 0, 0, 56, 63, 64, 0, 0, 0, 70, + 70, 0, 0, 70, 0, 63, 63, 63, 0, 0, + 0, 63, 63, 63, 66, 66, 66, 0, 0, 0, + + 0, 0, 66, 66, 0, 0, 0, 66, 76, 76, + 76, 76, 76, 76, 76, 76, 77, 0, 0, 77, + 77, 77, 78, 78, 78, 78, 78, 78, 78, 78, + 79, 79, 79, 79, 79, 79, 79, 79, 80, 0, + 80, 80, 80, 80, 80, 80, 81, 0, 81, 81, + 81, 81, 81, 81, 82, 82, 0, 82, 83, 0, + 83, 84, 84, 84, 85, 0, 85, 86, 86, 86, + 86, 86, 86, 86, 86, 87, 87, 87, 87, 87, + 87, 87, 87, 75, 75, 75, 75, 75, 75, 75, + 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, + + 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, + 75, 75 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 1; + +static yyconst short int yy_rule_linenum[13] = + { 0, + 69, 70, 71, 74, 77, 78, 79, 85, 86, 87, + 89, 92 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "scripts/genksyms/lex.l" +#define INITIAL 0 +/* Lexical analysis for genksyms. + Copyright 1996, 1997 Linux International. + + New implementation contributed by Richard Henderson <rth@tamu.edu> + Based on original work by Bjorn Ekwall <bj0rn@blox.se> + + Taken from Linux modutils 2.4.22. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#line 25 "scripts/genksyms/lex.l" + +#include <limits.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> + +#include "genksyms.h" +#include "parse.h" + +/* We've got a two-level lexer here. We let flex do basic tokenization + and then we categorize those basic tokens in the second stage. */ +#define YY_DECL static int yylex1(void) + +/* Version 2 checksumming does proper tokenization; version 1 wasn't + quite so pedantic. */ +#define V2_TOKENS 1 + +/* We don't do multiple input files. */ +#line 513 "scripts/genksyms/lex.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include <stdlib.h> +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + yy_current_buffer->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 65 "scripts/genksyms/lex.l" + + + + /* Keep track of our location in the original source files. */ +#line 672 "scripts/genksyms/lex.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 76 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 284 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + if ( yy_flex_debug ) + { + if ( yy_act == 0 ) + fprintf( stderr, "--scanner backing up\n" ); + else if ( yy_act < 13 ) + fprintf( stderr, "--accepting rule at line %d (\"%s\")\n", + yy_rule_linenum[yy_act], yytext ); + else if ( yy_act == 13 ) + fprintf( stderr, "--accepting default rule (\"%s\")\n", + yytext ); + else if ( yy_act == 14 ) + fprintf( stderr, "--(end of buffer or a NUL)\n" ); + else + fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); + } + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 69 "scripts/genksyms/lex.l" +return FILENAME; + YY_BREAK +case 2: +YY_RULE_SETUP +#line 70 "scripts/genksyms/lex.l" +cur_line++; + YY_BREAK +case 3: +YY_RULE_SETUP +#line 71 "scripts/genksyms/lex.l" +cur_line++; + YY_BREAK +/* Ignore all other whitespace. */ +case 4: +YY_RULE_SETUP +#line 74 "scripts/genksyms/lex.l" +; + YY_BREAK +case 5: +YY_RULE_SETUP +#line 77 "scripts/genksyms/lex.l" +return STRING; + YY_BREAK +case 6: +YY_RULE_SETUP +#line 78 "scripts/genksyms/lex.l" +return CHAR; + YY_BREAK +case 7: +YY_RULE_SETUP +#line 79 "scripts/genksyms/lex.l" +return IDENT; + YY_BREAK +/* The Pedant requires that the other C multi-character tokens be + recognized as tokens. We don't actually use them since we don't + parse expressions, but we do want whitespace to be arranged + around them properly. */ +case 8: +YY_RULE_SETUP +#line 85 "scripts/genksyms/lex.l" +return OTHER; + YY_BREAK +case 9: +YY_RULE_SETUP +#line 86 "scripts/genksyms/lex.l" +return INT; + YY_BREAK +case 10: +YY_RULE_SETUP +#line 87 "scripts/genksyms/lex.l" +return REAL; + YY_BREAK +case 11: +YY_RULE_SETUP +#line 89 "scripts/genksyms/lex.l" +return DOTS; + YY_BREAK +/* All other tokens are single characters. */ +case 12: +YY_RULE_SETUP +#line 92 "scripts/genksyms/lex.l" +return yytext[0]; + YY_BREAK +case 13: +YY_RULE_SETUP +#line 95 "scripts/genksyms/lex.l" +ECHO; + YY_BREAK +#line 842 "scripts/genksyms/lex.c" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(V2_TOKENS): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 76 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 76 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 75); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + yy_current_buffer->yy_at_bol = (c == '\n'); + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 95 "scripts/genksyms/lex.l" + + +/* Bring in the keyword recognizer. */ + +#include "keywords.c" + + +/* Macros to append to our phrase collection list. */ + +#define _APP(T,L) do { \ + cur_node = next_node; \ + next_node = xmalloc(sizeof(*next_node)); \ + next_node->next = cur_node; \ + cur_node->string = memcpy(xmalloc(L+1), T, L+1); \ + cur_node->tag = SYM_NORMAL; \ + } while (0) + +#define APP _APP(yytext, yyleng) + + +/* The second stage lexer. Here we incorporate knowledge of the state + of the parser to tailor the tokens that are returned. */ + +int +yylex(void) +{ + static enum { + ST_NOTSTARTED, ST_NORMAL, ST_ATTRIBUTE, ST_ASM, ST_BRACKET, ST_BRACE, + ST_EXPRESSION, ST_TABLE_1, ST_TABLE_2, ST_TABLE_3, ST_TABLE_4, + ST_TABLE_5, ST_TABLE_6 + } lexstate = ST_NOTSTARTED; + + static int suppress_type_lookup, dont_want_brace_phrase; + static struct string_list *next_node; + + int token, count = 0; + struct string_list *cur_node; + + if (lexstate == ST_NOTSTARTED) + { + BEGIN(V2_TOKENS); + next_node = xmalloc(sizeof(*next_node)); + next_node->next = NULL; + lexstate = ST_NORMAL; + } + +repeat: + token = yylex1(); + + if (token == 0) + return 0; + else if (token == FILENAME) + { + char *file, *e; + + /* Save the filename and line number for later error messages. */ + + if (cur_filename) + free(cur_filename); + + file = strchr(yytext, '\"')+1; + e = strchr(file, '\"'); + *e = '\0'; + cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1); + cur_line = atoi(yytext+2); + + goto repeat; + } + + switch (lexstate) + { + case ST_NORMAL: + switch (token) + { + case IDENT: + APP; + { + const struct resword *r = is_reserved_word(yytext, yyleng); + if (r) + { + switch (token = r->token) + { + case ATTRIBUTE_KEYW: + lexstate = ST_ATTRIBUTE; + count = 0; + goto repeat; + case ASM_KEYW: + lexstate = ST_ASM; + count = 0; + goto repeat; + + case STRUCT_KEYW: + case UNION_KEYW: + dont_want_brace_phrase = 3; + case ENUM_KEYW: + suppress_type_lookup = 2; + goto fini; + + case EXPORT_SYMBOL_KEYW: + goto fini; + } + } + if (!suppress_type_lookup) + { + struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF); + if (sym && sym->type == SYM_TYPEDEF) + token = TYPE; + } + } + break; + + case '[': + APP; + lexstate = ST_BRACKET; + count = 1; + goto repeat; + + case '{': + APP; + if (dont_want_brace_phrase) + break; + lexstate = ST_BRACE; + count = 1; + goto repeat; + + case '=': case ':': + APP; + lexstate = ST_EXPRESSION; + break; + + case DOTS: + default: + APP; + break; + } + break; + + case ST_ATTRIBUTE: + APP; + switch (token) + { + case '(': + ++count; + goto repeat; + case ')': + if (--count == 0) + { + lexstate = ST_NORMAL; + token = ATTRIBUTE_PHRASE; + break; + } + goto repeat; + default: + goto repeat; + } + break; + + case ST_ASM: + APP; + switch (token) + { + case '(': + ++count; + goto repeat; + case ')': + if (--count == 0) + { + lexstate = ST_NORMAL; + token = ASM_PHRASE; + break; + } + goto repeat; + default: + goto repeat; + } + break; + + case ST_BRACKET: + APP; + switch (token) + { + case '[': + ++count; + goto repeat; + case ']': + if (--count == 0) + { + lexstate = ST_NORMAL; + token = BRACKET_PHRASE; + break; + } + goto repeat; + default: + goto repeat; + } + break; + + case ST_BRACE: + APP; + switch (token) + { + case '{': + ++count; + goto repeat; + case '}': + if (--count == 0) + { + lexstate = ST_NORMAL; + token = BRACE_PHRASE; + break; + } + goto repeat; + default: + goto repeat; + } + break; + + case ST_EXPRESSION: + switch (token) + { + case '(': case '[': case '{': + ++count; + APP; + goto repeat; + case ')': case ']': case '}': + --count; + APP; + goto repeat; + case ',': case ';': + if (count == 0) + { + /* Put back the token we just read so's we can find it again + after registering the expression. */ + unput(token); + + lexstate = ST_NORMAL; + token = EXPRESSION_PHRASE; + break; + } + APP; + goto repeat; + default: + APP; + goto repeat; + } + break; + + case ST_TABLE_1: + goto repeat; + + case ST_TABLE_2: + if (token == IDENT && yyleng == 1 && yytext[0] == 'X') + { + token = EXPORT_SYMBOL_KEYW; + lexstate = ST_TABLE_5; + APP; + break; + } + lexstate = ST_TABLE_6; + /* FALLTHRU */ + + case ST_TABLE_6: + switch (token) + { + case '{': case '[': case '(': + ++count; + break; + case '}': case ']': case ')': + --count; + break; + case ',': + if (count == 0) + lexstate = ST_TABLE_2; + break; + }; + goto repeat; + + case ST_TABLE_3: + goto repeat; + + case ST_TABLE_4: + if (token == ';') + lexstate = ST_NORMAL; + goto repeat; + + case ST_TABLE_5: + switch (token) + { + case ',': + token = ';'; + lexstate = ST_TABLE_2; + APP; + break; + default: + APP; + break; + } + break; + + default: + abort(); + } +fini: + + if (suppress_type_lookup > 0) + --suppress_type_lookup; + if (dont_want_brace_phrase > 0) + --dont_want_brace_phrase; + + yylval = &next_node->next; + + return token; +} +#ifndef YYSTYPE +#define YYSTYPE int +#endif +#define ASM_KEYW 257 +#define ATTRIBUTE_KEYW 258 +#define AUTO_KEYW 259 +#define BOOL_KEYW 260 +#define CHAR_KEYW 261 +#define CONST_KEYW 262 +#define DOUBLE_KEYW 263 +#define ENUM_KEYW 264 +#define EXTERN_KEYW 265 +#define FLOAT_KEYW 266 +#define INLINE_KEYW 267 +#define INT_KEYW 268 +#define LONG_KEYW 269 +#define REGISTER_KEYW 270 +#define RESTRICT_KEYW 271 +#define SHORT_KEYW 272 +#define SIGNED_KEYW 273 +#define STATIC_KEYW 274 +#define STRUCT_KEYW 275 +#define TYPEDEF_KEYW 276 +#define UNION_KEYW 277 +#define UNSIGNED_KEYW 278 +#define VOID_KEYW 279 +#define VOLATILE_KEYW 280 +#define TYPEOF_KEYW 281 +#define EXPORT_SYMBOL_KEYW 282 +#define ASM_PHRASE 283 +#define ATTRIBUTE_PHRASE 284 +#define BRACE_PHRASE 285 +#define BRACKET_PHRASE 286 +#define EXPRESSION_PHRASE 287 +#define CHAR 288 +#define DOTS 289 +#define IDENT 290 +#define INT 291 +#define REAL 292 +#define STRING 293 +#define TYPE 294 +#define OTHER 295 +#define FILENAME 296 + + +extern 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 @@ +/* Lexical analysis for genksyms. + Copyright 1996, 1997 Linux International. + + New implementation contributed by Richard Henderson <rth@tamu.edu> + Based on original work by Bjorn Ekwall <bj0rn@blox.se> + + Taken from Linux modutils 2.4.22. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + +%{ + +#include <limits.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> + +#include "genksyms.h" +#include "parse.h" + +/* We've got a two-level lexer here. We let flex do basic tokenization + and then we categorize those basic tokens in the second stage. */ +#define YY_DECL static int yylex1(void) + +%} + +IDENT [A-Za-z_\$][A-Za-z0-9_\$]* + +O_INT 0[0-7]* +D_INT [1-9][0-9]* +X_INT 0[Xx][0-9A-Fa-f]+ +I_SUF [Uu]|[Ll]|[Uu][Ll]|[Ll][Uu] +INT ({O_INT}|{D_INT}|{X_INT}){I_SUF}? + +FRAC ([0-9]*\.[0-9]+)|([0-9]+\.) +EXP [Ee][+-]?[0-9]+ +F_SUF [FfLl] +REAL ({FRAC}{EXP}?{F_SUF}?)|([0-9]+{EXP}{F_SUF}?) + +STRING L?\"([^\\\"]*\\.)*[^\\\"]*\" +CHAR L?\'([^\\\']*\\.)*[^\\\']*\' + +MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>) + +/* Version 2 checksumming does proper tokenization; version 1 wasn't + quite so pedantic. */ +%s V2_TOKENS + +/* We don't do multiple input files. */ +%option noyywrap + +%% + + + /* Keep track of our location in the original source files. */ +^#[ \t]+{INT}[ \t]+\"[^\"\n]+\".*\n return FILENAME; +^#.*\n cur_line++; +\n cur_line++; + + /* Ignore all other whitespace. */ +[ \t\f\v\r]+ ; + + +{STRING} return STRING; +{CHAR} return CHAR; +{IDENT} return IDENT; + + /* The Pedant requires that the other C multi-character tokens be + recognized as tokens. We don't actually use them since we don't + parse expressions, but we do want whitespace to be arranged + around them properly. */ +<V2_TOKENS>{MC_TOKEN} return OTHER; +<V2_TOKENS>{INT} return INT; +<V2_TOKENS>{REAL} return REAL; + +"..." return DOTS; + + /* All other tokens are single characters. */ +. return yytext[0]; + + +%% + +/* Bring in the keyword recognizer. */ + +#include "keywords.c" + + +/* Macros to append to our phrase collection list. */ + +#define _APP(T,L) do { \ + cur_node = next_node; \ + next_node = xmalloc(sizeof(*next_node)); \ + next_node->next = cur_node; \ + cur_node->string = memcpy(xmalloc(L+1), T, L+1); \ + cur_node->tag = SYM_NORMAL; \ + } while (0) + +#define APP _APP(yytext, yyleng) + + +/* The second stage lexer. Here we incorporate knowledge of the state + of the parser to tailor the tokens that are returned. */ + +int +yylex(void) +{ + static enum { + ST_NOTSTARTED, ST_NORMAL, ST_ATTRIBUTE, ST_ASM, ST_BRACKET, ST_BRACE, + ST_EXPRESSION, ST_TABLE_1, ST_TABLE_2, ST_TABLE_3, ST_TABLE_4, + ST_TABLE_5, ST_TABLE_6 + } lexstate = ST_NOTSTARTED; + + static int suppress_type_lookup, dont_want_brace_phrase; + static struct string_list *next_node; + + int token, count = 0; + struct string_list *cur_node; + + if (lexstate == ST_NOTSTARTED) + { + BEGIN(V2_TOKENS); + next_node = xmalloc(sizeof(*next_node)); + next_node->next = NULL; + lexstate = ST_NORMAL; + } + +repeat: + token = yylex1(); + + if (token == 0) + return 0; + else if (token == FILENAME) + { + char *file, *e; + + /* Save the filename and line number for later error messages. */ + + if (cur_filename) + free(cur_filename); + + file = strchr(yytext, '\"')+1; + e = strchr(file, '\"'); + *e = '\0'; + cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1); + cur_line = atoi(yytext+2); + + goto repeat; + } + + switch (lexstate) + { + case ST_NORMAL: + switch (token) + { + case IDENT: + APP; + { + const struct resword *r = is_reserved_word(yytext, yyleng); + if (r) + { + switch (token = r->token) + { + case ATTRIBUTE_KEYW: + lexstate = ST_ATTRIBUTE; + count = 0; + goto repeat; + case ASM_KEYW: + lexstate = ST_ASM; + count = 0; + goto repeat; + + case STRUCT_KEYW: + case UNION_KEYW: + dont_want_brace_phrase = 3; + case ENUM_KEYW: + suppress_type_lookup = 2; + goto fini; + + case EXPORT_SYMBOL_KEYW: + goto fini; + } + } + if (!suppress_type_lookup) + { + struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF); + if (sym && sym->type == SYM_TYPEDEF) + token = TYPE; + } + } + break; + + case '[': + APP; + lexstate = ST_BRACKET; + count = 1; + goto repeat; + + case '{': + APP; + if (dont_want_brace_phrase) + break; + lexstate = ST_BRACE; + count = 1; + goto repeat; + + case '=': case ':': + APP; + lexstate = ST_EXPRESSION; + break; + + case DOTS: + default: + APP; + break; + } + break; + + case ST_ATTRIBUTE: + APP; + switch (token) + { + case '(': + ++count; + goto repeat; + case ')': + if (--count == 0) + { + lexstate = ST_NORMAL; + token = ATTRIBUTE_PHRASE; + break; + } + goto repeat; + default: + goto repeat; + } + break; + + case ST_ASM: + APP; + switch (token) + { + case '(': + ++count; + goto repeat; + case ')': + if (--count == 0) + { + lexstate = ST_NORMAL; + token = ASM_PHRASE; + break; + } + goto repeat; + default: + goto repeat; + } + break; + + case ST_BRACKET: + APP; + switch (token) + { + case '[': + ++count; + goto repeat; + case ']': + if (--count == 0) + { + lexstate = ST_NORMAL; + token = BRACKET_PHRASE; + break; + } + goto repeat; + default: + goto repeat; + } + break; + + case ST_BRACE: + APP; + switch (token) + { + case '{': + ++count; + goto repeat; + case '}': + if (--count == 0) + { + lexstate = ST_NORMAL; + token = BRACE_PHRASE; + break; + } + goto repeat; + default: + goto repeat; + } + break; + + case ST_EXPRESSION: + switch (token) + { + case '(': case '[': case '{': + ++count; + APP; + goto repeat; + case ')': case ']': case '}': + --count; + APP; + goto repeat; + case ',': case ';': + if (count == 0) + { + /* Put back the token we just read so's we can find it again + after registering the expression. */ + unput(token); + + lexstate = ST_NORMAL; + token = EXPRESSION_PHRASE; + break; + } + APP; + goto repeat; + default: + APP; + goto repeat; + } + break; + + case ST_TABLE_1: + goto repeat; + + case ST_TABLE_2: + if (token == IDENT && yyleng == 1 && yytext[0] == 'X') + { + token = EXPORT_SYMBOL_KEYW; + lexstate = ST_TABLE_5; + APP; + break; + } + lexstate = ST_TABLE_6; + /* FALLTHRU */ + + case ST_TABLE_6: + switch (token) + { + case '{': case '[': case '(': + ++count; + break; + case '}': case ']': case ')': + --count; + break; + case ',': + if (count == 0) + lexstate = ST_TABLE_2; + break; + }; + goto repeat; + + case ST_TABLE_3: + goto repeat; + + case ST_TABLE_4: + if (token == ';') + lexstate = ST_NORMAL; + goto repeat; + + case ST_TABLE_5: + switch (token) + { + case ',': + token = ';'; + lexstate = ST_TABLE_2; + APP; + break; + default: + APP; + break; + } + break; + + default: + abort(); + } +fini: + + if (suppress_type_lookup > 0) + --suppress_type_lookup; + if (dont_want_brace_phrase > 0) + --dont_want_brace_phrase; + + yylval = &next_node->next; + + return token; +} 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 @@ + +/* A Bison parser, made from scripts/genksyms/parse.y + by GNU Bison version 1.28 */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define ASM_KEYW 257 +#define ATTRIBUTE_KEYW 258 +#define AUTO_KEYW 259 +#define BOOL_KEYW 260 +#define CHAR_KEYW 261 +#define CONST_KEYW 262 +#define DOUBLE_KEYW 263 +#define ENUM_KEYW 264 +#define EXTERN_KEYW 265 +#define FLOAT_KEYW 266 +#define INLINE_KEYW 267 +#define INT_KEYW 268 +#define LONG_KEYW 269 +#define REGISTER_KEYW 270 +#define RESTRICT_KEYW 271 +#define SHORT_KEYW 272 +#define SIGNED_KEYW 273 +#define STATIC_KEYW 274 +#define STRUCT_KEYW 275 +#define TYPEDEF_KEYW 276 +#define UNION_KEYW 277 +#define UNSIGNED_KEYW 278 +#define VOID_KEYW 279 +#define VOLATILE_KEYW 280 +#define TYPEOF_KEYW 281 +#define EXPORT_SYMBOL_KEYW 282 +#define ASM_PHRASE 283 +#define ATTRIBUTE_PHRASE 284 +#define BRACE_PHRASE 285 +#define BRACKET_PHRASE 286 +#define EXPRESSION_PHRASE 287 +#define CHAR 288 +#define DOTS 289 +#define IDENT 290 +#define INT 291 +#define REAL 292 +#define STRING 293 +#define TYPE 294 +#define OTHER 295 +#define FILENAME 296 + +#line 24 "scripts/genksyms/parse.y" + + +#include <assert.h> +#include <malloc.h> +#include "genksyms.h" + +static int is_typedef; +static int is_extern; +static char *current_name; +static struct string_list *decl_spec; + +static void yyerror(const char *); + +static inline void +remove_node(struct string_list **p) +{ + struct string_list *node = *p; + *p = node->next; + free_node(node); +} + +static inline void +remove_list(struct string_list **pb, struct string_list **pe) +{ + struct string_list *b = *pb, *e = *pe; + *pb = e; + free_list(b, e); +} + +#ifndef YYSTYPE +#define YYSTYPE int +#endif +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif + +#include <stdio.h> + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 172 +#define YYFLAG -32768 +#define YYNTBASE 52 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 96) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 46, + 47, 48, 2, 45, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 51, 43, 2, + 49, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 50, 2, 44, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 5, 6, 9, 10, 14, 16, 18, 20, + 22, 25, 28, 32, 33, 35, 37, 41, 46, 47, + 49, 51, 54, 56, 58, 60, 62, 64, 66, 68, + 70, 72, 77, 80, 83, 86, 90, 94, 98, 101, + 104, 107, 109, 111, 113, 115, 117, 119, 121, 123, + 125, 127, 129, 132, 133, 135, 137, 140, 142, 144, + 146, 148, 151, 153, 155, 160, 165, 168, 172, 176, + 179, 181, 183, 185, 190, 195, 198, 202, 206, 209, + 211, 215, 216, 218, 220, 224, 227, 230, 232, 233, + 235, 237, 242, 247, 250, 254, 258, 262, 263, 265, + 268, 272, 276, 277, 279, 281, 284, 288, 291, 292, + 294, 296, 300, 303, 306, 308, 311, 312, 314, 317, + 318, 320 +}; + +static const short yyrhs[] = { 53, + 0, 52, 53, 0, 0, 54, 55, 0, 0, 22, + 56, 57, 0, 57, 0, 81, 0, 93, 0, 95, + 0, 1, 43, 0, 1, 44, 0, 61, 58, 43, + 0, 0, 59, 0, 60, 0, 59, 45, 60, 0, + 71, 94, 92, 82, 0, 0, 62, 0, 63, 0, + 62, 63, 0, 64, 0, 65, 0, 5, 0, 16, + 0, 20, 0, 11, 0, 13, 0, 66, 0, 70, + 0, 27, 46, 62, 47, 0, 21, 36, 0, 23, + 36, 0, 10, 36, 0, 21, 36, 84, 0, 23, + 36, 84, 0, 10, 36, 31, 0, 10, 31, 0, + 21, 84, 0, 23, 84, 0, 7, 0, 18, 0, + 14, 0, 15, 0, 19, 0, 24, 0, 12, 0, + 9, 0, 25, 0, 6, 0, 40, 0, 48, 68, + 0, 0, 69, 0, 70, 0, 69, 70, 0, 8, + 0, 26, 0, 30, 0, 17, 0, 67, 71, 0, + 72, 0, 36, 0, 72, 46, 75, 47, 0, 72, + 46, 1, 47, 0, 72, 32, 0, 46, 71, 47, + 0, 46, 1, 47, 0, 67, 73, 0, 74, 0, + 36, 0, 40, 0, 74, 46, 75, 47, 0, 74, + 46, 1, 47, 0, 74, 32, 0, 46, 73, 47, + 0, 46, 1, 47, 0, 76, 35, 0, 76, 0, + 77, 45, 35, 0, 0, 77, 0, 78, 0, 77, + 45, 78, 0, 62, 79, 0, 67, 79, 0, 80, + 0, 0, 36, 0, 40, 0, 80, 46, 75, 47, + 0, 80, 46, 1, 47, 0, 80, 32, 0, 46, + 79, 47, 0, 46, 1, 47, 0, 61, 71, 31, + 0, 0, 83, 0, 49, 33, 0, 50, 85, 44, + 0, 50, 1, 44, 0, 0, 86, 0, 87, 0, + 86, 87, 0, 61, 88, 43, 0, 1, 43, 0, + 0, 89, 0, 90, 0, 89, 45, 90, 0, 73, + 92, 0, 36, 91, 0, 91, 0, 51, 33, 0, + 0, 30, 0, 29, 43, 0, 0, 29, 0, 28, + 46, 36, 47, 43, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 101, 103, 106, 109, 112, 114, 115, 116, 117, 118, + 119, 120, 123, 137, 139, 142, 151, 163, 169, 171, + 174, 176, 179, 186, 189, 191, 192, 193, 194, 197, + 199, 200, 204, 206, 208, 212, 219, 226, 235, 236, + 237, 240, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 254, 259, 261, 264, 266, 269, 270, 270, + 271, 278, 280, 283, 293, 295, 297, 299, 301, 307, + 309, 312, 314, 315, 317, 319, 321, 323, 327, 329, + 330, 333, 335, 338, 340, 344, 349, 352, 355, 357, + 365, 369, 371, 373, 375, 377, 381, 390, 392, 396, + 401, 403, 406, 408, 411, 413, 416, 419, 423, 425, + 428, 430, 433, 435, 436, 439, 443, 445, 448, 452, + 454, 457 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","ASM_KEYW", +"ATTRIBUTE_KEYW","AUTO_KEYW","BOOL_KEYW","CHAR_KEYW","CONST_KEYW","DOUBLE_KEYW", +"ENUM_KEYW","EXTERN_KEYW","FLOAT_KEYW","INLINE_KEYW","INT_KEYW","LONG_KEYW", +"REGISTER_KEYW","RESTRICT_KEYW","SHORT_KEYW","SIGNED_KEYW","STATIC_KEYW","STRUCT_KEYW", +"TYPEDEF_KEYW","UNION_KEYW","UNSIGNED_KEYW","VOID_KEYW","VOLATILE_KEYW","TYPEOF_KEYW", +"EXPORT_SYMBOL_KEYW","ASM_PHRASE","ATTRIBUTE_PHRASE","BRACE_PHRASE","BRACKET_PHRASE", +"EXPRESSION_PHRASE","CHAR","DOTS","IDENT","INT","REAL","STRING","TYPE","OTHER", +"FILENAME","';'","'}'","','","'('","')'","'*'","'='","'{'","':'","declaration_seq", +"declaration","@1","declaration1","@2","simple_declaration","init_declarator_list_opt", +"init_declarator_list","init_declarator","decl_specifier_seq_opt","decl_specifier_seq", +"decl_specifier","storage_class_specifier","type_specifier","simple_type_specifier", +"ptr_operator","cvar_qualifier_seq_opt","cvar_qualifier_seq","cvar_qualifier", +"declarator","direct_declarator","nested_declarator","direct_nested_declarator", +"parameter_declaration_clause","parameter_declaration_list_opt","parameter_declaration_list", +"parameter_declaration","m_abstract_declarator","direct_m_abstract_declarator", +"function_definition","initializer_opt","initializer","class_body","member_specification_opt", +"member_specification","member_declaration","member_declarator_list_opt","member_declarator_list", +"member_declarator","member_bitfield_declarator","attribute_opt","asm_definition", +"asm_phrase_opt","export_definition", NULL +}; +#endif + +static const short yyr1[] = { 0, + 52, 52, 54, 53, 56, 55, 55, 55, 55, 55, + 55, 55, 57, 58, 58, 59, 59, 60, 61, 61, + 62, 62, 63, 63, 64, 64, 64, 64, 64, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 67, 68, 68, 69, 69, 70, 70, 70, + 70, 71, 71, 72, 72, 72, 72, 72, 72, 73, + 73, 74, 74, 74, 74, 74, 74, 74, 75, 75, + 75, 76, 76, 77, 77, 78, 79, 79, 80, 80, + 80, 80, 80, 80, 80, 80, 81, 82, 82, 83, + 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, + 89, 89, 90, 90, 90, 91, 92, 92, 93, 94, + 94, 95 +}; + +static const short yyr2[] = { 0, + 1, 2, 0, 2, 0, 3, 1, 1, 1, 1, + 2, 2, 3, 0, 1, 1, 3, 4, 0, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 2, 2, 2, 3, 3, 3, 2, 2, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 0, 1, 1, 2, 1, 1, 1, + 1, 2, 1, 1, 4, 4, 2, 3, 3, 2, + 1, 1, 1, 4, 4, 2, 3, 3, 2, 1, + 3, 0, 1, 1, 3, 2, 2, 1, 0, 1, + 1, 4, 4, 2, 3, 3, 3, 0, 1, 2, + 3, 3, 0, 1, 1, 2, 3, 2, 0, 1, + 1, 3, 2, 2, 1, 2, 0, 1, 2, 0, + 1, 5 +}; + +static const short yydefact[] = { 3, + 3, 1, 0, 2, 0, 25, 51, 42, 58, 49, + 0, 28, 48, 29, 44, 45, 26, 61, 43, 46, + 27, 0, 5, 0, 47, 50, 59, 0, 0, 0, + 60, 52, 4, 7, 14, 20, 21, 23, 24, 30, + 31, 8, 9, 10, 11, 12, 39, 35, 33, 0, + 40, 19, 34, 41, 0, 0, 119, 64, 0, 54, + 0, 15, 16, 0, 120, 63, 22, 38, 36, 0, + 109, 0, 0, 105, 6, 14, 37, 0, 0, 0, + 0, 53, 55, 56, 13, 0, 62, 121, 97, 117, + 67, 0, 108, 102, 72, 73, 0, 0, 0, 117, + 71, 0, 110, 111, 115, 101, 0, 106, 120, 32, + 0, 69, 68, 57, 17, 118, 98, 0, 89, 0, + 80, 83, 84, 114, 0, 72, 0, 116, 70, 113, + 76, 0, 107, 0, 122, 0, 18, 99, 66, 90, + 52, 0, 89, 86, 88, 65, 79, 0, 78, 77, + 0, 0, 112, 100, 0, 91, 0, 87, 94, 0, + 81, 85, 75, 74, 96, 95, 0, 0, 93, 92, + 0, 0 +}; + +static const short yydefgoto[] = { 1, + 2, 3, 33, 52, 34, 61, 62, 63, 71, 36, + 37, 38, 39, 40, 64, 82, 83, 41, 109, 66, + 100, 101, 120, 121, 122, 123, 144, 145, 42, 137, + 138, 51, 72, 73, 74, 102, 103, 104, 105, 117, + 43, 90, 44 +}; + +static const short yypact[] = {-32768, + 15,-32768, 197,-32768, 23,-32768,-32768,-32768,-32768,-32768, + -18,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, -28,-32768, -25,-32768,-32768,-32768, -26, -22, -12, +-32768,-32768,-32768,-32768, 49, 493,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768, 27, -8, 101, +-32768, 493, -8,-32768, 493, 10,-32768,-32768, 11, 9, + 18, 26,-32768, 49, -15, -13,-32768,-32768,-32768, 25, + 24, 48, 149,-32768,-32768, 49,-32768, 414, 39, 40, + 47,-32768, 9,-32768,-32768, 49,-32768,-32768,-32768, 66, +-32768, 241,-32768,-32768, 50,-32768, 5, 65, 42, 66, + 17, 56, 55,-32768,-32768,-32768, 60,-32768, 75,-32768, + 80,-32768,-32768,-32768,-32768,-32768, 81, 82, 370, 85, + 98, 89,-32768,-32768, 88,-32768, 91,-32768,-32768,-32768, +-32768, 284,-32768, 24,-32768, 103,-32768,-32768,-32768,-32768, +-32768, 8, 43,-32768, 30,-32768,-32768, 457,-32768,-32768, + 92, 93,-32768,-32768, 95,-32768, 96,-32768,-32768, 327, +-32768,-32768,-32768,-32768,-32768,-32768, 99, 104,-32768,-32768, + 148,-32768 +}; + +static const short yypgoto[] = {-32768, + 152,-32768,-32768,-32768, 119,-32768,-32768, 94, 0, -55, + -35,-32768,-32768,-32768, -69,-32768,-32768, -56, -30,-32768, + -76,-32768, -122,-32768,-32768, 29, -62,-32768,-32768,-32768, +-32768, -17,-32768,-32768, 105,-32768,-32768, 52, 86, 83, +-32768,-32768,-32768 +}; + + +#define YYLAST 533 + + +static const short yytable[] = { 78, + 67, 99, 35, 84, 65, 125, 54, 49, 155, 152, + 53, 80, 47, 88, 171, 89, 9, 48, 91, 55, + 127, 50, 129, 56, 50, 18, 114, 99, 81, 99, + 57, 69, 92, 87, 27, 77, 119, 168, 31, -89, + 126, 50, 67, 140, 96, 79, 58, 156, 131, 143, + 97, 76, 60, 142, -89, 60, 59, 68, 60, 95, + 85, 159, 132, 96, 99, 45, 46, 93, 94, 97, + 86, 60, 143, 143, 98, 160, 119, 126, 140, 157, + 158, 96, 156, 67, 58, 111, 112, 97, 142, 60, + 60, 106, 119, 113, 59, 116, 60, 128, 133, 134, + 98, 70, 93, 88, 119, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 135, 24, 25, 26, 27, 28, 139, 136, + 31, 146, 147, 148, 149, 154, -19, 150, 163, 164, + 32, 165, 166, -19, -103, 169, -19, 172, -19, 107, + 170, -19, 4, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 75, 24, 25, 26, 27, 28, 162, 108, 31, 115, + 124, 0, 130, 0, -19, 153, 0, 0, 32, 0, + 0, -19, -104, 0, -19, 0, -19, 5, 0, -19, + 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 0, 0, 0, + 0, 0, -19, 0, 0, 0, 32, 0, 0, -19, + 0, 118, -19, 0, -19, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 0, 24, 25, 26, 27, 28, 0, 0, + 31, 0, 0, 0, 0, -82, 0, 0, 0, 0, + 32, 0, 0, 0, 151, 0, 0, -82, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 0, 24, 25, 26, 27, + 28, 0, 0, 31, 0, 0, 0, 0, -82, 0, + 0, 0, 0, 32, 0, 0, 0, 167, 0, 0, + -82, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 0, 24, + 25, 26, 27, 28, 0, 0, 31, 0, 0, 0, + 0, -82, 0, 0, 0, 0, 32, 0, 0, 0, + 0, 0, 0, -82, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 0, 24, 25, 26, 27, 28, 0, 0, 31, + 0, 0, 0, 0, 0, 140, 0, 0, 0, 141, + 0, 0, 0, 0, 0, 142, 0, 60, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 0, 24, 25, 26, 27, + 28, 0, 0, 31, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, + 110, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 0, 24, + 25, 26, 27, 28, 0, 0, 31, 0, 0, 0, + 0, 161, 0, 0, 0, 0, 32, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 0, 24, 25, 26, 27, 28, + 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 32 +}; + +static const short yycheck[] = { 55, + 36, 71, 3, 60, 35, 1, 24, 36, 1, 132, + 36, 1, 31, 29, 0, 31, 8, 36, 32, 46, + 97, 50, 99, 46, 50, 17, 83, 97, 59, 99, + 43, 49, 46, 64, 26, 53, 92, 160, 30, 32, + 36, 50, 78, 36, 40, 36, 36, 40, 32, 119, + 46, 52, 48, 46, 47, 48, 46, 31, 48, 36, + 43, 32, 46, 40, 134, 43, 44, 43, 44, 46, + 45, 48, 142, 143, 51, 46, 132, 36, 36, 142, + 143, 40, 40, 119, 36, 47, 47, 46, 46, 48, + 48, 44, 148, 47, 46, 30, 48, 33, 43, 45, + 51, 1, 43, 29, 160, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 43, 23, 24, 25, 26, 27, 47, 49, + 30, 47, 35, 45, 47, 33, 36, 47, 47, 47, + 40, 47, 47, 43, 44, 47, 46, 0, 48, 1, + 47, 51, 1, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 52, 23, 24, 25, 26, 27, 148, 73, 30, 86, + 95, -1, 100, -1, 36, 134, -1, -1, 40, -1, + -1, 43, 44, -1, 46, -1, 48, 1, -1, 51, + -1, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, -1, -1, -1, + -1, -1, 36, -1, -1, -1, 40, -1, -1, 43, + -1, 1, 46, -1, 48, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, -1, 23, 24, 25, 26, 27, -1, -1, + 30, -1, -1, -1, -1, 35, -1, -1, -1, -1, + 40, -1, -1, -1, 1, -1, -1, 47, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, -1, 23, 24, 25, 26, + 27, -1, -1, 30, -1, -1, -1, -1, 35, -1, + -1, -1, -1, 40, -1, -1, -1, 1, -1, -1, + 47, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, -1, 23, + 24, 25, 26, 27, -1, -1, 30, -1, -1, -1, + -1, 35, -1, -1, -1, -1, 40, -1, -1, -1, + -1, -1, -1, 47, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, -1, 23, 24, 25, 26, 27, -1, -1, 30, + -1, -1, -1, -1, -1, 36, -1, -1, -1, 40, + -1, -1, -1, -1, -1, 46, -1, 48, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, -1, 23, 24, 25, 26, + 27, -1, -1, 30, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 40, -1, -1, -1, -1, -1, -1, + 47, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, -1, 23, + 24, 25, 26, 27, -1, -1, 30, -1, -1, -1, + -1, 35, -1, -1, -1, -1, 40, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, -1, 23, 24, 25, 26, 27, + -1, -1, 30, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 40 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/lib/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include <alloca.h> +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include <malloc.h> +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include <malloc.h> */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 217 "/usr/lib/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 3: +#line 107 "scripts/genksyms/parse.y" +{ is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ; + break;} +case 4: +#line 109 "scripts/genksyms/parse.y" +{ free_list(*yyvsp[0], NULL); *yyvsp[0] = NULL; ; + break;} +case 5: +#line 113 "scripts/genksyms/parse.y" +{ is_typedef = 1; ; + break;} +case 6: +#line 114 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 11: +#line 119 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 12: +#line 120 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 13: +#line 125 "scripts/genksyms/parse.y" +{ if (current_name) { + struct string_list *decl = (*yyvsp[0])->next; + (*yyvsp[0])->next = NULL; + add_symbol(current_name, + is_typedef ? SYM_TYPEDEF : SYM_NORMAL, + decl, is_extern); + current_name = NULL; + } + yyval = yyvsp[0]; + ; + break;} +case 14: +#line 138 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 16: +#line 144 "scripts/genksyms/parse.y" +{ struct string_list *decl = *yyvsp[0]; + *yyvsp[0] = NULL; + add_symbol(current_name, + is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); + current_name = NULL; + yyval = yyvsp[0]; + ; + break;} +case 17: +#line 152 "scripts/genksyms/parse.y" +{ struct string_list *decl = *yyvsp[0]; + *yyvsp[0] = NULL; + free_list(*yyvsp[-1], NULL); + *yyvsp[-1] = decl_spec; + add_symbol(current_name, + is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); + current_name = NULL; + yyval = yyvsp[0]; + ; + break;} +case 18: +#line 165 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1] ? yyvsp[-1] : yyvsp[-2] ? yyvsp[-2] : yyvsp[-3]; ; + break;} +case 19: +#line 170 "scripts/genksyms/parse.y" +{ decl_spec = NULL; ; + break;} +case 21: +#line 175 "scripts/genksyms/parse.y" +{ decl_spec = *yyvsp[0]; ; + break;} +case 22: +#line 176 "scripts/genksyms/parse.y" +{ decl_spec = *yyvsp[0]; ; + break;} +case 23: +#line 181 "scripts/genksyms/parse.y" +{ /* Version 2 checksumming ignores storage class, as that + is really irrelevant to the linkage. */ + remove_node(yyvsp[0]); + yyval = yyvsp[0]; + ; + break;} +case 28: +#line 193 "scripts/genksyms/parse.y" +{ is_extern = 1; yyval = yyvsp[0]; ; + break;} +case 29: +#line 194 "scripts/genksyms/parse.y" +{ is_extern = 0; yyval = yyvsp[0]; ; + break;} +case 33: +#line 205 "scripts/genksyms/parse.y" +{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_STRUCT; yyval = yyvsp[0]; ; + break;} +case 34: +#line 207 "scripts/genksyms/parse.y" +{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_UNION; yyval = yyvsp[0]; ; + break;} +case 35: +#line 209 "scripts/genksyms/parse.y" +{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_ENUM; yyval = yyvsp[0]; ; + break;} +case 36: +#line 213 "scripts/genksyms/parse.y" +{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r; + r = copy_node(i); r->tag = SYM_STRUCT; + r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL; + add_symbol(i->string, SYM_STRUCT, s, is_extern); + yyval = yyvsp[0]; + ; + break;} +case 37: +#line 220 "scripts/genksyms/parse.y" +{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r; + r = copy_node(i); r->tag = SYM_UNION; + r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL; + add_symbol(i->string, SYM_UNION, s, is_extern); + yyval = yyvsp[0]; + ; + break;} +case 38: +#line 227 "scripts/genksyms/parse.y" +{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r; + r = copy_node(i); r->tag = SYM_ENUM; + r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL; + add_symbol(i->string, SYM_ENUM, s, is_extern); + yyval = yyvsp[0]; + ; + break;} +case 39: +#line 235 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 40: +#line 236 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 41: +#line 237 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 52: +#line 251 "scripts/genksyms/parse.y" +{ (*yyvsp[0])->tag = SYM_TYPEDEF; yyval = yyvsp[0]; ; + break;} +case 53: +#line 256 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ; + break;} +case 54: +#line 260 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 57: +#line 266 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 61: +#line 272 "scripts/genksyms/parse.y" +{ /* restrict has no effect in prototypes so ignore it */ + remove_node(yyvsp[0]); + yyval = yyvsp[0]; + ; + break;} +case 62: +#line 279 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 64: +#line 285 "scripts/genksyms/parse.y" +{ if (current_name != NULL) { + error_with_pos("unexpected second declaration name"); + YYERROR; + } else { + current_name = (*yyvsp[0])->string; + yyval = yyvsp[0]; + } + ; + break;} +case 65: +#line 294 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 66: +#line 296 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 67: +#line 298 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 68: +#line 300 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 69: +#line 302 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 70: +#line 308 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 74: +#line 316 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 75: +#line 318 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 76: +#line 320 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 77: +#line 322 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 78: +#line 324 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 79: +#line 328 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 81: +#line 330 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 82: +#line 334 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 85: +#line 341 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 86: +#line 346 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ; + break;} +case 87: +#line 351 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ; + break;} +case 89: +#line 356 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 90: +#line 358 "scripts/genksyms/parse.y" +{ /* For version 2 checksums, we don't want to remember + private parameter names. */ + remove_node(yyvsp[0]); + yyval = yyvsp[0]; + ; + break;} +case 91: +#line 366 "scripts/genksyms/parse.y" +{ remove_node(yyvsp[0]); + yyval = yyvsp[0]; + ; + break;} +case 92: +#line 370 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 93: +#line 372 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 94: +#line 374 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 95: +#line 376 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 96: +#line 378 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 97: +#line 383 "scripts/genksyms/parse.y" +{ struct string_list *decl = *yyvsp[-1]; + *yyvsp[-1] = NULL; + add_symbol(current_name, SYM_NORMAL, decl, is_extern); + yyval = yyvsp[0]; + ; + break;} +case 98: +#line 391 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 100: +#line 398 "scripts/genksyms/parse.y" +{ remove_list(yyvsp[0], &(*yyvsp[-1])->next); yyval = yyvsp[0]; ; + break;} +case 101: +#line 402 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 102: +#line 403 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 103: +#line 407 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 106: +#line 413 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 107: +#line 418 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 108: +#line 420 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 109: +#line 424 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 112: +#line 430 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 113: +#line 434 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ; + break;} +case 114: +#line 435 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 116: +#line 440 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 117: +#line 444 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 119: +#line 449 "scripts/genksyms/parse.y" +{ yyval = yyvsp[0]; ; + break;} +case 120: +#line 453 "scripts/genksyms/parse.y" +{ yyval = NULL; ; + break;} +case 122: +#line 459 "scripts/genksyms/parse.y" +{ export_symbol((*yyvsp[-2])->string); yyval = yyvsp[0]; ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/lib/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 463 "scripts/genksyms/parse.y" + + +static void +yyerror(const char *e) +{ + error_with_pos("%s", e); +} 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 @@ +#ifndef YYSTYPE +#define YYSTYPE int +#endif +#define ASM_KEYW 257 +#define ATTRIBUTE_KEYW 258 +#define AUTO_KEYW 259 +#define BOOL_KEYW 260 +#define CHAR_KEYW 261 +#define CONST_KEYW 262 +#define DOUBLE_KEYW 263 +#define ENUM_KEYW 264 +#define EXTERN_KEYW 265 +#define FLOAT_KEYW 266 +#define INLINE_KEYW 267 +#define INT_KEYW 268 +#define LONG_KEYW 269 +#define REGISTER_KEYW 270 +#define RESTRICT_KEYW 271 +#define SHORT_KEYW 272 +#define SIGNED_KEYW 273 +#define STATIC_KEYW 274 +#define STRUCT_KEYW 275 +#define TYPEDEF_KEYW 276 +#define UNION_KEYW 277 +#define UNSIGNED_KEYW 278 +#define VOID_KEYW 279 +#define VOLATILE_KEYW 280 +#define TYPEOF_KEYW 281 +#define EXPORT_SYMBOL_KEYW 282 +#define ASM_PHRASE 283 +#define ATTRIBUTE_PHRASE 284 +#define BRACE_PHRASE 285 +#define BRACKET_PHRASE 286 +#define EXPRESSION_PHRASE 287 +#define CHAR 288 +#define DOTS 289 +#define IDENT 290 +#define INT 291 +#define REAL 292 +#define STRING 293 +#define TYPE 294 +#define OTHER 295 +#define FILENAME 296 + + +extern 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 @@ +/* C global declaration parser for genksyms. + Copyright 1996, 1997 Linux International. + + New implementation contributed by Richard Henderson <rth@tamu.edu> + Based on original work by Bjorn Ekwall <bj0rn@blox.se> + + This file is part of the Linux modutils. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + +%{ + +#include <assert.h> +#include <malloc.h> +#include "genksyms.h" + +static int is_typedef; +static int is_extern; +static char *current_name; +static struct string_list *decl_spec; + +static void yyerror(const char *); + +static inline void +remove_node(struct string_list **p) +{ + struct string_list *node = *p; + *p = node->next; + free_node(node); +} + +static inline void +remove_list(struct string_list **pb, struct string_list **pe) +{ + struct string_list *b = *pb, *e = *pe; + *pb = e; + free_list(b, e); +} + +%} + +%token ASM_KEYW +%token ATTRIBUTE_KEYW +%token AUTO_KEYW +%token BOOL_KEYW +%token CHAR_KEYW +%token CONST_KEYW +%token DOUBLE_KEYW +%token ENUM_KEYW +%token EXTERN_KEYW +%token FLOAT_KEYW +%token INLINE_KEYW +%token INT_KEYW +%token LONG_KEYW +%token REGISTER_KEYW +%token RESTRICT_KEYW +%token SHORT_KEYW +%token SIGNED_KEYW +%token STATIC_KEYW +%token STRUCT_KEYW +%token TYPEDEF_KEYW +%token UNION_KEYW +%token UNSIGNED_KEYW +%token VOID_KEYW +%token VOLATILE_KEYW +%token TYPEOF_KEYW + +%token EXPORT_SYMBOL_KEYW + +%token ASM_PHRASE +%token ATTRIBUTE_PHRASE +%token BRACE_PHRASE +%token BRACKET_PHRASE +%token EXPRESSION_PHRASE + +%token CHAR +%token DOTS +%token IDENT +%token INT +%token REAL +%token STRING +%token TYPE +%token OTHER +%token FILENAME + +%% + +declaration_seq: + declaration + | declaration_seq declaration + ; + +declaration: + { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; } + declaration1 + { free_list(*$2, NULL); *$2 = NULL; } + ; + +declaration1: + TYPEDEF_KEYW { is_typedef = 1; } simple_declaration + { $$ = $3; } + | simple_declaration + | function_definition + | asm_definition + | export_definition + | error ';' { $$ = $2; } + | error '}' { $$ = $2; } + ; + +simple_declaration: + decl_specifier_seq_opt init_declarator_list_opt ';' + { if (current_name) { + struct string_list *decl = (*$3)->next; + (*$3)->next = NULL; + add_symbol(current_name, + is_typedef ? SYM_TYPEDEF : SYM_NORMAL, + decl, is_extern); + current_name = NULL; + } + $$ = $3; + } + ; + +init_declarator_list_opt: + /* empty */ { $$ = NULL; } + | init_declarator_list + ; + +init_declarator_list: + init_declarator + { struct string_list *decl = *$1; + *$1 = NULL; + add_symbol(current_name, + is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); + current_name = NULL; + $$ = $1; + } + | init_declarator_list ',' init_declarator + { struct string_list *decl = *$3; + *$3 = NULL; + free_list(*$2, NULL); + *$2 = decl_spec; + add_symbol(current_name, + is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); + current_name = NULL; + $$ = $3; + } + ; + +init_declarator: + declarator asm_phrase_opt attribute_opt initializer_opt + { $$ = $4 ? $4 : $3 ? $3 : $2 ? $2 : $1; } + ; + +/* Hang on to the specifiers so that we can reuse them. */ +decl_specifier_seq_opt: + /* empty */ { decl_spec = NULL; } + | decl_specifier_seq + ; + +decl_specifier_seq: + decl_specifier { decl_spec = *$1; } + | decl_specifier_seq decl_specifier { decl_spec = *$2; } + ; + +decl_specifier: + storage_class_specifier + { /* Version 2 checksumming ignores storage class, as that + is really irrelevant to the linkage. */ + remove_node($1); + $$ = $1; + } + | type_specifier + ; + +storage_class_specifier: + AUTO_KEYW + | REGISTER_KEYW + | STATIC_KEYW + | EXTERN_KEYW { is_extern = 1; $$ = $1; } + | INLINE_KEYW { is_extern = 0; $$ = $1; } + ; + +type_specifier: + simple_type_specifier + | cvar_qualifier + | TYPEOF_KEYW '(' decl_specifier_seq ')' + + /* References to s/u/e's defined elsewhere. Rearrange things + so that it is easier to expand the definition fully later. */ + | STRUCT_KEYW IDENT + { remove_node($1); (*$2)->tag = SYM_STRUCT; $$ = $2; } + | UNION_KEYW IDENT + { remove_node($1); (*$2)->tag = SYM_UNION; $$ = $2; } + | ENUM_KEYW IDENT + { remove_node($1); (*$2)->tag = SYM_ENUM; $$ = $2; } + + /* Full definitions of an s/u/e. Record it. */ + | STRUCT_KEYW IDENT class_body + { struct string_list *s = *$3, *i = *$2, *r; + r = copy_node(i); r->tag = SYM_STRUCT; + r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; + add_symbol(i->string, SYM_STRUCT, s, is_extern); + $$ = $3; + } + | UNION_KEYW IDENT class_body + { struct string_list *s = *$3, *i = *$2, *r; + r = copy_node(i); r->tag = SYM_UNION; + r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; + add_symbol(i->string, SYM_UNION, s, is_extern); + $$ = $3; + } + | ENUM_KEYW IDENT BRACE_PHRASE + { struct string_list *s = *$3, *i = *$2, *r; + r = copy_node(i); r->tag = SYM_ENUM; + r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; + add_symbol(i->string, SYM_ENUM, s, is_extern); + $$ = $3; + } + + /* Anonymous s/u/e definitions. Nothing needs doing. */ + | ENUM_KEYW BRACE_PHRASE { $$ = $2; } + | STRUCT_KEYW class_body { $$ = $2; } + | UNION_KEYW class_body { $$ = $2; } + ; + +simple_type_specifier: + CHAR_KEYW + | SHORT_KEYW + | INT_KEYW + | LONG_KEYW + | SIGNED_KEYW + | UNSIGNED_KEYW + | FLOAT_KEYW + | DOUBLE_KEYW + | VOID_KEYW + | BOOL_KEYW + | TYPE { (*$1)->tag = SYM_TYPEDEF; $$ = $1; } + ; + +ptr_operator: + '*' cvar_qualifier_seq_opt + { $$ = $2 ? $2 : $1; } + ; + +cvar_qualifier_seq_opt: + /* empty */ { $$ = NULL; } + | cvar_qualifier_seq + ; + +cvar_qualifier_seq: + cvar_qualifier + | cvar_qualifier_seq cvar_qualifier { $$ = $2; } + ; + +cvar_qualifier: + CONST_KEYW | VOLATILE_KEYW | ATTRIBUTE_PHRASE + | RESTRICT_KEYW + { /* restrict has no effect in prototypes so ignore it */ + remove_node($1); + $$ = $1; + } + ; + +declarator: + ptr_operator declarator { $$ = $2; } + | direct_declarator + ; + +direct_declarator: + IDENT + { if (current_name != NULL) { + error_with_pos("unexpected second declaration name"); + YYERROR; + } else { + current_name = (*$1)->string; + $$ = $1; + } + } + | direct_declarator '(' parameter_declaration_clause ')' + { $$ = $4; } + | direct_declarator '(' error ')' + { $$ = $4; } + | direct_declarator BRACKET_PHRASE + { $$ = $2; } + | '(' declarator ')' + { $$ = $3; } + | '(' error ')' + { $$ = $3; } + ; + +/* Nested declarators differ from regular declarators in that they do + not record the symbols they find in the global symbol table. */ +nested_declarator: + ptr_operator nested_declarator { $$ = $2; } + | direct_nested_declarator + ; + +direct_nested_declarator: + IDENT + | TYPE + | direct_nested_declarator '(' parameter_declaration_clause ')' + { $$ = $4; } + | direct_nested_declarator '(' error ')' + { $$ = $4; } + | direct_nested_declarator BRACKET_PHRASE + { $$ = $2; } + | '(' nested_declarator ')' + { $$ = $3; } + | '(' error ')' + { $$ = $3; } + ; + +parameter_declaration_clause: + parameter_declaration_list_opt DOTS { $$ = $2; } + | parameter_declaration_list_opt + | parameter_declaration_list ',' DOTS { $$ = $3; } + ; + +parameter_declaration_list_opt: + /* empty */ { $$ = NULL; } + | parameter_declaration_list + ; + +parameter_declaration_list: + parameter_declaration + | parameter_declaration_list ',' parameter_declaration + { $$ = $3; } + ; + +parameter_declaration: + decl_specifier_seq m_abstract_declarator + { $$ = $2 ? $2 : $1; } + ; + +m_abstract_declarator: + ptr_operator m_abstract_declarator + { $$ = $2 ? $2 : $1; } + | direct_m_abstract_declarator + ; + +direct_m_abstract_declarator: + /* empty */ { $$ = NULL; } + | IDENT + { /* For version 2 checksums, we don't want to remember + private parameter names. */ + remove_node($1); + $$ = $1; + } + /* This wasn't really a typedef name but an identifier that + shadows one. */ + | TYPE + { remove_node($1); + $$ = $1; + } + | direct_m_abstract_declarator '(' parameter_declaration_clause ')' + { $$ = $4; } + | direct_m_abstract_declarator '(' error ')' + { $$ = $4; } + | direct_m_abstract_declarator BRACKET_PHRASE + { $$ = $2; } + | '(' m_abstract_declarator ')' + { $$ = $3; } + | '(' error ')' + { $$ = $3; } + ; + +function_definition: + decl_specifier_seq_opt declarator BRACE_PHRASE + { struct string_list *decl = *$2; + *$2 = NULL; + add_symbol(current_name, SYM_NORMAL, decl, is_extern); + $$ = $3; + } + ; + +initializer_opt: + /* empty */ { $$ = NULL; } + | initializer + ; + +/* We never care about the contents of an initializer. */ +initializer: + '=' EXPRESSION_PHRASE + { remove_list($2, &(*$1)->next); $$ = $2; } + ; + +class_body: + '{' member_specification_opt '}' { $$ = $3; } + | '{' error '}' { $$ = $3; } + ; + +member_specification_opt: + /* empty */ { $$ = NULL; } + | member_specification + ; + +member_specification: + member_declaration + | member_specification member_declaration { $$ = $2; } + ; + +member_declaration: + decl_specifier_seq_opt member_declarator_list_opt ';' + { $$ = $3; } + | error ';' + { $$ = $2; } + ; + +member_declarator_list_opt: + /* empty */ { $$ = NULL; } + | member_declarator_list + ; + +member_declarator_list: + member_declarator + | member_declarator_list ',' member_declarator { $$ = $3; } + ; + +member_declarator: + nested_declarator attribute_opt { $$ = $2 ? $2 : $1; } + | IDENT member_bitfield_declarator { $$ = $2; } + | member_bitfield_declarator + ; + +member_bitfield_declarator: + ':' EXPRESSION_PHRASE { $$ = $2; } + ; + +attribute_opt: + /* empty */ { $$ = NULL; } + | ATTRIBUTE_PHRASE + ; + +asm_definition: + ASM_PHRASE ';' { $$ = $2; } + ; + +asm_phrase_opt: + /* empty */ { $$ = NULL; } + | ASM_PHRASE + ; + +export_definition: + EXPORT_SYMBOL_KEYW '(' IDENT ')' ';' + { export_symbol((*$3)->string); $$ = $5; } + ; + + +%% + +static void +yyerror(const char *e) +{ + error_with_pos("%s", e); +} |