Commit 46bd1da6 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: [PATCH] put genksyms in scripts dir

This puts genksyms into scripts/genksyms/.

genksyms used to be maintained externally, though the only possible user
was the kernel build. Moving it into the kernel sources makes it easier to
keep it uptodate, like for example updating it to generate linker scripts
directly instead of postprocessing the generated header file fragments 
with sed, as we do currently.

Also, genksyms does not handle __typeof__, which needs to be fixed since
some of the exported symbol in the kernel are defined using __typeof__. 

(Rusty Russell/me)
parent 8e19dec4
......@@ -159,7 +159,7 @@ STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
AWK = awk
GENKSYMS = /sbin/genksyms
GENKSYMS = scripts/genksyms/genksyms
DEPMOD = /sbin/depmod
KALLSYMS = scripts/kallsyms
PERL = perl
......
......@@ -14,11 +14,13 @@ build-targets := $(host-progs) empty.o
modpost-objs := modpost.o file2alias.o
subdir-$(CONFIG_MODVERSIONS) += genksyms
# Let clean descend into subdirs
subdir- := lxdialog kconfig
subdir- += lxdialog kconfig
# fixdep is needed to compile other host programs
$(addprefix $(obj)/,$(filter-out fixdep,$(build-targets))): $(obj)/fixdep
$(addprefix $(obj)/,$(filter-out fixdep,$(build-targets)) $(subdir-y)): $(obj)/fixdep
# dependencies on generated files need to be listed explicitly
......
host-progs := genksyms
build-targets := $(host-progs)
genksyms-objs := genksyms.o parse.o lex.o
HOSTCFLAGS_parse.o := -Wno-uninitialized
# dependencies on generated files need to be listed explicitly
$(obj)/lex.o: $(obj)/parse.h $(obj)/keywords.c
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 += $(obj)/keywords.c $(obj)/lex.c $(obj)/parse.c $(obj)/parse.h
/* 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. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <stdarg.h>
#include <getopt.h>
#include "genksyms.h"
/*----------------------------------------------------------------------*/
#define HASH_BUCKETS 4099
static struct symbol *symtab[HASH_BUCKETS];
FILE *outfile, *debugfile;
int cur_line = 1;
char *cur_filename, *output_directory;
int flag_debug, flag_dump_defs, flag_warnings;
int checksum_version = 1, kernel_version = version(2,0,0);
static int errors;
static int nsyms;
static struct symbol *expansion_trail;
static const char *crc_prefix = "";
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 (checksum_version == 1)
crc = expand_and_crc_list(subsym->defn, crc);
else 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);
if (checksum_version > 1)
{
fprintf(outfile, "#define __ver_%s\t%s%08lx\n", name,
crc_prefix, crc);
fprintf(outfile, "#define %s\t_set_ver(%s)\n", name, name);
}
else
{
fprintf(outfile, "#define %s\t_set_ver(%s, %s%08lx)\n", name, name,
crc_prefix, crc);
}
}
}
/*----------------------------------------------------------------------*/
static int
parse_kernel_version(char * p)
{
int a, b, c;
a = strtoul(p, &p, 10);
if (*p != '.')
return -1;
b = strtoul(p+1, &p, 10);
if (*p != '.')
return -1;
c = strtoul(p+1, &p, 10);
if (*p != '\0')
return -1;
kernel_version = a << 16 | b << 8 | c;
return 0;
}
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] [-k kernel_version] [-p prefix] > .../linux/module/*.ver\n"
"\n"
" -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"
" -k ver\n"
" --kernel ver Set the kernel version for which we are compiling\n"
" -p string\n"
" --prefix string Set a mangling prefix for all symbols\n"
, stderr);
}
int
main(int argc, char **argv)
{
int o;
struct option long_opts[] = {
{"debug", 0, 0, 'd'},
{"warnings", 0, 0, 'w'},
{"quiet", 0, 0, 'q'},
{"dump", 0, 0, 'D'},
{"kernel", 1, 0, 'k'},
{"prefix", 1, 0, 'p'},
{"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)
switch (o)
{
case 'd':
flag_debug++;
break;
case 'w':
flag_warnings = 1;
break;
case 'q':
flag_warnings = 0;
break;
case 'V':
fputs("genksyms version " MODUTILS_VERSION "\n", stderr);
break;
case 'D':
flag_dump_defs = 1;
break;
case 'k':
if (parse_kernel_version(optarg)) {
fprintf( stderr, "unrecognised kernel version : %s\n", optarg);
return -1;
}
break;
case 'p':
crc_prefix = optarg;
break;
case 'h':
genksyms_usage();
return 0;
default:
genksyms_usage();
return 1;
}
if (kernel_version >= version(2,1,18))
{
if (optind != argc) {
genksyms_usage();
return 1;
}
/* For newer kernels, eliminate some irrelevant constructs. */
checksum_version = 2;
outfile = stdout;
}
else
{
if (optind+1 != argc) {
genksyms_usage();
return 1;
}
output_directory = argv[optind];
}
{
extern int yydebug;
extern int yy_flex_debug;
yydebug = (flag_debug > 1);
yy_flex_debug = (flag_debug > 2);
debugfile = stderr;
/* setlinebuf(debugfile); */
}
yyparse();
if (checksum_version == 1)
{
fputs("#endif\n#endif\n", outfile);
}
if (flag_debug)
{
fprintf(debugfile, "Hash table occupancy %d/%d = %g\n",
nsyms, HASH_BUCKETS, (double)nsyms / (double)HASH_BUCKETS);
}
return errors != 0;
}
/* 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>
#include <assert.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); assert(__ptr || size == 0); __ptr; })
#define xstrdup(str) ({ char *__str = strdup(str); assert(__str); __str; })
#endif /* genksyms.h */
/* 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 = 101, 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[] =
{
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 5,
105, 105, 105, 105, 105, 105, 0, 105, 105, 105,
0, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 0, 105, 0, 105, 20,
25, 0, 35, 30, 105, 20, 105, 105, 40, 30,
30, 0, 0, 105, 0, 0, 0, 15, 5, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105
};
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 = 39,
MIN_WORD_LENGTH = 3,
MAX_WORD_LENGTH = 17,
MIN_HASH_VALUE = 4,
MAX_HASH_VALUE = 104
};
static const struct resword wordlist[] =
{
{""}, {""}, {""}, {""},
{"auto", AUTO_KEYW},
{"short", SHORT_KEYW},
{"struct", STRUCT_KEYW},
{"__asm__", ASM_KEYW},
{"restrict", RESTRICT_KEYW},
{"_restrict", RESTRICT_KEYW},
{"__signed__", SIGNED_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},
{""},
{"static", STATIC_KEYW},
{"__const", CONST_KEYW},
{"__inline", INLINE_KEYW},
{"__const__", CONST_KEYW},
{"__inline__", INLINE_KEYW},
{""}, {""},
{"__signed", SIGNED_KEYW},
{""},
{"__asm", ASM_KEYW},
{"extern", EXTERN_KEYW},
{""},
{"register", REGISTER_KEYW},
{""},
{"float", FLOAT_KEYW},
{""},
{"typedef", TYPEDEF_KEYW},
{""}, {""},
{"_Bool", BOOL_KEYW},
{"double", DOUBLE_KEYW},
{""},
{"unsigned", UNSIGNED_KEYW},
{"enum", ENUM_KEYW},
{""}, {""}, {""},
{"volatile", VOLATILE_KEYW},
{"void", VOID_KEYW},
{"const", CONST_KEYW},
{""}, {""}, {""}, {""}, {""},
{"signed", SIGNED_KEYW},
{""},
{"asm", ASM_KEYW},
{""}, {""},
{"inline", INLINE_KEYW},
{""}, {""}, {""},
{"union", UNION_KEYW},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
{"long", LONG_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;
}
%{
%}
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
#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, 12,
12, 7, 7, 12, 12, 12, 12, 12, 9, 9,
12, 12, 12, 4, 0, 5, 0, 0, 6, 0,
0, 7, 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, 1, 7, 8, 9, 1,
1, 7, 10, 1, 11, 12, 7, 13, 14, 14,
14, 14, 14, 14, 14, 15, 15, 1, 1, 16,
17, 18, 1, 1, 19, 19, 19, 19, 20, 21,
22, 22, 22, 22, 22, 23, 22, 22, 22, 22,
22, 22, 22, 22, 24, 22, 22, 25, 22, 22,
1, 26, 1, 7, 22, 1, 19, 19, 19, 19,
20, 21, 22, 22, 22, 22, 22, 27, 22, 22,
22, 22, 22, 22, 22, 22, 24, 22, 22, 25,
22, 22, 1, 28, 1, 7, 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, 1, 1, 1, 3,
3, 4, 5, 5, 5, 1, 1, 1, 6, 7,
6, 8, 8, 8, 8, 1, 8, 1
} ;
static yyconst short int yy_base[88] =
{ 0,
0, 166, 22, 152, 151, 282, 39, 282, 26, 33,
138, 0, 39, 43, 124, 39, 36, 48, 52, 55,
41, 56, 54, 47, 73, 282, 0, 72, 282, 0,
116, 0, 78, 75, 122, 103, 282, 282, 106, 0,
97, 73, 76, 91, 65, 0, 0, 84, 81, 282,
132, 98, 84, 282, 117, 147, 282, 73, 134, 89,
100, 140, 172, 139, 134, 181, 282, 135, 106, 142,
168, 88, 52, 282, 282, 208, 216, 220, 228, 236,
244, 249, 254, 255, 260, 265, 273
} ;
static yyconst short int yy_def[88] =
{ 0,
75, 1, 1, 3, 75, 75, 75, 75, 76, 77,
75, 78, 78, 79, 75, 75, 75, 75, 75, 19,
75, 75, 75, 75, 76, 75, 80, 77, 75, 81,
75, 78, 76, 77, 79, 79, 75, 75, 75, 39,
19, 82, 83, 75, 75, 84, 20, 76, 77, 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[311] =
{ 0,
6, 7, 8, 7, 9, 6, 6, 6, 10, 6,
6, 11, 6, 6, 6, 6, 6, 6, 12, 12,
12, 12, 13, 12, 12, 6, 12, 6, 15, 16,
26, 15, 17, 18, 19, 20, 20, 21, 15, 22,
24, 29, 24, 33, 36, 37, 38, 34, 24, 23,
24, 27, 38, 38, 74, 38, 38, 38, 30, 31,
39, 39, 39, 40, 41, 41, 42, 47, 47, 47,
38, 43, 38, 38, 44, 45, 46, 26, 44, 75,
29, 38, 26, 29, 40, 55, 55, 57, 26, 29,
74, 57, 43, 65, 65, 44, 45, 30, 27, 44,
30, 59, 37, 27, 36, 37, 30, 59, 37, 27,
64, 64, 64, 35, 57, 51, 52, 52, 39, 39,
39, 75, 35, 69, 37, 53, 54, 50, 54, 56,
56, 56, 54, 59, 37, 59, 37, 37, 68, 35,
38, 59, 37, 59, 60, 60, 66, 66, 66, 31,
75, 64, 64, 64, 61, 62, 63, 14, 61, 56,
56, 56, 69, 35, 61, 62, 69, 67, 61, 67,
37, 14, 72, 67, 37, 75, 75, 75, 75, 75,
75, 75, 75, 75, 70, 70, 70, 75, 75, 75,
70, 70, 70, 66, 66, 66, 75, 75, 75, 75,
75, 54, 75, 54, 75, 75, 75, 54, 25, 25,
25, 25, 25, 25, 25, 25, 28, 28, 28, 28,
28, 28, 28, 28, 32, 32, 32, 32, 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[311] =
{ 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, 10, 7, 13, 14, 14, 16, 13, 24, 3,
24, 9, 17, 17, 73, 16, 21, 21, 10, 18,
18, 18, 18, 19, 19, 19, 19, 20, 20, 20,
23, 19, 22, 22, 19, 19, 19, 25, 19, 20,
28, 23, 33, 34, 42, 43, 43, 45, 48, 49,
72, 45, 42, 53, 53, 58, 58, 28, 25, 58,
34, 61, 61, 33, 36, 36, 49, 69, 69, 48,
52, 52, 52, 60, 44, 36, 36, 36, 39, 39,
39, 41, 52, 61, 35, 39, 39, 31, 39, 55,
55, 55, 39, 51, 51, 59, 59, 68, 59, 68,
15, 62, 62, 70, 51, 51, 65, 65, 65, 11,
5, 64, 64, 64, 51, 51, 51, 4, 51, 56,
56, 56, 62, 64, 70, 70, 62, 56, 70, 56,
71, 2, 71, 56, 63, 0, 0, 0, 0, 0,
0, 0, 0, 0, 63, 63, 63, 0, 0, 0,
63, 63, 63, 66, 66, 66, 0, 0, 0, 0,
0, 66, 0, 66, 0, 0, 0, 66, 76, 76,
76, 76, 76, 76, 76, 76, 77, 77, 77, 77,
77, 77, 77, 77, 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,
92, 95
} ;
/* 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>
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. */
#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 511 "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 670 "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] != 282 );
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
/* Version 1 checksums didn't recognize ellipsis as a token, but we
need it for proper parsing. We'll take care of backward compatibility
by altering the text of the token in the second stage lexer. */
case 11:
YY_RULE_SETUP
#line 92 "scripts/genksyms/lex.l"
return DOTS;
YY_BREAK
/* All other tokens are single characters. */
case 12:
YY_RULE_SETUP
#line 95 "scripts/genksyms/lex.l"
return yytext[0];
YY_BREAK
case 13:
YY_RULE_SETUP
#line 98 "scripts/genksyms/lex.l"
ECHO;
YY_BREAK
#line 843 "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 98 "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)
{
if (checksum_version > 1)
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);
/* Linux kernels 2.1.18 and above (roughly) get to ignore the
hackery below. */
if (checksum_version == 1)
{
static const char symtab_begin[] = "linux/symtab_begin.h";
static const char symtab_end[] = "linux/symtab_end.h";
/* When building 2.0 kernels, we are only given the output directory
and we're supposed to deduce the output filename from the cpp
output. */
if (outfile == NULL)
{
char buffer[PATH_MAX], *dot, *p, *q, *f;
dot = strrchr(file, '.');
f = strrchr(file, '/');
if (dot) *dot = '\0';
f = (f ? f+1 : file);
snprintf(buffer, sizeof(buffer), "%s/%s.ver", output_directory, f);
if ((outfile = fopen(buffer, "w")) == NULL)
{
perror(buffer);
exit(1);
}
fputs("/* This file is generated by genksyms DO NOT EDIT! */\n"
"#if (defined(CONFIG_MODVERSIONS) || defined(MODVERSIONS))"
" && !defined(__GENKSYMS__)\n", outfile);
q = buffer;
*q++ = '_';
for (p = f; *p ; ++p, ++q)
*q = (*p == '.' ? '_' : toupper(*p));
memcpy(q, "_VER_", 6);
fprintf(outfile, "#ifndef %s\n", buffer);
fprintf(outfile, "#define %s\n", buffer);
if (dot) *dot = '.';
}
/* For 2.0 kernels, symbol tables are constructed in big initialized
arrays that begin by including <linux/symtab_begin.h> and end by
including <linux/symtab_end.h>. We're going to transmute this
little bit o' nastiness into something that, from the perspective
of the grammar, resembles the 2.1 scheme in the following
fashion:
When we see a file name with a suffix matching symtab_begin we
should be in ST_EXPRESSION, having already seen the "= {" bits.
We get the grammar back to top-level in two stages, by returning
EXPRESSION_PHRASE then ';' as we move through ST_TABLE_1 to
ST_TABLE_2 eating the tokens we find that were contained in
symtab_begin.h. The body of the work is done in ST_TABLE_{2,5,6}
by transmuting X to EXPORT_SYMBOL and ',' to ';'. We return
to normal mode when we see a file name with a suffix matching
symtab_end.h.
This is not particularly pretty, but it is better than either
truely parsing expressions or some other bit o hackery to always
recognize and record "X" tokens for later perusal. */
if (e-file > sizeof(symtab_begin)
&& strcmp(e-sizeof(symtab_begin)+1, symtab_begin) == 0)
{
if (lexstate != ST_TABLE_1)
{
lexstate = ST_TABLE_1;
return EXPRESSION_PHRASE;
}
}
else if (e-file > sizeof(symtab_end)
&& strcmp(e-sizeof(symtab_end)+1, symtab_end) == 0)
lexstate = ST_TABLE_3;
else if (lexstate == ST_TABLE_1)
{
lexstate = ST_TABLE_2;
return ';';
}
else if (lexstate == ST_TABLE_3)
lexstate = ST_TABLE_4;
}
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:
if (checksum_version > 1)
goto fini;
else
token = IDENT;
}
}
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:
if (checksum_version == 1)
{
_APP(". . .", 5);
break;
}
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 EXPORT_SYMBOL_KEYW 281
#define ASM_PHRASE 282
#define ATTRIBUTE_PHRASE 283
#define BRACE_PHRASE 284
#define BRACKET_PHRASE 285
#define EXPRESSION_PHRASE 286
#define CHAR 287
#define DOTS 288
#define IDENT 289
#define INT 290
#define REAL 291
#define STRING 292
#define TYPE 293
#define OTHER 294
#define FILENAME 295
extern YYSTYPE yylval;
/* 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>
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 <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;
/* Version 1 checksums didn't recognize ellipsis as a token, but we
need it for proper parsing. We'll take care of backward compatibility
by altering the text of the token in the second stage lexer. */
"..." 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)
{
if (checksum_version > 1)
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);
/* Linux kernels 2.1.18 and above (roughly) get to ignore the
hackery below. */
if (checksum_version == 1)
{
static const char symtab_begin[] = "linux/symtab_begin.h";
static const char symtab_end[] = "linux/symtab_end.h";
/* When building 2.0 kernels, we are only given the output directory
and we're supposed to deduce the output filename from the cpp
output. */
if (outfile == NULL)
{
char buffer[PATH_MAX], *dot, *p, *q, *f;
dot = strrchr(file, '.');
f = strrchr(file, '/');
if (dot) *dot = '\0';
f = (f ? f+1 : file);
snprintf(buffer, sizeof(buffer), "%s/%s.ver", output_directory, f);
if ((outfile = fopen(buffer, "w")) == NULL)
{
perror(buffer);
exit(1);
}
fputs("/* This file is generated by genksyms DO NOT EDIT! */\n"
"#if (defined(CONFIG_MODVERSIONS) || defined(MODVERSIONS))"
" && !defined(__GENKSYMS__)\n", outfile);
q = buffer;
*q++ = '_';
for (p = f; *p ; ++p, ++q)
*q = (*p == '.' ? '_' : toupper(*p));
memcpy(q, "_VER_", 6);
fprintf(outfile, "#ifndef %s\n", buffer);
fprintf(outfile, "#define %s\n", buffer);
if (dot) *dot = '.';
}
/* For 2.0 kernels, symbol tables are constructed in big initialized
arrays that begin by including <linux/symtab_begin.h> and end by
including <linux/symtab_end.h>. We're going to transmute this
little bit o' nastiness into something that, from the perspective
of the grammar, resembles the 2.1 scheme in the following
fashion:
When we see a file name with a suffix matching symtab_begin we
should be in ST_EXPRESSION, having already seen the "= {" bits.
We get the grammar back to top-level in two stages, by returning
EXPRESSION_PHRASE then ';' as we move through ST_TABLE_1 to
ST_TABLE_2 eating the tokens we find that were contained in
symtab_begin.h. The body of the work is done in ST_TABLE_{2,5,6}
by transmuting X to EXPORT_SYMBOL and ',' to ';'. We return
to normal mode when we see a file name with a suffix matching
symtab_end.h.
This is not particularly pretty, but it is better than either
truely parsing expressions or some other bit o hackery to always
recognize and record "X" tokens for later perusal. */
if (e-file > sizeof(symtab_begin)
&& strcmp(e-sizeof(symtab_begin)+1, symtab_begin) == 0)
{
if (lexstate != ST_TABLE_1)
{
lexstate = ST_TABLE_1;
return EXPRESSION_PHRASE;
}
}
else if (e-file > sizeof(symtab_end)
&& strcmp(e-sizeof(symtab_end)+1, symtab_end) == 0)
lexstate = ST_TABLE_3;
else if (lexstate == ST_TABLE_1)
{
lexstate = ST_TABLE_2;
return ';';
}
else if (lexstate == ST_TABLE_3)
lexstate = ST_TABLE_4;
}
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:
if (checksum_version > 1)
goto fini;
else
token = IDENT;
}
}
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:
if (checksum_version == 1)
{
_APP(". . .", 5);
break;
}
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;
}
/* 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 EXPORT_SYMBOL_KEYW 281
#define ASM_PHRASE 282
#define ATTRIBUTE_PHRASE 283
#define BRACE_PHRASE 284
#define BRACKET_PHRASE 285
#define EXPRESSION_PHRASE 286
#define CHAR 287
#define DOTS 288
#define IDENT 289
#define INT 290
#define REAL 291
#define STRING 292
#define TYPE 293
#define OTHER 294
#define FILENAME 295
#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 168
#define YYFLAG -32768
#define YYNTBASE 51
#define YYTRANSLATE(x) ((unsigned)(x) <= 295 ? yytranslate[x] : 95)
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, 45, 2, 44, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 50, 42, 2,
48, 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, 49, 2, 43, 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
};
#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, 75, 78, 81, 85, 89, 93, 96, 99,
102, 104, 106, 108, 110, 112, 114, 116, 118, 120,
122, 124, 127, 128, 130, 132, 135, 137, 139, 141,
143, 146, 148, 150, 155, 160, 163, 167, 171, 174,
176, 178, 180, 185, 190, 193, 197, 201, 204, 206,
210, 211, 213, 215, 219, 222, 225, 227, 228, 230,
232, 237, 242, 245, 249, 253, 257, 258, 260, 263,
267, 271, 272, 274, 276, 279, 283, 286, 287, 289,
291, 295, 298, 301, 303, 306, 307, 309, 312, 313,
315
};
static const short yyrhs[] = { 52,
0, 51, 52, 0, 0, 53, 54, 0, 0, 22,
55, 56, 0, 56, 0, 80, 0, 92, 0, 94,
0, 1, 42, 0, 1, 43, 0, 60, 57, 42,
0, 0, 58, 0, 59, 0, 58, 44, 59, 0,
70, 93, 91, 81, 0, 0, 61, 0, 62, 0,
61, 62, 0, 63, 0, 64, 0, 5, 0, 16,
0, 20, 0, 11, 0, 13, 0, 65, 0, 69,
0, 21, 35, 0, 23, 35, 0, 10, 35, 0,
21, 35, 83, 0, 23, 35, 83, 0, 10, 35,
30, 0, 10, 30, 0, 21, 83, 0, 23, 83,
0, 7, 0, 18, 0, 14, 0, 15, 0, 19,
0, 24, 0, 12, 0, 9, 0, 25, 0, 6,
0, 39, 0, 45, 67, 0, 0, 68, 0, 69,
0, 68, 69, 0, 8, 0, 26, 0, 29, 0,
17, 0, 66, 70, 0, 71, 0, 35, 0, 71,
46, 74, 47, 0, 71, 46, 1, 47, 0, 71,
31, 0, 46, 70, 47, 0, 46, 1, 47, 0,
66, 72, 0, 73, 0, 35, 0, 39, 0, 73,
46, 74, 47, 0, 73, 46, 1, 47, 0, 73,
31, 0, 46, 72, 47, 0, 46, 1, 47, 0,
75, 34, 0, 75, 0, 76, 44, 34, 0, 0,
76, 0, 77, 0, 76, 44, 77, 0, 61, 78,
0, 66, 78, 0, 79, 0, 0, 35, 0, 39,
0, 79, 46, 74, 47, 0, 79, 46, 1, 47,
0, 79, 31, 0, 46, 78, 47, 0, 46, 1,
47, 0, 60, 70, 30, 0, 0, 82, 0, 48,
32, 0, 49, 84, 43, 0, 49, 1, 43, 0,
0, 85, 0, 86, 0, 85, 86, 0, 60, 87,
42, 0, 1, 42, 0, 0, 88, 0, 89, 0,
88, 44, 89, 0, 72, 91, 0, 35, 90, 0,
90, 0, 50, 32, 0, 0, 29, 0, 28, 42,
0, 0, 28, 0, 27, 46, 35, 47, 42, 0
};
#endif
#if YYDEBUG != 0
static const short yyrline[] = { 0,
100, 102, 105, 108, 111, 113, 114, 115, 116, 117,
118, 119, 122, 136, 138, 141, 150, 162, 168, 170,
173, 175, 178, 186, 189, 191, 192, 193, 194, 197,
199, 203, 205, 207, 211, 218, 225, 234, 235, 236,
239, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 253, 258, 260, 263, 265, 268, 269, 269, 270,
277, 279, 282, 292, 294, 296, 298, 300, 306, 308,
311, 313, 314, 316, 318, 320, 322, 326, 328, 329,
332, 334, 337, 339, 343, 348, 351, 354, 356, 365,
370, 372, 374, 376, 378, 382, 391, 393, 397, 402,
404, 407, 409, 412, 414, 417, 420, 424, 426, 429,
431, 434, 436, 437, 440, 444, 446, 449, 453, 455,
458
};
#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","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,
51, 51, 53, 52, 55, 54, 54, 54, 54, 54,
54, 54, 56, 57, 57, 58, 58, 59, 60, 60,
61, 61, 62, 62, 63, 63, 63, 63, 63, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 66, 67, 67, 68, 68, 69, 69, 69, 69,
70, 70, 71, 71, 71, 71, 71, 71, 72, 72,
73, 73, 73, 73, 73, 73, 73, 74, 74, 74,
75, 75, 76, 76, 77, 78, 78, 79, 79, 79,
79, 79, 79, 79, 79, 80, 81, 81, 82, 83,
83, 84, 84, 85, 85, 86, 86, 87, 87, 88,
88, 89, 89, 89, 90, 91, 91, 92, 93, 93,
94
};
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, 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, 50, 41, 57, 48,
0, 28, 47, 29, 43, 44, 26, 60, 42, 45,
27, 0, 5, 0, 46, 49, 58, 0, 0, 59,
51, 4, 7, 14, 20, 21, 23, 24, 30, 31,
8, 9, 10, 11, 12, 38, 34, 32, 0, 39,
19, 33, 40, 0, 118, 63, 53, 0, 0, 15,
16, 0, 119, 62, 22, 37, 35, 0, 108, 0,
0, 104, 6, 14, 36, 0, 52, 54, 55, 0,
0, 13, 0, 61, 120, 96, 116, 66, 0, 107,
101, 71, 72, 0, 0, 0, 116, 70, 0, 109,
110, 114, 100, 0, 105, 119, 0, 56, 68, 67,
17, 117, 97, 0, 88, 0, 79, 82, 83, 113,
0, 71, 0, 115, 69, 112, 75, 0, 106, 0,
121, 0, 18, 98, 65, 89, 51, 0, 88, 85,
87, 64, 78, 0, 77, 76, 0, 0, 111, 99,
0, 90, 0, 86, 93, 0, 80, 84, 74, 73,
95, 94, 0, 0, 92, 91, 0, 0
};
static const short yydefgoto[] = { 1,
2, 3, 32, 51, 33, 59, 60, 61, 69, 35,
36, 37, 38, 39, 62, 77, 78, 40, 106, 64,
97, 98, 116, 117, 118, 119, 140, 141, 41, 133,
134, 50, 70, 71, 72, 99, 100, 101, 102, 113,
42, 87, 43
};
static const short yypact[] = {-32768,
40,-32768, 297,-32768, -30,-32768,-32768,-32768,-32768,-32768,
-16,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768, 4,-32768, 11,-32768,-32768,-32768, 6, 17,-32768,
-32768,-32768,-32768, 63, 416,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768, 31, 23, 76,-32768,
416, 23,-32768, 33,-32768,-32768, -2, 10, 24, 35,
-32768, 63, -12, -21,-32768,-32768,-32768, 1, 28, 61,
122,-32768,-32768, 63,-32768, 65,-32768, -2,-32768, 73,
77,-32768, 63,-32768,-32768,-32768, 96,-32768, 168,-32768,
-32768, 94,-32768, 19, 117, 68, 96, -14, 108, 109,
-32768,-32768,-32768, 110,-32768, 126, 113,-32768,-32768,-32768,
-32768,-32768, 111, 115, 339, 116, 124, 112,-32768,-32768,
119,-32768, 123,-32768,-32768,-32768,-32768, 211,-32768, 28,
-32768, 128,-32768,-32768,-32768,-32768,-32768, 3, 71,-32768,
-9,-32768,-32768, 381,-32768,-32768, 143, 148,-32768,-32768,
149,-32768, 151,-32768,-32768, 254,-32768,-32768,-32768,-32768,
-32768,-32768, 152, 153,-32768,-32768, 171,-32768
};
static const short yypgoto[] = {-32768,
200,-32768,-32768,-32768, 154,-32768,-32768, 120, 0, -87,
-35,-32768,-32768,-32768, -68,-32768,-32768, -48, -29,-32768,
-73,-32768, -120,-32768,-32768, 60, -63,-32768,-32768,-32768,
-32768, -17,-32768,-32768, 135,-32768,-32768, 78, 118, 114,
-32768,-32768,-32768
};
#define YYLAST 455
static const short yytable[] = { 65,
96, 115, 34, 151, 63, 9, 53, 148, 79, 88,
80, 44, 45, 46, 18, 85, 127, 86, 47, 121,
123, 155, 125, 27, 89, 96, 30, 96, 81, 108,
67, 128, 84, -88, 75, 164, 156, 136, 48, 167,
115, 152, 90, 91, 56, 52, 139, 57, 138, -88,
74, 54, 49, 122, 57, 58, 115, 93, 55, 49,
66, 96, 92, 57, 94, 82, 93, 76, 115, 139,
139, 49, 57, 94, 153, 154, 68, 95, 83, 65,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 56, 24, 25,
26, 27, 122, 103, 30, 136, 93, 57, 58, 152,
-19, 107, 57, 94, 31, 57, 138, -19, -102, 109,
-19, -19, 104, 110, 112, -19, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 95, 24, 25, 26, 27, 124, 129,
30, 90, 130, 85, 131, 144, -19, 143, 132, 150,
31, 135, 142, -19, -103, 145, -19, -19, 114, 146,
168, -19, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 159,
24, 25, 26, 27, 160, 161, 30, 162, 165, 166,
4, -81, 111, 158, 73, 105, 31, 149, 0, 120,
126, 147, 0, 0, -81, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 0, 24, 25, 26, 27, 0, 0, 30,
0, 0, 0, 0, -81, 0, 0, 0, 0, 31,
0, 0, 0, 0, 163, 0, 0, -81, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 0, 24, 25, 26, 27,
0, 0, 30, 0, 0, 0, 0, -81, 0, 0,
0, 0, 31, 0, 0, 0, 0, 5, 0, 0,
-81, 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, 0, 0, 0, 0,
0, -19, 0, 0, 0, 31, 0, 0, -19, 0,
0, -19, -19, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
0, 24, 25, 26, 27, 0, 0, 30, 0, 0,
0, 0, 0, 136, 0, 0, 0, 137, 0, 0,
0, 0, 0, 57, 138, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 0, 24, 25, 26, 27, 0, 0, 30,
0, 0, 0, 0, 157, 0, 0, 0, 0, 31,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 0, 24, 25,
26, 27, 0, 0, 30, 0, 0, 0, 0, 0,
0, 0, 0, 0, 31
};
static const short yycheck[] = { 35,
69, 89, 3, 1, 34, 8, 24, 128, 57, 31,
1, 42, 43, 30, 17, 28, 31, 30, 35, 1,
94, 31, 96, 26, 46, 94, 29, 96, 58, 78,
48, 46, 62, 31, 52, 156, 46, 35, 35, 0,
128, 39, 42, 43, 35, 35, 115, 45, 46, 47,
51, 46, 49, 35, 45, 46, 144, 39, 42, 49,
30, 130, 35, 45, 46, 42, 39, 35, 156, 138,
139, 49, 45, 46, 138, 139, 1, 50, 44, 115,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 35, 23, 24,
25, 26, 35, 43, 29, 35, 39, 45, 46, 39,
35, 47, 45, 46, 39, 45, 46, 42, 43, 47,
45, 46, 1, 47, 29, 50, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 50, 23, 24, 25, 26, 32, 42,
29, 42, 44, 28, 42, 44, 35, 34, 48, 32,
39, 47, 47, 42, 43, 47, 45, 46, 1, 47,
0, 50, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 47,
23, 24, 25, 26, 47, 47, 29, 47, 47, 47,
1, 34, 83, 144, 51, 71, 39, 130, -1, 92,
97, 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, -1, -1, 29,
-1, -1, -1, -1, 34, -1, -1, -1, -1, 39,
-1, -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,
-1, -1, 29, -1, -1, -1, -1, 34, -1, -1,
-1, -1, 39, -1, -1, -1, -1, 1, -1, -1,
47, 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, -1, -1, -1, -1,
-1, 35, -1, -1, -1, 39, -1, -1, 42, -1,
-1, 45, 46, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
-1, 23, 24, 25, 26, -1, -1, 29, -1, -1,
-1, -1, -1, 35, -1, -1, -1, 39, -1, -1,
-1, -1, -1, 45, 46, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, -1, 23, 24, 25, 26, -1, -1, 29,
-1, -1, -1, -1, 34, -1, -1, -1, -1, 39,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, -1, 23, 24,
25, 26, -1, -1, 29, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 39
};
/* -*-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 106 "scripts/genksyms/parse.y"
{ is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ;
break;}
case 4:
#line 108 "scripts/genksyms/parse.y"
{ free_list(*yyvsp[0], NULL); *yyvsp[0] = NULL; ;
break;}
case 5:
#line 112 "scripts/genksyms/parse.y"
{ is_typedef = 1; ;
break;}
case 6:
#line 113 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 11:
#line 118 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 12:
#line 119 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 13:
#line 124 "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 137 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 16:
#line 143 "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 151 "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 164 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1] ? yyvsp[-1] : yyvsp[-2] ? yyvsp[-2] : yyvsp[-3]; ;
break;}
case 19:
#line 169 "scripts/genksyms/parse.y"
{ decl_spec = NULL; ;
break;}
case 21:
#line 174 "scripts/genksyms/parse.y"
{ decl_spec = *yyvsp[0]; ;
break;}
case 22:
#line 175 "scripts/genksyms/parse.y"
{ decl_spec = *yyvsp[0]; ;
break;}
case 23:
#line 180 "scripts/genksyms/parse.y"
{ /* Version 2 checksumming ignores storage class, as that
is really irrelevant to the linkage. */
if (checksum_version > 1)
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 32:
#line 204 "scripts/genksyms/parse.y"
{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_STRUCT; yyval = yyvsp[0]; ;
break;}
case 33:
#line 206 "scripts/genksyms/parse.y"
{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_UNION; yyval = yyvsp[0]; ;
break;}
case 34:
#line 208 "scripts/genksyms/parse.y"
{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_ENUM; yyval = yyvsp[0]; ;
break;}
case 35:
#line 212 "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 36:
#line 219 "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 37:
#line 226 "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 38:
#line 234 "scripts/genksyms/parse.y"
{ 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 51:
#line 250 "scripts/genksyms/parse.y"
{ (*yyvsp[0])->tag = SYM_TYPEDEF; yyval = yyvsp[0]; ;
break;}
case 52:
#line 255 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ;
break;}
case 53:
#line 259 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 56:
#line 265 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 60:
#line 271 "scripts/genksyms/parse.y"
{ /* restrict has no effect in prototypes so ignore it */
remove_node(yyvsp[0]);
yyval = yyvsp[0];
;
break;}
case 61:
#line 278 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 63:
#line 284 "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 64:
#line 293 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 65:
#line 295 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 66:
#line 297 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 67:
#line 299 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 68:
#line 301 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 69:
#line 307 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 73:
#line 315 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 74:
#line 317 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 75:
#line 319 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 76:
#line 321 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 77:
#line 323 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 78:
#line 327 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 80:
#line 329 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 81:
#line 333 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 84:
#line 340 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 85:
#line 345 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ;
break;}
case 86:
#line 350 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ;
break;}
case 88:
#line 355 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 89:
#line 357 "scripts/genksyms/parse.y"
{ /* For version 2 checksums, we don't want to remember
private parameter names. */
if (checksum_version > 1)
remove_node(yyvsp[0]);
yyval = yyvsp[0];
;
break;}
case 90:
#line 366 "scripts/genksyms/parse.y"
{ if (checksum_version > 1)
remove_node(yyvsp[0]);
yyval = yyvsp[0];
;
break;}
case 91:
#line 371 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 92:
#line 373 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 93:
#line 375 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 94:
#line 377 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 95:
#line 379 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 96:
#line 384 "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 97:
#line 392 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 99:
#line 399 "scripts/genksyms/parse.y"
{ remove_list(yyvsp[0], &(*yyvsp[-1])->next); yyval = yyvsp[0]; ;
break;}
case 100:
#line 403 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 101:
#line 404 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 102:
#line 408 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 105:
#line 414 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 106:
#line 419 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 107:
#line 421 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 108:
#line 425 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 111:
#line 431 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 112:
#line 435 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ;
break;}
case 113:
#line 436 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 115:
#line 441 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 116:
#line 445 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 118:
#line 450 "scripts/genksyms/parse.y"
{ yyval = yyvsp[0]; ;
break;}
case 119:
#line 454 "scripts/genksyms/parse.y"
{ yyval = NULL; ;
break;}
case 121:
#line 460 "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 464 "scripts/genksyms/parse.y"
static void
yyerror(const char *e)
{
error_with_pos("%s", e);
}
#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 EXPORT_SYMBOL_KEYW 281
#define ASM_PHRASE 282
#define ATTRIBUTE_PHRASE 283
#define BRACE_PHRASE 284
#define BRACKET_PHRASE 285
#define EXPRESSION_PHRASE 286
#define CHAR 287
#define DOTS 288
#define IDENT 289
#define INT 290
#define REAL 291
#define STRING 292
#define TYPE 293
#define OTHER 294
#define FILENAME 295
extern YYSTYPE yylval;
/* 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 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. */
if (checksum_version > 1)
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
/* 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. */
if (checksum_version > 1)
remove_node($1);
$$ = $1;
}
/* This wasn't really a typedef name but an identifier that
shadows one. */
| TYPE
{ if (checksum_version > 1)
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);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment