truncate tsort tty udpstat umount uname unexpand \
unstack update uud uue version vol wc \
whereis which who write writeisofs fetch \
- xargs yacc yes zdump zmodem pkgin_cd \
+ xargs yes zdump zmodem pkgin_cd \
mktemp worldstone updateboot update_bootcfg
.if ${MACHINE_ARCH} == "i386"
+++ /dev/null
-# $NetBSD: Makefile,v 1.8 2003/05/18 07:57:38 lukem Exp $
-
-PROG= yacc
-SRCS= closure.c error.c lalr.c lr0.c main.c mkpar.c output.c reader.c \
- skeleton.c symtab.c verbose.c warshall.c
-
-.include <bsd.prog.mk>
+++ /dev/null
-/* $NetBSD: defs.h,v 1.17 2009/04/14 09:41:30 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)defs.h 5.6 (Berkeley) 5/24/93
- */
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
-
-#include <assert.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-/* machine-dependent definitions */
-/* the following definitions are for the Tahoe */
-/* they might have to be changed for other machines */
-
-/* MAXCHAR is the largest unsigned character value */
-/* MAXSHORT is the largest value of a C short */
-/* MINSHORT is the most negative value of a C short */
-/* MAXTABLE is the maximum table size */
-/* BITS_PER_WORD is the number of bits in a C unsigned */
-/* WORDSIZE computes the number of words needed to */
-/* store n bits */
-/* BIT returns the value of the n-th bit starting */
-/* from r (0-indexed) */
-/* SETBIT sets the n-th bit starting from r */
-
-#define MAXCHAR 255
-#define MAXSHORT 32767
-#define MINSHORT -32768
-#define MAXTABLE 32500
-#define BITS_PER_WORD 32
-#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1)/BITS_PER_WORD))
-#define BIT(r, n) ((((r)[(n)>>5])>>((n)&31)&1))
-#define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31)))
-
-
-/* character names */
-
-#define NUL '\0' /* the null character */
-#define NEWLINE '\n' /* line feed */
-#define SP ' ' /* space */
-#define BS '\b' /* backspace */
-#define HT '\t' /* horizontal tab */
-#define VT '\013' /* vertical tab */
-#define CR '\r' /* carriage return */
-#define FF '\f' /* form feed */
-#define QUOTE '\'' /* single quote */
-#define DOUBLE_QUOTE '\"' /* double quote */
-#define BACKSLASH '\\' /* backslash */
-
-
-/* defines for constructing filenames */
-
-#define CODE_SUFFIX ".code.c"
-#define DEFINES_SUFFIX ".tab.h"
-#define OUTPUT_SUFFIX ".tab.c"
-#define VERBOSE_SUFFIX ".output"
-
-
-/* keyword codes */
-
-#define TOKEN 0
-#define LEFT 1
-#define RIGHT 2
-#define NONASSOC 3
-#define MARK 4
-#define TEXT 5
-#define TYPE 6
-#define START 7
-#define UNION 8
-#define IDENT 9
-#define EXPECT 10
-
-
-/* symbol classes */
-
-#define UNKNOWN 0
-#define TERM 1
-#define NONTERM 2
-
-
-/* the undefined value */
-
-#define UNDEFINED (-1)
-
-
-/* action codes */
-
-#define SHIFT 1
-#define REDUCE 2
-
-
-/* character macros */
-
-#define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
-#define IS_OCTAL(c) ((c) >= '0' && (c) <= '7')
-#define NUMERIC_VALUE(c) ((c) - '0')
-
-
-/* symbol macros */
-
-#define ISTOKEN(s) ((s) < start_symbol)
-#define ISVAR(s) ((s) >= start_symbol)
-
-
-/* storage allocation macros */
-
-#define CALLOC(k,n) (calloc((unsigned)(k),(unsigned)(n)))
-#define FREE(x) (free((char*)(x)))
-#define MALLOC(n) (malloc((unsigned)(n)))
-#define NEW(t) ((t*)allocate(sizeof(t)))
-#define NEW2(n,t) ((t*)allocate((unsigned)((n)*sizeof(t))))
-#define REALLOC(p,n) (realloc((char*)(p),(unsigned)(n)))
-
-
-/* the structure of a symbol table entry */
-
-typedef struct bucket bucket;
-struct bucket
-{
- struct bucket *link;
- struct bucket *next;
- char *name;
- char *tag;
- short value;
- short index;
- short prec;
- char class;
- char assoc;
-};
-
-
-/* the structure of the LR(0) state machine */
-
-typedef struct core core;
-struct core
-{
- struct core *next;
- struct core *link;
- short number;
- short accessing_symbol;
- short nitems;
- short items[1];
-};
-
-
-/* the structure used to record shifts */
-
-typedef struct shifts shifts;
-struct shifts
-{
- struct shifts *next;
- short number;
- short nshifts;
- short shift[1];
-};
-
-
-/* the structure used to store reductions */
-
-typedef struct reductions reductions;
-struct reductions
-{
- struct reductions *next;
- short number;
- short nreds;
- short rules[1];
-};
-
-
-/* the structure used to represent parser actions */
-
-typedef struct action action;
-struct action
-{
- struct action *next;
- short symbol;
- short number;
- short prec;
- char action_code;
- char assoc;
- char suppressed;
-};
-
-
-/* global variables */
-
-extern char dflag;
-extern char lflag;
-extern char rflag;
-extern char tflag;
-extern char vflag;
-extern const char *symbol_prefix;
-
-extern const char *myname;
-extern char *cptr;
-extern char *line;
-extern int lineno;
-extern int outline;
-
-extern const char * const banner[];
-extern const char * const tables[];
-extern const char * const header[];
-extern const char * const body[];
-extern const char * const trailer[];
-
-extern char *action_file_name;
-extern char *code_file_name;
-extern char *defines_file_name;
-extern const char *input_file_name;
-extern char *output_file_name;
-extern char *text_file_name;
-extern char *union_file_name;
-extern char *verbose_file_name;
-
-extern FILE *action_file;
-extern FILE *code_file;
-extern FILE *defines_file;
-extern FILE *input_file;
-extern FILE *output_file;
-extern FILE *text_file;
-extern FILE *union_file;
-extern FILE *verbose_file;
-
-extern int nitems;
-extern int nrules;
-extern int nsyms;
-extern int ntokens;
-extern int nvars;
-extern int ntags;
-
-extern char unionized;
-
-extern int start_symbol;
-extern char **symbol_name;
-extern short *symbol_value;
-extern short *symbol_prec;
-extern char *symbol_assoc;
-
-extern short *ritem;
-extern short *rlhs;
-extern short *rrhs;
-extern short *rprec;
-extern char *rassoc;
-
-extern short **derives;
-extern char *nullable;
-
-extern bucket *first_symbol;
-extern bucket *last_symbol;
-
-extern int nstates;
-extern core *first_state;
-extern shifts *first_shift;
-extern reductions *first_reduction;
-extern short *accessing_symbol;
-extern core **state_table;
-extern shifts **shift_table;
-extern reductions **reduction_table;
-extern unsigned *LA;
-extern short *LAruleno;
-extern short *lookaheads;
-extern short *goto_map;
-extern short *from_state;
-extern short *to_state;
-
-extern action **parser;
-extern int SRtotal;
-extern int RRtotal;
-extern short *SRconflicts;
-extern short *RRconflicts;
-extern short *defred;
-extern short *rules_used;
-extern short nunused;
-extern short final_state;
-
-/* global functions */
-
-extern char *allocate(unsigned);
-extern bucket *lookup(char *);
-extern bucket *make_bucket(const char *);
-
-extern void set_first_derives(void);
-extern void closure(short *, int);
-extern void finalize_closure(void);
-
-extern __dead void fatal(const char *);
-
-extern void reflexive_transitive_closure(unsigned *, int);
-extern __dead void done(int);
-
-extern __dead void no_space(void);
-extern __dead void open_error(const char *);
-extern __dead void unexpected_EOF(void);
-extern void print_pos(char *, char *);
-extern __dead void syntax_error(int, char *, char *);
-extern __dead void unterminated_comment(int, char *, char *);
-extern __dead void unterminated_string(int, char *, char *);
-extern __dead void unterminated_text(int, char *, char *);
-extern __dead void unterminated_union(int, char *, char *);
-extern __dead void over_unionized(char *);
-extern void illegal_tag(int, char *, char *);
-extern void illegal_character(char *);
-extern void used_reserved(char *);
-extern void tokenized_start(char *);
-extern void retyped_warning(char *);
-extern void reprec_warning(char *);
-extern void revalued_warning(char *);
-extern __dead void terminal_start(char *);
-extern void restarted_warning(void);
-extern __dead void no_grammar(void);
-extern __dead void terminal_lhs(int);
-extern void prec_redeclared(void);
-extern __dead void unterminated_action(int, char *, char *);
-extern void dollar_warning(int, int);
-extern __dead void dollar_error(int, char *, char *);
-extern __dead void untyped_lhs(void);
-extern __dead void untyped_rhs(int, char *);
-extern __dead void unknown_rhs(int);
-extern void default_action_warning(void);
-extern __dead void undefined_goal(char *);
-extern void undefined_symbol_warning(char *);
-
-extern void lalr(void);
-
-extern void reader(void);
-extern void lr0(void);
-extern void make_parser(void);
-extern void verbose(void);
-extern void output(void);
-extern void free_parser(void);
-extern void write_section(const char * const []);
-
-extern void create_symbol_table(void);
-extern void free_symbol_table(void);
-extern void free_symbols(void);
+++ /dev/null
-/* $NetBSD: lalr.c,v 1.11 2009/04/14 09:41:30 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)lalr.c 5.3 (Berkeley) 6/1/90";
-#else
-__RCSID("$NetBSD: lalr.c,v 1.11 2009/04/14 09:41:30 lukem Exp $");
-#endif
-#endif /* not lint */
-
-#include "defs.h"
-
-typedef
- struct shorts
- {
- struct shorts *next;
- short value;
- }
- shorts;
-
-short *lookaheads;
-short *LAruleno;
-unsigned *LA;
-short *accessing_symbol;
-core **state_table;
-shifts **shift_table;
-reductions **reduction_table;
-short *goto_map;
-short *from_state;
-short *to_state;
-
-static int tokensetsize;
-
-static short **transpose(short **, int);
-static void set_state_table(void);
-static void set_accessing_symbol(void);
-static void set_shift_table(void);
-static void set_reduction_table(void);
-static void set_maxrhs(void);
-static void initialize_LA(void);
-static void set_goto_map(void);
-static void initialize_F(void);
-static void build_relations(void);
-static void compute_FOLLOWS(void);
-static void compute_lookaheads(void);
-
-static int map_goto(int, int);
-static void digraph(short **);
-static void add_lookback_edge(int, int, int);
-static void traverse(int);
-
-
-static int infinity;
-static int maxrhs;
-static int ngotos;
-static unsigned *F;
-static short **includes;
-static shorts **lookback;
-static short **R;
-static short *INDEX;
-static short *VERTICES;
-static int top;
-
-void
-lalr(void)
-{
- tokensetsize = WORDSIZE(ntokens);
-
- set_state_table();
- set_accessing_symbol();
- set_shift_table();
- set_reduction_table();
- set_maxrhs();
- initialize_LA();
- set_goto_map();
- initialize_F();
- build_relations();
- compute_FOLLOWS();
- compute_lookaheads();
-}
-
-
-static void
-set_state_table(void)
-{
- core *sp;
-
- state_table = NEW2(nstates, core *);
- for (sp = first_state; sp; sp = sp->next)
- state_table[sp->number] = sp;
-}
-
-
-static void
-set_accessing_symbol(void)
-{
- core *sp;
-
- accessing_symbol = NEW2(nstates, short);
- for (sp = first_state; sp; sp = sp->next)
- accessing_symbol[sp->number] = sp->accessing_symbol;
-}
-
-
-static void
-set_shift_table(void)
-{
- shifts *sp;
-
- shift_table = NEW2(nstates, shifts *);
- for (sp = first_shift; sp; sp = sp->next)
- shift_table[sp->number] = sp;
-}
-
-
-static void
-set_reduction_table(void)
-{
- reductions *rp;
-
- reduction_table = NEW2(nstates, reductions *);
- for (rp = first_reduction; rp; rp = rp->next)
- reduction_table[rp->number] = rp;
-}
-
-
-static void
-set_maxrhs(void)
-{
- short *itemp;
- short *item_end;
- int length;
- int max;
-
- length = 0;
- max = 0;
- item_end = ritem + nitems;
- for (itemp = ritem; itemp < item_end; itemp++)
- {
- if (*itemp >= 0)
- {
- length++;
- }
- else
- {
- if (length > max) max = length;
- length = 0;
- }
- }
-
- maxrhs = max;
-}
-
-
-static void
-initialize_LA(void)
-{
- int i, j, k;
- reductions *rp;
-
- lookaheads = NEW2(nstates + 1, short);
-
- k = 0;
- for (i = 0; i < nstates; i++)
- {
- lookaheads[i] = k;
- rp = reduction_table[i];
- if (rp)
- k += rp->nreds;
- }
- lookaheads[nstates] = k;
-
- LA = NEW2(k * tokensetsize, unsigned);
- LAruleno = NEW2(k, short);
- lookback = NEW2(k, shorts *);
-
- k = 0;
- for (i = 0; i < nstates; i++)
- {
- rp = reduction_table[i];
- if (rp)
- {
- for (j = 0; j < rp->nreds; j++)
- {
- LAruleno[k] = rp->rules[j];
- k++;
- }
- }
- }
-}
-
-
-static void
-set_goto_map(void)
-{
- shifts *sp;
- int i;
- int symbol;
- int k;
- short *temp_map;
- int state2;
- int state1;
-
- goto_map = NEW2(nvars + 1, short) - ntokens;
- temp_map = NEW2(nvars + 1, short) - ntokens;
-
- ngotos = 0;
- for (sp = first_shift; sp; sp = sp->next)
- {
- for (i = sp->nshifts - 1; i >= 0; i--)
- {
- symbol = accessing_symbol[sp->shift[i]];
-
- if (ISTOKEN(symbol)) break;
-
- if (ngotos == MAXSHORT)
- fatal("too many gotos");
-
- ngotos++;
- goto_map[symbol]++;
- }
- }
-
- k = 0;
- for (i = ntokens; i < nsyms; i++)
- {
- temp_map[i] = k;
- k += goto_map[i];
- }
-
- for (i = ntokens; i < nsyms; i++)
- goto_map[i] = temp_map[i];
-
- goto_map[nsyms] = ngotos;
- temp_map[nsyms] = ngotos;
-
- from_state = NEW2(ngotos, short);
- to_state = NEW2(ngotos, short);
-
- for (sp = first_shift; sp; sp = sp->next)
- {
- state1 = sp->number;
- for (i = sp->nshifts - 1; i >= 0; i--)
- {
- state2 = sp->shift[i];
- symbol = accessing_symbol[state2];
-
- if (ISTOKEN(symbol)) break;
-
- k = temp_map[symbol]++;
- from_state[k] = state1;
- to_state[k] = state2;
- }
- }
-
- FREE(temp_map + ntokens);
-}
-
-
-
-/* Map_goto maps a state/symbol pair into its numeric representation. */
-
-static int
-map_goto(int state, int symbol)
-{
- int high;
- int low;
- int middle;
- int s;
-
- low = goto_map[symbol];
- high = goto_map[symbol + 1];
-
- for (;;)
- {
- assert(low <= high);
- middle = (low + high) >> 1;
- s = from_state[middle];
- if (s == state)
- return (middle);
- else if (s < state)
- low = middle + 1;
- else
- high = middle - 1;
- }
-}
-
-
-static void
-initialize_F(void)
-{
- int i;
- int j;
- int k;
- shifts *sp;
- short *edge;
- unsigned *rowp;
- short *rp;
- short **reads;
- int nedges;
- int stateno;
- int symbol;
- int nwords;
-
- nwords = ngotos * tokensetsize;
- F = NEW2(nwords, unsigned);
-
- reads = NEW2(ngotos, short *);
- edge = NEW2(ngotos + 1, short);
- nedges = 0;
-
- rowp = F;
- for (i = 0; i < ngotos; i++)
- {
- stateno = to_state[i];
- sp = shift_table[stateno];
-
- if (sp)
- {
- k = sp->nshifts;
-
- for (j = 0; j < k; j++)
- {
- symbol = accessing_symbol[sp->shift[j]];
- if (ISVAR(symbol))
- break;
- SETBIT(rowp, symbol);
- }
-
- for (; j < k; j++)
- {
- symbol = accessing_symbol[sp->shift[j]];
- if (nullable[symbol])
- edge[nedges++] = map_goto(stateno, symbol);
- }
-
- if (nedges)
- {
- reads[i] = rp = NEW2(nedges + 1, short);
-
- for (j = 0; j < nedges; j++)
- rp[j] = edge[j];
-
- rp[nedges] = -1;
- nedges = 0;
- }
- }
-
- rowp += tokensetsize;
- }
-
- SETBIT(F, 0);
- digraph(reads);
-
- for (i = 0; i < ngotos; i++)
- {
- if (reads[i])
- FREE(reads[i]);
- }
-
- FREE(reads);
- FREE(edge);
-}
-
-
-static void
-build_relations(void)
-{
- int i;
- int j;
- int k;
- short *rulep;
- short *rp;
- shifts *sp;
- int length;
- int nedges;
- int isdone;
- int state1;
- int stateno;
- int symbol1;
- int symbol2;
- short *shortp;
- short *edge;
- short *states;
- short **new_includes;
-
- includes = NEW2(ngotos, short *);
- edge = NEW2(ngotos + 1, short);
- states = NEW2(maxrhs + 1, short);
-
- for (i = 0; i < ngotos; i++)
- {
- nedges = 0;
- state1 = from_state[i];
- symbol1 = accessing_symbol[to_state[i]];
-
- for (rulep = derives[symbol1]; *rulep >= 0; rulep++)
- {
- length = 1;
- states[0] = state1;
- stateno = state1;
-
- for (rp = ritem + rrhs[*rulep]; *rp >= 0; rp++)
- {
- symbol2 = *rp;
- sp = shift_table[stateno];
- k = sp->nshifts;
-
- for (j = 0; j < k; j++)
- {
- stateno = sp->shift[j];
- if (accessing_symbol[stateno] == symbol2) break;
- }
-
- states[length++] = stateno;
- }
-
- add_lookback_edge(stateno, *rulep, i);
-
- length--;
- isdone = 0;
- while (!isdone)
- {
- isdone = 1;
- rp--;
- if (ISVAR(*rp))
- {
- stateno = states[--length];
- edge[nedges++] = map_goto(stateno, *rp);
- if (nullable[*rp] && length > 0) isdone = 0;
- }
- }
- }
-
- if (nedges)
- {
- includes[i] = shortp = NEW2(nedges + 1, short);
- for (j = 0; j < nedges; j++)
- shortp[j] = edge[j];
- shortp[nedges] = -1;
- }
- }
-
- new_includes = transpose(includes, ngotos);
-
- for (i = 0; i < ngotos; i++)
- if (includes[i])
- FREE(includes[i]);
-
- FREE(includes);
-
- includes = new_includes;
-
- FREE(edge);
- FREE(states);
-}
-
-
-static void
-add_lookback_edge(int stateno, int ruleno, int gotono)
-{
- int i, k;
- int found;
- shorts *sp;
-
- i = lookaheads[stateno];
- k = lookaheads[stateno + 1];
- found = 0;
- while (!found && i < k)
- {
- if (LAruleno[i] == ruleno)
- found = 1;
- else
- ++i;
- }
- assert(found);
-
- sp = NEW(shorts);
- sp->next = lookback[i];
- sp->value = gotono;
- lookback[i] = sp;
-}
-
-
-
-static short **
-transpose(short **tR, int n)
-{
- short **new_R;
- short **temp_R;
- short *nedges;
- short *sp;
- int i;
- int k;
-
- nedges = NEW2(n, short);
-
- for (i = 0; i < n; i++)
- {
- sp = tR[i];
- if (sp)
- {
- while (*sp >= 0)
- nedges[*sp++]++;
- }
- }
-
- new_R = NEW2(n, short *);
- temp_R = NEW2(n, short *);
-
- for (i = 0; i < n; i++)
- {
- k = nedges[i];
- if (k > 0)
- {
- sp = NEW2(k + 1, short);
- new_R[i] = sp;
- temp_R[i] = sp;
- sp[k] = -1;
- }
- }
-
- FREE(nedges);
-
- for (i = 0; i < n; i++)
- {
- sp = tR[i];
- if (sp)
- {
- while (*sp >= 0)
- *temp_R[*sp++]++ = i;
- }
- }
-
- FREE(temp_R);
-
- return (new_R);
-}
-
-
-static void
-compute_FOLLOWS(void)
-{
- digraph(includes);
-}
-
-
-static void
-compute_lookaheads(void)
-{
- int i, n;
- unsigned *fp1, *fp2, *fp3;
- shorts *sp, *next;
- unsigned *rowp;
-
- rowp = LA;
- n = lookaheads[nstates];
- for (i = 0; i < n; i++)
- {
- fp3 = rowp + tokensetsize;
- for (sp = lookback[i]; sp; sp = sp->next)
- {
- fp1 = rowp;
- fp2 = F + tokensetsize * sp->value;
- while (fp1 < fp3)
- *fp1++ |= *fp2++;
- }
- rowp = fp3;
- }
-
- for (i = 0; i < n; i++)
- for (sp = lookback[i]; sp; sp = next)
- {
- next = sp->next;
- FREE(sp);
- }
-
- FREE(lookback);
- FREE(F);
-}
-
-
-static void
-digraph(short **relation)
-{
- int i;
-
- infinity = ngotos + 2;
- INDEX = NEW2(ngotos + 1, short);
- VERTICES = NEW2(ngotos + 1, short);
- top = 0;
-
- R = relation;
-
- for (i = 0; i < ngotos; i++)
- INDEX[i] = 0;
-
- for (i = 0; i < ngotos; i++)
- {
- if (INDEX[i] == 0 && R[i])
- traverse(i);
- }
-
- FREE(INDEX);
- FREE(VERTICES);
-}
-
-
-static void
-traverse(int i)
-{
- unsigned *fp1;
- unsigned *fp2;
- unsigned *fp3;
- int j;
- short *rp;
-
- int height;
- unsigned *base;
-
- VERTICES[++top] = i;
- INDEX[i] = height = top;
-
- base = F + i * tokensetsize;
- fp3 = base + tokensetsize;
-
- rp = R[i];
- if (rp)
- {
- while ((j = *rp++) >= 0)
- {
- if (INDEX[j] == 0)
- traverse(j);
-
- if (INDEX[i] > INDEX[j])
- INDEX[i] = INDEX[j];
-
- fp1 = base;
- fp2 = F + j * tokensetsize;
-
- while (fp1 < fp3)
- *fp1++ |= *fp2++;
- }
- }
-
- if (INDEX[i] == height)
- {
- for (;;)
- {
- j = VERTICES[top--];
- INDEX[j] = infinity;
-
- if (i == j)
- break;
-
- fp1 = base;
- fp2 = F + j * tokensetsize;
-
- while (fp1 < fp3)
- *fp2++ = *fp1++;
- }
- }
-}
+++ /dev/null
-/* $NetBSD: main.c,v 1.21 2009/04/14 09:41:30 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
-
-#include <sys/cdefs.h>
-#if defined(__COPYRIGHT) && !defined(lint)
-__COPYRIGHT("@(#) Copyright (c) 1989\
- The Regents of the University of California. All rights reserved.");
-#endif /* not lint */
-
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93";
-#else
-__RCSID("$NetBSD: main.c,v 1.21 2009/04/14 09:41:30 lukem Exp $");
-#endif
-#endif /* not lint */
-
-#include <signal.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "defs.h"
-
-char dflag;
-char lflag;
-char rflag;
-char tflag;
-char vflag;
-
-const char *symbol_prefix;
-const char *myname = "yacc";
-
-
-int lineno;
-int outline;
-
-char *action_file_name;
-char *code_file_name;
-char *defines_file_name;
-const char *input_file_name = "";
-char *output_file_name;
-char *text_file_name;
-char *union_file_name;
-char *verbose_file_name;
-
-FILE *action_file; /* a temp file, used to save actions associated */
- /* with rules until the parser is written */
-FILE *code_file; /* y.code.c (used when the -r option is specified) */
-FILE *defines_file; /* y.tab.h */
-FILE *input_file; /* the input file */
-FILE *output_file; /* y.tab.c */
-FILE *text_file; /* a temp file, used to save text until all */
- /* symbols have been defined */
-FILE *union_file; /* a temp file, used to save the union */
- /* definition until all symbol have been */
- /* defined */
-FILE *verbose_file; /* y.output */
-
-int nitems;
-int nrules;
-int nsyms;
-int ntokens;
-int nvars;
-
-int start_symbol;
-char **symbol_name;
-short *symbol_value;
-short *symbol_prec;
-char *symbol_assoc;
-
-short *ritem;
-short *rlhs;
-short *rrhs;
-short *rprec;
-char *rassoc;
-short **derives;
-char *nullable;
-
-static const char *file_prefix = "y";
-static const char *temp_form = "yacc.XXXXXXX";
-static int explicit_file_name;
-
-
-static __dead void onintr(int);
-static void set_signals(void);
-static __dead void usage(void);
-static void getargs(int, char *[]);
-static void create_file_names(void);
-static void open_files(void);
-
-/* coverity[+kill] */
-__dead void
-done(int k)
-{
- if (action_file) { fclose(action_file); unlink(action_file_name); }
- if (text_file) { fclose(text_file); unlink(text_file_name); }
- if (union_file) { fclose(union_file); unlink(union_file_name); }
- exit(k);
-}
-
-
-static void
-onintr(int signo)
-{
- done(1);
-}
-
-
-static void
-set_signals()
-{
-#ifdef SIGINT
- if (signal(SIGINT, SIG_IGN) != SIG_IGN)
- signal(SIGINT, onintr);
-#endif
-#ifdef SIGTERM
- if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
- signal(SIGTERM, onintr);
-#endif
-#ifdef SIGHUP
- if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
- signal(SIGHUP, onintr);
-#endif
-}
-
-
-static void
-usage(void)
-{
- fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-o outputfile] "
- "[-p symbol_prefix] filename\n", myname);
- exit(1);
-}
-
-
-static void
-getargs(int argc, char *argv[])
-{
- int i;
- char *s;
-
- if (argc > 0) myname = argv[0];
- for (i = 1; i < argc; ++i)
- {
- s = argv[i];
- if (*s != '-') break;
- switch (*++s)
- {
- case '\0':
- input_file = stdin;
- if (i + 1 < argc) usage();
- return;
-
- case '-':
- ++i;
- goto no_more_options;
-
- case 'b':
- if (*++s)
- file_prefix = s;
- else if (++i < argc)
- file_prefix = argv[i];
- else
- usage();
- continue;
-
- case 'd':
- dflag = 1;
- break;
-
- case 'l':
- lflag = 1;
- break;
-
- case 'o':
- if (*++s)
- output_file_name = s;
- else if (++i < argc)
- output_file_name = argv[i];
- else
- usage();
- explicit_file_name = 1;
- continue;
-
- case 'p':
- if (*++s)
- symbol_prefix = s;
- else if (++i < argc)
- symbol_prefix = argv[i];
- else
- usage();
- continue;
-
- case 'r':
- rflag = 1;
- break;
-
- case 't':
- tflag = 1;
- break;
-
- case 'v':
- vflag = 1;
- break;
-
- default:
- usage();
- }
-
- for (;;)
- {
- switch (*++s)
- {
- case '\0':
- goto end_of_option;
-
- case 'd':
- dflag = 1;
- break;
-
- case 'l':
- lflag = 1;
- break;
-
- case 'r':
- rflag = 1;
- break;
-
- case 't':
- tflag = 1;
- break;
-
- case 'v':
- vflag = 1;
- break;
-
- default:
- usage();
- }
- }
-end_of_option:;
- }
-
-no_more_options:;
- if (i + 1 != argc) usage();
- input_file_name = argv[i];
-}
-
-
-char *
-allocate(unsigned n)
-{
- char *p;
-
- p = NULL;
- if (n)
- {
- p = CALLOC(1, n);
- if (!p) no_space();
- }
- return (p);
-}
-
-
-static void
-create_file_names(void)
-{
- int i, len;
- const char *tmpdir;
-
- tmpdir = getenv("TMPDIR");
- if (tmpdir == 0) tmpdir = "/tmp";
-
- len = strlen(tmpdir);
- i = len + 13;
- if (len && tmpdir[len-1] != '/')
- ++i;
-
- action_file_name = MALLOC(i);
- if (action_file_name == 0) no_space();
- text_file_name = MALLOC(i);
- if (text_file_name == 0) no_space();
- union_file_name = MALLOC(i);
- if (union_file_name == 0) no_space();
-
- strlcpy(action_file_name, tmpdir, i);
- strlcpy(text_file_name, tmpdir, i);
- strlcpy(union_file_name, tmpdir, i);
-
- if (len && tmpdir[len - 1] != '/')
- {
- action_file_name[len] = '/';
- text_file_name[len] = '/';
- union_file_name[len] = '/';
- ++len;
- }
-
- strlcpy(action_file_name + len, temp_form, i - len);
- strlcpy(text_file_name + len, temp_form, i - len);
- strlcpy(union_file_name + len, temp_form, i - len);
-
- action_file_name[len + 5] = 'a';
- text_file_name[len + 5] = 't';
- union_file_name[len + 5] = 'u';
-
- len = strlen(file_prefix);
-
- if (!output_file_name)
- {
- output_file_name = MALLOC(strlen(file_prefix) + strlen(OUTPUT_SUFFIX)
- + 1);
- if (output_file_name == 0)
- no_space();
- sprintf(output_file_name, "%s%s", file_prefix, OUTPUT_SUFFIX);
- }
-
-
- if (rflag)
- {
- code_file_name = MALLOC(strlen(file_prefix) + strlen(CODE_SUFFIX)
- + 1);
- if (code_file_name == 0)
- no_space();
- sprintf(code_file_name, "%s%s", file_prefix, CODE_SUFFIX);
- }
- else
- code_file_name = output_file_name;
-
- if (dflag)
- {
- if (explicit_file_name)
- {
- char *suffix;
- defines_file_name = strdup(output_file_name);
- if (defines_file_name == 0)
- no_space();
- /* does the output_file_name have a known suffix */
- suffix = strrchr(output_file_name, '.');
- if (suffix != 0 &&
- (!strcmp(suffix, ".c") || /* good, old-fashioned C */
- !strcmp(suffix, ".C") || /* C++, or C on Windows */
- !strcmp(suffix, ".cc") || /* C++ */
- !strcmp(suffix, ".cxx") || /* C++ */
- !strcmp(suffix, ".cpp"))) /* C++ (Windows) */
- {
- strncpy(defines_file_name, output_file_name,
- suffix - output_file_name + 1);
- defines_file_name[suffix - output_file_name + 1] = 'h';
- defines_file_name[suffix - output_file_name + 2] = 0;
- } else {
- fprintf(stderr,"%s: suffix of output file name %s"
- " not recognized, no -d file generated.\n",
- myname, output_file_name);
- dflag = 0;
- free(defines_file_name);
- defines_file_name = 0;
- }
- }
- else
- {
- defines_file_name = MALLOC(strlen(file_prefix) + strlen(DEFINES_SUFFIX)
- + 1);
- if (defines_file_name == 0)
- no_space();
- sprintf(defines_file_name, "%s%s", file_prefix, DEFINES_SUFFIX);
- }
- }
-
- if (vflag)
- {
- verbose_file_name = MALLOC(strlen(file_prefix) + strlen(VERBOSE_SUFFIX)
- + 1);
- if (verbose_file_name == 0)
- no_space();
- sprintf(verbose_file_name, "%s%s", file_prefix, VERBOSE_SUFFIX);
-
- }
-}
-
-
-static void
-open_files(void)
-{
- int fd;
-
- create_file_names();
-
- if (input_file == 0)
- {
- input_file = fopen(input_file_name, "r");
- if (input_file == 0)
- open_error(input_file_name);
- }
-
- if (((fd = mkstemp(action_file_name)) == -1) ||
- (action_file = fdopen(fd, "w")) == NULL)
- open_error(action_file_name);
-
- if (((fd = mkstemp(text_file_name)) == -1) ||
- (text_file = fdopen(fd, "w")) == NULL)
- open_error(text_file_name);
-
- if (vflag)
- {
- verbose_file = fopen(verbose_file_name, "w");
- if (verbose_file == 0)
- open_error(verbose_file_name);
- }
-
- if (dflag)
- {
- defines_file = fopen(defines_file_name, "w");
- if (defines_file == 0)
- open_error(defines_file_name);
- if (((fd = mkstemp(union_file_name)) == -1) ||
- (union_file = fdopen(fd, "w")) == NULL)
- open_error(union_file_name);
- }
-
- output_file = fopen(output_file_name, "w");
- if (output_file == 0)
- open_error(output_file_name);
-
- if (rflag)
- {
- code_file = fopen(code_file_name, "w");
- if (code_file == 0)
- open_error(code_file_name);
- }
- else
- code_file = output_file;
-}
-
-
-int
-main(int argc, char *argv[])
-{
- set_signals();
- getargs(argc, argv);
- open_files();
- reader();
- lr0();
- lalr();
- make_parser();
- verbose();
- output();
- done(0);
- /*NOTREACHED*/
- return 0;
-}
+++ /dev/null
-/* $NetBSD: output.c,v 1.15 2009/04/14 09:41:31 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93";
-#else
-__RCSID("$NetBSD: output.c,v 1.15 2009/04/14 09:41:31 lukem Exp $");
-#endif
-#endif /* not lint */
-
-#include "defs.h"
-
-static int nvectors;
-static int nentries;
-static short **froms;
-static short **tos;
-static short *tally;
-static short *width;
-static short *state_count;
-static short *order;
-static short *base;
-static short *pos;
-static int maxtable;
-static short *table;
-static short *check;
-static int lowzero;
-static int high;
-
-static void output_prefix(void);
-static void output_rule_data(void);
-static void output_yydefred(void);
-static void output_actions(void);
-static void token_actions(void);
-static void goto_actions(void);
-static int default_goto(int);
-static void save_column(int, int);
-static void sort_actions(void);
-static void pack_table(void);
-static int matching_vector(int);
-static int pack_vector(int);
-static void output_base(void);
-static void output_table(void);
-static void output_check(void);
-static int is_C_identifier(char *);
-static void output_defines(void);
-static void output_stored_text(void);
-static void output_debug(void);
-static void output_stype(void);
-static void output_trailing_text(void);
-static void output_semantic_actions(void);
-static void free_itemsets(void);
-static void free_shifts(void);
-static void free_reductions(void);
-
-static const char line_format[] = "#line %d \"%s\"\n";
-
-void
-output(void)
-{
- free_itemsets();
- free_shifts();
- free_reductions();
- output_prefix();
- output_stored_text();
- output_defines();
- output_rule_data();
- output_yydefred();
- output_actions();
- free_parser();
- output_debug();
- output_stype();
- if (rflag) write_section(tables);
- write_section(header);
- output_trailing_text();
- write_section(body);
- output_semantic_actions();
- write_section(trailer);
-}
-
-static void
-output_prefix(void)
-{
- if (symbol_prefix == NULL)
- symbol_prefix = "yy";
- else
- {
- ++outline;
- fprintf(code_file, "#define yyparse %sparse\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yylex %slex\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyerror %serror\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yychar %schar\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyval %sval\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yylval %slval\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yydebug %sdebug\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yynerrs %snerrs\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyerrflag %serrflag\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyss %sss\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yysslim %ssslim\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyssp %sssp\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyvs %svs\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyvsp %svsp\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yystacksize %sstacksize\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yylhs %slhs\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yylen %slen\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yydefred %sdefred\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yydgoto %sdgoto\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yysindex %ssindex\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyrindex %srindex\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yygindex %sgindex\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yytable %stable\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yycheck %scheck\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyname %sname\n", symbol_prefix);
- ++outline;
- fprintf(code_file, "#define yyrule %srule\n", symbol_prefix);
- }
- ++outline;
- fprintf(code_file, "#define YYPREFIX \"%s\"\n", symbol_prefix);
-}
-
-static void
-output_rule_data(void)
-{
- int i;
- int j;
-
-
- fprintf(output_file, "const short %slhs[] = {%42d,", symbol_prefix,
- symbol_value[start_symbol]);
-
- j = 10;
- for (i = 3; i < nrules; i++)
- {
- if (j >= 10)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
- else
- ++j;
-
- fprintf(output_file, "%5d,", symbol_value[rlhs[i]]);
- }
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\n");
-
- fprintf(output_file, "const short %slen[] = {%42d,", symbol_prefix, 2);
-
- j = 10;
- for (i = 3; i < nrules; i++)
- {
- if (j >= 10)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
- else
- j++;
-
- fprintf(output_file, "%5d,", rrhs[i + 1] - rrhs[i] - 1);
- }
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\n");
-}
-
-static void
-output_yydefred(void)
-{
- int i, j;
-
- fprintf(output_file, "const short %sdefred[] = {%39d,", symbol_prefix,
- (defred[0] ? defred[0] - 2 : 0));
-
- j = 10;
- for (i = 1; i < nstates; i++)
- {
- if (j < 10)
- ++j;
- else
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
-
- fprintf(output_file, "%5d,", (defred[i] ? defred[i] - 2 : 0));
- }
-
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\n");
-}
-
-static void
-output_actions(void)
-{
- nvectors = 2*nstates + nvars;
-
- froms = NEW2(nvectors, short *);
- tos = NEW2(nvectors, short *);
- tally = NEW2(nvectors, short);
- width = NEW2(nvectors, short);
-
- token_actions();
- FREE(lookaheads);
- FREE(LA);
- FREE(LAruleno);
- FREE(accessing_symbol);
-
- goto_actions();
- FREE(goto_map + ntokens);
- FREE(from_state);
- FREE(to_state);
-
- sort_actions();
- pack_table();
- output_base();
- output_table();
- output_check();
-}
-
-static void
-token_actions(void)
-{
- int i, j;
- int shiftcount, reducecount;
- int max, min;
- short *actionrow, *r, *s;
- action *p;
-
- actionrow = NEW2(2*ntokens, short);
- for (i = 0; i < nstates; ++i)
- {
- if (parser[i])
- {
- for (j = 0; j < 2*ntokens; ++j)
- actionrow[j] = 0;
-
- shiftcount = 0;
- reducecount = 0;
- for (p = parser[i]; p; p = p->next)
- {
- if (p->suppressed == 0)
- {
- if (p->action_code == SHIFT)
- {
- ++shiftcount;
- actionrow[p->symbol] = p->number;
- }
- else if (p->action_code == REDUCE && p->number != defred[i])
- {
- ++reducecount;
- actionrow[p->symbol + ntokens] = p->number;
- }
- }
- }
-
- tally[i] = shiftcount;
- tally[nstates+i] = reducecount;
- width[i] = 0;
- width[nstates+i] = 0;
- if (shiftcount > 0)
- {
- froms[i] = r = NEW2(shiftcount, short);
- tos[i] = s = NEW2(shiftcount, short);
- min = MAXSHORT;
- max = 0;
- for (j = 0; j < ntokens; ++j)
- {
- if (actionrow[j])
- {
- if (min > symbol_value[j])
- min = symbol_value[j];
- if (max < symbol_value[j])
- max = symbol_value[j];
- *r++ = symbol_value[j];
- *s++ = actionrow[j];
- }
- }
- width[i] = max - min + 1;
- }
- if (reducecount > 0)
- {
- froms[nstates+i] = r = NEW2(reducecount, short);
- tos[nstates+i] = s = NEW2(reducecount, short);
- min = MAXSHORT;
- max = 0;
- for (j = 0; j < ntokens; ++j)
- {
- if (actionrow[ntokens+j])
- {
- if (min > symbol_value[j])
- min = symbol_value[j];
- if (max < symbol_value[j])
- max = symbol_value[j];
- *r++ = symbol_value[j];
- *s++ = actionrow[ntokens+j] - 2;
- }
- }
- width[nstates+i] = max - min + 1;
- }
- }
- }
- FREE(actionrow);
-}
-
-static void
-goto_actions(void)
-{
- int i, j, k;
-
- state_count = NEW2(nstates, short);
-
- k = default_goto(start_symbol + 1);
- fprintf(output_file, "const short %sdgoto[] = {%40d,", symbol_prefix, k);
- save_column(start_symbol + 1, k);
-
- j = 10;
- for (i = start_symbol + 2; i < nsyms; i++)
- {
- if (j >= 10)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
- else
- ++j;
-
- k = default_goto(i);
- fprintf(output_file, "%5d,", k);
- save_column(i, k);
- }
-
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\n");
- FREE(state_count);
-}
-
-static int
-default_goto(int symbol)
-{
- int i;
- int m;
- int n;
- int default_state;
- int max;
-
- m = goto_map[symbol];
- n = goto_map[symbol + 1];
-
- if (m == n) return (0);
-
- for (i = 0; i < nstates; i++)
- state_count[i] = 0;
-
- for (i = m; i < n; i++)
- state_count[to_state[i]]++;
-
- max = 0;
- default_state = 0;
- for (i = 0; i < nstates; i++)
- {
- if (state_count[i] > max)
- {
- max = state_count[i];
- default_state = i;
- }
- }
-
- return (default_state);
-}
-
-
-static void
-save_column(int symbol, int default_state)
-{
- int i;
- int m;
- int n;
- short *sp;
- short *sp1;
- short *sp2;
- int count;
- int symno;
-
- m = goto_map[symbol];
- n = goto_map[symbol + 1];
-
- count = 0;
- for (i = m; i < n; i++)
- {
- if (to_state[i] != default_state)
- ++count;
- }
- if (count == 0) return;
-
- symno = symbol_value[symbol] + 2*nstates;
-
- froms[symno] = sp1 = sp = NEW2(count, short);
- tos[symno] = sp2 = NEW2(count, short);
-
- for (i = m; i < n; i++)
- {
- if (to_state[i] != default_state)
- {
- *sp1++ = from_state[i];
- *sp2++ = to_state[i];
- }
- }
-
- tally[symno] = count;
- width[symno] = sp1[-1] - sp[0] + 1;
-}
-
-static void
-sort_actions(void)
-{
- int i;
- int j;
- int k;
- int t;
- int w;
-
- order = NEW2(nvectors, short);
- nentries = 0;
-
- for (i = 0; i < nvectors; i++)
- {
- if (tally[i] > 0)
- {
- t = tally[i];
- w = width[i];
- j = nentries - 1;
-
- while (j >= 0 && (width[order[j]] < w))
- j--;
-
- while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
- j--;
-
- for (k = nentries - 1; k > j; k--)
- order[k + 1] = order[k];
-
- order[j + 1] = i;
- nentries++;
- }
- }
-}
-
-
-static void
-pack_table(void)
-{
- int i;
- int place;
- int state;
-
- base = NEW2(nvectors, short);
- pos = NEW2(nentries, short);
-
- maxtable = 1000;
- table = NEW2(maxtable, short);
- check = NEW2(maxtable, short);
-
- lowzero = 0;
- high = 0;
-
- for (i = 0; i < maxtable; i++)
- check[i] = -1;
-
- for (i = 0; i < nentries; i++)
- {
- state = matching_vector(i);
-
- if (state < 0)
- place = pack_vector(i);
- else
- place = base[state];
-
- pos[i] = place;
- base[order[i]] = place;
- }
-
- for (i = 0; i < nvectors; i++)
- {
- if (froms[i])
- FREE(froms[i]);
- if (tos[i])
- FREE(tos[i]);
- }
-
- FREE(froms);
- FREE(tos);
- FREE(pos);
-}
-
-
-/* The function matching_vector determines if the vector specified by */
-/* the input parameter matches a previously considered vector. The */
-/* test at the start of the function checks if the vector represents */
-/* a row of shifts over terminal symbols or a row of reductions, or a */
-/* column of shifts over a nonterminal symbol. Berkeley Yacc does not */
-/* check if a column of shifts over a nonterminal symbols matches a */
-/* previously considered vector. Because of the nature of LR parsing */
-/* tables, no two columns can match. Therefore, the only possible */
-/* match would be between a row and a column. Such matches are */
-/* unlikely. Therefore, to save time, no attempt is made to see if a */
-/* column matches a previously considered vector. */
-/* */
-/* Matching_vector is poorly designed. The test could easily be made */
-/* faster. Also, it depends on the vectors being in a specific */
-/* order. */
-
-static int
-matching_vector(int vector)
-{
- int i;
- int j;
- int k;
- int t;
- int w;
- int match;
- int prev;
-
- i = order[vector];
- if (i >= 2*nstates)
- return (-1);
-
- t = tally[i];
- w = width[i];
-
- for (prev = vector - 1; prev >= 0; prev--)
- {
- j = order[prev];
- if (width[j] != w || tally[j] != t)
- return (-1);
-
- match = 1;
- for (k = 0; match && k < t; k++)
- {
- if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k])
- match = 0;
- }
-
- if (match)
- return (j);
- }
-
- return (-1);
-}
-
-
-
-static int
-pack_vector(int vector)
-{
- int i, j, k, l;
- int t;
- int loc;
- int ok;
- short *from;
- short *to;
- int newmax;
-
- i = order[vector];
- t = tally[i];
- assert(t);
-
- from = froms[i];
- to = tos[i];
-
- j = lowzero - from[0];
- for (k = 1; k < t; ++k)
- if (lowzero - from[k] > j)
- j = lowzero - from[k];
- for (;; ++j)
- {
- if (j == 0)
- continue;
- ok = 1;
- for (k = 0; ok && k < t; k++)
- {
- loc = j + from[k];
- if (loc >= maxtable)
- {
- if (loc >= MAXTABLE)
- fatal("maximum table size exceeded");
-
- newmax = maxtable;
- do { newmax += 200; } while (newmax <= loc);
- table = (short *) REALLOC(table, newmax*sizeof(short));
- if (table == 0) no_space();
- check = (short *) REALLOC(check, newmax*sizeof(short));
- if (check == 0) no_space();
- for (l = maxtable; l < newmax; ++l)
- {
- table[l] = 0;
- check[l] = -1;
- }
- maxtable = newmax;
- }
-
- if (check[loc] != -1)
- ok = 0;
- }
- for (k = 0; ok && k < vector; k++)
- {
- if (pos[k] == j)
- ok = 0;
- }
- if (ok)
- {
- for (k = 0; k < t; k++)
- {
- loc = j + from[k];
- table[loc] = to[k];
- check[loc] = from[k];
- if (loc > high) high = loc;
- }
-
- while (check[lowzero] != -1)
- ++lowzero;
-
- return (j);
- }
- }
-}
-
-
-static void
-output_base(void)
-{
- int i, j;
-
- fprintf(output_file, "const short %ssindex[] = {%39d,", symbol_prefix,
- base[0]);
-
- j = 10;
- for (i = 1; i < nstates; i++)
- {
- if (j >= 10)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
- else
- ++j;
-
- fprintf(output_file, "%5d,", base[i]);
- }
-
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\nconst short %srindex[] = {%39d,", symbol_prefix,
- base[nstates]);
-
- j = 10;
- for (i = nstates + 1; i < 2*nstates; i++)
- {
- if (j >= 10)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
- else
- ++j;
-
- fprintf(output_file, "%5d,", base[i]);
- }
-
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\nconst short %sgindex[] = {%39d,", symbol_prefix,
- base[2*nstates]);
-
- j = 10;
- for (i = 2*nstates + 1; i < nvectors - 1; i++)
- {
- if (j >= 10)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
- else
- ++j;
-
- fprintf(output_file, "%5d,", base[i]);
- }
-
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\n");
- FREE(base);
-}
-
-
-static void
-output_table(void)
-{
- int i;
- int j;
-
- ++outline;
- fprintf(code_file, "#define YYTABLESIZE %d\n", high);
- fprintf(output_file, "const short %stable[] = {%40d,", symbol_prefix,
- table[0]);
-
- j = 10;
- for (i = 1; i <= high; i++)
- {
- if (j >= 10)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
- else
- ++j;
-
- fprintf(output_file, "%5d,", table[i]);
- }
-
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\n");
- FREE(table);
-}
-
-
-static void
-output_check(void)
-{
- int i;
- int j;
-
- fprintf(output_file, "const short %scheck[] = {%40d,", symbol_prefix,
- check[0]);
-
- j = 10;
- for (i = 1; i <= high; i++)
- {
- if (j >= 10)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 1;
- }
- else
- ++j;
-
- fprintf(output_file, "%5d,", check[i]);
- }
-
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\n");
- FREE(check);
-}
-
-
-static int
-is_C_identifier(char *name)
-{
- char *s;
- unsigned char c;
-
- s = name;
- c = *s;
- if (c == '"')
- {
- c = *++s;
- if (!isalpha(c) && c != '_' && c != '$')
- return (0);
- while ((c = *++s) != '"')
- {
- if (!isalnum(c) && c != '_' && c != '$')
- return (0);
- }
- return (1);
- }
-
- if (!isalpha(c) && c != '_' && c != '$')
- return (0);
- while ((c = *++s) != '\0')
- {
- if (!isalnum(c) && c != '_' && c != '$')
- return (0);
- }
- return (1);
-}
-
-
-static void
-output_defines(void)
-{
- int c, i;
- char *s;
-
- for (i = 2; i < ntokens; ++i)
- {
- s = symbol_name[i];
- if (is_C_identifier(s))
- {
- fprintf(code_file, "#define ");
- if (dflag) fprintf(defines_file, "#define ");
- c = *s;
- if (c == '"')
- {
- while ((c = *++s) != '"')
- {
- putc(c, code_file);
- if (dflag) putc(c, defines_file);
- }
- }
- else
- {
- do
- {
- putc(c, code_file);
- if (dflag) putc(c, defines_file);
- }
- while ((c = *++s) != '\0');
- }
- ++outline;
- fprintf(code_file, " %d\n", symbol_value[i]);
- if (dflag) fprintf(defines_file, " %d\n", symbol_value[i]);
- }
- }
-
- ++outline;
- fprintf(code_file, "#define YYERRCODE %d\n", symbol_value[1]);
-
- if (dflag && unionized)
- {
- fclose(union_file);
- union_file = fopen(union_file_name, "r");
- if (union_file == NULL) open_error(union_file_name);
- while ((c = getc(union_file)) != EOF)
- putc(c, defines_file);
- fprintf(defines_file, " YYSTYPE;\nextern YYSTYPE %slval;\n",
- symbol_prefix);
- }
-}
-
-
-static void
-output_stored_text(void)
-{
- int c;
- FILE *in, *out;
-
- fclose(text_file);
- text_file = fopen(text_file_name, "r");
- if (text_file == NULL)
- open_error(text_file_name);
- in = text_file;
- if ((c = getc(in)) == EOF)
- return;
- out = code_file;
- if (c == '\n')
- ++outline;
- putc(c, out);
- while ((c = getc(in)) != EOF)
- {
- if (c == '\n')
- ++outline;
- putc(c, out);
- }
- if (!lflag)
- fprintf(out, line_format, ++outline + 1, code_file_name);
-}
-
-
-static void
-output_debug(void)
-{
- int i, j, k, max;
- const char **symnam, *s;
-
- ++outline;
- fprintf(code_file, "#define YYFINAL %d\n", final_state);
- outline += 3;
- fprintf(code_file, "#ifndef YYDEBUG\n#define YYDEBUG %d\n#endif\n",
- tflag);
- if (rflag)
- fprintf(output_file, "#ifndef YYDEBUG\n#define YYDEBUG %d\n#endif\n",
- tflag);
-
- max = 0;
- for (i = 2; i < ntokens; ++i)
- if (symbol_value[i] > max)
- max = symbol_value[i];
- ++outline;
- fprintf(code_file, "#define YYMAXTOKEN %d\n", max);
-
- symnam = (const char **) MALLOC((max+1)*sizeof(char *));
- if (symnam == 0) no_space();
-
- /* Note that it is not necessary to initialize the element */
- /* symnam[max]. */
- for (i = 0; i < max; ++i)
- symnam[i] = 0;
- for (i = ntokens - 1; i >= 2; --i)
- symnam[symbol_value[i]] = symbol_name[i];
- symnam[0] = "end-of-file";
-
- if (!rflag) ++outline;
- fprintf(output_file, "#if YYDEBUG\nconst char * const %sname[] = {",
- symbol_prefix);
- j = 80;
- for (i = 0; i <= max; ++i)
- {
- if ((s = symnam[i]) != NULL)
- {
- if (s[0] == '"')
- {
- k = 7;
- while (*++s != '"')
- {
- ++k;
- if (*s == '\\')
- {
- k += 2;
- if (*++s == '\\')
- ++k;
- }
- }
- j += k;
- if (j > 80)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = k;
- }
- fprintf(output_file, "\"\\\"");
- s = symnam[i];
- while (*++s != '"')
- {
- if (*s == '\\')
- {
- fprintf(output_file, "\\\\");
- if (*++s == '\\')
- fprintf(output_file, "\\\\");
- else
- putc(*s, output_file);
- }
- else
- putc(*s, output_file);
- }
- fprintf(output_file, "\\\"\",");
- }
- else if (s[0] == '\'')
- {
- if (s[1] == '"')
- {
- j += 7;
- if (j > 80)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 7;
- }
- fprintf(output_file, "\"'\\\"'\",");
- }
- else
- {
- k = 5;
- while (*++s != '\'')
- {
- ++k;
- if (*s == '\\')
- {
- k += 2;
- if (*++s == '\\')
- ++k;
- }
- }
- j += k;
- if (j > 80)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = k;
- }
- fprintf(output_file, "\"'");
- s = symnam[i];
- while (*++s != '\'')
- {
- if (*s == '\\')
- {
- fprintf(output_file, "\\\\");
- if (*++s == '\\')
- fprintf(output_file, "\\\\");
- else
- putc(*s, output_file);
- }
- else
- putc(*s, output_file);
- }
- fprintf(output_file, "'\",");
- }
- }
- else
- {
- k = strlen(s) + 3;
- j += k;
- if (j > 80)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = k;
- }
- putc('"', output_file);
- do { putc(*s, output_file); } while (*++s);
- fprintf(output_file, "\",");
- }
- }
- else
- {
- j += 2;
- if (j > 80)
- {
- if (!rflag) ++outline;
- putc('\n', output_file);
- j = 2;
- }
- fprintf(output_file, "0,");
- }
- }
- if (!rflag) outline += 2;
- fprintf(output_file, "\n};\n");
- FREE(symnam);
-
- if (!rflag) ++outline;
- fprintf(output_file, "const char * const %srule[] = {\n", symbol_prefix);
- for (i = 2; i < nrules; ++i)
- {
- fprintf(output_file, "\"%s :", symbol_name[rlhs[i]]);
- for (j = rrhs[i]; ritem[j] > 0; ++j)
- {
- s = symbol_name[ritem[j]];
- if (s[0] == '"')
- {
- fprintf(output_file, " \\\"");
- while (*++s != '"')
- {
- if (*s == '\\')
- {
- if (s[1] == '\\')
- fprintf(output_file, "\\\\\\\\");
- else
- fprintf(output_file, "\\\\%c", s[1]);
- ++s;
- }
- else
- putc(*s, output_file);
- }
- fprintf(output_file, "\\\"");
- }
- else if (s[0] == '\'')
- {
- if (s[1] == '"')
- fprintf(output_file, " '\\\"'");
- else if (s[1] == '\\')
- {
- if (s[2] == '\\')
- fprintf(output_file, " '\\\\\\\\");
- else
- fprintf(output_file, " '\\\\%c", s[2]);
- s += 2;
- while (*++s != '\'')
- putc(*s, output_file);
- putc('\'', output_file);
- }
- else
- fprintf(output_file, " '%c'", s[1]);
- }
- else
- fprintf(output_file, " %s", s);
- }
- if (!rflag) ++outline;
- fprintf(output_file, "\",\n");
- }
-
- if (!rflag) outline += 2;
- fprintf(output_file, "};\n#endif\n");
-}
-
-
-static void
-output_stype(void)
-{
- if (!unionized && ntags == 0)
- {
- outline += 3;
- fprintf(code_file, "#ifndef YYSTYPE\ntypedef int YYSTYPE;\n#endif\n");
- }
-}
-
-
-static void
-output_trailing_text(void)
-{
- int c, last;
- FILE *in, *out;
-
- if (line == 0)
- return;
-
- in = input_file;
- out = code_file;
- c = *cptr;
- if (c == '\n')
- {
- ++lineno;
- if ((c = getc(in)) == EOF)
- return;
- if (!lflag)
- {
- ++outline;
- fprintf(out, line_format, lineno, input_file_name);
- }
- if (c == '\n')
- ++outline;
- putc(c, out);
- last = c;
- }
- else
- {
- if (!lflag)
- {
- ++outline;
- fprintf(out, line_format, lineno, input_file_name);
- }
- do { putc(c, out); } while ((c = *++cptr) != '\n');
- ++outline;
- putc('\n', out);
- last = '\n';
- }
-
- while ((c = getc(in)) != EOF)
- {
- if (c == '\n')
- ++outline;
- putc(c, out);
- last = c;
- }
-
- if (last != '\n')
- {
- ++outline;
- putc('\n', out);
- }
- if (!lflag)
- fprintf(out, line_format, ++outline + 1, code_file_name);
-}
-
-
-static void
-output_semantic_actions(void)
-{
- int c, last;
- FILE *out;
-
- fclose(action_file);
- action_file = fopen(action_file_name, "r");
- if (action_file == NULL)
- open_error(action_file_name);
-
- if ((c = getc(action_file)) == EOF)
- return;
-
- out = code_file;
- last = c;
- if (c == '\n')
- ++outline;
- putc(c, out);
- while ((c = getc(action_file)) != EOF)
- {
- if (c == '\n')
- ++outline;
- putc(c, out);
- last = c;
- }
-
- if (last != '\n')
- {
- ++outline;
- putc('\n', out);
- }
-
- if (!lflag)
- fprintf(out, line_format, ++outline + 1, code_file_name);
-}
-
-
-static void
-free_itemsets(void)
-{
- core *cp, *next;
-
- FREE(state_table);
- for (cp = first_state; cp; cp = next)
- {
- next = cp->next;
- FREE(cp);
- }
-}
-
-
-static void
-free_shifts(void)
-{
- shifts *sp, *next;
-
- FREE(shift_table);
- for (sp = first_shift; sp; sp = next)
- {
- next = sp->next;
- FREE(sp);
- }
-}
-
-
-static void
-free_reductions(void)
-{
- reductions *rp, *next;
-
- FREE(reduction_table);
- for (rp = first_reduction; rp; rp = next)
- {
- next = rp->next;
- FREE(rp);
- }
-}
+++ /dev/null
-/* $NetBSD: symtab.c,v 1.12 2009/04/14 09:41:31 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)symtab.c 5.3 (Berkeley) 6/1/90";
-#else
-__RCSID("$NetBSD: symtab.c,v 1.12 2009/04/14 09:41:31 lukem Exp $");
-#endif
-#endif /* not lint */
-
-#include "defs.h"
-
-/* TABLE_SIZE is the number of entries in the symbol table. */
-/* TABLE_SIZE must be a power of two. */
-
-#define TABLE_SIZE 1024
-
-
-bucket *first_symbol;
-bucket *last_symbol;
-
-static bucket **symbol_table;
-
-static int hash(const char *);
-
-
-static int
-hash(const char *name)
-{
- const char *s;
- int c, k;
-
- assert(name && *name);
- s = name;
- k = *s;
- while ((c = *++s) != '\0')
- k = (31*k + c) & (TABLE_SIZE - 1);
-
- return (k);
-}
-
-
-bucket *
-make_bucket(const char *name)
-{
- bucket *bp;
-
- assert(name);
- bp = (bucket *) MALLOC(sizeof(bucket));
- if (bp == 0) no_space();
- bp->link = 0;
- bp->next = 0;
- bp->name = strdup(name);
- if (bp->name == 0) no_space();
- bp->tag = 0;
- bp->value = UNDEFINED;
- bp->index = 0;
- bp->prec = 0;
- bp-> class = UNKNOWN;
- bp->assoc = TOKEN;
-
- return (bp);
-}
-
-
-bucket *
-lookup(char *name)
-{
- bucket *bp, **bpp;
-
- bpp = symbol_table + hash(name);
- bp = *bpp;
-
- while (bp)
- {
- if (strcmp(name, bp->name) == 0) return (bp);
- bpp = &bp->link;
- bp = *bpp;
- }
-
- *bpp = bp = make_bucket(name);
- last_symbol->next = bp;
- last_symbol = bp;
-
- return (bp);
-}
-
-
-void
-create_symbol_table(void)
-{
- int i;
- bucket *bp;
-
- symbol_table = (bucket **) MALLOC(TABLE_SIZE*sizeof(bucket *));
- if (symbol_table == 0) no_space();
- for (i = 0; i < TABLE_SIZE; i++)
- symbol_table[i] = 0;
-
- bp = make_bucket("error");
- bp->index = 1;
- bp->class = TERM;
-
- first_symbol = bp;
- last_symbol = bp;
- symbol_table[hash("error")] = bp;
-}
-
-
-void
-free_symbol_table(void)
-{
- FREE(symbol_table);
- symbol_table = 0;
-}
-
-
-void
-free_symbols(void)
-{
- bucket *p, *q;
-
- for (p = first_symbol; p; p = q)
- {
- q = p->next;
- FREE(p);
- }
-}
+++ /dev/null
-#ifndef lint
-/*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/
-static char rcsid[] = "$NetBSD: error.tab.c,v 1.4 1997/01/09 20:23:30 tls Exp $";
-#endif
-#define YYBYACC 1
-#define YYMAJOR 1
-#define YYMINOR 9
-#define yyclearin (yychar=(-1))
-#define yyerrok (yyerrflag=0)
-#define YYRECOVERING (yyerrflag!=0)
-#define YYPREFIX "yy"
-#define YYERRCODE 256
-short yylhs[] = { -1,
- 0,
-};
-short yylen[] = { 2,
- 1,
-};
-short yydefred[] = { 0,
- 1, 0,
-};
-short yydgoto[] = { 2,
-};
-short yysindex[] = { -256,
- 0, 0,
-};
-short yyrindex[] = { 0,
- 0, 0,
-};
-short yygindex[] = { 0,
-};
-#define YYTABLESIZE 0
-short yytable[] = { 1,
-};
-short yycheck[] = { 256,
-};
-#define YYFINAL 2
-#ifndef YYDEBUG
-#define YYDEBUG 0
-#endif
-#define YYMAXTOKEN 0
-#if YYDEBUG
-char *yyname[] = {
-"end-of-file",
-};
-char *yyrule[] = {
-"$accept : S",
-"S : error",
-};
-#endif
-#ifndef YYSTYPE
-typedef int YYSTYPE;
-#endif
-#ifdef YYSTACKSIZE
-#undef YYMAXDEPTH
-#define YYMAXDEPTH YYSTACKSIZE
-#else
-#ifdef YYMAXDEPTH
-#define YYSTACKSIZE YYMAXDEPTH
-#else
-#define YYSTACKSIZE 500
-#define YYMAXDEPTH 500
-#endif
-#endif
-int yydebug;
-int yynerrs;
-int yyerrflag;
-int yychar;
-short *yyssp;
-YYSTYPE *yyvsp;
-YYSTYPE yyval;
-YYSTYPE yylval;
-short yyss[YYSTACKSIZE];
-YYSTYPE yyvs[YYSTACKSIZE];
-#define yystacksize YYSTACKSIZE
-#line 4 "error.y"
-main(){printf("yyparse() = %d\n",yyparse());}
-yylex(){return-1;}
-yyerror(s)char*s;{printf("%s\n",s);}
-#line 80 "error.tab.c"
-#define YYABORT goto yyabort
-#define YYREJECT goto yyabort
-#define YYACCEPT goto yyaccept
-#define YYERROR goto yyerrlab
-int
-yyparse()
-{
- register int yym, yyn, yystate;
-#if YYDEBUG
- register char *yys;
- extern char *getenv();
-
- if (yys = getenv("YYDEBUG"))
- {
- yyn = *yys;
- if (yyn >= '0' && yyn <= '9')
- yydebug = yyn - '0';
- }
-#endif
-
- yynerrs = 0;
- yyerrflag = 0;
- yychar = (-1);
-
- yyssp = yyss;
- yyvsp = yyvs;
- *yyssp = yystate = 0;
-
-yyloop:
- if (yyn = yydefred[yystate]) goto yyreduce;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, reading %d (%s)\n",
- YYPREFIX, yystate, yychar, yys);
- }
-#endif
- }
- if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, shifting to state %d\n",
- YYPREFIX, yystate, yytable[yyn]);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- yychar = (-1);
- if (yyerrflag > 0) --yyerrflag;
- goto yyloop;
- }
- if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
- yyn = yytable[yyn];
- goto yyreduce;
- }
- if (yyerrflag) goto yyinrecovery;
-#ifdef lint
- goto yynewerror;
-#endif
-yynewerror:
- yyerror("syntax error");
-#ifdef lint
- goto yyerrlab;
-#endif
-yyerrlab:
- ++yynerrs;
-yyinrecovery:
- if (yyerrflag < 3)
- {
- yyerrflag = 3;
- for (;;)
- {
- if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, error recovery shifting\
- to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- goto yyloop;
- }
- else
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: error recovery discarding state %d\n",
- YYPREFIX, *yyssp);
-#endif
- if (yyssp <= yyss) goto yyabort;
- --yyssp;
- --yyvsp;
- }
- }
- }
- else
- {
- if (yychar == 0) goto yyabort;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
- YYPREFIX, yystate, yychar, yys);
- }
-#endif
- yychar = (-1);
- goto yyloop;
- }
-yyreduce:
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, reducing by rule %d (%s)\n",
- YYPREFIX, yystate, yyn, yyrule[yyn]);
-#endif
- yym = yylen[yyn];
- yyval = yyvsp[1-yym];
- switch (yyn)
- {
- }
- yyssp -= yym;
- yystate = *yyssp;
- yyvsp -= yym;
- yym = yylhs[yyn];
- if (yystate == 0 && yym == 0)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: after reduction, shifting from state 0 to\
- state %d\n", YYPREFIX, YYFINAL);
-#endif
- yystate = YYFINAL;
- *++yyssp = YYFINAL;
- *++yyvsp = yyval;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, reading %d (%s)\n",
- YYPREFIX, YYFINAL, yychar, yys);
- }
-#endif
- }
- if (yychar == 0) goto yyaccept;
- goto yyloop;
- }
- if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
- yystate = yytable[yyn];
- else
- yystate = yydgoto[yym];
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: after reduction, shifting from state %d \
-to state %d\n", YYPREFIX, *yyssp, yystate);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate;
- *++yyvsp = yyval;
- goto yyloop;
-yyoverflow:
- yyerror("yacc stack overflow");
-yyabort:
- return (1);
-yyaccept:
- return (0);
-}
+++ /dev/null
-/* $NetBSD: error.tab.h,v 1.2 1998/01/09 08:08:55 perry Exp $ */
-
+++ /dev/null
-%%
-S: error
-%%
-main(){printf("yyparse() = %d\n",yyparse());}
-yylex(){return-1;}
-yyerror(s)char*s;{printf("%s\n",s);}
+++ /dev/null
-/* $NetBSD: warshall.c,v 1.8 2006/05/24 18:01:43 christos Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)warshall.c 5.4 (Berkeley) 5/24/93";
-#else
-__RCSID("$NetBSD: warshall.c,v 1.8 2006/05/24 18:01:43 christos Exp $");
-#endif
-#endif /* not lint */
-
-#include "defs.h"
-
-static void transitive_closure(unsigned *, int);
-
-static void
-transitive_closure(unsigned *R, int n)
-{
- int rowsize;
- unsigned i;
- unsigned *rowj;
- unsigned *rp;
- unsigned *rend;
- unsigned *ccol;
- unsigned *relend;
- unsigned *cword;
- unsigned *rowi;
-
- rowsize = WORDSIZE(n);
- relend = R + n*rowsize;
-
- cword = R;
- i = 0;
- rowi = R;
- while (rowi < relend)
- {
- ccol = cword;
- rowj = R;
-
- while (rowj < relend)
- {
- if (*ccol & (1 << i))
- {
- rp = rowi;
- rend = rowj + rowsize;
- while (rowj < rend)
- *rowj++ |= *rp++;
- }
- else
- {
- rowj += rowsize;
- }
-
- ccol += rowsize;
- }
-
- if (++i >= BITS_PER_WORD)
- {
- i = 0;
- cword++;
- }
-
- rowi += rowsize;
- }
-}
-
-void
-reflexive_transitive_closure(unsigned *R, int n)
-{
- int rowsize;
- unsigned i;
- unsigned *rp;
- unsigned *relend;
-
- transitive_closure(R, n);
-
- rowsize = WORDSIZE(n);
- relend = R + n*rowsize;
-
- i = 0;
- rp = R;
- while (rp < relend)
- {
- *rp |= (1 << i);
- if (++i >= BITS_PER_WORD)
- {
- i = 0;
- rp++;
- }
-
- rp += rowsize;
- }
-}
.include <bsd.own.mk>
-SUBDIR=mdocml file
+SUBDIR=byacc file mdocml
.include <bsd.subdir.mk>
--- /dev/null
+# $NetBSD: Makefile,v 1.1 2009/10/29 00:56:35 christos Exp $
+
+SUBDIR= bin
+
+.include <bsd.subdir.mk>
--- /dev/null
+# $NetBSD: Makefile.inc,v 1.2 2011/09/16 16:41:20 joerg Exp $
+
+WARNS=4
+
+.include <bsd.own.mk>
+
+BINDIR?= /usr/bin
+
+IDIST= ${NETBSDSRCDIR}/external/bsd/byacc/dist
+
+CPPFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR}/../include -I${IDIST}
+CWARNFLAGS+= -Wno-missing-noreturn
+
+.PATH: ${IDIST}
--- /dev/null
+# $NetBSD: Makefile,v 1.3 2011/08/14 13:29:26 christos Exp $
+
+.include "bsd.own.mk"
+
+PROG= yacc
+SRCS= closure.c error.c lalr.c lr0.c main.c mkpar.c output.c reader.c \
+ skeleton.c symtab.c verbose.c warshall.c graph.c
+
+CPPFLAGS+= -DGCC_NORETURN=__dead
+
+COPTS.output.c += -Wno-format-nonliteral
+COPTS.reader.c += -Wno-format-nonliteral
+
+.include <bsd.prog.mk>
-.\" $NetBSD: yacc.1,v 1.13 2003/08/07 11:17:55 agc Exp $
+.\" $NetBSD: yacc.1,v 1.4 2011/09/10 21:38:59 christos Exp $
.\"
.\" Copyright (c) 1989, 1990 The Regents of the University of California.
.\" All rights reserved.
.\" SUCH DAMAGE.
.\"
.\" from: @(#)yacc.1 5.7 (Berkeley) 7/30/91
-.\" $NetBSD: yacc.1,v 1.13 2003/08/07 11:17:55 agc Exp $
+.\" from: Id: yacc.1,v 1.12 2011/09/08 00:40:44 tom Exp
+.\" $NetBSD: yacc.1,v 1.4 2011/09/10 21:38:59 christos Exp $
.\"
-.Dd July 30, 1991
+.Dd September 7, 2011
.Dt YACC 1
.Os
.Sh NAME
parser generator
.Sh SYNOPSIS
.Nm
-.Op Fl dlrtv
+.Op Fl dgilPrtVv
.Op Fl b Ar prefix
.Op Fl o Ar outputfile
.Op Fl p Ar symbol_prefix
reads the grammar specification in the file
.Ar filename
and generates an
-.Tn LR(1)
+.Tn LALR(1)
parser for it.
The parsers consist of a set of
.Tn LALR(1)
option causes the header file
.Pa y.tab.h
to be written.
+It contains #define's for the token identifiers.
+.It Fl g
+The
+.Fl g
+option causes a graphical description of the generated
+.Tn LALR(1)
+parser to be written to the file
+.Pa y.dot
+in graphviz format, ready to be processed by
+.Xr dot 1 .
+.It Fl i
+The
+.Fl i
+option causes a supplementary header file
+.Pa y.tab.i
+to be written.
+It contains extern declarations
+and supplementary #define's as needed to map the conventional
+.Nm
+yy-prefixed names to whatever the
+.Fl p
+option may specify.
+The code file, e.g.,
+.Pa y.tab.c
+is modified to #include this file
+as well as the
+.Pa y.tab.h
+file, enforcing consistent usage of the symbols defined in those files.
+The supplementary header file makes it simpler to separate compilation
+of lex- and yacc-files.
.It Fl l
If the
.Fl l
.Fl o
option specifies an explicit output file name should be used instead
of the default.
+.It Fl P
+The
+.Fl P
+options instructs
+.Nm
+to create a reentrant parser, like
+.Dq %pure-parser
+does.
.It Fl p Ar symbol_prefix
The
.Fl p
option changes the preprocessor directives generated by
.Nm
so that debugging statements will be incorporated in the compiled code.
+.It Fl V
+The
+.Fl V
+option prints the version number to the standard output.
.It Fl v
The
.Fl v
be written to the file
.Pa y.output .
.El
+.Sh EXTENSIONS
+.Nm
+provides some extensions for compatibility with
+.Xr bison 1
+and other implementations
+of
+.Nm :
+.Pp
+.Bl -tag -width "%expect-rr number" -compact
+.It Dv %expect Ar number
+Tell
+.Nm
+the expected number of shift/reduce conflicts.
+That makes it only report the number if it differs.
+.It Dv %expect-rr Ar number
+Tell
+.Nm
+the expected number of reduce/reduce conflicts.
+That makes it only report the number if it differs.
+This is (unlike
+.Xr bison 1 )
+allowable in
+.Tn LALR(1)
+parsers.
+.It Dv %lex-param Ar { Ar argument-declaration Ar }
+By default, the lexer accepts no parameters, e.g.,
+.Fn yylex .
+Use this directive to add parameter declarations for your customized lexer.
+.It Dv %parse-param Ar { Ar argument-declaration Ar }
+By default, the parser accepts no parameters, e.g.,
+.Fn yyparse .
+Use this directive to add parameter declarations for your customized parser.
+.It Dv %pure-parser
+Most variables (other than
+.Fa yydebug
+and
+.Fa yynerrs )
+are allocated on the stack within
+.Fn yyparse ,
+making the parser reasonably reentrant.
+.El
.Sh ENVIRONMENT
The following environment variable is referenced by
.Nm :
--- /dev/null
+#! /bin/sh
+#
+# $NetBSD: byacc2netbsd,v 1.4 2011/10/08 19:28:39 christos Exp $
+#
+# Copyright (c) 2000 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# byacc2netbsd: convert a byacc tree into a
+# netbsd byacc source tree, under src/external/bsd/byacc/dist,
+# based on byacc2netbsd by Bernd Ernesti and changes by Simon Burge
+#
+# Rough instructions for importing new byacc release:
+#
+# $ cd /some/where/temporary
+# $ tar xpfz /new/byacc/release/tar/file
+# $ sh /usr/src/external/bsd/byacc/dist/byacc2netbsd byacc-YYYYMMDD `pwd`
+# $ cd src/external/bsd/byacc/dist
+# $ cvs import -m "Import byacc YYYYMMDD" src/external/bsd/byacc/dist DICKEY byacc-YYYYMMDD
+# $ cd ../../../../../byacc-YYYYMMDD
+# $ run ./configure
+# $ run make
+# check the config file and copy it to /usr/src/external/bsd/byacc/include
+# remove the version from SYSTEM_NAME
+# check the manual page against our copy if there are new options and
+# update
+
+if [ $# -ne 2 ]; then echo "byacc2netbsd src dest"; exit 1; fi
+
+r=$1
+d=$2/src/external/bsd/byacc/dist
+
+case "$d" in
+ /*)
+ ;;
+ *)
+ d=`/bin/pwd`/$d
+ ;;
+esac
+
+case "$r" in
+ /*)
+ ;;
+ *)
+ r=`/bin/pwd`/$r
+ ;;
+esac
+
+echo preparing directory $d
+rm -rf $d
+mkdir -p $d
+
+### Copy the files and directories
+echo copying $r to $d
+cd $r
+pax -rw * $d
+
+### Remove the $'s around RCS tags
+cleantags $d
+
+### Add our NetBSD RCS Id
+find $d -type f -name '*.[chly]' -print | while read c; do
+ sed 1q < $c | grep -q '\$NetBSD' || (
+echo "/* \$NetBSD\$ */" >/tmp/byacc3n$$
+echo "" >>/tmp/byacc3n$$
+cat $c >> /tmp/byacc3n$$
+mv /tmp/byacc3n$$ $c && echo added NetBSD RCS tag to $c
+ )
+done
+
+find $d -type f -name '*.[0-9]' -print | while read m; do
+ sed 1q < $m | grep -q '\$NetBSD' || (
+echo ".\\\" \$NetBSD\$" >/tmp/byacc2m$$
+echo ".\\\"" >>/tmp/byacc2m$$
+cat $m >> /tmp/byacc2m$$
+mv /tmp/byacc2m$$ $m && echo added NetBSD RCS tag to $m
+ )
+done
+
+find $d -type f -name '*.texi' -print | while read t; do
+ sed "2 s/^/@c \$NetBSD\$\\
+/" < $t > /tmp/byacc4t$$
+ mv /tmp/byacc4t$$ $t && echo added NetBSD RCS tag to $t
+done
+
+echo done
+
+### Clean up any CVS directories that might be around.
+echo "cleaning up CVS residue."
+(
+ cd $d
+ find . -type d -name "CVS" -print | xargs rm -r
+)
+echo done
+
+### Fixing file and directory permissions.
+echo "Fixing file/directory permissions."
+(
+ cd $d
+ find . -type f -print | xargs chmod u+rw,go+r
+ find . -type d -print | xargs chmod u+rwx,go+rx
+)
+echo done
+
+exit 0
--- /dev/null
+-- Id: AUTHORS,v 1.1 2010/06/06 20:31:51 tom Exp
+-- vile:txtmode
+-- This file is used by a script that collects contributor information and
+-- resolves nicknames vs fullnames.
+dickey Thomas Dickey
+schmitz Sylvain Schmitz
+unknown Robert Corbett
--- /dev/null
+2011-09-08 Thomas E. Dickey <tom@invisible-island.net>
+
+ * package/debian/changelog, package/byacc.spec, VERSION: bump
+
+ * output.c:
+ fix some more interaction between -i and -d flags to ensure YYERRCODE
+ and YYSTYPE are declared, tested with cproto.
+
+2011-09-07 Thomas E. Dickey <tom@invisible-island.net>
+
+ * yacc.1: document "-i" option.
+
+ * package/debian/changelog, package/byacc.spec, VERSION: bump
+
+ * output.c: fix an interaction between -i and -d
+
+ * test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c:
+ regen - changes for "-i" option move the global/impure variables near the
+ macros that may add a prefix, etc.
+
+ * skeleton.c, output.c, defs.h: changes to support "-i" option.
+
+2011-09-06 Thomas E. Dickey <tom@invisible-island.net>
+
+ * reader.c: pass explicit file-pointer to write_section()
+
+ * main.c:
+ add "-i" option, to generate interface-file (suggested by Denis M. Wilson)
+
+2011-09-05 Thomas E. Dickey <tom@invisible-island.net>
+
+ * configure: regen
+
+ * aclocal.m4:
+ resync with my-autoconf: CF_ANSI_CC_CHECK (check for $CFLAGS in $CC)
+ and CF_XOPEN_SOURCE (update aix, cygwin and netbsd checks)
+
+ * defs.h, error.c, reader.c:
+ add check for missing "}" on %parse-param and %lex-param lines (report by Denis M Wilson)
+
+2011-04-01 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.sub: 2011-04-01
+
+2011-02-02 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.guess: 2011-01-01
+
+2010-12-29 Thomas E. Dickey <tom@invisible-island.net>
+
+ * defs.h, skeleton.c:
+ add const qualifier to skeleton data, per NetBSD changes (report by Christos Zoulas)
+
+ * defs.h:
+ mark all of the error-functions as non-returning (report by Christos Zoulas)
+
+ * test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c:
+ regen
+
+ * skeleton.c:
+ use only realloc() rather than realloc+malloc, agree that systems needing this
+ are very rare (prompted by NetBSD change).
+
+ * test/ftp.tab.c: regen
+
+2010-12-29 Christos.Zoulas
+
+ * test/ftp.y:
+ improve example, which was stuck in 19XX and assumed file sizes were longs.
+
+2010-12-29 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c:
+ regen
+
+ * test/pure_error.y, test/pure_calc.y, test/ftp.y, test/error.y, test/code_error.y, test/code_calc.y, test/calc.y, test/calc3.y, test/calc2.y, test/calc1.y:
+ use byacc's YYLEX_DECL/YYERROR_DECL symbols to prototype yylex/yyerror
+
+ * skeleton.c:
+ remove explicit prototype for yylex() via YYLEX_DECL() macro, since that
+ would prevent declaring yylex() static (request by Christos Zoulas).
+
+ * test/calc2.tab.c, test/calc3.tab.c: regen
+
+2010-12-29 Christos.Zoulas
+
+ * output.c: correct definition for YYERROR_DECL()
+
+2010-12-29 Thomas E. Dickey <tom@invisible-island.net>
+
+ * package/debian/changelog, package/byacc.spec, VERSION: bump
+
+2010-12-26 Thomas E. Dickey <tom@invisible-island.net>
+
+ * defs.h, main.c:
+ change return-type of allocate() to avoid warnings of alignment problems
+
+ * main.c: Solaris declares chmod() in <sys/stat.h>
+
+ * configure: regen
+
+ * main.c: ifdef'd use of fcntl.h
+
+ * configure.in: add configure checks for fcntl.h, atexit and mkstemp
+
+ * main.c: for cases where mkstemp() is not available, use tempnam/open
+
+ * aclocal.m4: add CF_MKSTEMP
+
+ * aclocal.m4:
+ improve quoting, deprecate ${name-value} in favor of standard ${name:-value}
+
+2010-12-25 Thomas E. Dickey <tom@invisible-island.net>
+
+ * main.c:
+ start revising use of tmpfile(), to make this work with MinGW. Start by
+ implementing a mkstemp() alternative - noting that mkstemp() also is broken
+ for MinGW.
+
+ * package/debian/changelog, package/byacc.spec, VERSION: bump
+
+2010-11-27 Thomas E. Dickey <tom@invisible-island.net>
+
+ * package/byacc.spec, package/debian/changelog, VERSION: bump
+
+ * test/calc2.tab.c, test/calc3.tab.c: regen
+
+ * output.c:
+ corrected use of %parse-param value in yyerror(); it doesn't use &yylval
+ (report by Clifford Yapp)
+
+2010-11-26 Thomas E. Dickey <tom@invisible-island.net>
+
+ * skeleton.c: typo
+
+ * output.c:
+ correct line-numbering when "-r" option is used; the 'outline' variable
+ should only be incremented when writing to the code-file.
+
+ * test/code_calc.code.c, test/code_error.code.c: regen
+
+ * yacc.1: bump date
+
+ * yacc.1: comment on -b option vs -r
+
+ * test/calc2.tab.c, test/calc2.y, test/calc3.tab.c, test/calc3.y, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c:
+ regen
+
+ * output.c:
+ improve on YYERROR_DECL(), adding dummy params which can be used for the
+ actual function declaration. Also add YYERROR_CALL(). The two macros
+ simplify maintaining sets of grammars which may/may not be pure.
+
+ * test/calc1.y, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c:
+ regen
+
+ * output.c: generate yyerror() calls in output.c
+ This is for compatibility with bison, which passes the yylval to yyerror
+ when the %parse-param feature is used.
+
+ * skeleton.c, defs.h: generate yyerror() calls in output.c
+
+ * output.c: simplified a little, using putc_code() and putl_code()
+
+ * test/calc1.tab.h: regen
+
+ * reader.c:
+ improve ifdef for YYSTYPE union declaration (report by Clifford Yapp)
+
+ * reader.c:
+ accept underscore as a replacement for dash in command names, e.g.,
+ "%pure_parser" vs "%pure-parser".
+
+ * test/calc1.tab.c: regen
+
+ * output.c, reader.c:
+ also ifdef YYSTYPE declaration in the generated code (report by Clifford Yapp)
+
+ * package/debian/changelog, package/byacc.spec, VERSION: bump
+
+2010-11-24 Thomas E. Dickey <tom@invisible-island.net>
+
+ * main.c, defs.h, symtab.c, error.c: reduce global variables
+
+ * package/debian/changelog, package/byacc.spec, VERSION: bump
+
+ * reader.c:
+ amend fix for Redhat #112617 to still call default_action_warning() for
+ empty rules (report by Bruce Cran).
+
+2010-11-22 Thomas E. Dickey <tom@invisible-island.net>
+
+ * output.c:
+ add ifdef to guard against redefinition of YYSTYPE union (request by Clifford Yapp).
+
+ * test/calc1.tab.c: regen
+
+ * test/calc1.y: cleanup compiler warnings
+
+ * test/grammar.y: add "%expect"
+
+ * test/calc1.tab.h: regen
+
+ * test/calc1.output, test/calc1.tab.c, test/calc1.tab.h: RCS_BASE
+
+ * test/calc2.tab.c, test/calc3.tab.c: regen
+
+ * test/calc1.y:
+ advanced example from Steve Johnson's paper, uses unions
+
+ * test/calc3.y, test/calc2.y: init 'base', so examples can run
+
+ * test/ftp.tab.c, test/ftp.y: tweaks to compile with g++
+
+ * output.c: compensate for fix in reader.c
+
+ * reader.c:
+ add/use putc_both() and puts_both(), incidentally fixing a place where
+ a union copied to the union_file may be missing the end of the last line.
+
+ * package/debian/changelog, package/byacc.spec, VERSION: bump
+
+2010-09-28 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.guess: 2010-09-24
+
+2010-09-10 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.sub: 2010-09-11
+
+2010-06-10 Thomas E. Dickey <tom@invisible-island.net>
+
+ * yacc.1, package/debian/changelog, package/byacc.spec, VERSION:
+ bump to 2010/06/10
+
+2010-06-09 Thomas E. Dickey <tom@invisible-island.net>
+
+ * reader.c: free declarations in leak-testing code.
+
+ * main.c: close code_file if -r option used, for leak-testing
+
+ * defs.h, reader.c:
+ improve %lex-param / %parse-param implementation by allowing for arrays to
+ be passed as parameters, e.g., "int regs[26]".
+
+ * test/calc3.tab.c, test/calc3.y, test/calc3.output, test/calc3.tab.h, test/calc2.tab.c, test/calc2.y, test/calc2.tab.h, test/calc2.output:
+ RCS_BASE
+
+ * output.c:
+ improve %lex-param / %parse-param implementation by allowing for arrays to
+ be passed as parameters, e.g., "int regs[26]".
+
+ * test/calc.tab.c, test/calc.y:
+ test-cases and reference files for %lex-param / %parse-param
+
+ * makefile.in: add docs-rule, for html/pdf/txt form of manpage
+
+ * configure: regen
+
+ * aclocal.m4: add CF_XOPEN_SOURCE, etc.
+
+ * configure.in:
+ use CF_XOPEN_SOURCE check to ensure that strdup is in scope, e.g., for c89
+
+ * test/ftp.tab.c, test/ftp.y, reader.c, symtab.c, verbose.c, lr0.c, main.c, mkpar.c, output.c, defs.h, closure.c:
+ fix warnings from clang --analyze
+
+2010-06-08 Thomas E. Dickey <tom@invisible-island.net>
+
+ * output.c: fix to build with c89, etc.
+
+ * reader.c: gcc warning
+
+ * test/ftp.tab.c, test/ftp.y, test/calc.tab.c, test/code_calc.code.c, test/code_error.code.c, test/code_error.y, test/code_calc.y, test/calc.y, test/pure_error.tab.c, test/error.tab.c, test/error.y, test/pure_error.y, test/pure_calc.tab.c, test/pure_calc.y:
+ modified test-cases to allow them to compile, to validate pure-parser changes.
+ updated reference files to match.
+
+ * output.c:
+ move call for output_stype() earlier since it is used in pure-parser declarations
+
+ * test/grammar.tab.c, test/grammar.y:
+ modified test-cases to allow them to compile, to validate pure-parser changes.
+ updated reference files to match.
+
+ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
+ regen
+
+ * yacc.1: document %lex-param and %parse-param
+
+ * test/run_lint.sh, test/run_make.sh: RCS_BASE
+
+ * test/run_test.sh:
+ further modify to allow build-directory to be in a different location by
+ passing this directory's location as a parameter to the script.
+
+ * makefile.in:
+ add check_make and check_lint rules to help validate the generated files
+ in the test-directory
+
+2010-06-07 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/pure_calc.tab.c, test/pure_error.tab.c: RCS_BASE
+
+ * test/run_test.sh:
+ provide for testing -r and -P options by checking if the ".y" filename
+ begins with "code_" or "pure_", respectively.
+
+ * test/code_error.code.c, test/code_error.tab.c, test/code_error.tab.h, test/code_calc.code.c, test/code_calc.tab.c, test/code_calc.tab.h, test/pure_calc.output, test/pure_calc.tab.h, test/pure_error.output, test/pure_error.tab.h, test/code_calc.output, test/code_error.output:
+ RCS_BASE
+
+ * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c: regen
+
+ * test/run_test.sh:
+ changes to support running "make check" in a separate build-tree
+
+ * main.c: add "-P" to usage message
+
+ * reader.c: use UCH() macro to hide casts.
+
+2010-06-07 Andres.Mejia
+
+ * main.c, output.c, reader.c, defs.h, skeleton.c:
+ Fix the output order of the generated parse code file. This allows for
+ the use of YYPARSE_PARAM, by having the output that checks for
+ YYPARSE_PARAM to be defined come after the C code block in the
+ definitions section of a yacc file.
+
+ Implement support for YYLEX_PARAM, similar to bison. This is useful for
+ support for building reentrant lexers with flex.
+
+ Fix a compatibility issue with bison's pure-parser option. Bison
+ defines yylex as sending at least one parameter, &yylval, as the first
+ parameter and doesn't seem to have an easy way to remove that parameter.
+ This on the other hand is rather convenient to support saving to yylval
+ from flex when building reentrant lexers and parsers.
+
+ Add support for the %parse-param and %lex-param directives used in
+ bison. This change bears some similarity to NetBSD's changes to byacc
+ at http://www.mail-archive.com/source-changes-full@netbsd.org/msg08143.html
+
+ Bison allows for POSIX yacc emulation via a yacc directive in the yacc
+ file, and also via a command line switch. Implement this feature as a
+ no-op for byacc, since byacc is designed to be POSIX yacc compatible
+ anyway. This allows for better compatibility with yacc sources written
+ for bison.
+
+2010-06-07 Thomas E. Dickey <tom@invisible-island.net>
+
+ * VERSION: bump to 2010/06/07
+
+2010-06-06 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/calc.tab.c, configure: regen
+
+ * skeleton.c:
+ move #include's down into the generated code, to allow user-defined code
+ to override feature definitions, particularly with stdlib.h (request by
+ Marcus Kool).
+
+ * lr0.c, error.c, reader.c, defs.h:
+ strict gcc 3.4.6 warnings on 64-bit platform
+
+ * aclocal.m4, configure.in: add check for lint
+
+ * makefile.in: add lint rule
+
+ * defs.h, closure.c, lr0.c, warshall.c, main.c:
+ fix gcc warnings, mostly for 64-bit platform
+
+ * aclocal.m4:
+ add macros for checking ctags/etags, e.g., to work with NetBSD pkgsrc
+
+ * makefile.in: add etags/TAGS if available
+
+ * configure.in: add configure check for actual ctags and etags programs
+
+ * package/debian/copyright: add copyright notices for non-PD files
+
+ * package/debian/changelog:
+ incorporated scripts in upstream to use for test-builds
+
+ * makefile.in: drop mkdirs.sh, just use "mkdir -p"
+
+ * AUTHORS: nicknames for some contributors (see CHANGES for details)
+
+ * package/byacc.spec: RPM file for byacc
+
+ * VERSION: bump to 2010/06/06
+
+ * aclocal.m4: add copyright notice, from "my-autoconf" macros
+ http://invisible-island.net/autoconf/autoconf.html
+
+ * package/RCS, package/debian/RCS, package/debian/source/RCS, package/pkgsrc/RCS:
+ PERMIT FILE
+
+ * aclocal.m4: resync with my-autoconf. summary of changes:
+ a) CF_ADD_CFLAGS, etc., improve quoting of ifelse() parameter
+ b) CF_DISABLE_ECHO, change indent-convention for substituted makefile
+ c) CF_GCC_VERSION, ignore stderr
+ d) CF_GCC_WARNINGS, adjust options to work with c89 wrapper of gcc
+
+2010-04-20 Thomas E. Dickey <tom@invisible-island.net>
+
+ * package/debian/changelog, package/debian/compat, package/debian/control, package/debian/copyright, package/debian/docs, package/debian/postinst, package/debian/prerm, package/debian/rules, package/debian/watch:
+ scripts from Debian package
+
+2010-02-16 Thomas E. Dickey <tom@invisible-island.net>
+
+ * yacc.1: document -P and bison-extensions
+
+ * test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c:
+ regen
+
+ * output.c: implement %pure-parser
+
+ * skeleton.c:
+ implement %pure-parser, like bison. To help with this, changed the stack
+ variables, putting them into a struct.
+
+ * reader.c: implement %pure-parser
+
+ * defs.h: modified skeleton to support %pure-parser feature
+
+ * main.c: add -P option to set %pure-parser
+
+ * output.c:
+ make -r and -p options work together. The -r option splits the generated
+ parser into code/table files; for this case we cannot use static data.
+ Also, we have to repeat the #define's used for prefix (-p) as well as the
+ redeclaration of yyparse(). Finally, allow any of the prefixed names to
+ be overridden, e.g., by passing a -D option to the compiler. Make that
+ a little more readable by putting a blank line before each chunk.
+
+ * defs.h: add definitions for %pure-parser
+
+ * skeleton.c:
+ put blank line before/after the redeclaration of yyparse()
+
+ * output.c: allow for other program redefining yylex()
+
+ * skeleton.c:
+ split-off xdecls[] array, to move declaration of yyparse() after #define's
+
+ * defs.h: split-out xdecls[]
+
+ * VERSION: bump
+
+ * configure: regen
+
+ * aclocal.m4: add CF_REMOVE_DEFINE, needed by CF_ADD_CFLAGS
+
+ * aclocal.m4:
+ resync with my-autoconf CF_ADD_CFLAGS and CF_DISABLE_ECHO changes.
+
+2010-02-16 Ostap.Cherkashi
+
+ * skeleton.c: fix a memory leak in the generated skeleton
+
+2010-01-01 Thomas E. Dickey <tom@invisible-island.net>
+
+ * package/debian/source/format: scripts from Debian package
+
+2009-12-31 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.guess: 2009-12-30
+
+ * config.sub: 2009-12-31
+
+2009-10-27 Thomas E. Dickey <tom@invisible-island.net>
+
+ * VERSION: 20091027
+
+ * output.c, mkpar.c, defs.h, lalr.c, closure.c, graph.c, lr0.c, verbose.c, main.c, reader.c:
+ strict compiler warnings
+
+2009-10-26 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c:
+ resync
+
+ * main.c, defs.h: introduce some typedefs for portability, etc.
+
+ * makefile.in:
+ don't remove "*.log" in mostlyclean rule since it interferes with regression
+ script.
+
+ * configure: regen
+
+ * aclocal.m4: resync with my-autoconf
+
+2009-08-25 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.guess, config.sub: 2009-08-19
+
+2009-02-21 Thomas E. Dickey <tom@invisible-island.net>
+
+ * VERSION: bump
+
+ * output.c: restore "yylval" symbol, omitted in cleanup on 2008/8/25
+
+2008-12-26 Thomas E. Dickey <tom@invisible-island.net>
+
+ * configure: regen with autoconf-2.52 (patched)
+
+2008-12-25 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c:
+ regenerated
+
+2008-12-24 Thomas E. Dickey <tom@invisible-island.net>
+
+ * VERSION: bump
+
+ * skeleton.c:
+ remove ifdef-lint from goto yyerrlab, to quiet gcc warning
+
+2008-11-26 Thomas E. Dickey <tom@invisible-island.net>
+
+ * verbose.c, main.c, defs.h, mkpar.c, reader.c:
+ completed implementation of "%expect" (report by Perry E. Metzger).
+ add "%expect-rr", which is (unlike bison) allowable in LALR parsers.
+
+2008-11-24 Thomas E. Dickey <tom@invisible-island.net>
+
+ * closure.c, defs.h, error.c, graph.c, lalr.c, lr0.c, main.c, mkpar.c, output.c, reader.c, skeleton.c, symtab.c, verbose.c, warshall.c:
+ change indent-style (request by Perry E. Metzger)
+
+2008-08-27 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
+ better implementation of YYPARSE_PARAM, using YYPARSE_DECL() macro
+
+ * VERSION: bump
+
+ * skeleton.c:
+ better implementation of YYPARSE_PARAM, using YYPARSE_DECL() macro
+
+ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, skeleton.c:
+ change YYRECOVERING to YYRECOVERING(), for compatibility with other yacc's.
+
+ * configure: regen'd
+
+ * configure.in: add -Wwrite-strings to warnings
+
+ * test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/error.tab.c:
+ add YYPARSE_PARAM and YYPARSE_PARAM_TYPE
+
+ * skeleton.c:
+ add YYPARSE_PARAM (bison) and YYPARSE_PARAM_TYPE (FreeBSD) features.
+
+ * main.c, defs.h, output.c, skeleton.c, symtab.c, error.c, reader.c:
+ fixes for gcc -Wwrite-strings
+
+ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
+ generate the tables as static-const (this is an interface change)
+
+ * output.c: realign columns in start_table()
+
+ * output.c:
+ generate the tables as static-const (this is an interface change)
+
+ * output.c: reorder functions to eliminate forward-references
+
+ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
+ remove 'register' keywords
+
+2008-08-26 Thomas E. Dickey <tom@invisible-island.net>
+
+ * warshall.c, verbose.c, symtab.c, skeleton.c, reader.c, output.c, mkpar.c, main.c, lr0.c, lalr.c, graph.c, error.c, closure.c:
+ remove 'register' keywords
+
+2008-08-25 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/ftp.tab.c: regen'd
+
+ * reader.c:
+ improve the left-curly fix by testing after blanks, to avoid having a
+ " {" at the beginning of a line.
+
+ * test/error.tab.c, test/grammar.tab.c: regen'd
+
+ * output.c:
+ move the remaining newline-counting into write_XXX functions.
+
+ * test/calc.tab.c: regen'd
+
+ * output.c:
+ simplify part of the output_file formatting using new functions, e.g.,
+ start_int_table(), output_newline().
+
+ * reader.c:
+ modify copy_action() to indent the first character, it if is is left-curly
+ brace. That makes the output look more like the original, as well as makes
+ it simpler to edit (not confuse editors which look for a left-curly in the
+ first column as if it were the beginning of a function).
+
+ * skeleton.c: minor fixes to avoid gcc -Wconversion warnings
+
+ * output.c: align the #define's produced for "-p" option
+
+ * test/run_test.sh: use the "-p" option for better coverage.
+
+ * output.c: simplify output_prefix() with new define_prefixed()
+
+ * skeleton.c: include string.h, for memset()
+ change stack size to unsigned to fix gcc -Wconversion warnings.
+
+ * VERSION: bump to 2008/8/25
+
+ * makefile.in: add dependency on VERSION file.
+
+2008-08-24 Thomas E. Dickey <tom@invisible-island.net>
+
+ * VERSION: bump
+
+ * lalr.c: improved memory-leak checking by freeing data in includes[]
+
+ * test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c:
+ update to match skeleton-change
+
+ * configure: regen'd
+
+ * skeleton.c: Add fix for stack discussed
+ http://undeadly.org/cgi?action=article&sid=20080708155228
+ and applied
+ http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/yacc/skeleton.c.diff?r1=1.28&r2=1.29
+
+ * aclocal.m4: resync with my-autoconf (no major changes)
+
+2008-07-24 Thomas E. Dickey <tom@invisible-island.net>
+
+ * package/pkgsrc/Makefile, package/pkgsrc/distinfo:
+ scripts from NetBSD pkgsrc, for test-builds
+
+2008-03-14 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.sub: update to 2008-03-08
+
+ * config.guess: update to 2008-03-12
+
+2007-05-09 Thomas E. Dickey <tom@invisible-island.net>
+
+ * main.c: close graph, verbose files if opened, on exit.
+
+ * main.c:
+ audit memory leaks - valgrind reported some memory still in use on exit.
+
+ * lalr.c, output.c, reader.c, mkpar.c, lr0.c:
+ add hook for auditing memory leaks
+
+ * defs.h: add hooks for auditing memory leaks
+
+ * configure: regen'd
+
+ * configure.in:
+ use CF_DISABLE_LEAKS, which combines --disable-leaks, --with-valgrind,
+ --with-dbmalloc and --with-dmalloc
+
+ * aclocal.m4: add CF_DISABLE_LEAKS and CF_WITH_VALGRIND
+
+ * aclocal.m4: improve version-checking in CF_GCC_VERSION
+ rework dbmalloc/dmalloc options using CF_NO_LEAKS_OPTION macro
+
+ * VERSION: 2007/5/9
+
+ * main.c: file_prefix did not always have a trailing null.
+
+2007-03-25 Thomas E. Dickey <tom@invisible-island.net>
+
+ * mkdirs.sh: improved version for "make -j"
+
+2006-12-22 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.guess: 2006/12/22
+
+2006-12-08 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.sub: 2006/12/08
+
+2005-08-13 Thomas E. Dickey <tom@invisible-island.net>
+
+ * main.c: add -V to usage message
+
+ * makefile.in: remove -t option from ctags
+
+ * VERSION: 2005/8/13
+
+2005-08-13 schmitz
+
+ * main.c: Sylvain Schmitz:
+ modify the '-o' option to work like bison's, which sets the file-prefix.
+
+2005-08-13 Matt.Kraai
+
+ * output.c:
+ Debian #322858 (don't close union_file, which contained data).
+ This feature is used in groff.
+
+2005-08-13 Thomas E. Dickey <tom@invisible-island.net>
+
+ * configure: regenerated
+
+ * aclocal.m4: improve checks for Intel compiler warnings
+
+2005-06-25 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.sub: 2005/6/2
+
+ * config.guess: 2005/5/27
+
+2005-05-05 Thomas E. Dickey <tom@invisible-island.net>
+
+ * defs.h: add a fallback for GCC_UNUSED
+
+2005-05-04 Thomas E. Dickey <tom@invisible-island.net>
+
+ * makefile.in: add "." to include-path to pickup config.h
+
+ * reader.c:
+ apply fix suggested by Steve Dum for end_rule() in Redhat Bugzilla #112617.
+
+ * output.c:
+ correct a limit check in pack_vector() - report/analysis by William Evans
+
+ * main.c:
+ exit after printing version. Otherwise "yacc -V" will exit with an erro
+ after printing the usage message.
+
+ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
+ regenerated after skeleton-changes
+
+ * skeleton.c: replace a few -1's with YYEMPTY
+
+ * skeleton.c:
+ delete yynewerror (no one uses it any more, and it just makes compiler warnings)
+
+ * skeleton.c: adapt yygrowstack() and related definitions from FreeBSD
+
+ * test/run_test.sh:
+ filter out lines with YYPATCH, since that will change with each update
+
+ * yacc.1: add -V option
+
+ * main.c: add -V option to print the version.
+ simplify option-parsing by moving the duplicate logic for setting flags into
+ new function setflag().
+
+ * skeleton.c:
+ move the actual definition of YYMAJOR and YYMINOR to defs.h (as numbers).
+ add YYPATCH here so it can be tested by applications.
+
+ * defs.h:
+ add macros to define VERSION in terms of the (numeric) YYMAJOR, YYMINOR and
+ YYPATCH symbols.
+
+ * lalr.c, lr0.c, mkpar.c, defs.h, closure.c, warshall.c, output.c, verbose.c, graph.c, reader.c, main.c, symtab.c:
+ reduce externs by making static the procedures that are not referenced outside
+ the module in which they are defined.
+
+ * makefile.in:
+ the VERSION file holds the patch-date. Define YYPATCH, so this will be
+ compiled into the skeleton.
+
+ * VERSION: patch-level for byacc
+
+ * main.c:
+ add "-o" to usage message. It is too long for a single line; rewrite usage()
+ to show one option per line.
+
+2005-05-03 Thomas E. Dickey <tom@invisible-island.net>
+
+ * main.c: add -o option, to work with scripts that assume bison.
+ simplify create_file_names() with a macro.
+ simplify done() with a macro.
+ adapt fix from FreeBSD for signal race, e.g., if done() is interrupted by
+ onintr(), do not flush output via exit(), but use _exit() instead.
+
+ * defs.h: remove unnecessary externs for main.c
+
+ * yacc.1: add -o option
+
+ * graph.c: remove unused parameter
+
+ * mkpar.c, defs.h, reader.c:
+ add support for "%expect", a bison feature from FreeBSD sources
+
+ * lr0.c, reader.c, main.c, skeleton.c, graph.c, symtab.c, closure.c, mkpar.c, lalr.c, error.c, warshall.c, verbose.c, output.c:
+ indent'd
+
+ * configure: regenerated for 2005/5/5
+
+ * aclocal.m4: miscellaneous updates (adds CF_INTEL_COMPILER)
+
+2005-04-27 schmitz
+
+ * defs.h, graph.c, lr0.c, main.c, makefile.in, reader.c, yacc.1:
+ Sylvain Schmitz <schmitz@i3s.unice.fr>:
+ add graphical output of the LALR(1) automaton for graphviz,
+ associated with command-line option `-g'
+
+2005-04-16 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.sub: 2005/2/10
+
+ * config.guess: 2005/3/24
+
+2005-04-13 Thomas E. Dickey <tom@invisible-island.net>
+
+ * package/pkgsrc/PLIST: scripts from NetBSD pkgsrc, for test-builds
+
+2005-03-21 Thomas E. Dickey <tom@invisible-island.net>
+
+ * package/pkgsrc/DESCR: scripts from NetBSD pkgsrc, for test-builds
+
+2004-03-28 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/calc.tab.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c:
+ updates due to adding yyparse() prototype
+
+ * configure: RCS_BASE
+
+ * configure.in:
+ add AC_ARG_PROGRAM to make --program-prefix, etc., work.
+
+ * makefile.in: first cut of script to support --program-prefix
+
+ * configure.in:
+ reorder AC_INIT/AC_CONFIG_HEADER to make this "work" with autoconf 2.52
+
+ * makefile.in: modify so DESTDIR works
+
+ * makefile.in: use EXEEXT and OBJEXT
+
+ * configure.in: use CF_PROG_EXT
+ generate a config.h
+
+ * defs.h: make this use the generated config.h
+
+ * skeleton.c: add a forward-reference for yyparse()
+
+ * aclocal.m4: add CF_CHECK_CACHE, needed for CF_PROG_EXT
+
+ * yacc.1: remove the discussion of TMPDIR since it is obsolete
+
+ * skeleton.c: fix a couple of minor compiler-warnings in the skeleton
+
+ * defs.h: remove action_file_name, etc., since we use tmpfile() now.
+
+ * main.c:
+ use tmpfile() for opening the working files. This quiets a warning
+ advising the use of mkstemp().
+
+ * output.c:
+ Do not close temporary-files here, since they are opened with tmpfile().
+ Just rewind them, and they're ready to read back the data stored in them.
+
+ * test/grammar.output, test/grammar.tab.c, test/grammar.tab.h: RCS_BASE
+
+ * makefile.in: turn on "make check" rule
+
+ * test/calc.output, test/run_test.sh, test/calc.tab.h: RCS_BASE
+
+ * test/ftp.tab.c: yyparse() is now yyparse(void)
+
+ * test/calc.tab.c: RCS_BASE
+
+ * test/error.tab.c: yyparse() is now yyparse(void)
+
+ * test/README: RCS_BASE
+
+ * yacc.1: various typography fixes prompted by Debian #100947
+
+ * aclocal.m4, makefile.in, configure.in: RCS_BASE
+
+ * README: updated to note that this is not the original
+
+2004-03-24 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/grammar.y: RCS_BASE
+
+2004-02-23 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.sub: RCS_BASE
+
+2004-02-17 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config.guess: RCS_BASE
+
+2003-11-29 Thomas E. Dickey <tom@invisible-island.net>
+
+ * install-sh: improved quoting
+
+2002-06-29 Thomas E. Dickey <tom@invisible-island.net>
+
+ * mkdirs.sh:
+ don't use character range, since some locales don't work as expected
+
+2001-06-22 Thomas E. Dickey <tom@invisible-island.net>
+
+ * install-sh: RCS_BASE
+
+2000-11-20 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/calc.y: RCS_BASE
+
+ * test/code_calc.y, test/pure_calc.y: copy of calc.y
+
+ * vmsbuild.com: original version
+
+2000-02-23 Thomas E. Dickey <dickey@invisible-island.net>
+
+ * test/RCS, RCS: PERMIT FILE
+
+2000-02-14 Thomas E. Dickey <tom@invisible-island.net>
+
+ * main.c: fix for VMS port - making pathname for temp-file
+
+ * descrip.mms: original version
+
+2000-02-13 Thomas E. Dickey <tom@invisible-island.net>
+
+ * defs.h, verbose.c, reader.c, main.c, skeleton.c, warshall.c, symtab.c, closure.c, mkpar.c, lalr.c, lr0.c, output.c, error.c:
+ ansify
+
+1999-11-30 Thomas E. Dickey <tom@invisible-island.net>
+
+ * mkdirs.sh: RCS_BASE
+
+1995-01-01 Thomas E. Dickey <tom@invisible-island.net>
+
+ * config_h.in: RCS_BASE
+
+1993-12-23 unknown
+
+ * README.DOS, main.c: MSDOS-port
+
+1993-12-22 unknown
+
+ * reader.c, defs.h: MSDOS-port
+
+1993-03-02 unknown
+
+ * README: original version
+
+1993-02-22 unknown
+
+ * test/ftp.output, test/ftp.tab.c, test/ftp.tab.h, test/error.output, test/error.tab.c, test/error.tab.h:
+ RCS_BASE
+
+ * skeleton.c, warshall.c, main.c, output.c, reader.c, closure.c, NOTES:
+ original version
+
+1992-10-12 unknown
+
+ * yacc.1: original version
+
+1992-10-11 unknown
+
+ * defs.h: original version
+
+1991-01-20 unknown
+
+ * mkpar.c, verbose.c: original version
+
+1991-01-14 unknown
+
+ * lr0.c, Makefile, Makefile.old: original version
+
+1990-07-16 unknown
+
+ * NEW_FEATURES: original version
+
+1990-06-03 unknown
+
+ * ACKNOWLEDGEMENTS: original version
+
+1990-02-05 unknown
+
+ * symtab.c, lalr.c, error.c: original version
+
+1990-01-16 Thomas E. Dickey <tom@invisible-island.net>
+
+ * test/code_error.y, test/pure_error.y: RCS_BASE
+
+1990-01-16 unknown
+
+ * test/error.y: RCS_BASE
+
+1989-11-22 unknown
+
+ * NO_WARRANTY: original version
+
+1989-09-23 unknown
+
+ * test/ftp.y: RCS_BASE
+
-$NetBSD: NOTES,v 1.3 1997/10/20 03:41:15 lukem Exp $
+$NetBSD: NOTES,v 1.2 2009/10/29 00:56:19 christos Exp $
Berkeley Yacc reflects its origins. The reason so many routines
use exactly six register variables is that Berkeley Yacc was
--- /dev/null
+ Berkeley Yacc is distributed with no warranty whatever. The author
+and any other contributors take no responsibility for the consequences of
+its use.
+-- Id: README,v 1.2 2004/03/28 17:24:53 tom Exp
+
+The original README is below. I've updated this version of Berkeley Yacc
+to make it ANSI C compliant - Thomas Dickey
+
+-------------------------------------------------------------------------------
Berkeley Yacc is an LALR(1) parser generator. Berkeley Yacc has been made
as compatible as possible with AT&T Yacc. Berkeley Yacc can accept any input
specification that conforms to the AT&T Yacc documentation. Specifications
--- /dev/null
+dnl Id: aclocal.m4,v 1.18 2011/09/05 23:45:06 tom Exp
+dnl Macros for byacc configure script (Thomas E. Dickey)
+dnl ---------------------------------------------------------------------------
+dnl Copyright 2004-2009,2010 Thomas E. Dickey
+dnl
+dnl Permission is hereby granted, free of charge, to any person obtaining a
+dnl copy of this software and associated documentation files (the
+dnl "Software"), to deal in the Software without restriction, including
+dnl without limitation the rights to use, copy, modify, merge, publish,
+dnl distribute, distribute with modifications, sublicense, and/or sell
+dnl copies of the Software, and to permit persons to whom the Software is
+dnl furnished to do so, subject to the following conditions:
+dnl
+dnl The above copyright notice and this permission notice shall be included
+dnl in all copies or portions of the Software.
+dnl
+dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+dnl
+dnl Except as contained in this notice, the name(s) of the above copyright
+dnl holders shall not be used in advertising or otherwise to promote the
+dnl sale, use or other dealings in this Software without prior written
+dnl authorization.
+dnl ---------------------------------------------------------------------------
+dnl ---------------------------------------------------------------------------
+dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
+dnl -------------
+dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
+dnl The second parameter if given makes this macro verbose.
+dnl
+dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
+dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
+dnl confused by the quotes (which require backslashes to keep them usable).
+AC_DEFUN([CF_ADD_CFLAGS],
+[
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $1
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+ CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+ ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+ ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+ ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+AC_SUBST(EXTRA_CPPFLAGS)
+
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ANSI_CC_CHECK version: 11 updated: 2011/07/01 19:47:45
+dnl ----------------
+dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
+dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
+AC_DEFUN([CF_ANSI_CC_CHECK],
+[
+# This should have been defined by AC_PROG_CC
+: ${CC:=cc}
+
+# Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
+# into CC. This will not help with broken scripts that wrap the compiler with
+# options, but eliminates a more common category of user confusion.
+AC_MSG_CHECKING(\$CC variable)
+case "$CC" in #(vi
+*[[\ \ ]]-[[IUD]]*)
+ AC_MSG_RESULT(broken)
+ AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
+ # humor him...
+ cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]]//'`
+ CC=`echo "$CC" | sed -e 's/[[ ]].*//'`
+ CF_ADD_CFLAGS($cf_flags)
+ ;;
+*)
+ AC_MSG_RESULT(ok)
+ ;;
+esac
+
+AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
+cf_cv_ansi_cc=no
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX -Aa -D_HPUX_SOURCE
+# SVR4 -Xc
+# UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
+for cf_arg in "-DCC_HAS_PROTOS" \
+ "" \
+ -qlanglvl=ansi \
+ -std1 \
+ -Ae \
+ "-Aa -D_HPUX_SOURCE" \
+ -Xc
+do
+ CF_ADD_CFLAGS($cf_arg)
+ AC_TRY_COMPILE(
+[
+#ifndef CC_HAS_PROTOS
+#if !defined(__STDC__) || (__STDC__ != 1)
+choke me
+#endif
+#endif
+],[
+ int test (int i, double x);
+ struct s1 {int (*f) (int a);};
+ struct s2 {int (*f) (double a);};],
+ [cf_cv_ansi_cc="$cf_arg"; break])
+done
+CFLAGS="$cf_save_CFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS"
+])
+
+if test "$cf_cv_ansi_cc" != "no"; then
+if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
+ CF_ADD_CFLAGS($cf_cv_ansi_cc)
+else
+ AC_DEFINE(CC_HAS_PROTOS)
+fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
+dnl ---------------
+dnl For programs that must use an ANSI compiler, obtain compiler options that
+dnl will make it recognize prototypes. We'll do preprocessor checks in other
+dnl macros, since tools such as unproto can fake prototypes, but only part of
+dnl the preprocessor.
+AC_DEFUN([CF_ANSI_CC_REQD],
+[AC_REQUIRE([CF_ANSI_CC_CHECK])
+if test "$cf_cv_ansi_cc" = "no"; then
+ AC_MSG_ERROR(
+[Your compiler does not appear to recognize prototypes.
+You have the following choices:
+ a. adjust your compiler options
+ b. get an up-to-date compiler
+ c. use a wrapper such as unproto])
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
+dnl --------------
+dnl Allow user to disable a normally-on option.
+AC_DEFUN([CF_ARG_DISABLE],
+[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
+dnl -------------
+dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
+dnl values.
+dnl
+dnl Parameters:
+dnl $1 = option name
+dnl $2 = help-string
+dnl $3 = action to perform if option is not default
+dnl $4 = action if perform if option is default
+dnl $5 = default option value (either 'yes' or 'no')
+AC_DEFUN([CF_ARG_OPTION],
+[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
+ if test "$enableval" != "$5" ; then
+ifelse([$3],,[ :]dnl
+,[ $3]) ifelse([$4],,,[
+ else
+ $4])
+ fi],[enableval=$5 ifelse([$4],,,[
+ $4
+])dnl
+ ])])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
+dnl --------------
+dnl Check if we're accidentally using a cache from a different machine.
+dnl Derive the system name, as a check for reusing the autoconf cache.
+dnl
+dnl If we've packaged config.guess and config.sub, run that (since it does a
+dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
+dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
+dnl which is useful in cross-compiles.
+dnl
+dnl Note: we would use $ac_config_sub, but that is one of the places where
+dnl autoconf 2.5x broke compatibility with autoconf 2.13
+AC_DEFUN([CF_CHECK_CACHE],
+[
+if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+ ifelse([$1],,[AC_CANONICAL_HOST],[$1])
+ system_name="$host_os"
+else
+ system_name="`(uname -s -r) 2>/dev/null`"
+ if test -z "$system_name" ; then
+ system_name="`(hostname) 2>/dev/null`"
+ fi
+fi
+test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
+AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
+
+test -z "$system_name" && system_name="$cf_cv_system_name"
+test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
+
+if test ".$system_name" != ".$cf_cv_system_name" ; then
+ AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
+ AC_MSG_ERROR("Please remove config.cache and try again.")
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
+dnl ---------------
+dnl You can always use "make -n" to see the actual options, but it's hard to
+dnl pick out/analyze warning messages when the compile-line is long.
+dnl
+dnl Sets:
+dnl ECHO_LT - symbol to control if libtool is verbose
+dnl ECHO_LD - symbol to prefix "cc -o" lines
+dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
+dnl SHOW_CC - symbol to put before explicit "cc -c" lines
+dnl ECHO_CC - symbol to put before any "cc" line
+dnl
+AC_DEFUN([CF_DISABLE_ECHO],[
+AC_MSG_CHECKING(if you want to see long compiling messages)
+CF_ARG_DISABLE(echo,
+ [ --disable-echo display "compiling" commands],
+ [
+ ECHO_LT='--silent'
+ ECHO_LD='@echo linking [$]@;'
+ RULE_CC='@echo compiling [$]<'
+ SHOW_CC='@echo compiling [$]@'
+ ECHO_CC='@'
+],[
+ ECHO_LT=''
+ ECHO_LD=''
+ RULE_CC=''
+ SHOW_CC=''
+ ECHO_CC=''
+])
+AC_MSG_RESULT($enableval)
+AC_SUBST(ECHO_LT)
+AC_SUBST(ECHO_LD)
+AC_SUBST(RULE_CC)
+AC_SUBST(SHOW_CC)
+AC_SUBST(ECHO_CC)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
+dnl ----------------
+dnl Combine no-leak checks with the libraries or tools that are used for the
+dnl checks.
+AC_DEFUN([CF_DISABLE_LEAKS],[
+
+AC_REQUIRE([CF_WITH_DMALLOC])
+AC_REQUIRE([CF_WITH_DBMALLOC])
+AC_REQUIRE([CF_WITH_VALGRIND])
+
+AC_MSG_CHECKING(if you want to perform memory-leak testing)
+AC_ARG_ENABLE(leaks,
+ [ --disable-leaks test: free permanent memory, analyze leaks],
+ [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
+ : ${with_no_leaks:=no})
+AC_MSG_RESULT($with_no_leaks)
+
+if test "$with_no_leaks" = yes ; then
+ AC_DEFINE(NO_LEAKS)
+ AC_DEFINE(YY_NO_LEAKS)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
+dnl -----------------
+dnl Test for availability of useful gcc __attribute__ directives to quiet
+dnl compiler warnings. Though useful, not all are supported -- and contrary
+dnl to documentation, unrecognized directives cause older compilers to barf.
+AC_DEFUN([CF_GCC_ATTRIBUTES],
+[
+if test "$GCC" = yes
+then
+cat > conftest.i <<EOF
+#ifndef GCC_PRINTF
+#define GCC_PRINTF 0
+#endif
+#ifndef GCC_SCANF
+#define GCC_SCANF 0
+#endif
+#ifndef GCC_NORETURN
+#define GCC_NORETURN /* nothing */
+#endif
+#ifndef GCC_UNUSED
+#define GCC_UNUSED /* nothing */
+#endif
+EOF
+if test "$GCC" = yes
+then
+ AC_CHECKING([for $CC __attribute__ directives])
+cat > conftest.$ac_ext <<EOF
+#line __oline__ "${as_me:-configure}"
+#include "confdefs.h"
+#include "conftest.h"
+#include "conftest.i"
+#if GCC_PRINTF
+#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
+#else
+#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
+#endif
+#if GCC_SCANF
+#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
+#else
+#define GCC_SCANFLIKE(fmt,var) /*nothing*/
+#endif
+extern void wow(char *,...) GCC_SCANFLIKE(1,2);
+extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
+extern void foo(void) GCC_NORETURN;
+int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
+EOF
+ cf_printf_attribute=no
+ cf_scanf_attribute=no
+ for cf_attribute in scanf printf unused noreturn
+ do
+ CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
+ cf_directive="__attribute__(($cf_attribute))"
+ echo "checking for $CC $cf_directive" 1>&AC_FD_CC
+
+ case $cf_attribute in #(vi
+ printf) #(vi
+ cf_printf_attribute=yes
+ cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE 1
+EOF
+ ;;
+ scanf) #(vi
+ cf_scanf_attribute=yes
+ cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE 1
+EOF
+ ;;
+ *) #(vi
+ cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE $cf_directive
+EOF
+ ;;
+ esac
+
+ if AC_TRY_EVAL(ac_compile); then
+ test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
+ cat conftest.h >>confdefs.h
+ case $cf_attribute in #(vi
+ printf) #(vi
+ if test "$cf_printf_attribute" = no ; then
+ cat >>confdefs.h <<EOF
+#define GCC_PRINTFLIKE(fmt,var) /* nothing */
+EOF
+ else
+ cat >>confdefs.h <<EOF
+#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
+EOF
+ fi
+ ;;
+ scanf) #(vi
+ if test "$cf_scanf_attribute" = no ; then
+ cat >>confdefs.h <<EOF
+#define GCC_SCANFLIKE(fmt,var) /* nothing */
+EOF
+ else
+ cat >>confdefs.h <<EOF
+#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
+EOF
+ fi
+ ;;
+ esac
+ fi
+ done
+else
+ fgrep define conftest.i >>confdefs.h
+fi
+rm -rf conftest*
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
+dnl --------------
+dnl Find version of gcc
+AC_DEFUN([CF_GCC_VERSION],[
+AC_REQUIRE([AC_PROG_CC])
+GCC_VERSION=none
+if test "$GCC" = yes ; then
+ AC_MSG_CHECKING(version of $CC)
+ GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
+ test -z "$GCC_VERSION" && GCC_VERSION=unknown
+ AC_MSG_RESULT($GCC_VERSION)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
+dnl ---------------
+dnl Check if the compiler supports useful warning options. There's a few that
+dnl we don't use, simply because they're too noisy:
+dnl
+dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
+dnl -Wredundant-decls (system headers make this too noisy)
+dnl -Wtraditional (combines too many unrelated messages, only a few useful)
+dnl -Wwrite-strings (too noisy, but should review occasionally). This
+dnl is enabled for ncurses using "--enable-const".
+dnl -pedantic
+dnl
+dnl Parameter:
+dnl $1 is an optional list of gcc warning flags that a particular
+dnl application might want to use, e.g., "no-unused" for
+dnl -Wno-unused
+dnl Special:
+dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
+dnl
+AC_DEFUN([CF_GCC_WARNINGS],
+[
+AC_REQUIRE([CF_GCC_VERSION])
+CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
+
+cat > conftest.$ac_ext <<EOF
+#line __oline__ "${as_me:-configure}"
+int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
+EOF
+
+if test "$INTEL_COMPILER" = yes
+then
+# The "-wdXXX" options suppress warnings:
+# remark #1419: external declaration in primary source file
+# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
+# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
+# remark #193: zero used for undefined preprocessing identifier
+# remark #593: variable "curs_sb_left_arrow" was set but never used
+# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
+# remark #869: parameter "tw" was never referenced
+# remark #981: operands are evaluated in unspecified order
+# warning #279: controlling expression is constant
+
+ AC_CHECKING([for $CC warning options])
+ cf_save_CFLAGS="$CFLAGS"
+ EXTRA_CFLAGS="-Wall"
+ for cf_opt in \
+ wd1419 \
+ wd1683 \
+ wd1684 \
+ wd193 \
+ wd593 \
+ wd279 \
+ wd810 \
+ wd869 \
+ wd981
+ do
+ CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+ if AC_TRY_EVAL(ac_compile); then
+ test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
+ fi
+ done
+ CFLAGS="$cf_save_CFLAGS"
+
+elif test "$GCC" = yes
+then
+ AC_CHECKING([for $CC warning options])
+ cf_save_CFLAGS="$CFLAGS"
+ EXTRA_CFLAGS=
+ cf_warn_CONST=""
+ test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
+ for cf_opt in W Wall \
+ Wbad-function-cast \
+ Wcast-align \
+ Wcast-qual \
+ Winline \
+ Wmissing-declarations \
+ Wmissing-prototypes \
+ Wnested-externs \
+ Wpointer-arith \
+ Wshadow \
+ Wstrict-prototypes \
+ Wundef $cf_warn_CONST $1
+ do
+ CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+ if AC_TRY_EVAL(ac_compile); then
+ test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
+ case $cf_opt in #(vi
+ Wcast-qual) #(vi
+ CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
+ ;;
+ Winline) #(vi
+ case $GCC_VERSION in
+ [[34]].*)
+ CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
+ continue;;
+ esac
+ ;;
+ esac
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
+ fi
+ done
+ CFLAGS="$cf_save_CFLAGS"
+fi
+rm -rf conftest*
+
+AC_SUBST(EXTRA_CFLAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
+dnl -------------
+dnl Check if we must define _GNU_SOURCE to get a reasonable value for
+dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
+dnl (or misfeature) of glibc2, which breaks portability of many applications,
+dnl since it is interwoven with GNU extensions.
+dnl
+dnl Well, yes we could work around it...
+AC_DEFUN([CF_GNU_SOURCE],
+[
+AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
+AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _XOPEN_SOURCE
+make an error
+#endif],
+ [cf_cv_gnu_source=no],
+ [cf_save="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+ AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _XOPEN_SOURCE
+make an error
+#endif],
+ [cf_cv_gnu_source=no],
+ [cf_cv_gnu_source=yes])
+ CPPFLAGS="$cf_save"
+ ])
+])
+test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
+dnl -----------------
+dnl Check if the given compiler is really the Intel compiler for Linux. It
+dnl tries to imitate gcc, but does not return an error when it finds a mismatch
+dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
+dnl
+dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
+dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
+dnl the wrappers for gcc and g++ warnings.
+dnl
+dnl $1 = GCC (default) or GXX
+dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
+dnl $3 = CFLAGS (default) or CXXFLAGS
+AC_DEFUN([CF_INTEL_COMPILER],[
+ifelse([$2],,INTEL_COMPILER,[$2])=no
+
+if test "$ifelse([$1],,[$1],GCC)" = yes ; then
+ case $host_os in
+ linux*|gnu*)
+ AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
+ cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
+ ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
+ AC_TRY_COMPILE([],[
+#ifdef __INTEL_COMPILER
+#else
+make an error
+#endif
+],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
+],[])
+ ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
+ AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
+ ;;
+ esac
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
+dnl ------------
+dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
+dnl a monocase filesystem.
+AC_DEFUN([CF_MAKE_TAGS],[
+AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
+
+AC_CHECK_PROGS(CTAGS, exctags ctags)
+AC_CHECK_PROGS(ETAGS, exetags etags)
+
+AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
+
+if test "$cf_cv_mixedcase" = yes ; then
+ AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
+else
+ MAKE_UPPER_TAGS=no
+fi
+
+if test "$MAKE_UPPER_TAGS" = yes ; then
+ MAKE_UPPER_TAGS=
+else
+ MAKE_UPPER_TAGS="#"
+fi
+
+if test "$MAKE_LOWER_TAGS" = yes ; then
+ MAKE_LOWER_TAGS=
+else
+ MAKE_LOWER_TAGS="#"
+fi
+
+AC_SUBST(CTAGS)
+AC_SUBST(ETAGS)
+
+AC_SUBST(MAKE_UPPER_TAGS)
+AC_SUBST(MAKE_LOWER_TAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
+dnl ----------------------
+dnl Check if the file-system supports mixed-case filenames. If we're able to
+dnl create a lowercase name and see it as uppercase, it doesn't support that.
+AC_DEFUN([CF_MIXEDCASE_FILENAMES],
+[
+AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
+if test "$cross_compiling" = yes ; then
+ case $target_alias in #(vi
+ *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
+ cf_cv_mixedcase=no
+ ;;
+ *)
+ cf_cv_mixedcase=yes
+ ;;
+ esac
+else
+ rm -f conftest CONFTEST
+ echo test >conftest
+ if test -f CONFTEST ; then
+ cf_cv_mixedcase=no
+ else
+ cf_cv_mixedcase=yes
+ fi
+ rm -f conftest CONFTEST
+fi
+])
+test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_MKSTEMP version: 7 updated: 2010/08/14 18:25:37
+dnl ----------
+dnl Check for a working mkstemp. This creates two files, checks that they are
+dnl successfully created and distinct (AmigaOS apparently fails on the last).
+AC_DEFUN([CF_MKSTEMP],[
+AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
+rm -rf conftest*
+AC_TRY_RUN([
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+int main()
+{
+ char *tmpl = "conftestXXXXXX";
+ char name[2][80];
+ int n;
+ int result = 0;
+ int fd;
+ struct stat sb;
+
+ umask(077);
+ for (n = 0; n < 2; ++n) {
+ strcpy(name[n], tmpl);
+ if ((fd = mkstemp(name[n])) >= 0) {
+ if (!strcmp(name[n], tmpl)
+ || stat(name[n], &sb) != 0
+ || (sb.st_mode & S_IFMT) != S_IFREG
+ || (sb.st_mode & 077) != 0) {
+ result = 1;
+ }
+ close(fd);
+ }
+ }
+ if (result == 0
+ && !strcmp(name[0], name[1]))
+ result = 1;
+ ${cf_cv_main_return:-return}(result);
+}
+],[cf_cv_func_mkstemp=yes
+],[cf_cv_func_mkstemp=no
+],[AC_CHECK_FUNC(mkstemp)
+])
+])
+if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
+ AC_DEFINE(HAVE_MKSTEMP)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
+dnl ----------
+dnl Write a debug message to config.log, along with the line number in the
+dnl configure script.
+AC_DEFUN([CF_MSG_LOG],[
+echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
+dnl ------------------
+dnl see CF_WITH_NO_LEAKS
+AC_DEFUN([CF_NO_LEAKS_OPTION],[
+AC_MSG_CHECKING(if you want to use $1 for testing)
+AC_ARG_WITH($1,
+ [$2],
+ [AC_DEFINE($3)ifelse([$4],,[
+ $4
+])
+ : ${with_cflags:=-g}
+ : ${with_no_leaks:=yes}
+ with_$1=yes],
+ [with_$1=])
+AC_MSG_RESULT(${with_$1:-no})
+
+case .$with_cflags in #(vi
+.*-g*)
+ case .$CFLAGS in #(vi
+ .*-g*) #(vi
+ ;;
+ *)
+ CF_ADD_CFLAGS([-g])
+ ;;
+ esac
+ ;;
+esac
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
+dnl -----------------
+dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
+dnl
+dnl POSIX.1-1990 _POSIX_SOURCE
+dnl POSIX.1-1990 and _POSIX_SOURCE and
+dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
+dnl Bindings Option
+dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
+dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
+dnl X/Open 2000 _POSIX_C_SOURCE=200112L
+dnl
+dnl Parameters:
+dnl $1 is the nominal value for _POSIX_C_SOURCE
+AC_DEFUN([CF_POSIX_C_SOURCE],
+[
+cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
+
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+
+CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
+CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
+
+AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
+ CF_MSG_LOG(if the symbol is already defined go no further)
+ AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif],
+ [cf_cv_posix_c_source=no],
+ [cf_want_posix_source=no
+ case .$cf_POSIX_C_SOURCE in #(vi
+ .[[12]]??*) #(vi
+ cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+ ;;
+ .2) #(vi
+ cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+ cf_want_posix_source=yes
+ ;;
+ .*)
+ cf_want_posix_source=yes
+ ;;
+ esac
+ if test "$cf_want_posix_source" = yes ; then
+ AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _POSIX_SOURCE
+make an error
+#endif],[],
+ cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
+ fi
+ CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
+ CFLAGS="$cf_trim_CFLAGS"
+ CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
+ CF_MSG_LOG(if the second compile does not leave our definition intact error)
+ AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif],,
+ [cf_cv_posix_c_source=no])
+ CFLAGS="$cf_save_CFLAGS"
+ CPPFLAGS="$cf_save_CPPFLAGS"
+ ])
+])
+
+if test "$cf_cv_posix_c_source" != no ; then
+ CFLAGS="$cf_trim_CFLAGS"
+ CPPFLAGS="$cf_trim_CPPFLAGS"
+ CF_ADD_CFLAGS($cf_cv_posix_c_source)
+fi
+
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
+dnl -----------
+dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
+AC_DEFUN([CF_PROG_EXT],
+[
+AC_REQUIRE([CF_CHECK_CACHE])
+case $cf_cv_system_name in
+os2*)
+ CFLAGS="$CFLAGS -Zmt"
+ CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
+ CXXFLAGS="$CXXFLAGS -Zmt"
+ # autoconf's macro sets -Zexe and suffix both, which conflict:w
+ LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
+ ac_cv_exeext=.exe
+ ;;
+esac
+
+AC_EXEEXT
+AC_OBJEXT
+
+PROG_EXT="$EXEEXT"
+AC_SUBST(PROG_EXT)
+test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
+dnl ------------
+AC_DEFUN([CF_PROG_LINT],
+[
+AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
+AC_SUBST(LINT_OPTS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
+dnl ----------------
+dnl Remove all -U and -D options that refer to the given symbol from a list
+dnl of C compiler options. This works around the problem that not all
+dnl compilers process -U and -D options from left-to-right, so a -U option
+dnl cannot be used to cancel the effect of a preceding -D option.
+dnl
+dnl $1 = target (which could be the same as the source variable)
+dnl $2 = source (including '$')
+dnl $3 = symbol to remove
+define([CF_REMOVE_DEFINE],
+[
+$1=`echo "$2" | \
+ sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
+ -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
+dnl --------
+dnl Make an uppercase version of a variable
+dnl $1=uppercase($2)
+AC_DEFUN([CF_UPPER],
+[
+$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
+dnl ----------
+dnl Use AC_VERBOSE w/o the warnings
+AC_DEFUN([CF_VERBOSE],
+[test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
+CF_MSG_LOG([$1])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
+dnl ----------------
+dnl Configure-option for dbmalloc. The optional parameter is used to override
+dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
+AC_DEFUN([CF_WITH_DBMALLOC],[
+CF_NO_LEAKS_OPTION(dbmalloc,
+ [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
+ [USE_DBMALLOC])
+
+if test "$with_dbmalloc" = yes ; then
+ AC_CHECK_HEADER(dbmalloc.h,
+ [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
+dnl ---------------
+dnl Configure-option for dmalloc. The optional parameter is used to override
+dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
+AC_DEFUN([CF_WITH_DMALLOC],[
+CF_NO_LEAKS_OPTION(dmalloc,
+ [ --with-dmalloc test: use Gray Watson's dmalloc library],
+ [USE_DMALLOC])
+
+if test "$with_dmalloc" = yes ; then
+ AC_CHECK_HEADER(dmalloc.h,
+ [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
+dnl ----------------
+AC_DEFUN([CF_WITH_VALGRIND],[
+CF_NO_LEAKS_OPTION(valgrind,
+ [ --with-valgrind test: use valgrind],
+ [USE_VALGRIND])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
+dnl ----------------
+dnl Combine the checks for gcc features into a configure-script option
+dnl
+dnl Parameters:
+dnl $1 - see CF_GCC_WARNINGS
+AC_DEFUN([CF_WITH_WARNINGS],
+[
+if ( test "$GCC" = yes || test "$GXX" = yes )
+then
+AC_MSG_CHECKING(if you want to check for gcc warnings)
+AC_ARG_WITH(warnings,
+ [ --with-warnings test: turn on gcc warnings],
+ [cf_opt_with_warnings=$withval],
+ [cf_opt_with_warnings=no])
+AC_MSG_RESULT($cf_opt_with_warnings)
+if test "$cf_opt_with_warnings" != no ; then
+ CF_GCC_ATTRIBUTES
+ CF_GCC_WARNINGS([$1])
+fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_XOPEN_SOURCE version: 37 updated: 2011/08/06 20:32:05
+dnl ---------------
+dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
+dnl or adapt to the vendor's definitions to get equivalent functionality,
+dnl without losing the common non-POSIX features.
+dnl
+dnl Parameters:
+dnl $1 is the nominal value for _XOPEN_SOURCE
+dnl $2 is the nominal value for _POSIX_C_SOURCE
+AC_DEFUN([CF_XOPEN_SOURCE],[
+
+cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
+cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
+cf_xopen_source=
+
+case $host_os in #(vi
+aix[[4-7]]*) #(vi
+ cf_xopen_source="-D_ALL_SOURCE"
+ ;;
+cygwin) #(vi
+ cf_XOPEN_SOURCE=600
+ ;;
+darwin[[0-8]].*) #(vi
+ cf_xopen_source="-D_APPLE_C_SOURCE"
+ ;;
+darwin*) #(vi
+ cf_xopen_source="-D_DARWIN_C_SOURCE"
+ ;;
+freebsd*|dragonfly*) #(vi
+ # 5.x headers associate
+ # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+ # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+ cf_POSIX_C_SOURCE=200112L
+ cf_XOPEN_SOURCE=600
+ cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ ;;
+hpux11*) #(vi
+ cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
+ ;;
+hpux*) #(vi
+ cf_xopen_source="-D_HPUX_SOURCE"
+ ;;
+irix[[56]].*) #(vi
+ cf_xopen_source="-D_SGI_SOURCE"
+ ;;
+linux*|gnu*|mint*|k*bsd*-gnu) #(vi
+ CF_GNU_SOURCE
+ ;;
+mirbsd*) #(vi
+ # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+ ;;
+netbsd*) #(vi
+ cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+ ;;
+openbsd*) #(vi
+ # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+ ;;
+osf[[45]]*) #(vi
+ cf_xopen_source="-D_OSF_SOURCE"
+ ;;
+nto-qnx*) #(vi
+ cf_xopen_source="-D_QNX_SOURCE"
+ ;;
+sco*) #(vi
+ # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+ ;;
+solaris2.1[[0-9]]) #(vi
+ cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ ;;
+solaris2.[[1-9]]) #(vi
+ cf_xopen_source="-D__EXTENSIONS__"
+ ;;
+*)
+ AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
+ AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _XOPEN_SOURCE
+make an error
+#endif],
+ [cf_cv_xopen_source=no],
+ [cf_save="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _XOPEN_SOURCE
+make an error
+#endif],
+ [cf_cv_xopen_source=no],
+ [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
+ CPPFLAGS="$cf_save"
+ ])
+])
+ if test "$cf_cv_xopen_source" != no ; then
+ CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
+ CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
+ cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+ CF_ADD_CFLAGS($cf_temp_xopen_source)
+ fi
+ CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
+ ;;
+esac
+
+if test -n "$cf_xopen_source" ; then
+ CF_ADD_CFLAGS($cf_xopen_source)
+fi
+])
-/* $NetBSD: closure.c,v 1.8 2006/05/24 18:01:43 christos Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
+/* $NetBSD: closure.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
-#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)closure.c 5.3 (Berkeley) 5/24/93";
-#else
-__RCSID("$NetBSD: closure.c,v 1.8 2006/05/24 18:01:43 christos Exp $");
-#endif
-#endif /* not lint */
+/* Id: closure.c,v 1.9 2010/06/09 08:21:47 tom Exp */
#include "defs.h"
-short *itemset;
-short *itemsetend;
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: closure.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
+
+Value_t *itemset;
+Value_t *itemsetend;
unsigned *ruleset;
static unsigned *first_derives;
static unsigned *EFF;
-static void set_EFF(void);
-
static void
set_EFF(void)
{
#endif
}
-
void
set_first_derives(void)
{
unsigned *vrow;
int j;
unsigned k;
- unsigned cword;
+ unsigned cword = 0;
short *rp;
int rule;
int rulesetsize;
int varsetsize;
- cword = 0;
-
rulesetsize = WORDSIZE(nrules);
varsetsize = WORDSIZE(nvars);
first_derives = NEW2(nvars * rulesetsize, unsigned) - ntokens * rulesetsize;
k = 0;
}
- if (cword & (1 << k))
+ if (cword & (unsigned)(1 << k))
{
rp = derives[j];
while ((rule = *rp++) >= 0)
}
}
- vrow += varsetsize;
rrow += rulesetsize;
}
FREE(EFF);
}
-
void
closure(short *nucleus, int n)
{
- int ruleno;
+ unsigned ruleno;
unsigned word;
unsigned i;
- short *csp;
+ Value_t *csp;
unsigned *dsp;
unsigned *rsp;
int rulesetsize;
- short *csend;
+ Value_t *csend;
unsigned *rsend;
int symbol;
- int itemno;
+ Value_t itemno;
rulesetsize = WORDSIZE(nrules);
- rsp = ruleset;
rsend = ruleset + rulesetsize;
for (rsp = ruleset; rsp < rsend; rsp++)
*rsp = 0;
{
for (i = 0; i < BITS_PER_WORD; ++i)
{
- if (word & (1 << i))
+ if (word & (unsigned)(1 << i))
{
- itemno = rrhs[ruleno+i];
+ itemno = rrhs[ruleno + i];
while (csp < csend && *csp < itemno)
*itemsetend++ = *csp++;
*itemsetend++ = itemno;
*itemsetend++ = *csp++;
#ifdef DEBUG
- print_closure(n);
+ print_closure(n);
#endif
}
-
void
finalize_closure(void)
{
- FREE(itemset);
- FREE(ruleset);
- FREE(first_derives + ntokens * WORDSIZE(nrules));
+ FREE(itemset);
+ FREE(ruleset);
+ FREE(first_derives + ntokens * WORDSIZE(nrules));
}
-
#ifdef DEBUG
void
print_closure(int n)
{
- short *isp;
+ short *isp;
- printf("\n\nn = %d\n\n", n);
- for (isp = itemset; isp < itemsetend; isp++)
- printf(" %d\n", *isp);
+ printf("\n\nn = %d\n\n", n);
+ for (isp = itemset; isp < itemsetend; isp++)
+ printf(" %d\n", *isp);
}
-
void
print_EFF(void)
{
}
}
-
void
print_first_derives(void)
{
int i;
int j;
unsigned *rp;
- unsigned cword;
+ unsigned cword = 0;
unsigned k;
printf("\n\n\nFirst Derives\n");
rp = first_derives + i * WORDSIZE(nrules);
k = BITS_PER_WORD;
for (j = 0; j <= nrules; k++, j++)
- {
- if (k >= BITS_PER_WORD)
- {
- cword = *rp++;
- k = 0;
- }
-
- if (cword & (1 << k))
- printf(" %d\n", j);
+ {
+ if (k >= BITS_PER_WORD)
+ {
+ cword = *rp++;
+ k = 0;
+ }
+
+ if (cword & (1 << k))
+ printf(" %d\n", j);
}
}
- fflush(stdout);
+ fflush(stdout);
}
#endif
--- /dev/null
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+# 2911 Free Software Foundation, Inc.
+
+timestamp='2011-01-01'
+
+# This file 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., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner. Please send patches (context
+# diff format) to <config-patches@gnu.org> and include a ChangeLog
+# entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ELF__
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ exitcode=$?
+ trap '' 0
+ exit $exitcode ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ s390x:SunOS:*:*)
+ echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+ echo i386-pc-auroraux${UNAME_RELEASE}
+ exit ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ eval $set_cc_for_build
+ SUN_ARCH="i386"
+ # If there is a compiler, see if it is configured for 64-bit objects.
+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+ # This test works for both compilers.
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ SUN_ARCH="x86_64"
+ fi
+ fi
+ echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[4567])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep -q __LP64__
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ *:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ *:Interix*:*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ authenticamd | genuineintel | EM64T)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ IA64)
+ echo ia64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ 8664:Windows_NT:*)
+ echo x86_64-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null | \
+ grep -q __ARM_EABI__
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ else
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ LIBC=gnu
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:* | mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef ${UNAME_MACHINE}
+ #undef ${UNAME_MACHINE}el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=${UNAME_MACHINE}el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=${UNAME_MACHINE}
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ padre:Linux:*:*)
+ echo sparc-unknown-linux-gnu
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ tile*:Linux:*:*)
+ echo ${UNAME_MACHINE}-tilera-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ xtensa*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i586.
+ # Note: whatever this is, it MUST be the same as what config.sub
+ # prints for the "djgpp" host, or else GDB configury will decide that
+ # this is a cross-build.
+ echo i586-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+ OS_REL='.3'
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
+ echo i586-pc-haiku
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ i386)
+ eval $set_cc_for_build
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ UNAME_PROCESSOR="x86_64"
+ fi
+ fi ;;
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NEO-?:NONSTOP_KERNEL:*:*)
+ echo neo-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+ i*86:AROS:*:*)
+ echo ${UNAME_MACHINE}-pc-aros
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+# 2011 Free Software Foundation, Inc.
+
+timestamp='2011-04-01'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file 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., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted GNU ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray | -microblaze)
+ os=
+ basic_machine=$1
+ ;;
+ -bluegene*)
+ os=-cnk
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | lm32 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore | mep | metag \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | moxie \
+ | mt \
+ | msp430 \
+ | nds32 | nds32le | nds32be \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | open8 \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle \
+ | pyramid \
+ | rx \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu \
+ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+ | ubicom32 \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xstormy16 | xtensa \
+ | z8k | z80)
+ basic_machine=$basic_machine-unknown
+ ;;
+ c54x)
+ basic_machine=tic54x-unknown
+ ;;
+ c55x)
+ basic_machine=tic55x-unknown
+ ;;
+ c6x)
+ basic_machine=tic6x-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12 | picochip)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+ strongarm | thumb | xscale)
+ basic_machine=arm-unknown
+ ;;
+ xscaleeb)
+ basic_machine=armeb-unknown
+ ;;
+ xscaleel)
+ basic_machine=armel-unknown
+ ;;
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | lm32-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64octeon-* | mips64octeonel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64r5900-* | mips64r5900el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nds32-* | nds32le-* | nds32be-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | open8-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+ | pyramid-* \
+ | romp-* | rs6000-* | rx-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+ | tahoe-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tile-* | tilegx-* \
+ | tron-* \
+ | ubicom32-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* \
+ | xstormy16-* | xtensa*-* \
+ | ymp-* \
+ | z8k-* | z80-*)
+ ;;
+ # Recognize the basic CPU types without company name, with glob match.
+ xtensa*)
+ basic_machine=$basic_machine-unknown
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aros)
+ basic_machine=i386-pc
+ os=-aros
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=-linux
+ ;;
+ blackfin-*)
+ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ bluegene*)
+ basic_machine=powerpc-ibm
+ os=-cnk
+ ;;
+ c54x-*)
+ basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c55x-*)
+ basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c6x-*)
+ basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ cegcc)
+ basic_machine=arm-unknown
+ os=-cegcc
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16 | cr16-*)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dicos)
+ basic_machine=i686-pc
+ os=-dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=-linux
+ ;;
+ m68knommu-*)
+ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ microblaze)
+ basic_machine=microblaze-xilinx
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next)
+ basic_machine=m68k-next
+ case $os in
+ -nextstep*)
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ neo-tandem)
+ basic_machine=neo-tandem
+ ;;
+ nse-tandem)
+ basic_machine=nse-tandem
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=-linux
+ ;;
+ parisc-*)
+ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power)
+ basic_machine=power-ibm
+ ;;
+ ppc | ppcbe)
+ basic_machine=powerpc-unknown
+ ;;
+ ppc-* | ppcbe-*)
+ basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64)
+ basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*)
+ basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ strongarm-* | thumb-*)
+ basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ # This must be matched before tile*.
+ tilegx*)
+ basic_machine=tilegx-unknown
+ os=-linux-gnu
+ ;;
+ tile*)
+ basic_machine=tile-unknown
+ os=-linux-gnu
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ xscale-* | xscalee[bl]-*)
+ basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ z80-*-coff)
+ basic_machine=z80-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -auroraux)
+ os=-auroraux
+ ;;
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+ | -sym* | -kopensolaris* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* | -aros* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2)
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -dicos*)
+ os=-dicos
+ ;;
+ -nacl*)
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ tic54x-*)
+ os=-coff
+ ;;
+ tic55x-*)
+ os=-coff
+ ;;
+ tic6x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mep-*)
+ os=-elf
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next)
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -cnk*|-aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null
+/* @configure_input@ */
+/* Id: config_h.in,v 1.1 1995/01/01 19:34:59 tom Exp */
+@DEFS@
--- /dev/null
+#! /bin/sh
+# From configure.in Revision: 1.10 .
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by Autoconf 2.52.20101002.
+#
+# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+
+# Name of the executable.
+as_me=`echo "$0" |sed 's,.*[\\/],,'`
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+as_executable_p="test -f"
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+# NLS nuisances.
+$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
+$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
+$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
+$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
+$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
+$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
+$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
+$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+cross_compiling=no
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete. It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+ac_unique_file="main.c"
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_prev=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/-/_/g'`
+ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+ localstatedir libdir includedir oldincludedir infodir mandir
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) ;;
+ *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: should be removed in autoconf 3.0.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2
+ { (exit 1); exit 1; }; }
+ else
+ { echo "$as_me: error: cannot find sources in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+ fi
+fi
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<EOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+EOF
+
+ cat <<EOF
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --infodir=DIR info documentation [PREFIX/info]
+ --mandir=DIR man documentation [PREFIX/man]
+EOF
+
+ cat <<\EOF
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST build programs to run on HOST [BUILD]
+ --target=TARGET configure for building compilers for TARGET [HOST]
+EOF
+fi
+
+if test -n "$ac_init_help"; then
+
+ cat <<\EOF
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+
+Optional Features:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+
+ --with-warnings test: turn on gcc warnings
+ --disable-echo display "compiling" commands
+ --with-dmalloc test: use Gray Watson's dmalloc library
+ --with-dbmalloc test: use Conor Cahill's dbmalloc library
+ --with-valgrind test: use valgrind
+ --disable-leaks test: free permanent memory, analyze leaks
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
+ headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+EOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ ac_popdir=`pwd`
+ for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue
+ cd $ac_subdir
+ # A "../" for each directory in /$ac_subdir.
+ ac_dots=`echo $ac_subdir |
+ sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'`
+
+ case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_sub_srcdir=$srcdir ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_sub_srcdir=$srcdir/$ac_subdir ;;
+ *) # Relative path.
+ ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;;
+ esac
+
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_sub_srcdir/configure.gnu; then
+ echo
+ $SHELL $ac_sub_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_sub_srcdir/configure; then
+ echo
+ $SHELL $ac_sub_srcdir/configure --help=recursive
+ elif test -f $ac_sub_srcdir/configure.ac ||
+ test -f $ac_sub_srcdir/configure.in; then
+ echo
+ $ac_configure --help
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2
+ fi
+ cd $ac_popdir
+ done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+ cat <<\EOF
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+EOF
+ exit 0
+fi
+exec 5>config.log
+cat >&5 <<EOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.52.20101002. Invocation command line was
+
+ $ $0 $@
+
+EOF
+{
+cat <<_ASUNAME
+## ---------- ##
+## Platform. ##
+## ---------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+PATH = $PATH
+
+_ASUNAME
+} >&5
+
+cat >&5 <<EOF
+## ------------ ##
+## Core tests. ##
+## ------------ ##
+
+EOF
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell meta-characters.
+ac_configure_args=
+ac_sep=
+for ac_arg
+do
+ case $ac_arg in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ ac_sep=" " ;;
+ *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg"
+ ac_sep=" " ;;
+ esac
+ # Get rid of the leading space.
+done
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ echo >&5
+ echo "## ----------------- ##" >&5
+ echo "## Cache variables. ##" >&5
+ echo "## ----------------- ##" >&5
+ echo >&5
+ # The following way of writing the cache mishandles newlines in values,
+{
+ (set) 2>&1 |
+ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ sed -n \
+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ ;;
+ *)
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+} >&5
+ sed "/^$/d" confdefs.h >conftest.log
+ if test -s conftest.log; then
+ echo >&5
+ echo "## ------------ ##" >&5
+ echo "## confdefs.h. ##" >&5
+ echo "## ------------ ##" >&5
+ echo >&5
+ cat conftest.log >&5
+ fi
+ (echo; echo) >&5
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal" >&5
+ echo "$as_me: exit $exit_status" >&5
+ rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files &&
+ exit $exit_status
+ ' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:845: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ cat "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { echo "$as_me:856: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . $cache_file;;
+ *) . ./$cache_file;;
+ esac
+ fi
+else
+ { echo "$as_me:864: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+ eval ac_new_val="\$ac_env_${ac_var}_value"
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:880: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:884: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:890: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:892: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:894: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status. It doesn't matter if
+ # we pass some twice (in addition to the command line arguments).
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"`
+ ac_configure_args="$ac_configure_args '$ac_arg'"
+ ;;
+ *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val"
+ ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:913: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:915: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+echo "#! $SHELL" >conftest.sh
+echo "exit 0" >>conftest.sh
+chmod +x conftest.sh
+if { (echo "$as_me:936: PATH=\".;.\"; conftest.sh") >&5
+ (PATH=".;."; conftest.sh) 2>&5
+ ac_status=$?
+ echo "$as_me:939: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ ac_path_separator=';'
+else
+ ac_path_separator=:
+fi
+PATH_SEPARATOR="$ac_path_separator"
+rm -f conftest.sh
+
+ac_config_headers="$ac_config_headers config.h:config_h.in"
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f $ac_dir/shtool; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { echo "$as_me:967: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+ { { echo "$as_me:977: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+echo "$as_me:981: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+ ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+ { { echo "$as_me:990: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+ { { echo "$as_me:994: error: $ac_config_sub $ac_cv_build_alias failed." >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:999: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+echo "$as_me:1006: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+ ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+ { { echo "$as_me:1015: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:1020: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+ echo "$as_me:1028: checking target system type" >&5
+echo $ECHO_N "checking target system type... $ECHO_C" >&6
+if test "${ac_cv_target+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_target_alias=$target_alias
+test "x$ac_cv_target_alias" = "x" &&
+ ac_cv_target_alias=$ac_cv_host_alias
+ac_cv_target=`$ac_config_sub $ac_cv_target_alias` ||
+ { { echo "$as_me:1037: error: $ac_config_sub $ac_cv_target_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:1042: result: $ac_cv_target" >&5
+echo "${ECHO_T}$ac_cv_target" >&6
+target=$ac_cv_target
+target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+ system_name="$host_os"
+else
+ system_name="`(uname -s -r) 2>/dev/null`"
+ if test -z "$system_name" ; then
+ system_name="`(hostname) 2>/dev/null`"
+ fi
+fi
+test -n "$system_name" && cat >>confdefs.h <<EOF
+#define SYSTEM_NAME "$system_name"
+EOF
+
+if test "${cf_cv_system_name+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cf_cv_system_name="$system_name"
+fi
+
+test -z "$system_name" && system_name="$cf_cv_system_name"
+test -n "$cf_cv_system_name" && echo "$as_me:1073: result: Configuring for $cf_cv_system_name" >&5
+echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6
+
+if test ".$system_name" != ".$cf_cv_system_name" ; then
+ echo "$as_me:1077: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
+echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6
+ { { echo "$as_me:1079: error: \"Please remove config.cache and try again.\"" >&5
+echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,$program_prefix,;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$,$program_suffix,;$program_transform_name"
+# Double any \ or $. echo might interpret backslashes.
+# By default was `s,x,x', remove it if useless.
+cat <<\_ACEOF >conftest.sed
+s/[\\$]/&&/g;s/;s,x,x,$//
+_ACEOF
+program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
+rm conftest.sed
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:1106: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="${ac_tool_prefix}gcc"
+echo "$as_me:1121: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:1129: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:1132: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:1141: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="gcc"
+echo "$as_me:1156: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:1164: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:1167: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:1180: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="${ac_tool_prefix}cc"
+echo "$as_me:1195: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:1203: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:1206: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:1215: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="cc"
+echo "$as_me:1230: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:1238: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:1241: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:1254: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+fi
+ac_cv_prog_CC="cc"
+echo "$as_me:1274: found $ac_dir/$ac_word" >&5
+break
+done
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" ${1+"$@"}
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:1296: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:1299: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:1310: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+echo "$as_me:1325: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:1333: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:1336: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:1349: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="$ac_prog"
+echo "$as_me:1364: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:1372: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:1375: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_CC" && break
+done
+
+ CC=$ac_ct_CC
+fi
+
+fi
+
+test -z "$CC" && { { echo "$as_me:1387: error: no acceptable cc found in \$PATH" >&5
+echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
+ { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:1392:" \
+ "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:1395: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:1398: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:1400: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:1403: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:1405: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:1408: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 1412 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:1428: checking for C compiler default output" >&5
+echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:1431: \"$ac_link_default\"") >&5
+ (eval $ac_link_default) 2>&5
+ ac_status=$?
+ echo "$as_me:1434: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Find the output, starting from the most likely. This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+for ac_file in `ls a.exe conftest.exe 2>/dev/null;
+ ls a.out conftest 2>/dev/null;
+ ls a.* conftest.* 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+ a.out ) # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ # FIXME: I believe we export ac_cv_exeext for Libtool --akim.
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+{ { echo "$as_me:1457: error: C compiler cannot create executables" >&5
+echo "$as_me: error: C compiler cannot create executables" >&2;}
+ { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:1463: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:1468: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (eval echo "$as_me:1474: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:1477: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { echo "$as_me:1484: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+echo "$as_me:1492: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:1499: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:1501: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:1504: checking for executable suffix" >&5
+echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
+if { (eval echo "$as_me:1506: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:1509: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { echo "$as_me:1525: error: cannot compute EXEEXT: cannot compile and link" >&5
+echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:1531: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:1537: checking for object suffix" >&5
+echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 1543 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:1555: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:1558: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.map | *.inf ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+{ { echo "$as_me:1570: error: cannot compute OBJEXT: cannot compile" >&5
+echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:1577: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:1581: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 1587 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1602: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:1605: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:1608: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:1611: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_compiler_gnu=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:1623: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:1629: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 1635 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1647: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:1650: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:1653: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:1656: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:1666: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+ choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1693: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:1696: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:1699: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:1702: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ for ac_declaration in \
+ ''\
+ '#include <stdlib.h>' \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);'
+do
+ cat >conftest.$ac_ext <<_ACEOF
+#line 1714 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1727: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:1730: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:1733: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:1736: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+continue
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+#line 1746 "configure"
+#include "confdefs.h"
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1758: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:1761: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:1764: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:1767: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ break
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+rm -rf conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
+
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+
+echo "$as_me:1795: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+#line 1803 "configure"
+#include "confdefs.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX 10.20 and later -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1852: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:1855: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:1858: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:1861: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+ x|xno)
+ echo "$as_me:1878: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+ *)
+ echo "$as_me:1881: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+ CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+echo "$as_me:1886: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 1892 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+ /* Ultrix mips cc rejects this. */
+ typedef int charset[2];
+ const charset x;
+ /* SunOS 4.1.1 cc rejects this. */
+ char const *const *ccp;
+ char **p;
+ /* NEC SVR4.0.2 mips cc rejects this. */
+ struct point {int x, y;};
+ static struct point const zero = {0,0};
+ /* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in
+ an arm of an if-expression whose if-part is not a constant
+ expression */
+ const char *g = "string";
+ ccp = &g + (g ? g-g : 0);
+ /* HPUX 7.0 cc rejects these. */
+ ++ccp;
+ p = (char**) ccp;
+ ccp = (char const *const *) p;
+ { /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+ }
+ { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+ }
+ { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+ }
+ { /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+ }
+ { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+ }
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1950: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:1953: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:1956: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:1959: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_const=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_c_const=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:1969: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo "$as_me:1979: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.make <<\EOF
+all:
+ @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftest.make
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$as_me:1999: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ SET_MAKE=
+else
+ echo "$as_me:2003: result: no" >&5
+echo "${ECHO_T}no" >&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo "$as_me:2020: checking for a BSD compatible install" >&5
+echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ for ac_dir in $PATH; do
+ IFS=$ac_save_IFS
+ # Account for people who put trailing slashes in PATH elements.
+ case $ac_dir/ in
+ / | ./ | .// | /cC/* \
+ | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \
+ | /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if $as_executable_p "$ac_dir/$ac_prog"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL=$ac_install_sh
+ fi
+fi
+echo "$as_me:2069: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo "$as_me:2080: checking if filesystem supports mixed-case filenames" >&5
+echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6
+if test "${cf_cv_mixedcase+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+if test "$cross_compiling" = yes ; then
+ case $target_alias in #(vi
+ *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
+ cf_cv_mixedcase=no
+ ;;
+ *)
+ cf_cv_mixedcase=yes
+ ;;
+ esac
+else
+ rm -f conftest CONFTEST
+ echo test >conftest
+ if test -f CONFTEST ; then
+ cf_cv_mixedcase=no
+ else
+ cf_cv_mixedcase=yes
+ fi
+ rm -f conftest CONFTEST
+fi
+
+fi
+echo "$as_me:2107: result: $cf_cv_mixedcase" >&5
+echo "${ECHO_T}$cf_cv_mixedcase" >&6
+test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF
+#define MIXEDCASE_FILENAMES 1
+EOF
+
+for ac_prog in exctags ctags
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:2117: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CTAGS+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CTAGS"; then
+ ac_cv_prog_CTAGS="$CTAGS" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CTAGS="$ac_prog"
+echo "$as_me:2132: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CTAGS=$ac_cv_prog_CTAGS
+if test -n "$CTAGS"; then
+ echo "$as_me:2140: result: $CTAGS" >&5
+echo "${ECHO_T}$CTAGS" >&6
+else
+ echo "$as_me:2143: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CTAGS" && break
+done
+
+for ac_prog in exetags etags
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:2154: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ETAGS+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ETAGS"; then
+ ac_cv_prog_ETAGS="$ETAGS" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ETAGS="$ac_prog"
+echo "$as_me:2169: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ETAGS=$ac_cv_prog_ETAGS
+if test -n "$ETAGS"; then
+ echo "$as_me:2177: result: $ETAGS" >&5
+echo "${ECHO_T}$ETAGS" >&6
+else
+ echo "$as_me:2180: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ETAGS" && break
+done
+
+# Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args.
+set dummy ${CTAGS:-ctags}; ac_word=$2
+echo "$as_me:2189: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$MAKE_LOWER_TAGS"; then
+ ac_cv_prog_MAKE_LOWER_TAGS="$MAKE_LOWER_TAGS" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_MAKE_LOWER_TAGS="yes"
+echo "$as_me:2204: found $ac_dir/$ac_word" >&5
+break
+done
+
+ test -z "$ac_cv_prog_MAKE_LOWER_TAGS" && ac_cv_prog_MAKE_LOWER_TAGS="no"
+fi
+fi
+MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS
+if test -n "$MAKE_LOWER_TAGS"; then
+ echo "$as_me:2213: result: $MAKE_LOWER_TAGS" >&5
+echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6
+else
+ echo "$as_me:2216: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test "$cf_cv_mixedcase" = yes ; then
+ # Extract the first word of "${ETAGS:-etags}", so it can be a program name with args.
+set dummy ${ETAGS:-etags}; ac_word=$2
+echo "$as_me:2223: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$MAKE_UPPER_TAGS"; then
+ ac_cv_prog_MAKE_UPPER_TAGS="$MAKE_UPPER_TAGS" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_MAKE_UPPER_TAGS="yes"
+echo "$as_me:2238: found $ac_dir/$ac_word" >&5
+break
+done
+
+ test -z "$ac_cv_prog_MAKE_UPPER_TAGS" && ac_cv_prog_MAKE_UPPER_TAGS="no"
+fi
+fi
+MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS
+if test -n "$MAKE_UPPER_TAGS"; then
+ echo "$as_me:2247: result: $MAKE_UPPER_TAGS" >&5
+echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6
+else
+ echo "$as_me:2250: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+else
+ MAKE_UPPER_TAGS=no
+fi
+
+if test "$MAKE_UPPER_TAGS" = yes ; then
+ MAKE_UPPER_TAGS=
+else
+ MAKE_UPPER_TAGS="#"
+fi
+
+if test "$MAKE_LOWER_TAGS" = yes ; then
+ MAKE_LOWER_TAGS=
+else
+ MAKE_LOWER_TAGS="#"
+fi
+
+for ac_prog in tdlint lint alint splint lclint
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:2274: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_LINT+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$LINT"; then
+ ac_cv_prog_LINT="$LINT" # Let the user override the test.
+else
+ ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+ IFS=$ac_save_IFS
+ test -z "$ac_dir" && ac_dir=.
+ $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_LINT="$ac_prog"
+echo "$as_me:2289: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+LINT=$ac_cv_prog_LINT
+if test -n "$LINT"; then
+ echo "$as_me:2297: result: $LINT" >&5
+echo "${ECHO_T}$LINT" >&6
+else
+ echo "$as_me:2300: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$LINT" && break
+done
+
+# This should have been defined by AC_PROG_CC
+: ${CC:=cc}
+
+# Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
+# into CC. This will not help with broken scripts that wrap the compiler with
+# options, but eliminates a more common category of user confusion.
+echo "$as_me:2313: checking \$CC variable" >&5
+echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6
+case "$CC" in #(vi
+*[\ \ ]-[IUD]*)
+ echo "$as_me:2317: result: broken" >&5
+echo "${ECHO_T}broken" >&6
+ { echo "$as_me:2319: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5
+echo "$as_me: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;}
+ # humor him...
+ cf_flags=`echo "$CC" | sed -e 's/^[^ ]*[ ]//'`
+ CC=`echo "$CC" | sed -e 's/[ ].*//'`
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_flags
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+ ;;
+*)
+ echo "$as_me:2405: result: ok" >&5
+echo "${ECHO_T}ok" >&6
+ ;;
+esac
+
+echo "$as_me:2410: checking for ${CC:-cc} option to accept ANSI C" >&5
+echo $ECHO_N "checking for ${CC:-cc} option to accept ANSI C... $ECHO_C" >&6
+if test "${cf_cv_ansi_cc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_cv_ansi_cc=no
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX -Aa -D_HPUX_SOURCE
+# SVR4 -Xc
+# UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
+for cf_arg in "-DCC_HAS_PROTOS" \
+ "" \
+ -qlanglvl=ansi \
+ -std1 \
+ -Ae \
+ "-Aa -D_HPUX_SOURCE" \
+ -Xc
+do
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_arg
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+ cat >conftest.$ac_ext <<_ACEOF
+#line 2514 "configure"
+#include "confdefs.h"
+
+#ifndef CC_HAS_PROTOS
+#if !defined(__STDC__) || (__STDC__ != 1)
+choke me
+#endif
+#endif
+
+int
+main ()
+{
+
+ int test (int i, double x);
+ struct s1 {int (*f) (int a);};
+ struct s2 {int (*f) (double a);};
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2535: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:2538: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:2541: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:2544: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cf_cv_ansi_cc="$cf_arg"; break
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+CFLAGS="$cf_save_CFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS"
+
+fi
+echo "$as_me:2557: result: $cf_cv_ansi_cc" >&5
+echo "${ECHO_T}$cf_cv_ansi_cc" >&6
+
+if test "$cf_cv_ansi_cc" != "no"; then
+if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_cv_ansi_cc
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+else
+ cat >>confdefs.h <<\EOF
+#define CC_HAS_PROTOS 1
+EOF
+
+fi
+fi
+
+if test "$cf_cv_ansi_cc" = "no"; then
+ { { echo "$as_me:2650: error: Your compiler does not appear to recognize prototypes.
+You have the following choices:
+ a. adjust your compiler options
+ b. get an up-to-date compiler
+ c. use a wrapper such as unproto" >&5
+echo "$as_me: error: Your compiler does not appear to recognize prototypes.
+You have the following choices:
+ a. adjust your compiler options
+ b. get an up-to-date compiler
+ c. use a wrapper such as unproto" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+cf_XOPEN_SOURCE=500
+cf_POSIX_C_SOURCE=199506L
+cf_xopen_source=
+
+case $host_os in #(vi
+aix[4-7]*) #(vi
+ cf_xopen_source="-D_ALL_SOURCE"
+ ;;
+cygwin) #(vi
+ cf_XOPEN_SOURCE=600
+ ;;
+darwin[0-8].*) #(vi
+ cf_xopen_source="-D_APPLE_C_SOURCE"
+ ;;
+darwin*) #(vi
+ cf_xopen_source="-D_DARWIN_C_SOURCE"
+ ;;
+freebsd*|dragonfly*) #(vi
+ # 5.x headers associate
+ # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+ # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+ cf_POSIX_C_SOURCE=200112L
+ cf_XOPEN_SOURCE=600
+ cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ ;;
+hpux11*) #(vi
+ cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
+ ;;
+hpux*) #(vi
+ cf_xopen_source="-D_HPUX_SOURCE"
+ ;;
+irix[56].*) #(vi
+ cf_xopen_source="-D_SGI_SOURCE"
+ ;;
+linux*|gnu*|mint*|k*bsd*-gnu) #(vi
+
+echo "$as_me:2699: checking if we must define _GNU_SOURCE" >&5
+echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_gnu_source+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 2706 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2721: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:2724: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:2727: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:2730: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cf_cv_gnu_source=no
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_save="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+ cat >conftest.$ac_ext <<_ACEOF
+#line 2739 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2754: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:2757: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:2760: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:2763: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cf_cv_gnu_source=no
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_gnu_source=yes
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ CPPFLAGS="$cf_save"
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:2778: result: $cf_cv_gnu_source" >&5
+echo "${ECHO_T}$cf_cv_gnu_source" >&6
+test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+
+ ;;
+mirbsd*) #(vi
+ # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+ ;;
+netbsd*) #(vi
+ cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+ ;;
+openbsd*) #(vi
+ # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+ ;;
+osf[45]*) #(vi
+ cf_xopen_source="-D_OSF_SOURCE"
+ ;;
+nto-qnx*) #(vi
+ cf_xopen_source="-D_QNX_SOURCE"
+ ;;
+sco*) #(vi
+ # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+ ;;
+solaris2.1[0-9]) #(vi
+ cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ ;;
+solaris2.[1-9]) #(vi
+ cf_xopen_source="-D__EXTENSIONS__"
+ ;;
+*)
+ echo "$as_me:2808: checking if we should define _XOPEN_SOURCE" >&5
+echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_xopen_source+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+#line 2815 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2830: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:2833: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:2836: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:2839: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cf_cv_xopen_source=no
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_save="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ cat >conftest.$ac_ext <<_ACEOF
+#line 2848 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2863: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:2866: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:2869: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:2872: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cf_cv_xopen_source=no
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xopen_source=$cf_XOPEN_SOURCE
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ CPPFLAGS="$cf_save"
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:2887: result: $cf_cv_xopen_source" >&5
+echo "${ECHO_T}$cf_cv_xopen_source" >&6
+ if test "$cf_cv_xopen_source" != no ; then
+
+CFLAGS=`echo "$CFLAGS" | \
+ sed -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?$//g'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?$//g'`
+
+ cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_temp_xopen_source
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+ fi
+
+cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
+
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+
+cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \
+ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'`
+
+cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
+ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'`
+
+echo "$as_me:2994: checking if we should define _POSIX_C_SOURCE" >&5
+echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_posix_c_source+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+echo "${as_me:-configure}:3000: testing if the symbol is already defined go no further ..." 1>&5
+
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3003 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3018: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:3021: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:3024: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:3027: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cf_cv_posix_c_source=no
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_want_posix_source=no
+ case .$cf_POSIX_C_SOURCE in #(vi
+ .[12]??*) #(vi
+ cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+ ;;
+ .2) #(vi
+ cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+ cf_want_posix_source=yes
+ ;;
+ .*)
+ cf_want_posix_source=yes
+ ;;
+ esac
+ if test "$cf_want_posix_source" = yes ; then
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3048 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifdef _POSIX_SOURCE
+make an error
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3063: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:3066: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:3069: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:3072: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+
+echo "${as_me:-configure}:3083: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+
+ CFLAGS="$cf_trim_CFLAGS"
+ CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
+
+echo "${as_me:-configure}:3088: testing if the second compile does not leave our definition intact error ..." 1>&5
+
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3091 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3106: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:3109: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:3112: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:3115: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_posix_c_source=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$cf_save_CFLAGS"
+ CPPFLAGS="$cf_save_CPPFLAGS"
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:3131: result: $cf_cv_posix_c_source" >&5
+echo "${ECHO_T}$cf_cv_posix_c_source" >&6
+
+if test "$cf_cv_posix_c_source" != no ; then
+ CFLAGS="$cf_trim_CFLAGS"
+ CPPFLAGS="$cf_trim_CPPFLAGS"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_cv_posix_c_source
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+fi
+
+ ;;
+esac
+
+if test -n "$cf_xopen_source" ; then
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_xopen_source
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+echo "$as_me:3309: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3330 "configure"
+#include "confdefs.h"
+#include <assert.h>
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:3335: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:3341: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3364 "configure"
+#include "confdefs.h"
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:3368: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:3374: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:3411: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3421 "configure"
+#include "confdefs.h"
+#include <assert.h>
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:3426: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:3432: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3455 "configure"
+#include "confdefs.h"
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:3459: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:3465: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:3493: error: C preprocessor \"$CPP\" fails sanity check" >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+
+for ac_header in fcntl.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:3508: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3514 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:3518: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:3524: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:3543: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+for ac_func in atexit
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:3556: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3562 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3593: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:3596: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:3599: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:3602: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:3612: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:3622: checking for working mkstemp" >&5
+echo $ECHO_N "checking for working mkstemp... $ECHO_C" >&6
+if test "${cf_cv_func_mkstemp+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+rm -rf conftest*
+if test "$cross_compiling" = yes; then
+ echo "$as_me:3630: checking for mkstemp" >&5
+echo $ECHO_N "checking for mkstemp... $ECHO_C" >&6
+if test "${ac_cv_func_mkstemp+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3636 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char mkstemp (); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char mkstemp ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_mkstemp) || defined (__stub___mkstemp)
+choke me
+#else
+f = mkstemp;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3667: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:3670: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:3673: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:3676: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_mkstemp=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_mkstemp=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:3686: result: $ac_cv_func_mkstemp" >&5
+echo "${ECHO_T}$ac_cv_func_mkstemp" >&6
+
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3691 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+int main()
+{
+ char *tmpl = "conftestXXXXXX";
+ char name[2][80];
+ int n;
+ int result = 0;
+ int fd;
+ struct stat sb;
+
+ umask(077);
+ for (n = 0; n < 2; ++n) {
+ strcpy(name[n], tmpl);
+ if ((fd = mkstemp(name[n])) >= 0) {
+ if (!strcmp(name[n], tmpl)
+ || stat(name[n], &sb) != 0
+ || (sb.st_mode & S_IFMT) != S_IFREG
+ || (sb.st_mode & 077) != 0) {
+ result = 1;
+ }
+ close(fd);
+ }
+ }
+ if (result == 0
+ && !strcmp(name[0], name[1]))
+ result = 1;
+ ${cf_cv_main_return:-return}(result);
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:3729: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:3732: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:3734: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:3737: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cf_cv_func_mkstemp=yes
+
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_func_mkstemp=no
+
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+fi
+echo "$as_me:3752: result: $cf_cv_func_mkstemp" >&5
+echo "${ECHO_T}$cf_cv_func_mkstemp" >&6
+if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
+ cat >>confdefs.h <<\EOF
+#define HAVE_MKSTEMP 1
+EOF
+
+fi
+
+GCC_VERSION=none
+if test "$GCC" = yes ; then
+ echo "$as_me:3763: checking version of $CC" >&5
+echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
+ GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
+ test -z "$GCC_VERSION" && GCC_VERSION=unknown
+ echo "$as_me:3767: result: $GCC_VERSION" >&5
+echo "${ECHO_T}$GCC_VERSION" >&6
+fi
+
+if ( test "$GCC" = yes || test "$GXX" = yes )
+then
+echo "$as_me:3773: checking if you want to check for gcc warnings" >&5
+echo $ECHO_N "checking if you want to check for gcc warnings... $ECHO_C" >&6
+
+# Check whether --with-warnings or --without-warnings was given.
+if test "${with_warnings+set}" = set; then
+ withval="$with_warnings"
+ cf_opt_with_warnings=$withval
+else
+ cf_opt_with_warnings=no
+fi;
+echo "$as_me:3783: result: $cf_opt_with_warnings" >&5
+echo "${ECHO_T}$cf_opt_with_warnings" >&6
+if test "$cf_opt_with_warnings" != no ; then
+
+if test "$GCC" = yes
+then
+cat > conftest.i <<EOF
+#ifndef GCC_PRINTF
+#define GCC_PRINTF 0
+#endif
+#ifndef GCC_SCANF
+#define GCC_SCANF 0
+#endif
+#ifndef GCC_NORETURN
+#define GCC_NORETURN /* nothing */
+#endif
+#ifndef GCC_UNUSED
+#define GCC_UNUSED /* nothing */
+#endif
+EOF
+if test "$GCC" = yes
+then
+ { echo "$as_me:3805: checking for $CC __attribute__ directives..." >&5
+echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
+cat > conftest.$ac_ext <<EOF
+#line 3808 "${as_me:-configure}"
+#include "confdefs.h"
+#include "conftest.h"
+#include "conftest.i"
+#if GCC_PRINTF
+#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
+#else
+#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
+#endif
+#if GCC_SCANF
+#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
+#else
+#define GCC_SCANFLIKE(fmt,var) /*nothing*/
+#endif
+extern void wow(char *,...) GCC_SCANFLIKE(1,2);
+extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
+extern void foo(void) GCC_NORETURN;
+int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
+EOF
+ cf_printf_attribute=no
+ cf_scanf_attribute=no
+ for cf_attribute in scanf printf unused noreturn
+ do
+
+cf_ATTRIBUTE=`echo "$cf_attribute" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+ cf_directive="__attribute__(($cf_attribute))"
+ echo "checking for $CC $cf_directive" 1>&5
+
+ case $cf_attribute in #(vi
+ printf) #(vi
+ cf_printf_attribute=yes
+ cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE 1
+EOF
+ ;;
+ scanf) #(vi
+ cf_scanf_attribute=yes
+ cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE 1
+EOF
+ ;;
+ *) #(vi
+ cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE $cf_directive
+EOF
+ ;;
+ esac
+
+ if { (eval echo "$as_me:3857: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:3860: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ test -n "$verbose" && echo "$as_me:3862: result: ... $cf_attribute" >&5
+echo "${ECHO_T}... $cf_attribute" >&6
+ cat conftest.h >>confdefs.h
+ case $cf_attribute in #(vi
+ printf) #(vi
+ if test "$cf_printf_attribute" = no ; then
+ cat >>confdefs.h <<EOF
+#define GCC_PRINTFLIKE(fmt,var) /* nothing */
+EOF
+ else
+ cat >>confdefs.h <<EOF
+#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
+EOF
+ fi
+ ;;
+ scanf) #(vi
+ if test "$cf_scanf_attribute" = no ; then
+ cat >>confdefs.h <<EOF
+#define GCC_SCANFLIKE(fmt,var) /* nothing */
+EOF
+ else
+ cat >>confdefs.h <<EOF
+#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
+EOF
+ fi
+ ;;
+ esac
+ fi
+ done
+else
+ fgrep define conftest.i >>confdefs.h
+fi
+rm -rf conftest*
+fi
+
+INTEL_COMPILER=no
+
+if test "$GCC" = yes ; then
+ case $host_os in
+ linux*|gnu*)
+ echo "$as_me:3902: checking if this is really Intel C compiler" >&5
+echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6
+ cf_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -no-gcc"
+ cat >conftest.$ac_ext <<_ACEOF
+#line 3907 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+#ifdef __INTEL_COMPILER
+#else
+make an error
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3924: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:3927: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:3930: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:3933: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ INTEL_COMPILER=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
+
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$cf_save_CFLAGS"
+ echo "$as_me:3944: result: $INTEL_COMPILER" >&5
+echo "${ECHO_T}$INTEL_COMPILER" >&6
+ ;;
+ esac
+fi
+
+cat > conftest.$ac_ext <<EOF
+#line 3951 "${as_me:-configure}"
+int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
+EOF
+
+if test "$INTEL_COMPILER" = yes
+then
+# The "-wdXXX" options suppress warnings:
+# remark #1419: external declaration in primary source file
+# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
+# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
+# remark #193: zero used for undefined preprocessing identifier
+# remark #593: variable "curs_sb_left_arrow" was set but never used
+# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
+# remark #869: parameter "tw" was never referenced
+# remark #981: operands are evaluated in unspecified order
+# warning #279: controlling expression is constant
+
+ { echo "$as_me:3968: checking for $CC warning options..." >&5
+echo "$as_me: checking for $CC warning options..." >&6;}
+ cf_save_CFLAGS="$CFLAGS"
+ EXTRA_CFLAGS="-Wall"
+ for cf_opt in \
+ wd1419 \
+ wd1683 \
+ wd1684 \
+ wd193 \
+ wd593 \
+ wd279 \
+ wd810 \
+ wd869 \
+ wd981
+ do
+ CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+ if { (eval echo "$as_me:3984: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:3987: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ test -n "$verbose" && echo "$as_me:3989: result: ... -$cf_opt" >&5
+echo "${ECHO_T}... -$cf_opt" >&6
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
+ fi
+ done
+ CFLAGS="$cf_save_CFLAGS"
+
+elif test "$GCC" = yes
+then
+ { echo "$as_me:3998: checking for $CC warning options..." >&5
+echo "$as_me: checking for $CC warning options..." >&6;}
+ cf_save_CFLAGS="$CFLAGS"
+ EXTRA_CFLAGS=
+ cf_warn_CONST=""
+ test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
+ for cf_opt in W Wall \
+ Wbad-function-cast \
+ Wcast-align \
+ Wcast-qual \
+ Winline \
+ Wmissing-declarations \
+ Wmissing-prototypes \
+ Wnested-externs \
+ Wpointer-arith \
+ Wshadow \
+ Wstrict-prototypes \
+ Wundef $cf_warn_CONST Wwrite-strings
+ do
+ CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+ if { (eval echo "$as_me:4018: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:4021: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ test -n "$verbose" && echo "$as_me:4023: result: ... -$cf_opt" >&5
+echo "${ECHO_T}... -$cf_opt" >&6
+ case $cf_opt in #(vi
+ Wcast-qual) #(vi
+ CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
+ ;;
+ Winline) #(vi
+ case $GCC_VERSION in
+ [34].*)
+ test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6
+
+echo "${as_me:-configure}:4034: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
+
+ continue;;
+ esac
+ ;;
+ esac
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
+ fi
+ done
+ CFLAGS="$cf_save_CFLAGS"
+fi
+rm -rf conftest*
+
+fi
+fi
+
+echo "$as_me:4050: checking if you want to see long compiling messages" >&5
+echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6
+
+# Check whether --enable-echo or --disable-echo was given.
+if test "${enable_echo+set}" = set; then
+ enableval="$enable_echo"
+ test "$enableval" != no && enableval=yes
+ if test "$enableval" != "yes" ; then
+
+ ECHO_LT='--silent'
+ ECHO_LD='@echo linking $@;'
+ RULE_CC='@echo compiling $<'
+ SHOW_CC='@echo compiling $@'
+ ECHO_CC='@'
+
+ else
+
+ ECHO_LT=''
+ ECHO_LD=''
+ RULE_CC=''
+ SHOW_CC=''
+ ECHO_CC=''
+
+ fi
+else
+ enableval=yes
+
+ ECHO_LT=''
+ ECHO_LD=''
+ RULE_CC=''
+ SHOW_CC=''
+ ECHO_CC=''
+
+fi;
+echo "$as_me:4084: result: $enableval" >&5
+echo "${ECHO_T}$enableval" >&6
+
+case $cf_cv_system_name in
+os2*)
+ CFLAGS="$CFLAGS -Zmt"
+ CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
+ CXXFLAGS="$CXXFLAGS -Zmt"
+ # autoconf's macro sets -Zexe and suffix both, which conflict:w
+ LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
+ ac_cv_exeext=.exe
+ ;;
+esac
+
+PROG_EXT="$EXEEXT"
+
+test -n "$PROG_EXT" && cat >>confdefs.h <<EOF
+#define PROG_EXT "$PROG_EXT"
+EOF
+
+echo "$as_me:4104: checking if you want to use dmalloc for testing" >&5
+echo $ECHO_N "checking if you want to use dmalloc for testing... $ECHO_C" >&6
+
+# Check whether --with-dmalloc or --without-dmalloc was given.
+if test "${with_dmalloc+set}" = set; then
+ withval="$with_dmalloc"
+ cat >>confdefs.h <<\EOF
+#define USE_DMALLOC 1
+EOF
+
+ : ${with_cflags:=-g}
+ : ${with_no_leaks:=yes}
+ with_dmalloc=yes
+else
+ with_dmalloc=
+fi;
+echo "$as_me:4120: result: ${with_dmalloc:-no}" >&5
+echo "${ECHO_T}${with_dmalloc:-no}" >&6
+
+case .$with_cflags in #(vi
+.*-g*)
+ case .$CFLAGS in #(vi
+ .*-g*) #(vi
+ ;;
+ *)
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in -g
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+ ;;
+ esac
+ ;;
+esac
+
+if test "$with_dmalloc" = yes ; then
+ echo "$as_me:4214: checking for dmalloc.h" >&5
+echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
+if test "${ac_cv_header_dmalloc_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 4220 "configure"
+#include "confdefs.h"
+#include <dmalloc.h>
+_ACEOF
+if { (eval echo "$as_me:4224: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:4230: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_cv_header_dmalloc_h=yes
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_header_dmalloc_h=no
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:4249: result: $ac_cv_header_dmalloc_h" >&5
+echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
+if test $ac_cv_header_dmalloc_h = yes; then
+
+echo "$as_me:4253: checking for dmalloc_debug in -ldmalloc" >&5
+echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6
+if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldmalloc $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 4261 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dmalloc_debug ();
+int
+main ()
+{
+dmalloc_debug ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4280: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:4283: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:4286: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:4289: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dmalloc_dmalloc_debug=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_dmalloc_dmalloc_debug=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:4300: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
+echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6
+if test $ac_cv_lib_dmalloc_dmalloc_debug = yes; then
+ cat >>confdefs.h <<EOF
+#define HAVE_LIBDMALLOC 1
+EOF
+
+ LIBS="-ldmalloc $LIBS"
+
+fi
+
+fi
+
+fi
+
+echo "$as_me:4315: checking if you want to use dbmalloc for testing" >&5
+echo $ECHO_N "checking if you want to use dbmalloc for testing... $ECHO_C" >&6
+
+# Check whether --with-dbmalloc or --without-dbmalloc was given.
+if test "${with_dbmalloc+set}" = set; then
+ withval="$with_dbmalloc"
+ cat >>confdefs.h <<\EOF
+#define USE_DBMALLOC 1
+EOF
+
+ : ${with_cflags:=-g}
+ : ${with_no_leaks:=yes}
+ with_dbmalloc=yes
+else
+ with_dbmalloc=
+fi;
+echo "$as_me:4331: result: ${with_dbmalloc:-no}" >&5
+echo "${ECHO_T}${with_dbmalloc:-no}" >&6
+
+case .$with_cflags in #(vi
+.*-g*)
+ case .$CFLAGS in #(vi
+ .*-g*) #(vi
+ ;;
+ *)
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in -g
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+ ;;
+ esac
+ ;;
+esac
+
+if test "$with_dbmalloc" = yes ; then
+ echo "$as_me:4425: checking for dbmalloc.h" >&5
+echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6
+if test "${ac_cv_header_dbmalloc_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 4431 "configure"
+#include "confdefs.h"
+#include <dbmalloc.h>
+_ACEOF
+if { (eval echo "$as_me:4435: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:4441: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_cv_header_dbmalloc_h=yes
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_header_dbmalloc_h=no
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:4460: result: $ac_cv_header_dbmalloc_h" >&5
+echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6
+if test $ac_cv_header_dbmalloc_h = yes; then
+
+echo "$as_me:4464: checking for debug_malloc in -ldbmalloc" >&5
+echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6
+if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldbmalloc $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 4472 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char debug_malloc ();
+int
+main ()
+{
+debug_malloc ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4491: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:4494: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:4497: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:4500: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dbmalloc_debug_malloc=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_dbmalloc_debug_malloc=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:4511: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
+echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6
+if test $ac_cv_lib_dbmalloc_debug_malloc = yes; then
+ cat >>confdefs.h <<EOF
+#define HAVE_LIBDBMALLOC 1
+EOF
+
+ LIBS="-ldbmalloc $LIBS"
+
+fi
+
+fi
+
+fi
+
+echo "$as_me:4526: checking if you want to use valgrind for testing" >&5
+echo $ECHO_N "checking if you want to use valgrind for testing... $ECHO_C" >&6
+
+# Check whether --with-valgrind or --without-valgrind was given.
+if test "${with_valgrind+set}" = set; then
+ withval="$with_valgrind"
+ cat >>confdefs.h <<\EOF
+#define USE_VALGRIND 1
+EOF
+
+ : ${with_cflags:=-g}
+ : ${with_no_leaks:=yes}
+ with_valgrind=yes
+else
+ with_valgrind=
+fi;
+echo "$as_me:4542: result: ${with_valgrind:-no}" >&5
+echo "${ECHO_T}${with_valgrind:-no}" >&6
+
+case .$with_cflags in #(vi
+.*-g*)
+ case .$CFLAGS in #(vi
+ .*-g*) #(vi
+ ;;
+ *)
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in -g
+do
+case $cf_fix_cppflags in
+no)
+ case $cf_add_cflags in #(vi
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+ case $cf_add_cflags in
+ -D*)
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=yes
+
+ if test $cf_fix_cppflags = yes ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ elif test "${cf_tst_cflags}" = "\"'" ; then
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+ continue
+ fi
+ ;;
+ esac
+ case "$CPPFLAGS" in
+ *$cf_add_cflags) #(vi
+ ;;
+ *) #(vi
+ case $cf_add_cflags in #(vi
+ -D*)
+ cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \
+ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'`
+
+ ;;
+ esac
+ cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+ *)
+ cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ ;;
+ esac
+ ;;
+yes)
+ cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+ cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+ test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+ && test -z "${cf_tst_cflags}" \
+ && cf_fix_cppflags=no
+ ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+ CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+ CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+ EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+ ;;
+ esac
+ ;;
+esac
+
+echo "$as_me:4635: checking if you want to perform memory-leak testing" >&5
+echo $ECHO_N "checking if you want to perform memory-leak testing... $ECHO_C" >&6
+
+# Check whether --enable-leaks or --disable-leaks was given.
+if test "${enable_leaks+set}" = set; then
+ enableval="$enable_leaks"
+ if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
+else
+ : ${with_no_leaks:=no}
+fi;
+echo "$as_me:4645: result: $with_no_leaks" >&5
+echo "${ECHO_T}$with_no_leaks" >&6
+
+if test "$with_no_leaks" = yes ; then
+ cat >>confdefs.h <<\EOF
+#define NO_LEAKS 1
+EOF
+
+ cat >>confdefs.h <<\EOF
+#define YY_NO_LEAKS 1
+EOF
+
+fi
+
+### output makefile
+ac_config_files="$ac_config_files makefile"
+ac_config_commands="$ac_config_commands default"
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overriden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+ (set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+} |
+ sed '
+ t clear
+ : clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ : end' >>confcache
+if cmp -s $cache_file confcache; then :; else
+ if test -w $cache_file; then
+ test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+ cat confcache >$cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ ]*$//;
+}'
+fi
+
+DEFS=-DHAVE_CONFIG_H
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:4741: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+ac_cs_invocation="\$0 \$@"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+
+# Name of the executable.
+as_me=`echo "$0" |sed 's,.*[\\/],,'`
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+as_executable_p="test -f"
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+# NLS nuisances.
+$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
+$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
+$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
+$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
+$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
+$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
+$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
+$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+
+exec 6>&1
+
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\EOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <dickey@invisible-island.net>."
+EOF
+
+cat >>$CONFIG_STATUS <<EOF
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.52.20101002,
+ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+EOF
+
+cat >>$CONFIG_STATUS <<\EOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "x$1" : 'x\([^=]*\)='`
+ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+ shift
+ set dummy "$ac_option" "$ac_optarg" ${1+"$@"}
+ shift
+ ;;
+ -*);;
+ *) # This is not an option, so the user has probably given explicit
+ # arguments.
+ ac_need_defaults=false;;
+ esac
+
+ case $1 in
+ # Handling of the options.
+EOF
+cat >>$CONFIG_STATUS <<EOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion"
+ exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;;
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+ --version | --vers* | -V )
+ echo "$ac_cs_version"; exit 0 ;;
+ --he | --h)
+ # Conflict between --help and --header
+ { { echo "$as_me:4917: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ shift
+ CONFIG_FILES="$CONFIG_FILES $1"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $1"
+ ac_need_defaults=false;;
+
+ # This is an error.
+ -*) { { echo "$as_me:4936: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
+ esac
+ shift
+done
+
+exec 5>>config.log
+cat >&5 << _ACEOF
+
+## ----------------------- ##
+## Running config.status. ##
+## ----------------------- ##
+
+This file was extended by $as_me 2.52.20101002, executed with
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ > $ac_cs_invocation
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+
+_ACEOF
+EOF
+
+cat >>$CONFIG_STATUS <<\EOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "makefile" ) CONFIG_FILES="$CONFIG_FILES makefile" ;;
+ "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
+ "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config_h.in" ;;
+ *) { { echo "$as_me:4974: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+: ${TMPDIR=/tmp}
+{
+ tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=$TMPDIR/cs$$-$RANDOM
+ (umask 077 && mkdir $tmp)
+} ||
+{
+ echo "$me: cannot create a temporary directory in $TMPDIR" >&2
+ { (exit 1); exit 1; }
+}
+
+EOF
+
+cat >>$CONFIG_STATUS <<EOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+ # Protect against being on the right side of a sed subst in config.status.
+ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@DEFS@,$DEFS,;t t
+s,@LIBS@,$LIBS,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@target@,$target,;t t
+s,@target_cpu@,$target_cpu,;t t
+s,@target_vendor@,$target_vendor,;t t
+s,@target_os@,$target_os,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@SET_MAKE@,$SET_MAKE,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@CTAGS@,$CTAGS,;t t
+s,@ETAGS@,$ETAGS,;t t
+s,@MAKE_LOWER_TAGS@,$MAKE_LOWER_TAGS,;t t
+s,@MAKE_UPPER_TAGS@,$MAKE_UPPER_TAGS,;t t
+s,@LINT@,$LINT,;t t
+s,@LINT_OPTS@,$LINT_OPTS,;t t
+s,@EXTRA_CPPFLAGS@,$EXTRA_CPPFLAGS,;t t
+s,@CPP@,$CPP,;t t
+s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t
+s,@ECHO_LT@,$ECHO_LT,;t t
+s,@ECHO_LD@,$ECHO_LD,;t t
+s,@RULE_CC@,$RULE_CC,;t t
+s,@SHOW_CC@,$SHOW_CC,;t t
+s,@ECHO_CC@,$ECHO_CC,;t t
+s,@PROG_EXT@,$PROG_EXT,;t t
+CEOF
+
+EOF
+
+ cat >>$CONFIG_STATUS <<\EOF
+ # Split the substitutions into bite-sized pieces for seds with
+ # small command number limits, like on Digital OSF/1 and HP-UX.
+ ac_max_sed_lines=48
+ ac_sed_frag=1 # Number of current file.
+ ac_beg=1 # First line for current file.
+ ac_end=$ac_max_sed_lines # Line after last line for current file.
+ ac_more_lines=:
+ ac_sed_cmds=
+ while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ else
+ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ fi
+ if test ! -s $tmp/subs.frag; then
+ ac_more_lines=false
+ else
+ # The purpose of the label and of the branching condition is to
+ # speed up the sed processing (if there are no `@' at all, there
+ # is no need to browse any of the substitutions).
+ # These are the two extra sed commands mentioned above.
+ (echo ':t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+ fi
+ ac_sed_frag=`expr $ac_sed_frag + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+ done
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+ fi
+fi # test -n "$CONFIG_FILES"
+
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+ ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ { case "$ac_dir" in
+ [\\/]* | ?:[\\/]* ) as_incr_dir=;;
+ *) as_incr_dir=.;;
+esac
+as_dummy="$ac_dir"
+for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
+ case $as_mkdir_dir in
+ # Skip DOS drivespec
+ ?:) as_incr_dir=$as_mkdir_dir ;;
+ *)
+ as_incr_dir=$as_incr_dir/$as_mkdir_dir
+ test -d "$as_incr_dir" || mkdir "$as_incr_dir"
+ ;;
+ esac
+done; }
+
+ ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case $srcdir in
+ .) ac_srcdir=.
+ if test -z "$ac_dots"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* )
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_dots$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_dots$srcdir ;;
+ esac
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_dots$INSTALL ;;
+ esac
+
+ if test x"$ac_file" != x-; then
+ { echo "$as_me:5208: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ rm -f "$ac_file"
+ fi
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated automatically by config.status. */
+ configure_input="Generated automatically from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:5226: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo $f;;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo $f
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo $srcdir/$f
+ else
+ # /dev/null tree
+ { { echo "$as_me:5239: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+EOF
+cat >>$CONFIG_STATUS <<EOF
+ sed "$ac_vpsub
+$extrasub
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+ rm -f $tmp/stdin
+ if test x"$ac_file" != x-; then
+ mv $tmp/out $ac_file
+ else
+ cat $tmp/out
+ rm -f $tmp/out
+ fi
+
+done
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+
+#
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='[ ].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_i turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_iA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_iB='\([ ]\),\1#\2define\3'
+ac_iC=' '
+ac_iD='\4,;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ test x"$ac_file" != x- && { echo "$as_me:5305: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:5316: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo $f;;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo $f
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo $srcdir/$f
+ else
+ # /dev/null tree
+ { { echo "$as_me:5329: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+ # Remove the trailing spaces.
+ sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
+
+EOF
+
+# Transform confdefs.h into a list of #define's. We won't use it as a sed
+# script, but as data to insert where we see @DEFS@. We expect AC_SAVE_DEFS to
+# be either 'cat' or 'sort'.
+cat confdefs.h | uniq >conftest.vals
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+echo ' rm -f conftest.frag' >> $CONFIG_STATUS
+while grep . conftest.vals >/dev/null
+do
+ # Write chunks of a limited-size here document to conftest.frag.
+ echo ' cat >> conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals | sed -e 's/#ifdef.*/#if 0/' >> $CONFIG_STATUS
+ echo 'CEOF' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+# Run sed to substitute the contents of conftest.frag into $tmp/in at the
+# marker @DEFS@.
+echo ' cat >> conftest.edit <<CEOF
+/@DEFS@/r conftest.frag
+/@DEFS@/d
+CEOF
+sed -f conftest.edit $tmp/in > $tmp/out
+rm -f $tmp/in
+mv $tmp/out $tmp/in
+rm -f conftest.edit conftest.frag
+' >> $CONFIG_STATUS
+
+cat >>$CONFIG_STATUS <<\EOF
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated automatically by config.status. */
+ if test x"$ac_file" = x-; then
+ echo "/* Generated automatically by configure. */" >$tmp/config.h
+ else
+ echo "/* $ac_file. Generated automatically by configure. */" >$tmp/config.h
+ fi
+ cat $tmp/in >>$tmp/config.h
+ rm -f $tmp/in
+ if test x"$ac_file" != x-; then
+ if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
+ { echo "$as_me:5387: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ { case "$ac_dir" in
+ [\\/]* | ?:[\\/]* ) as_incr_dir=;;
+ *) as_incr_dir=.;;
+esac
+as_dummy="$ac_dir"
+for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
+ case $as_mkdir_dir in
+ # Skip DOS drivespec
+ ?:) as_incr_dir=$as_mkdir_dir ;;
+ *)
+ as_incr_dir=$as_incr_dir/$as_mkdir_dir
+ test -d "$as_incr_dir" || mkdir "$as_incr_dir"
+ ;;
+ esac
+done; }
+
+ fi
+ rm -f $ac_file
+ mv $tmp/config.h $ac_file
+ fi
+ else
+ cat $tmp/config.h
+ rm -f $tmp/config.h
+ fi
+done
+EOF
+
+cat >>$CONFIG_STATUS <<\EOF
+
+{ (exit 0); exit 0; }
+EOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
--- /dev/null
+dnl Process this file with 'autoconf' to produce a 'configure' script
+dnl Id: configure.in,v 1.10 2010/12/26 19:10:21 tom Exp
+AC_PREREQ(2.13.20020210)
+AC_REVISION(Revision: 1.10)
+AC_INIT(main.c)
+AC_CONFIG_HEADER(config.h:config_h.in)
+
+CF_CHECK_CACHE([AC_CANONICAL_SYSTEM])
+
+AC_ARG_PROGRAM
+AC_PROG_CC
+AC_CONST
+AC_PROG_MAKE_SET
+AC_PROG_INSTALL
+CF_MAKE_TAGS
+CF_PROG_LINT
+
+CF_ANSI_CC_REQD
+CF_XOPEN_SOURCE
+AC_CHECK_HEADERS(fcntl.h)
+AC_CHECK_FUNCS(atexit)
+CF_MKSTEMP
+
+CF_WITH_WARNINGS(Wwrite-strings)
+CF_DISABLE_ECHO
+CF_PROG_EXT
+CF_DISABLE_LEAKS
+
+### output makefile
+AC_OUTPUT(makefile,,,cat)
--- /dev/null
+/* $NetBSD: defs.h,v 1.5 2011/09/10 21:29:04 christos Exp $ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+/* Id: defs.h,v 1.35 2011/09/07 08:55:03 tom Exp */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h>
+
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define CONCAT(first,second) first #second
+#define CONCAT1(string,number) CONCAT(string, number)
+#define CONCAT2(first,second) #first "." #second
+
+#ifdef YYPATCH
+#define VSTRING(a,b) CONCAT2(a,b) CONCAT1(" ",YYPATCH)
+#else
+#define VSTRING(a,b) CONCAT2(a,b)
+#endif
+
+#define VERSION VSTRING(YYMAJOR, YYMINOR)
+
+/* machine-dependent definitions */
+/* the following definitions are for the Tahoe */
+/* they might have to be changed for other machines */
+
+/* MAXCHAR is the largest unsigned character value */
+/* MAXSHORT is the largest value of a C short */
+/* MINSHORT is the most negative value of a C short */
+/* MAXTABLE is the maximum table size */
+/* BITS_PER_WORD is the number of bits in a C unsigned */
+/* WORDSIZE computes the number of words needed to */
+/* store n bits */
+/* BIT returns the value of the n-th bit starting */
+/* from r (0-indexed) */
+/* SETBIT sets the n-th bit starting from r */
+
+#define MAXCHAR 255
+#define MAXSHORT 32767
+#define MINSHORT -32768
+#define MAXTABLE 32500
+#define BITS_PER_WORD 32
+#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
+#define BIT(r, n) ((((r)[(n)>>5])>>((n)&31))&1)
+#define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31)))
+
+/* character names */
+
+#define NUL '\0' /* the null character */
+#define NEWLINE '\n' /* line feed */
+#define SP ' ' /* space */
+#define BS '\b' /* backspace */
+#define HT '\t' /* horizontal tab */
+#define VT '\013' /* vertical tab */
+#define CR '\r' /* carriage return */
+#define FF '\f' /* form feed */
+#define QUOTE '\'' /* single quote */
+#define DOUBLE_QUOTE '\"' /* double quote */
+#define BACKSLASH '\\' /* backslash */
+
+#define UCH(c) (unsigned char)(c)
+
+/* defines for constructing filenames */
+
+#if defined(VMS)
+#define CODE_SUFFIX "_code.c"
+#define DEFINES_SUFFIX "_tab.h"
+#define EXTERNS_SUFFIX "_tab.i"
+#define OUTPUT_SUFFIX "_tab.c"
+#else
+#define CODE_SUFFIX ".code.c"
+#define DEFINES_SUFFIX ".tab.h"
+#define EXTERNS_SUFFIX ".tab.i"
+#define OUTPUT_SUFFIX ".tab.c"
+#endif
+#define VERBOSE_SUFFIX ".output"
+#define GRAPH_SUFFIX ".dot"
+
+/* keyword codes */
+
+#define TOKEN 0
+#define LEFT 1
+#define RIGHT 2
+#define NONASSOC 3
+#define MARK 4
+#define TEXT 5
+#define TYPE 6
+#define START 7
+#define UNION 8
+#define IDENT 9
+#define EXPECT 10
+#define EXPECT_RR 11
+#define PURE_PARSER 12
+#define PARSE_PARAM 13
+#define LEX_PARAM 14
+#define POSIX_YACC 15
+
+/* symbol classes */
+
+#define UNKNOWN 0
+#define TERM 1
+#define NONTERM 2
+
+/* the undefined value */
+
+#define UNDEFINED (-1)
+
+/* action codes */
+
+#define SHIFT 1
+#define REDUCE 2
+
+/* character macros */
+
+#define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
+#define IS_OCTAL(c) ((c) >= '0' && (c) <= '7')
+#define NUMERIC_VALUE(c) ((c) - '0')
+
+/* symbol macros */
+
+#define ISTOKEN(s) ((s) < start_symbol)
+#define ISVAR(s) ((s) >= start_symbol)
+
+/* storage allocation macros */
+
+#define CALLOC(k,n) (calloc((size_t)(k),(size_t)(n)))
+#define FREE(x) (free((char*)(x)))
+#define MALLOC(n) (malloc((size_t)(n)))
+#define NEW(t) ((t*)allocate(sizeof(t)))
+#define NEW2(n,t) ((t*)allocate(((size_t)(n)*sizeof(t))))
+#define REALLOC(p,n) (realloc((char*)(p),(size_t)(n)))
+
+#define DO_FREE(x) if (x) { FREE(x); x = 0; }
+
+#define NO_SPACE(p) if (p == 0) no_space(); assert(p != 0)
+
+/* messages */
+#define PLURAL(n) ((n) > 1 ? "s" : "")
+
+typedef char Assoc_t;
+typedef char Class_t;
+typedef short Index_t;
+typedef short Value_t;
+
+/* the structure of a symbol table entry */
+
+typedef struct bucket bucket;
+struct bucket
+{
+ struct bucket *link;
+ struct bucket *next;
+ char *name;
+ char *tag;
+ Value_t value;
+ Index_t index;
+ Value_t prec;
+ Class_t class;
+ Assoc_t assoc;
+};
+
+/* the structure of the LR(0) state machine */
+
+typedef struct core core;
+struct core
+{
+ struct core *next;
+ struct core *link;
+ Value_t number;
+ Value_t accessing_symbol;
+ Value_t nitems;
+ Value_t items[1];
+};
+
+/* the structure used to record shifts */
+
+typedef struct shifts shifts;
+struct shifts
+{
+ struct shifts *next;
+ Value_t number;
+ Value_t nshifts;
+ Value_t shift[1];
+};
+
+/* the structure used to store reductions */
+
+typedef struct reductions reductions;
+struct reductions
+{
+ struct reductions *next;
+ Value_t number;
+ Value_t nreds;
+ Value_t rules[1];
+};
+
+/* the structure used to represent parser actions */
+
+typedef struct action action;
+struct action
+{
+ struct action *next;
+ Value_t symbol;
+ Value_t number;
+ Value_t prec;
+ char action_code;
+ Assoc_t assoc;
+ char suppressed;
+};
+
+/* the structure used to store parse/lex parameters */
+typedef struct param param;
+struct param
+{
+ struct param *next;
+ char *name; /* parameter name */
+ char *type; /* everything before parameter name */
+ char *type2; /* everything after parameter name */
+};
+
+/* global variables */
+
+extern char dflag;
+extern char gflag;
+extern char iflag;
+extern char lflag;
+extern char rflag;
+extern char tflag;
+extern char vflag;
+extern const char *symbol_prefix;
+
+extern const char *myname;
+extern char *cptr;
+extern char *line;
+extern int lineno;
+extern int outline;
+extern int exit_code;
+extern int pure_parser;
+
+extern const char *const banner[];
+extern const char *const xdecls[];
+extern const char *const tables[];
+extern const char *const global_vars[];
+extern const char *const impure_vars[];
+extern const char *const hdr_defs[];
+extern const char *const hdr_vars[];
+extern const char *const body_1[];
+extern const char *const body_vars[];
+extern const char *const body_2[];
+extern const char *const body_3[];
+extern const char *const trailer[];
+extern const char *const trailer_2[];
+
+extern char *code_file_name;
+extern char *input_file_name;
+extern char *defines_file_name;
+extern char *externs_file_name;
+
+extern FILE *action_file;
+extern FILE *code_file;
+extern FILE *defines_file;
+extern FILE *externs_file;
+extern FILE *input_file;
+extern FILE *output_file;
+extern FILE *text_file;
+extern FILE *union_file;
+extern FILE *verbose_file;
+extern FILE *graph_file;
+
+extern int nitems;
+extern int nrules;
+extern int nsyms;
+extern int ntokens;
+extern int nvars;
+extern int ntags;
+
+extern char unionized;
+extern char line_format[];
+
+extern Value_t start_symbol;
+extern char **symbol_name;
+extern char **symbol_pname;
+extern Value_t *symbol_value;
+extern Value_t *symbol_prec;
+extern char *symbol_assoc;
+
+extern Value_t *ritem;
+extern Value_t *rlhs;
+extern Value_t *rrhs;
+extern Value_t *rprec;
+extern Assoc_t *rassoc;
+
+extern Value_t **derives;
+extern char *nullable;
+
+extern bucket *first_symbol;
+extern bucket *last_symbol;
+
+extern int pure_parser;
+extern int nstates;
+extern core *first_state;
+extern shifts *first_shift;
+extern reductions *first_reduction;
+extern Value_t *accessing_symbol;
+extern core **state_table;
+extern shifts **shift_table;
+extern reductions **reduction_table;
+extern unsigned *LA;
+extern Value_t *LAruleno;
+extern Value_t *lookaheads;
+extern Value_t *goto_map;
+extern Value_t *from_state;
+extern Value_t *to_state;
+
+extern action **parser;
+extern int SRexpect;
+extern int RRexpect;
+extern int SRtotal;
+extern int RRtotal;
+extern Value_t *SRconflicts;
+extern Value_t *RRconflicts;
+extern Value_t *defred;
+extern Value_t *rules_used;
+extern Value_t nunused;
+extern Value_t final_state;
+
+extern Value_t *itemset;
+extern Value_t *itemsetend;
+extern unsigned *ruleset;
+
+extern param *lex_param;
+extern param *parse_param;
+
+/* global functions */
+
+extern bucket *lookup(const char *);
+extern bucket *make_bucket(const char *);
+
+#ifndef GCC_NORETURN
+#define GCC_NORETURN /* nothing */
+#endif
+
+#ifndef GCC_UNUSED
+#define GCC_UNUSED /* nothing */
+#endif
+
+/* closure.c */
+extern void closure(Value_t * nucleus, int n);
+extern void finalize_closure(void);
+extern void set_first_derives(void);
+
+/* error.c */
+extern void default_action_warning(void);
+extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN;
+extern void dollar_warning(int a_lineno, int i);
+extern void fatal(const char *msg) GCC_NORETURN;
+extern void illegal_character(char *c_cptr) GCC_NORETURN;
+extern void illegal_tag(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN;
+extern void missing_brace(void) GCC_NORETURN;
+extern void no_grammar(void) GCC_NORETURN;
+extern void no_space(void) GCC_NORETURN;
+extern void open_error(const char *filename) GCC_NORETURN;
+extern void over_unionized(char *u_cptr) GCC_NORETURN;
+extern void prec_redeclared(void);
+extern void reprec_warning(char *s);
+extern void restarted_warning(void);
+extern void retyped_warning(char *s);
+extern void revalued_warning(char *s);
+extern void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN;
+extern void terminal_lhs(int s_lineno) GCC_NORETURN;
+extern void terminal_start(char *s) GCC_NORETURN;
+extern void tokenized_start(char *s) GCC_NORETURN;
+extern void undefined_goal(char *s) GCC_NORETURN;
+extern void undefined_symbol_warning(char *s);
+extern void unexpected_EOF(void) GCC_NORETURN;
+extern void unknown_rhs(int i) GCC_NORETURN;
+extern void unterminated_action(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN;
+extern void unterminated_comment(int c_lineno, char *c_line, char *c_cptr) GCC_NORETURN;
+extern void unterminated_string(int s_lineno, char *s_line, char *s_cptr) GCC_NORETURN;
+extern void unterminated_text(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN;
+extern void unterminated_union(int u_lineno, char *u_line, char *u_cptr) GCC_NORETURN;
+extern void untyped_lhs(void) GCC_NORETURN;
+extern void untyped_rhs(int i, char *s) GCC_NORETURN;
+extern void used_reserved(char *s) GCC_NORETURN;
+
+/* graph.c */
+extern void graph(void);
+
+/* lalr.c */
+extern void create_symbol_table(void);
+extern void free_symbol_table(void);
+extern void free_symbols(void);
+
+/* lalr.c */
+extern void lalr(void);
+
+/* lr0.c */
+extern void lr0(void);
+extern void show_cores(void);
+extern void show_ritems(void);
+extern void show_rrhs(void);
+extern void show_shifts(void);
+
+/* main.c */
+extern void *allocate(size_t n);
+extern void done(int k) GCC_NORETURN;
+
+/* mkpar.c */
+extern void free_parser(void);
+extern void make_parser(void);
+
+/* output.c */
+extern void output(void);
+
+/* reader.c */
+extern void reader(void);
+
+/* skeleton.c */
+extern void write_section(FILE *fp, const char *const section[]);
+
+/* verbose.c */
+extern void verbose(void);
+
+/* warshall.c */
+extern void reflexive_transitive_closure(unsigned *R, int n);
+
+#ifdef NO_LEAKS
+extern void lr0_leaks(void);
+extern void lalr_leaks(void);
+extern void mkpar_leaks(void);
+extern void output_leaks(void);
+extern void reader_leaks(void);
+#endif
--- /dev/null
+CFLAGS = /decc $(CC_OPTIONS)/Diagnostics /Define=(NDEBUG) /Object=$@ /Include=([])
+
+LINKFLAGS = /map=$(MMS$TARGET_NAME)/cross_reference/exec=$(MMS$TARGET_NAME).exe
+
+LINKER = cc
+
+OBJS = closure.obj, \
+ error.obj, \
+ lalr.obj, \
+ lr0.obj, \
+ main.obj, \
+ mkpar.obj, \
+ output.obj, \
+ reader.obj, \
+ skeleton.obj, \
+ symtab.obj, \
+ verbose.obj, \
+ warshall.obj
+
+PROGRAM = yacc.exe
+
+all : $(PROGRAM)
+
+$(PROGRAM) : $(OBJS)
+ @ write sys$output "Loading $(PROGRAM) ... "
+ @ $(LINK) $(LINKFLAGS) $(OBJS)
+ @ write sys$output "done"
+
+clean :
+ @- if f$search("*.obj") .nes. "" then delete *.obj;*
+ @- if f$search("*.lis") .nes. "" then delete *.lis;*
+ @- if f$search("*.log") .nes. "" then delete *.log;*
+
+clobber : clean
+ @- if f$search("*.exe") .nes. "" then delete *.exe;*
+
+$(OBJS) : defs.h
-/* $NetBSD: error.c,v 1.11 2009/04/14 09:41:30 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
+/* $NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
+/* Id: error.c,v 1.9 2011/09/05 23:27:43 tom Exp */
+
+#include "defs.h"
#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
-#else
-__RCSID("$NetBSD: error.c,v 1.11 2009/04/14 09:41:30 lukem Exp $");
-#endif
-#endif /* not lint */
+__RCSID("$NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
/* routines for printing error messages */
-#include "defs.h"
-
__dead void
fatal(const char *msg)
{
done(2);
}
-
__dead void
no_space(void)
{
done(2);
}
-__dead void
+void
+missing_brace(void)
+{
+ fprintf(stderr, "%s: e - line %d of \"%s\", missing '}'\n",
+ myname, lineno, input_file_name);
+ done(1);
+}
+
+void
unexpected_EOF(void)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
done(1);
}
-void
+static void
print_pos(char *st_line, char *st_cptr)
{
char *s;
- if (st_line == 0) return;
+ if (st_line == 0)
+ return;
for (s = st_line; *s != '\n'; ++s)
{
- if (isprint((unsigned char)*s) || *s == '\t')
+ if (isprint(UCH(*s)) || *s == '\t')
putc(*s, stderr);
else
putc('?', stderr);
__dead void
used_reserved(char *s)
{
- fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
+ fprintf(stderr,
+ "%s: e - line %d of \"%s\", illegal use of reserved symbol \
%s\n", myname, lineno, input_file_name, s);
done(1);
}
__dead void
tokenized_start(char *s)
{
- fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
+ fprintf(stderr,
+ "%s: e - line %d of \"%s\", the start symbol %s cannot be \
declared to be a token\n", myname, lineno, input_file_name, s);
- done(1);
+ done(1);
}
void
void
reprec_warning(char *s)
{
- fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
+ fprintf(stderr,
+ "%s: w - line %d of \"%s\", the precedence of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
redeclared\n", myname, lineno, input_file_name, s);
}
-__dead void
+void
terminal_start(char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
redeclared\n", myname, lineno, input_file_name);
}
-__dead void
+void
no_grammar(void)
{
fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
done(1);
}
-__dead void
+void
terminal_lhs(int s_lineno)
{
fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
specifiers\n", myname, lineno, input_file_name);
}
-__dead void
+void
unterminated_action(int a_lineno, char *a_line, char *a_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
void
default_action_warning(void)
{
- fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
+ fprintf(stderr,
+ "%s: w - line %d of \"%s\", the default action assigns an \
undefined value to $$\n", myname, lineno, input_file_name);
}
-__dead void
+void
undefined_goal(char *s)
{
fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
--- /dev/null
+/* $NetBSD: graph.c,v 1.4 2010/12/25 23:43:30 christos Exp $ */
+/* Id: graph.c,v 1.7 2009/10/27 09:25:20 tom Exp */
+
+#include "defs.h"
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: graph.c,v 1.4 2010/12/25 23:43:30 christos Exp $");
+
+static void graph_state(int stateno);
+static void graph_LA(int ruleno);
+
+static unsigned int larno;
+
+void
+graph(void)
+{
+ int i;
+ int j;
+ shifts *sp;
+ int sn;
+ int as;
+
+ if (!gflag)
+ return;
+
+ for (i = 0; i < nstates; ++i)
+ {
+ closure(state_table[i]->items, state_table[i]->nitems);
+ graph_state(i);
+ }
+
+ fprintf(graph_file, "\n\n");
+ for (i = 0; i < nstates; ++i)
+ {
+
+ sp = shift_table[i];
+ if (sp)
+ for (j = 0; j < sp->nshifts; ++j)
+ {
+ sn = sp->shift[j];
+ as = accessing_symbol[sn];
+ fprintf(graph_file,
+ "\tq%d -> q%d [label=\"%s\"];\n",
+ i, sn, symbol_pname[as]);
+ }
+ }
+
+ fprintf(graph_file, "}\n");
+
+ for (i = 0; i < nsyms; ++i)
+ FREE(symbol_pname[i]);
+ FREE(symbol_pname);
+}
+
+static void
+graph_state(int stateno)
+{
+ short *isp;
+ int rule;
+ short *sp;
+ short *sp1;
+
+ larno = (unsigned)lookaheads[stateno];
+ fprintf(graph_file, "\n\tq%d [label=\"%d:\\l", stateno, stateno);
+
+ for (isp = itemset; isp < itemsetend; isp++)
+ {
+ sp1 = sp = ritem + *isp;
+
+ while (*sp >= 0)
+ ++sp;
+ rule = -(*sp);
+ fprintf(graph_file, " %s -> ", symbol_pname[rlhs[rule]]);
+
+ for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
+ fprintf(graph_file, "%s ", symbol_pname[*sp]);
+
+ putc('.', graph_file);
+
+ while (*sp >= 0)
+ {
+ fprintf(graph_file, " %s", symbol_pname[*sp]);
+ sp++;
+ }
+
+ if (*sp1 < 0)
+ graph_LA(-*sp1);
+
+ fprintf(graph_file, "\\l");
+ }
+ fprintf(graph_file, "\"];");
+}
+
+static void
+graph_LA(int ruleno)
+{
+ int i;
+ unsigned tokensetsize;
+ unsigned *rowp;
+
+ tokensetsize = (unsigned)WORDSIZE(ntokens);
+
+ if (ruleno == LAruleno[larno])
+ {
+ rowp = LA + larno * tokensetsize;
+
+ fprintf(graph_file, " { ");
+ for (i = ntokens - 1; i >= 0; i--)
+ {
+ if (BIT(rowp, i))
+ fprintf(graph_file, "%s ", symbol_pname[i]);
+ }
+ fprintf(graph_file, "}");
+ ++larno;
+ }
+}
--- /dev/null
+#! /bin/sh
+#
+# install - install a program, script, or datafile
+#
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd=$cpprog
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd=$stripprog
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "$0: no input file specified" >&2
+ exit 1
+else
+ :
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d "$dst" ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=$mkdirprog
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f "$src" ] || [ -d "$src" ]
+ then
+ :
+ else
+ echo "$0: $src does not exist" >&2
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "$0: no destination specified" >&2
+ exit 1
+ else
+ :
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d "$dst" ]
+ then
+ dst=$dst/`basename "$src"`
+ else
+ :
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+ '
+IFS="${IFS-$defaultIFS}"
+
+oIFS=$IFS
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS=$oIFS
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp=$pathcomp$1
+ shift
+
+ if [ ! -d "$pathcomp" ] ;
+ then
+ $mkdirprog "$pathcomp"
+ else
+ :
+ fi
+
+ pathcomp=$pathcomp/
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd "$dst" &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename "$dst"`
+ else
+ dstfile=`basename "$dst" $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename "$dst"`
+ else
+ :
+ fi
+
+# Make a couple of temp file names in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+ rmtmp=$dstdir/#rm.$$#
+
+# Trap to clean up temp files at exit.
+
+ trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
+ trap '(exit $?); exit' 1 2 13 15
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd "$src" "$dsttmp" &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
+
+# Now remove or move aside any old file at destination location. We try this
+# two ways since rm can't unlink itself on some systems and the destination
+# file might be busy for other reasons. In this case, the final cleanup
+# might fail but the new file should still install successfully.
+
+{
+ if [ -f "$dstdir/$dstfile" ]
+ then
+ $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
+ $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
+ {
+ echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+ (exit 1); exit
+ }
+ else
+ :
+ fi
+} &&
+
+# Now rename the file to the real destination.
+
+ $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+
+fi &&
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+
+{
+ (exit 0); exit
+}
--- /dev/null
+/* $NetBSD: lalr.c,v 1.5 2011/09/10 21:29:04 christos Exp $ */
+/* Id: lalr.c,v 1.9 2009/10/27 09:49:27 tom Exp */
+
+#include "defs.h"
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: lalr.c,v 1.5 2011/09/10 21:29:04 christos Exp $");
+
+typedef struct shorts
+{
+ struct shorts *next;
+ Value_t value;
+}
+shorts;
+
+static Value_t map_goto(int state, int symbol);
+static Value_t **transpose(Value_t ** R, int n);
+static void add_lookback_edge(int stateno, int ruleno, int gotono);
+static void build_relations(void);
+static void compute_FOLLOWS(void);
+static void compute_lookaheads(void);
+static void digraph(Value_t ** relation);
+static void initialize_F(void);
+static void initialize_LA(void);
+static void set_accessing_symbol(void);
+static void set_goto_map(void);
+static void set_maxrhs(void);
+static void set_reduction_table(void);
+static void set_shift_table(void);
+static void set_state_table(void);
+static void traverse(int i);
+
+static int tokensetsize;
+Value_t *lookaheads;
+Value_t *LAruleno;
+unsigned *LA;
+Value_t *accessing_symbol;
+core **state_table;
+shifts **shift_table;
+reductions **reduction_table;
+Value_t *goto_map;
+Value_t *from_state;
+Value_t *to_state;
+
+static Value_t infinity;
+static int maxrhs;
+static int ngotos;
+static unsigned *F;
+static Value_t **includes;
+static shorts **lookback;
+static Value_t **R;
+static Value_t *INDEX;
+static Value_t *VERTICES;
+static Value_t top;
+
+void
+lalr(void)
+{
+ tokensetsize = WORDSIZE(ntokens);
+
+ set_state_table();
+ set_accessing_symbol();
+ set_shift_table();
+ set_reduction_table();
+ set_maxrhs();
+ initialize_LA();
+ set_goto_map();
+ initialize_F();
+ build_relations();
+ compute_FOLLOWS();
+ compute_lookaheads();
+}
+
+static void
+set_state_table(void)
+{
+ core *sp;
+
+ state_table = NEW2(nstates, core *);
+ for (sp = first_state; sp; sp = sp->next)
+ state_table[sp->number] = sp;
+}
+
+static void
+set_accessing_symbol(void)
+{
+ core *sp;
+
+ accessing_symbol = NEW2(nstates, Value_t);
+ for (sp = first_state; sp; sp = sp->next)
+ accessing_symbol[sp->number] = sp->accessing_symbol;
+}
+
+static void
+set_shift_table(void)
+{
+ shifts *sp;
+
+ shift_table = NEW2(nstates, shifts *);
+ for (sp = first_shift; sp; sp = sp->next)
+ shift_table[sp->number] = sp;
+}
+
+static void
+set_reduction_table(void)
+{
+ reductions *rp;
+
+ reduction_table = NEW2(nstates, reductions *);
+ for (rp = first_reduction; rp; rp = rp->next)
+ reduction_table[rp->number] = rp;
+}
+
+static void
+set_maxrhs(void)
+{
+ Value_t *itemp;
+ Value_t *item_end;
+ int length;
+ int max;
+
+ length = 0;
+ max = 0;
+ item_end = ritem + nitems;
+ for (itemp = ritem; itemp < item_end; itemp++)
+ {
+ if (*itemp >= 0)
+ {
+ length++;
+ }
+ else
+ {
+ if (length > max)
+ max = length;
+ length = 0;
+ }
+ }
+
+ maxrhs = max;
+}
+
+static void
+initialize_LA(void)
+{
+ int i, j, k;
+ reductions *rp;
+
+ lookaheads = NEW2(nstates + 1, Value_t);
+
+ k = 0;
+ for (i = 0; i < nstates; i++)
+ {
+ lookaheads[i] = (Value_t) k;
+ rp = reduction_table[i];
+ if (rp)
+ k += rp->nreds;
+ }
+ lookaheads[nstates] = (Value_t) k;
+
+ LA = NEW2(k * tokensetsize, unsigned);
+ LAruleno = NEW2(k, Value_t);
+ lookback = NEW2(k, shorts *);
+
+ k = 0;
+ for (i = 0; i < nstates; i++)
+ {
+ rp = reduction_table[i];
+ if (rp)
+ {
+ for (j = 0; j < rp->nreds; j++)
+ {
+ LAruleno[k] = rp->rules[j];
+ k++;
+ }
+ }
+ }
+}
+
+static void
+set_goto_map(void)
+{
+ shifts *sp;
+ int i;
+ int symbol;
+ int k;
+ Value_t *temp_map;
+ Value_t state2;
+ Value_t state1;
+
+ goto_map = NEW2(nvars + 1, Value_t) - ntokens;
+ temp_map = NEW2(nvars + 1, Value_t) - ntokens;
+
+ ngotos = 0;
+ for (sp = first_shift; sp; sp = sp->next)
+ {
+ for (i = sp->nshifts - 1; i >= 0; i--)
+ {
+ symbol = accessing_symbol[sp->shift[i]];
+
+ if (ISTOKEN(symbol))
+ break;
+
+ if (ngotos == MAXSHORT)
+ fatal("too many gotos");
+
+ ngotos++;
+ goto_map[symbol]++;
+ }
+ }
+
+ k = 0;
+ for (i = ntokens; i < nsyms; i++)
+ {
+ temp_map[i] = (Value_t) k;
+ k += goto_map[i];
+ }
+
+ for (i = ntokens; i < nsyms; i++)
+ goto_map[i] = temp_map[i];
+
+ goto_map[nsyms] = (Value_t) ngotos;
+ temp_map[nsyms] = (Value_t) ngotos;
+
+ from_state = NEW2(ngotos, Value_t);
+ to_state = NEW2(ngotos, Value_t);
+
+ for (sp = first_shift; sp; sp = sp->next)
+ {
+ state1 = sp->number;
+ for (i = sp->nshifts - 1; i >= 0; i--)
+ {
+ state2 = sp->shift[i];
+ symbol = accessing_symbol[state2];
+
+ if (ISTOKEN(symbol))
+ break;
+
+ k = temp_map[symbol]++;
+ from_state[k] = state1;
+ to_state[k] = state2;
+ }
+ }
+
+ FREE(temp_map + ntokens);
+}
+
+/* Map_goto maps a state/symbol pair into its numeric representation. */
+
+static Value_t
+map_goto(int state, int symbol)
+{
+ int high;
+ int low;
+ int middle;
+ int s;
+
+ low = goto_map[symbol];
+ high = goto_map[symbol + 1];
+
+ for (;;)
+ {
+ assert(low <= high);
+ middle = (low + high) >> 1;
+ s = from_state[middle];
+ if (s == state)
+ return (Value_t) (middle);
+ else if (s < state)
+ low = middle + 1;
+ else
+ high = middle - 1;
+ }
+}
+
+static void
+initialize_F(void)
+{
+ int i;
+ int j;
+ int k;
+ shifts *sp;
+ Value_t *edge;
+ unsigned *rowp;
+ Value_t *rp;
+ Value_t **reads;
+ int nedges;
+ int stateno;
+ int symbol;
+ int nwords;
+
+ nwords = ngotos * tokensetsize;
+ F = NEW2(nwords, unsigned);
+
+ reads = NEW2(ngotos, Value_t *);
+ edge = NEW2(ngotos + 1, Value_t);
+ nedges = 0;
+
+ rowp = F;
+ for (i = 0; i < ngotos; i++)
+ {
+ stateno = to_state[i];
+ sp = shift_table[stateno];
+
+ if (sp)
+ {
+ k = sp->nshifts;
+
+ for (j = 0; j < k; j++)
+ {
+ symbol = accessing_symbol[sp->shift[j]];
+ if (ISVAR(symbol))
+ break;
+ SETBIT(rowp, symbol);
+ }
+
+ for (; j < k; j++)
+ {
+ symbol = accessing_symbol[sp->shift[j]];
+ if (nullable[symbol])
+ edge[nedges++] = map_goto(stateno, symbol);
+ }
+
+ if (nedges)
+ {
+ reads[i] = rp = NEW2(nedges + 1, Value_t);
+
+ for (j = 0; j < nedges; j++)
+ rp[j] = edge[j];
+
+ rp[nedges] = -1;
+ nedges = 0;
+ }
+ }
+
+ rowp += tokensetsize;
+ }
+
+ SETBIT(F, 0);
+ digraph(reads);
+
+ for (i = 0; i < ngotos; i++)
+ {
+ if (reads[i])
+ FREE(reads[i]);
+ }
+
+ FREE(reads);
+ FREE(edge);
+}
+
+static void
+build_relations(void)
+{
+ int i;
+ int j;
+ int k;
+ Value_t *rulep;
+ Value_t *rp;
+ shifts *sp;
+ int length;
+ int nedges;
+ int done_flag;
+ Value_t state1;
+ Value_t stateno;
+ int symbol1;
+ int symbol2;
+ Value_t *shortp;
+ Value_t *edge;
+ Value_t *states;
+ Value_t **new_includes;
+
+ includes = NEW2(ngotos, Value_t *);
+ edge = NEW2(ngotos + 1, Value_t);
+ states = NEW2(maxrhs + 1, Value_t);
+
+ for (i = 0; i < ngotos; i++)
+ {
+ nedges = 0;
+ state1 = from_state[i];
+ symbol1 = accessing_symbol[to_state[i]];
+
+ for (rulep = derives[symbol1]; *rulep >= 0; rulep++)
+ {
+ length = 1;
+ states[0] = state1;
+ stateno = state1;
+
+ for (rp = ritem + rrhs[*rulep]; *rp >= 0; rp++)
+ {
+ symbol2 = *rp;
+ sp = shift_table[stateno];
+ k = sp->nshifts;
+
+ for (j = 0; j < k; j++)
+ {
+ stateno = sp->shift[j];
+ if (accessing_symbol[stateno] == symbol2)
+ break;
+ }
+
+ states[length++] = stateno;
+ }
+
+ add_lookback_edge(stateno, *rulep, i);
+
+ length--;
+ done_flag = 0;
+ while (!done_flag)
+ {
+ done_flag = 1;
+ rp--;
+ if (ISVAR(*rp))
+ {
+ stateno = states[--length];
+ edge[nedges++] = map_goto(stateno, *rp);
+ if (nullable[*rp] && length > 0)
+ done_flag = 0;
+ }
+ }
+ }
+
+ if (nedges)
+ {
+ includes[i] = shortp = NEW2(nedges + 1, Value_t);
+ for (j = 0; j < nedges; j++)
+ shortp[j] = edge[j];
+ shortp[nedges] = -1;
+ }
+ }
+
+ new_includes = transpose(includes, ngotos);
+
+ for (i = 0; i < ngotos; i++)
+ if (includes[i])
+ FREE(includes[i]);
+
+ FREE(includes);
+
+ includes = new_includes;
+
+ FREE(edge);
+ FREE(states);
+}
+
+static void
+add_lookback_edge(int stateno, int ruleno, int gotono)
+{
+ int i, k;
+ int found;
+ shorts *sp;
+
+ i = lookaheads[stateno];
+ k = lookaheads[stateno + 1];
+ found = 0;
+ while (!found && i < k)
+ {
+ if (LAruleno[i] == ruleno)
+ found = 1;
+ else
+ ++i;
+ }
+ assert(found);
+
+ sp = NEW(shorts);
+ sp->next = lookback[i];
+ sp->value = (Value_t) gotono;
+ lookback[i] = sp;
+}
+
+static Value_t **
+transpose(Value_t ** R2, int n)
+{
+ Value_t **new_R;
+ Value_t **temp_R;
+ Value_t *nedges;
+ Value_t *sp;
+ int i;
+ int k;
+
+ nedges = NEW2(n, Value_t);
+
+ for (i = 0; i < n; i++)
+ {
+ sp = R2[i];
+ if (sp)
+ {
+ while (*sp >= 0)
+ nedges[*sp++]++;
+ }
+ }
+
+ new_R = NEW2(n, Value_t *);
+ temp_R = NEW2(n, Value_t *);
+
+ for (i = 0; i < n; i++)
+ {
+ k = nedges[i];
+ if (k > 0)
+ {
+ sp = NEW2(k + 1, Value_t);
+ new_R[i] = sp;
+ temp_R[i] = sp;
+ sp[k] = -1;
+ }
+ }
+
+ FREE(nedges);
+
+ for (i = 0; i < n; i++)
+ {
+ sp = R2[i];
+ if (sp)
+ {
+ while (*sp >= 0)
+ *temp_R[*sp++]++ = (Value_t) i;
+ }
+ }
+
+ FREE(temp_R);
+
+ return (new_R);
+}
+
+static void
+compute_FOLLOWS(void)
+{
+ digraph(includes);
+}
+
+static void
+compute_lookaheads(void)
+{
+ int i, n;
+ unsigned *fp1, *fp2, *fp3;
+ shorts *sp, *next;
+ unsigned *rowp;
+
+ rowp = LA;
+ n = lookaheads[nstates];
+ for (i = 0; i < n; i++)
+ {
+ fp3 = rowp + tokensetsize;
+ for (sp = lookback[i]; sp; sp = sp->next)
+ {
+ fp1 = rowp;
+ fp2 = F + tokensetsize * sp->value;
+ while (fp1 < fp3)
+ *fp1++ |= *fp2++;
+ }
+ rowp = fp3;
+ }
+
+ for (i = 0; i < n; i++)
+ for (sp = lookback[i]; sp; sp = next)
+ {
+ next = sp->next;
+ FREE(sp);
+ }
+
+ FREE(lookback);
+ FREE(F);
+}
+
+static void
+digraph(Value_t ** relation)
+{
+ int i;
+
+ infinity = (Value_t) (ngotos + 2);
+ INDEX = NEW2(ngotos + 1, Value_t);
+ VERTICES = NEW2(ngotos + 1, Value_t);
+ top = 0;
+
+ R = relation;
+
+ for (i = 0; i < ngotos; i++)
+ INDEX[i] = 0;
+
+ for (i = 0; i < ngotos; i++)
+ {
+ if (INDEX[i] == 0 && R[i])
+ traverse(i);
+ }
+
+ FREE(INDEX);
+ FREE(VERTICES);
+}
+
+static void
+traverse(int i)
+{
+ unsigned *fp1;
+ unsigned *fp2;
+ unsigned *fp3;
+ int j;
+ Value_t *rp;
+
+ Value_t height;
+ unsigned *base;
+
+ VERTICES[++top] = (Value_t) i;
+ INDEX[i] = height = top;
+
+ base = F + i * tokensetsize;
+ fp3 = base + tokensetsize;
+
+ rp = R[i];
+ if (rp)
+ {
+ while ((j = *rp++) >= 0)
+ {
+ if (INDEX[j] == 0)
+ traverse(j);
+
+ if (INDEX[i] > INDEX[j])
+ INDEX[i] = INDEX[j];
+
+ fp1 = base;
+ fp2 = F + j * tokensetsize;
+
+ while (fp1 < fp3)
+ *fp1++ |= *fp2++;
+ }
+ }
+
+ if (INDEX[i] == height)
+ {
+ for (;;)
+ {
+ j = VERTICES[top--];
+ INDEX[j] = infinity;
+
+ if (i == j)
+ break;
+
+ fp1 = base;
+ fp2 = F + j * tokensetsize;
+
+ while (fp1 < fp3)
+ *fp2++ = *fp1++;
+ }
+ }
+}
+
+#ifdef NO_LEAKS
+void
+lalr_leaks(void)
+{
+ int i;
+
+ if (includes != 0)
+ {
+ for (i = 0; i < ngotos; i++)
+ {
+ free(includes[i]);
+ }
+ DO_FREE(includes);
+ }
+}
+#endif
-/* $NetBSD: lr0.c,v 1.10 2009/04/14 09:41:30 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91";
-#else
-__RCSID("$NetBSD: lr0.c,v 1.10 2009/04/14 09:41:30 lukem Exp $");
-#endif
-#endif /* not lint */
+/* $NetBSD: lr0.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
+/* Id: lr0.c,v 1.12 2010/06/09 08:53:17 tom Exp */
#include "defs.h"
-extern short *itemset;
-extern short *itemsetend;
-extern unsigned *ruleset;
-
-int nstates;
-core *first_state;
-shifts *first_shift;
-reductions *first_reduction;
-
-static int get_state(int);
-static core *new_state(int);
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: lr0.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
+static core *new_state(int symbol);
+static Value_t get_state(int symbol);
static void allocate_itemsets(void);
static void allocate_storage(void);
static void append_states(void);
static void generate_states(void);
static void initialize_states(void);
static void new_itemsets(void);
-#ifdef DEBUG
-static void show_cores(void);
-static void show_ritems(void);
-static void show_rrhs(void);
-static void show_shifts(void);
-#endif
-static void save_shifts(void);
static void save_reductions(void);
+static void save_shifts(void);
static void set_derives(void);
static void set_nullable(void);
-#ifdef DEBUG
-static void print_derives(void);
-static void free_derives(void);
-static void free_nullable(void);
-#endif
+
+int nstates;
+core *first_state;
+shifts *first_shift;
+reductions *first_reduction;
static core **state_set;
static core *this_state;
static int nshifts;
static short *shift_symbol;
-static short *redset;
-static short *shiftset;
+static Value_t *redset;
+static Value_t *shiftset;
-static short **kernel_base;
-static short **kernel_end;
-static short *kernel_items;
+static Value_t **kernel_base;
+static Value_t **kernel_end;
+static Value_t *kernel_items;
static void
allocate_itemsets(void)
{
int i;
int j;
- int symbol;
+ Value_t symbol;
#ifdef TRACE
fprintf(stderr, "Entering append_states()\n");
FREE(state_set);
}
-
static void
generate_states(void)
{
this_state = this_state->next;
}
- finalize_closure();
free_storage();
}
-
-
-static int
+static Value_t
get_state(int symbol)
{
int key;
isp1 = kernel_base[symbol];
iend = kernel_end[symbol];
- n = iend - isp1;
+ n = (int)(iend - isp1);
key = *isp1;
assert(0 <= key && key < nitems);
return (sp->number);
}
-
static void
initialize_states(void)
{
- int i;
+ unsigned i;
short *start_derives;
core *p;
for (i = 0; start_derives[i] >= 0; ++i)
continue;
- p = (core *) MALLOC(sizeof(core) + i*sizeof(short));
- if (p == 0) no_space();
+ p = (core *)MALLOC(sizeof(core) + i * sizeof(short));
+ NO_SPACE(p);
p->next = 0;
p->link = 0;
p->number = 0;
p->accessing_symbol = 0;
- p->nitems = i;
+ p->nitems = (Value_t) i;
- for (i = 0; start_derives[i] >= 0; ++i)
+ for (i = 0; start_derives[i] >= 0; ++i)
p->items[i] = rrhs[start_derives[i]];
first_state = last_state = this_state = p;
nstates = 1;
}
-
static void
new_itemsets(void)
{
- int i;
+ Value_t i;
int shiftcount;
short *isp;
short *ksp;
- int symbol;
+ Value_t symbol;
for (i = 0; i < nsyms; i++)
kernel_end[i] = 0;
ksp = kernel_base[symbol];
}
- *ksp++ = i + 1;
+ *ksp++ = (Value_t) (i + 1);
kernel_end[symbol] = ksp;
}
}
nshifts = shiftcount;
}
-
-
static core *
new_state(int symbol)
{
- int n;
+ unsigned n;
core *p;
short *isp1;
short *isp2;
isp1 = kernel_base[symbol];
iend = kernel_end[symbol];
- n = iend - isp1;
+ n = (unsigned)(iend - isp1);
- p = (core *) allocate((unsigned) (sizeof(core) + (n - 1) * sizeof(short)));
- p->accessing_symbol = symbol;
- p->number = nstates;
- p->nitems = n;
+ p = (core *)allocate((sizeof(core) + (n - 1) * sizeof(short)));
+ p->accessing_symbol = (Value_t) symbol;
+ p->number = (Value_t) nstates;
+ p->nitems = (Value_t) n;
isp2 = p->items;
while (isp1 < iend)
return (p);
}
-#ifdef DEBUG
/* show_cores is used for debugging */
-static void
+
+void
show_cores(void)
{
core *p;
k = 0;
for (p = first_state; p; ++k, p = p->next)
{
- if (k) printf("\n");
+ if (k)
+ printf("\n");
printf("state %d, number = %d, accessing symbol = %s\n",
- k, p->number, symbol_name[p->accessing_symbol]);
+ k, p->number, symbol_name[p->accessing_symbol]);
n = p->nitems;
for (i = 0; i < n; ++i)
{
itemno = p->items[i];
printf("%4d ", itemno);
j = itemno;
- while (ritem[j] >= 0) ++j;
+ while (ritem[j] >= 0)
+ ++j;
printf("%s :", symbol_name[rlhs[-ritem[j]]]);
j = rrhs[-ritem[j]];
while (j < itemno)
}
}
-
/* show_ritems is used for debugging */
-static void
+
+void
show_ritems(void)
{
int i;
printf("ritem[%d] = %d\n", i, ritem[i]);
}
-
/* show_rrhs is used for debugging */
-static void
+void
show_rrhs(void)
{
int i;
printf("rrhs[%d] = %d\n", i, rrhs[i]);
}
-
/* show_shifts is used for debugging */
-static void
+
+void
show_shifts(void)
{
shifts *p;
k = 0;
for (p = first_shift; p; ++k, p = p->next)
{
- if (k) printf("\n");
+ if (k)
+ printf("\n");
printf("shift %d, number = %d, nshifts = %d\n", k, p->number,
- p->nshifts);
+ p->nshifts);
j = p->nshifts;
for (i = 0; i < j; ++i)
printf("\t%d\n", p->shift[i]);
}
}
-#endif
-
static void
save_shifts(void)
short *sp2;
short *send;
- p = (shifts *) allocate((unsigned) (sizeof(shifts) +
- (nshifts - 1) * sizeof(short)));
+ p = (shifts *)allocate((sizeof(shifts) +
+ (unsigned)(nshifts - 1) * sizeof(short)));
p->number = this_state->number;
- p->nshifts = nshifts;
+ p->nshifts = (Value_t) nshifts;
sp1 = shiftset;
sp2 = p->shift;
}
}
-
static void
save_reductions(void)
{
short *rp1;
short *rp2;
int item;
- int count;
+ Value_t count;
reductions *p;
short *rend;
item = ritem[*isp];
if (item < 0)
{
- redset[count++] = -item;
+ redset[count++] = (Value_t) - item;
}
}
if (count)
{
- p = (reductions *) allocate((unsigned) (sizeof(reductions) +
- (count - 1) * sizeof(short)));
+ p = (reductions *)allocate((sizeof(reductions) +
+ (unsigned)(count - 1) *
+ sizeof(short)));
p->number = this_state->number;
p->nreds = count;
}
}
-
static void
set_derives(void)
{
- int i, k;
+ Value_t i, k;
int lhs;
short *rules;
derives = NEW2(nsyms, short *);
- if (start_symbol >= nsyms)
- return;
-
rules = NEW2(nvars + nrules, short);
k = 0;
#endif
}
-#ifdef DEBUG
-static void
-free_derives(void)
-{
- FREE(derives[start_symbol]);
- FREE(derives);
-}
-#endif
-
#ifdef DEBUG
-static void
+void
print_derives(void)
{
int i;
}
#endif
-
static void
set_nullable(void)
{
int i, j;
int empty;
- int isdone;
+ int done_flag;
nullable = MALLOC(nsyms);
- if (nullable == 0) no_space();
+ NO_SPACE(nullable);
for (i = 0; i < nsyms; ++i)
nullable[i] = 0;
- isdone = 0;
- while (!isdone)
+ done_flag = 0;
+ while (!done_flag)
{
- isdone = 1;
+ done_flag = 1;
for (i = 1; i < nitems; i++)
{
empty = 1;
if (!nullable[j])
{
nullable[j] = 1;
- isdone = 0;
+ done_flag = 0;
}
}
}
#endif
}
-
-#ifdef DEBUG
-static void
-free_nullable(void)
-{
- FREE(nullable);
-}
-#endif
-
-
void
lr0(void)
{
set_nullable();
generate_states();
}
+
+#ifdef NO_LEAKS
+void
+lr0_leaks(void)
+{
+ DO_FREE(derives[start_symbol]);
+ DO_FREE(derives);
+ DO_FREE(nullable);
+}
+#endif
--- /dev/null
+/* $NetBSD: main.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
+/* Id: main.c,v 1.36 2011/09/06 22:44:45 tom Exp */
+
+#include "defs.h"
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: main.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
+
+#include <signal.h>
+#include <unistd.h> /* for _exit() */
+
+
+#if defined(HAVE_ATEXIT)
+# ifdef HAVE_MKSTEMP
+# define USE_MKSTEMP 1
+# elif defined(HAVE_FCNTL_H)
+# define USE_MKSTEMP 1
+# include <fcntl.h> /* for open(), O_EXCL, etc. */
+# else
+# define USE_MKSTEMP 0
+# endif
+#else
+# define USE_MKSTEMP 0
+#endif
+
+#if USE_MKSTEMP
+#include <sys/types.h>
+#include <sys/stat.h>
+
+typedef struct _my_tmpfiles
+{
+ struct _my_tmpfiles *next;
+ char *name;
+}
+MY_TMPFILES;
+
+static MY_TMPFILES *my_tmpfiles;
+#endif /* USE_MKSTEMP */
+
+char dflag;
+char gflag;
+char iflag;
+char lflag;
+static char oflag;
+char rflag;
+char tflag;
+char vflag;
+
+const char *symbol_prefix;
+const char *myname = "yacc";
+
+int lineno;
+int outline;
+
+static char empty_string[] = "";
+static char default_file_prefix[] = "y";
+static int explicit_file_name;
+
+static char *file_prefix = default_file_prefix;
+
+char *code_file_name;
+char *input_file_name = empty_string;
+char *defines_file_name;
+char *externs_file_name;
+
+static char *graph_file_name;
+static char *output_file_name;
+static char *verbose_file_name;
+
+FILE *action_file; /* a temp file, used to save actions associated */
+ /* with rules until the parser is written */
+FILE *code_file; /* y.code.c (used when the -r option is specified) */
+FILE *defines_file; /* y.tab.h */
+FILE *externs_file; /* y.tab.i */
+FILE *input_file; /* the input file */
+FILE *output_file; /* y.tab.c */
+FILE *text_file; /* a temp file, used to save text until all */
+ /* symbols have been defined */
+FILE *union_file; /* a temp file, used to save the union */
+ /* definition until all symbol have been */
+ /* defined */
+FILE *verbose_file; /* y.output */
+FILE *graph_file; /* y.dot */
+
+int nitems;
+int nrules;
+int nsyms;
+int ntokens;
+int nvars;
+
+Value_t start_symbol;
+char **symbol_name;
+char **symbol_pname;
+Value_t *symbol_value;
+short *symbol_prec;
+char *symbol_assoc;
+
+int pure_parser;
+int exit_code;
+
+Value_t *ritem;
+Value_t *rlhs;
+Value_t *rrhs;
+Value_t *rprec;
+Assoc_t *rassoc;
+Value_t **derives;
+char *nullable;
+
+/*
+ * Since fclose() is called via the signal handler, it might die. Don't loop
+ * if there is a problem closing a file.
+ */
+#define DO_CLOSE(fp) \
+ if (fp != 0) { \
+ FILE *use = fp; \
+ fp = 0; \
+ fclose(use); \
+ }
+
+static int got_intr = 0;
+
+void
+done(int k)
+{
+ DO_CLOSE(input_file);
+ DO_CLOSE(output_file);
+
+ DO_CLOSE(action_file);
+ DO_CLOSE(defines_file);
+ DO_CLOSE(graph_file);
+ DO_CLOSE(text_file);
+ DO_CLOSE(union_file);
+ DO_CLOSE(verbose_file);
+
+ if (got_intr)
+ _exit(EXIT_FAILURE);
+
+#ifdef NO_LEAKS
+ if (rflag)
+ DO_FREE(code_file_name);
+
+ if (dflag)
+ DO_FREE(defines_file_name);
+
+ if (iflag)
+ DO_FREE(externs_file_name);
+
+ if (oflag)
+ DO_FREE(output_file_name);
+
+ if (vflag)
+ DO_FREE(verbose_file_name);
+
+ if (gflag)
+ DO_FREE(graph_file_name);
+
+ lr0_leaks();
+ lalr_leaks();
+ mkpar_leaks();
+ output_leaks();
+ reader_leaks();
+#endif
+
+ if (rflag)
+ DO_CLOSE(code_file);
+
+ exit(k);
+}
+
+static void
+onintr(int sig GCC_UNUSED)
+{
+ got_intr = 1;
+ done(EXIT_FAILURE);
+}
+
+static void
+set_signals(void)
+{
+#ifdef SIGINT
+ if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+ signal(SIGINT, onintr);
+#endif
+#ifdef SIGTERM
+ if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
+ signal(SIGTERM, onintr);
+#endif
+#ifdef SIGHUP
+ if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
+ signal(SIGHUP, onintr);
+#endif
+}
+
+static void
+usage(void)
+{
+ static const char *msg[] =
+ {
+ ""
+ ,"Options:"
+ ," -b file_prefix set filename prefix (default \"y.\")"
+ ," -d write definitions (y.tab.h)"
+ ," -i write interface (y.tab.i)"
+ ," -g write a graphical description"
+ ," -l suppress #line directives"
+ ," -o output_file (default \"y.tab.c\")"
+ ," -p symbol_prefix set symbol prefix (default \"yy\")"
+ ," -P create a reentrant parser, e.g., \"%pure-parser\""
+ ," -r produce separate code and table files (y.code.c)"
+ ," -t add debugging support"
+ ," -v write description (y.output)"
+ ," -V show version information and exit"
+ };
+ unsigned n;
+
+ fflush(stdout);
+ fprintf(stderr, "Usage: %s [options] filename\n", myname);
+ for (n = 0; n < sizeof(msg) / sizeof(msg[0]); ++n)
+ fprintf(stderr, "%s\n", msg[n]);
+
+ exit(1);
+}
+
+static void
+setflag(int ch)
+{
+ switch (ch)
+ {
+ case 'd':
+ dflag = 1;
+ break;
+
+ case 'g':
+ gflag = 1;
+ break;
+
+ case 'i':
+ iflag = 1;
+ break;
+
+ case 'l':
+ lflag = 1;
+ break;
+
+ case 'P':
+ pure_parser = 1;
+ break;
+
+ case 'r':
+ rflag = 1;
+ break;
+
+ case 't':
+ tflag = 1;
+ break;
+
+ case 'v':
+ vflag = 1;
+ break;
+
+ case 'V':
+ printf("%s - %s\n", myname, VERSION);
+ exit(EXIT_SUCCESS);
+
+ case 'y':
+ /* noop for bison compatibility. byacc is already designed to be posix
+ * yacc compatible. */
+ break;
+
+ default:
+ usage();
+ }
+}
+
+static void
+getargs(int argc, char *argv[])
+{
+ int i;
+ char *s;
+ int ch;
+
+ if (argc > 0)
+ myname = argv[0];
+
+ for (i = 1; i < argc; ++i)
+ {
+ s = argv[i];
+ if (*s != '-')
+ break;
+ switch (ch = *++s)
+ {
+ case '\0':
+ input_file = stdin;
+ if (i + 1 < argc)
+ usage();
+ return;
+
+ case '-':
+ ++i;
+ goto no_more_options;
+
+ case 'b':
+ if (*++s)
+ file_prefix = s;
+ else if (++i < argc)
+ file_prefix = argv[i];
+ else
+ usage();
+ continue;
+
+ case 'o':
+ if (*++s)
+ output_file_name = s;
+ else if (++i < argc)
+ output_file_name = argv[i];
+ else
+ usage();
+ explicit_file_name = 1;
+ continue;
+
+ case 'p':
+ if (*++s)
+ symbol_prefix = s;
+ else if (++i < argc)
+ symbol_prefix = argv[i];
+ else
+ usage();
+ continue;
+
+ default:
+ setflag(ch);
+ break;
+ }
+
+ for (;;)
+ {
+ switch (ch = *++s)
+ {
+ case '\0':
+ goto end_of_option;
+
+ default:
+ setflag(ch);
+ break;
+ }
+ }
+ end_of_option:;
+ }
+
+ no_more_options:;
+ if (i + 1 != argc)
+ usage();
+ input_file_name = argv[i];
+}
+
+void *
+allocate(size_t n)
+{
+ void *p;
+
+ p = NULL;
+ if (n)
+ {
+ p = CALLOC(1, n);
+ NO_SPACE(p);
+ }
+ return (p);
+}
+
+#define CREATE_FILE_NAME(dest, suffix) \
+ dest = MALLOC(len + strlen(suffix) + 1); \
+ NO_SPACE(dest); \
+ strcpy(dest, file_prefix); \
+ strcpy(dest + len, suffix)
+
+static void
+create_file_names(void)
+{
+ size_t len;
+ const char *defines_suffix;
+ const char *externs_suffix;
+ char *prefix;
+
+ prefix = NULL;
+ defines_suffix = DEFINES_SUFFIX;
+ externs_suffix = EXTERNS_SUFFIX;
+
+ /* compute the file_prefix from the user provided output_file_name */
+ if (output_file_name != 0)
+ {
+ if (!(prefix = strstr(output_file_name, ".tab.c"))
+ && (prefix = strstr(output_file_name, ".c")))
+ {
+ defines_suffix = ".h";
+ externs_suffix = ".i";
+ }
+ }
+
+ if (prefix != NULL)
+ {
+ len = (size_t) (prefix - output_file_name);
+ file_prefix = MALLOC(len + 1);
+ NO_SPACE(file_prefix);
+ strncpy(file_prefix, output_file_name, len)[len] = 0;
+ }
+ else
+ len = strlen(file_prefix);
+
+ /* if "-o filename" was not given */
+ if (output_file_name == 0)
+ {
+ oflag = 1;
+ CREATE_FILE_NAME(output_file_name, OUTPUT_SUFFIX);
+ }
+
+ if (rflag)
+ {
+ CREATE_FILE_NAME(code_file_name, CODE_SUFFIX);
+ }
+ else
+ code_file_name = output_file_name;
+
+ if (dflag)
+ {
+ if (explicit_file_name)
+ {
+ char *suffix;
+ defines_file_name = strdup(output_file_name);
+ if (defines_file_name == 0)
+ no_space();
+ /* does the output_file_name have a known suffix */
+ suffix = strrchr(output_file_name, '.');
+ if (suffix != 0 &&
+ (!strcmp(suffix, ".c") || /* good, old-fashioned C */
+ !strcmp(suffix, ".C") || /* C++, or C on Windows */
+ !strcmp(suffix, ".cc") || /* C++ */
+ !strcmp(suffix, ".cxx") || /* C++ */
+ !strcmp(suffix, ".cpp"))) /* C++ (Windows) */
+ {
+ strncpy(defines_file_name, output_file_name,
+ suffix - output_file_name + 1);
+ defines_file_name[suffix - output_file_name + 1] = 'h';
+ defines_file_name[suffix - output_file_name + 2] = 0;
+ } else {
+ fprintf(stderr,"%s: suffix of output file name %s"
+ " not recognized, no -d file generated.\n",
+ myname, output_file_name);
+ dflag = 0;
+ free(defines_file_name);
+ defines_file_name = 0;
+ }
+ } else {
+ CREATE_FILE_NAME(defines_file_name, defines_suffix);
+ }
+ }
+
+ if (iflag)
+ {
+ CREATE_FILE_NAME(externs_file_name, externs_suffix);
+ }
+
+ if (vflag)
+ {
+ CREATE_FILE_NAME(verbose_file_name, VERBOSE_SUFFIX);
+ }
+
+ if (gflag)
+ {
+ CREATE_FILE_NAME(graph_file_name, GRAPH_SUFFIX);
+ }
+
+ if (prefix != NULL)
+ {
+ FREE(file_prefix);
+ }
+}
+
+#if USE_MKSTEMP
+static void
+close_tmpfiles(void)
+{
+ while (my_tmpfiles != 0)
+ {
+ MY_TMPFILES *next = my_tmpfiles->next;
+
+ chmod(my_tmpfiles->name, 0644);
+ unlink(my_tmpfiles->name);
+
+ free(my_tmpfiles->name);
+ free(my_tmpfiles);
+
+ my_tmpfiles = next;
+ }
+}
+
+#ifndef HAVE_MKSTEMP
+static int
+my_mkstemp(char *temp)
+{
+ int fd;
+ char *dname;
+ char *fname;
+ char *name;
+
+ /*
+ * Split-up to use tempnam, rather than tmpnam; the latter (like
+ * mkstemp) is unusable on Windows.
+ */
+ if ((fname = strrchr(temp, '/')) != 0)
+ {
+ dname = strdup(temp);
+ dname[++fname - temp] = '\0';
+ }
+ else
+ {
+ dname = 0;
+ fname = temp;
+ }
+ if ((name = tempnam(dname, fname)) != 0)
+ {
+ fd = open(name, O_CREAT | O_EXCL | O_RDWR);
+ strcpy(temp, name);
+ }
+ else
+ {
+ fd = -1;
+ }
+
+ if (dname != 0)
+ free(dname);
+
+ return fd;
+}
+#define mkstemp(s) my_mkstemp(s)
+#endif
+
+#endif
+
+/*
+ * tmpfile() should be adequate, except that it may require special privileges
+ * to use, e.g., MinGW and Windows 7 where it tries to use the root directory.
+ */
+static FILE *
+open_tmpfile(const char *label)
+{
+ FILE *result;
+#if USE_MKSTEMP
+ int fd;
+ const char *tmpdir;
+ char *name;
+ const char *mark;
+
+ if ((tmpdir = getenv("TMPDIR")) == 0 || access(tmpdir, W_OK) != 0)
+ {
+#ifdef P_tmpdir
+ tmpdir = P_tmpdir;
+#else
+ tmpdir = "/tmp";
+#endif
+ if (access(tmpdir, W_OK) != 0)
+ tmpdir = ".";
+ }
+
+ name = malloc(strlen(tmpdir) + 10 + strlen(label));
+
+ result = 0;
+ if (name != 0)
+ {
+ if ((mark = strrchr(label, '_')) == 0)
+ mark = label + strlen(label);
+
+ sprintf(name, "%s/%.*sXXXXXX", tmpdir, (int)(mark - label), label);
+ fd = mkstemp(name);
+ if (fd >= 0)
+ {
+ result = fdopen(fd, "w+");
+ if (result != 0)
+ {
+ MY_TMPFILES *item;
+
+ if (my_tmpfiles == 0)
+ {
+ atexit(close_tmpfiles);
+ }
+
+ item = NEW(MY_TMPFILES);
+ NO_SPACE(item);
+
+ item->name = name;
+ NO_SPACE(item->name);
+
+ item->next = my_tmpfiles;
+ my_tmpfiles = item;
+ }
+ }
+ }
+#else
+ result = tmpfile();
+#endif
+
+ if (result == 0)
+ open_error(label);
+ return result;
+}
+
+static void
+open_files(void)
+{
+ create_file_names();
+
+ if (input_file == 0)
+ {
+ input_file = fopen(input_file_name, "r");
+ if (input_file == 0)
+ open_error(input_file_name);
+ }
+
+ action_file = open_tmpfile("action_file");
+ text_file = open_tmpfile("text_file");
+
+ if (vflag)
+ {
+ verbose_file = fopen(verbose_file_name, "w");
+ if (verbose_file == 0)
+ open_error(verbose_file_name);
+ }
+
+ if (gflag)
+ {
+ graph_file = fopen(graph_file_name, "w");
+ if (graph_file == 0)
+ open_error(graph_file_name);
+ fprintf(graph_file, "digraph %s {\n", file_prefix);
+ fprintf(graph_file, "\tedge [fontsize=10];\n");
+ fprintf(graph_file, "\tnode [shape=box,fontsize=10];\n");
+ fprintf(graph_file, "\torientation=landscape;\n");
+ fprintf(graph_file, "\trankdir=LR;\n");
+ fprintf(graph_file, "\t/*\n");
+ fprintf(graph_file, "\tmargin=0.2;\n");
+ fprintf(graph_file, "\tpage=\"8.27,11.69\"; // for A4 printing\n");
+ fprintf(graph_file, "\tratio=auto;\n");
+ fprintf(graph_file, "\t*/\n");
+ }
+
+ if (dflag)
+ {
+ defines_file = fopen(defines_file_name, "w");
+ if (defines_file == 0)
+ open_error(defines_file_name);
+ union_file = open_tmpfile("union_file");
+ }
+
+ if (iflag)
+ {
+ externs_file = fopen(externs_file_name, "w");
+ if (externs_file == 0)
+ open_error(externs_file_name);
+ }
+
+ output_file = fopen(output_file_name, "w");
+ if (output_file == 0)
+ open_error(output_file_name);
+
+ if (rflag)
+ {
+ code_file = fopen(code_file_name, "w");
+ if (code_file == 0)
+ open_error(code_file_name);
+ }
+ else
+ code_file = output_file;
+}
+
+int
+main(int argc, char *argv[])
+{
+ SRexpect = -1;
+ RRexpect = -1;
+ exit_code = EXIT_SUCCESS;
+
+ set_signals();
+ getargs(argc, argv);
+ open_files();
+ reader();
+ lr0();
+ lalr();
+ make_parser();
+ graph();
+ finalize_closure();
+ verbose();
+ output();
+ done(exit_code);
+ /*NOTREACHED */
+}
--- /dev/null
+# Id: makefile.in,v 1.16 2010/06/09 09:46:37 tom Exp
+#
+# UNIX template-makefile for Berkeley Yacc
+
+THIS = yacc
+
+#### Start of system configuration section. ####
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+CC = @CC@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+transform = @program_transform_name@
+
+DEFINES =
+EXTRA_CFLAGS = @EXTRA_CFLAGS@
+CPPFLAGS = -I. -I$(srcdir) $(DEFINES) -DHAVE_CONFIG_H -DYYPATCH=`cat $(srcdir)/VERSION` @CPPFLAGS@
+CFLAGS = @CFLAGS@ $(CPPFLAGS) $(EXTRA_CFLAGS)
+
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+
+CTAGS = @CTAGS@
+ETAGS = @ETAGS@
+LINT = @LINT@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = $(DESTDIR)@bindir@
+mandir = $(DESTDIR)@mandir@/man1
+manext = 1
+
+testdir = $(srcdir)/test
+
+x = @EXEEXT@
+o = .@OBJEXT@
+
+#### End of system configuration section. ####
+
+SHELL = /bin/sh
+@SET_MAKE@
+
+H_FILES = \
+ defs.h
+
+C_FILES = \
+ closure.c \
+ error.c \
+ graph.c \
+ lalr.c \
+ lr0.c \
+ main.c \
+ mkpar.c \
+ output.c \
+ reader.c \
+ skeleton.c \
+ symtab.c \
+ verbose.c \
+ warshall.c
+
+OBJS = \
+ closure$o \
+ error$o \
+ graph$o \
+ lalr$o \
+ lr0$o \
+ main$o \
+ mkpar$o \
+ output$o \
+ reader$o \
+ skeleton$o \
+ symtab$o \
+ verbose$o \
+ warshall$o
+
+TRANSFORM_BIN = sed 's/$x$$//' |sed '$(transform)'|sed 's/$$/$x/'
+TRANSFORM_MAN = sed 's/$(manext)$$//'|sed '$(transform)'|sed 's/$$/$(manext)/'
+
+actual_bin = `echo $(THIS)$x | $(TRANSFORM_BIN)`
+actual_man = `echo $(THIS).$(manext)| $(TRANSFORM_MAN)`
+
+all : $(THIS)$x
+
+install: all installdirs
+ $(INSTALL_PROGRAM) $(THIS)$x $(bindir)/$(actual_bin)
+ - $(INSTALL_DATA) $(srcdir)/$(THIS).1 $(mandir)/$(actual_man)
+
+installdirs:
+ mkdir -p $(bindir)
+ - mkdir -p $(mandir)
+
+uninstall:
+ - rm -f $(bindir)/$(actual_bin)
+ - rm -f $(mandir)/$(actual_man)
+
+################################################################################
+.SUFFIXES : $o .i .html .$(manext) .cat .ps .pdf .txt
+
+.c$o:
+ @RULE_CC@
+ @ECHO_CC@$(CC) -c $(CFLAGS) $<
+
+.c.i :
+ @RULE_CC@
+ @ECHO_CC@$(CPP) -C $(CPPFLAGS) $*.c >$@
+
+.$(manext).cat :
+ - nroff -man $(srcdir)/$(THIS).$(manext) >$@
+
+.$(manext).html :
+ GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | groff -Thtml -man" >$@
+
+.$(manext).ps :
+ $(SHELL) -c "tbl $*.$(manext) | groff -man" >$@
+
+.$(manext).txt :
+ GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | nroff -Tascii -man | col -bx" >$@
+
+.ps.pdf :
+ ps2pdf $*.ps
+
+################################################################################
+
+$(THIS)$x : $(OBJS)
+ @ECHO_LD@$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
+
+mostlyclean :
+ - rm -f core .nfs* *$o *.bak *.BAK *.out
+
+clean : mostlyclean
+ - rm -f $(THIS)$x
+
+distclean : clean
+ - rm -f config.log config.cache config.status config.h makefile
+ - rm -f *.html *.cat *.pdf *.ps *.txt
+ - cd test && rm -f test-*
+
+realclean: distclean
+ - rm -f tags TAGS
+
+################################################################################
+docs :: $(THIS).html \
+ $(THIS).pdf \
+ $(THIS).ps \
+ $(THIS).txt
+$(THIS).html : $(THIS).$(manext)
+$(THIS).pdf : $(THIS).ps
+$(THIS).ps : $(THIS).$(manext)
+$(THIS).txt : $(THIS).$(manext)
+################################################################################
+check: $(THIS)$x
+ $(SHELL) $(testdir)/run_test.sh $(testdir)
+
+check_make:
+ $(SHELL) $(testdir)/run_make.sh $(testdir)
+
+check_lint:
+ $(SHELL) $(testdir)/run_lint.sh $(testdir)
+################################################################################
+tags: $(H_FILES) $(C_FILES)
+ $(CTAGS) $(C_FILES) $(H_FILES)
+
+lint: $(C_FILES)
+ $(LINT) $(CPPFLAGS) $(C_FILES)
+
+@MAKE_UPPER_TAGS@TAGS: $(H_FILES) $(C_FILES)
+@MAKE_UPPER_TAGS@ $(ETAGS) $(C_FILES) $(H_FILES)
+
+depend:
+ makedepend -- $(CPPFLAGS) -- $(C_FILES)
+
+$(OBJS) : defs.h
+
+main$o \
+skeleton$o : makefile VERSION
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
-/* $NetBSD: mkpar.c,v 1.12 2009/04/14 09:41:31 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
+/* $NetBSD: mkpar.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
+/* Id: mkpar.c,v 1.11 2010/06/09 08:53:17 tom Exp */
+
+#include "defs.h"
#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91";
-#else
-__RCSID("$NetBSD: mkpar.c,v 1.12 2009/04/14 09:41:31 lukem Exp $");
-#endif
-#endif /* not lint */
+__RCSID("$NetBSD: mkpar.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
-#include "defs.h"
+static action *add_reduce(action *actions, int ruleno, int symbol);
+static action *add_reductions(int stateno, action *actions);
+static action *get_shifts(int stateno);
+static action *parse_actions(int stateno);
+static int sole_reduction(int stateno);
+static void defreds(void);
+static void find_final_state(void);
+static void free_action_row(action *p);
+static void remove_conflicts(void);
+static void total_conflicts(void);
+static void unused_rules(void);
action **parser;
-int SRtotal;
-int RRtotal;
-short *SRconflicts;
-short *RRconflicts;
-short *defred;
-short *rules_used;
-short nunused;
-short final_state;
-
-static int SRcount;
-static int RRcount;
-static action *parse_actions(int);
-static action *get_shifts(int);
-static action *add_reductions(int, action *);
-static action *add_reduce(action *, int, int);
+int SRexpect;
+int RRexpect;
-static int sole_reduction(int);
-static void free_action_row(action *);
+int SRtotal;
+int RRtotal;
-static void find_final_state(void);
-static void unused_rules(void);
-static void remove_conflicts(void);
-static void total_conflicts(void);
-static void defreds(void);
+Value_t *SRconflicts;
+Value_t *RRconflicts;
+Value_t *defred;
+Value_t *rules_used;
+Value_t nunused;
+Value_t final_state;
+static Value_t SRcount;
+static Value_t RRcount;
void
make_parser(void)
find_final_state();
remove_conflicts();
unused_rules();
- if (SRtotal + RRtotal > 0) total_conflicts();
+ if (SRtotal + RRtotal > 0)
+ total_conflicts();
defreds();
}
-
static action *
parse_actions(int stateno)
{
return (actions);
}
-
static action *
get_shifts(int stateno)
{
action *actions, *temp;
shifts *sp;
- short *state;
- int i, k;
- int symbol;
+ Value_t *to_state2;
+ Value_t i, k;
+ Value_t symbol;
actions = 0;
sp = shift_table[stateno];
if (sp)
{
- state = sp->shift;
- for (i = sp->nshifts - 1; i >= 0; i--)
+ to_state2 = sp->shift;
+ for (i = (Value_t) (sp->nshifts - 1); i >= 0; i--)
{
- k = state[i];
+ k = to_state2[i];
symbol = accessing_symbol[k];
if (ISTOKEN(symbol))
{
return (actions);
}
-
static action *
-add_reduce(action *actions, int ruleno, int symbol)
+add_reduce(action *actions,
+ int ruleno,
+ int symbol)
{
action *temp, *prev, *next;
}
while (next && next->symbol == symbol &&
- next->action_code == REDUCE && next->number < ruleno)
+ next->action_code == REDUCE && next->number < ruleno)
{
prev = next;
next = next->next;
temp = NEW(action);
temp->next = next;
- temp->symbol = symbol;
- temp->number = ruleno;
+ temp->symbol = (Value_t) symbol;
+ temp->number = (Value_t) ruleno;
temp->prec = rprec[ruleno];
temp->action_code = REDUCE;
temp->assoc = rassoc[ruleno];
return (actions);
}
-
static void
find_final_state(void)
{
int goal, i;
- short *state;
+ Value_t *to_state2;
shifts *p;
p = shift_table[0];
- state = p->shift;
+ to_state2 = p->shift;
goal = ritem[1];
for (i = p->nshifts - 1; i >= 0; --i)
{
- final_state = state[i];
- if (accessing_symbol[final_state] == goal) break;
+ final_state = to_state2[i];
+ if (accessing_symbol[final_state] == goal)
+ break;
}
}
-
static void
unused_rules(void)
{
int i;
action *p;
- rules_used = (short *) MALLOC(nrules*sizeof(short));
- if (rules_used == 0) no_space();
+ rules_used = (Value_t *) MALLOC((unsigned)nrules * sizeof(Value_t));
+ NO_SPACE(rules_used);
for (i = 0; i < nrules; ++i)
rules_used[i] = 0;
nunused = 0;
for (i = 3; i < nrules; ++i)
- if (!rules_used[i]) ++nunused;
+ if (!rules_used[i])
+ ++nunused;
- if (nunused) {
+ if (nunused)
+ {
if (nunused == 1)
fprintf(stderr, "%s: 1 rule never reduced\n", myname);
else
}
}
-
static void
remove_conflicts(void)
{
int i;
int symbol;
- action *p, *pref;
+ action *p, *pref = 0;
- pref = NULL;
SRtotal = 0;
RRtotal = 0;
- SRconflicts = NEW2(nstates, short);
- RRconflicts = NEW2(nstates, short);
+ SRconflicts = NEW2(nstates, Value_t);
+ RRconflicts = NEW2(nstates, Value_t);
for (i = 0; i < nstates; i++)
{
SRcount = 0;
SRcount++;
p->suppressed = 1;
}
- else
+ else if (pref != 0 && pref->action_code == SHIFT)
{
- assert(pref != NULL);
- if (pref->action_code == SHIFT)
+ if (pref->prec > 0 && p->prec > 0)
{
- if (pref->prec > 0 && p->prec > 0)
+ if (pref->prec < p->prec)
+ {
+ pref->suppressed = 2;
+ pref = p;
+ }
+ else if (pref->prec > p->prec)
+ {
+ p->suppressed = 2;
+ }
+ else if (pref->assoc == LEFT)
+ {
+ pref->suppressed = 2;
+ pref = p;
+ }
+ else if (pref->assoc == RIGHT)
{
- if (pref->prec < p->prec)
- {
- pref->suppressed = 2;
- pref = p;
- }
- else if (pref->prec > p->prec)
- {
- p->suppressed = 2;
- }
- else if (pref->assoc == LEFT)
- {
- pref->suppressed = 2;
- pref = p;
- }
- else if (pref->assoc == RIGHT)
- {
- p->suppressed = 2;
- }
- else
- {
- pref->suppressed = 2;
- p->suppressed = 2;
- }
+ p->suppressed = 2;
}
else
{
- SRcount++;
- p->suppressed = 1;
+ pref->suppressed = 2;
+ p->suppressed = 2;
}
}
else
{
- RRcount++;
+ SRcount++;
p->suppressed = 1;
}
}
+ else
+ {
+ RRcount++;
+ p->suppressed = 1;
+ }
}
SRtotal += SRcount;
RRtotal += RRcount;
}
}
-
static void
total_conflicts(void)
{
fprintf(stderr, "%d reduce/reduce conflicts", RRtotal);
fprintf(stderr, ".\n");
-}
+ if (SRexpect >= 0 && SRtotal != SRexpect)
+ {
+ fprintf(stderr, "%s: ", myname);
+ fprintf(stderr, "expected %d shift/reduce conflict%s.\n",
+ SRexpect, PLURAL(SRexpect));
+ exit_code = EXIT_FAILURE;
+ }
+ if (RRexpect >= 0 && RRtotal != RRexpect)
+ {
+ fprintf(stderr, "%s: ", myname);
+ fprintf(stderr, "expected %d reduce/reduce conflict%s.\n",
+ RRexpect, PLURAL(RRexpect));
+ exit_code = EXIT_FAILURE;
+ }
+}
static int
sole_reduction(int stateno)
action *p;
count = 0;
- ruleno = 0;
+ ruleno = 0;
for (p = parser[stateno]; p; p = p->next)
{
if (p->action_code == SHIFT && p->suppressed == 0)
return (ruleno);
}
-
static void
defreds(void)
{
int i;
- defred = NEW2(nstates, short);
+ defred = NEW2(nstates, Value_t);
for (i = 0; i < nstates; i++)
- defred[i] = sole_reduction(i);
+ defred[i] = (Value_t) sole_reduction(i);
}
-static void
+static void
free_action_row(action *p)
{
- action *q;
+ action *q;
- while (p)
+ while (p)
{
- q = p->next;
- FREE(p);
- p = q;
+ q = p->next;
+ FREE(p);
+ p = q;
}
}
void
free_parser(void)
{
- int i;
+ int i;
- for (i = 0; i < nstates; i++)
- free_action_row(parser[i]);
+ for (i = 0; i < nstates; i++)
+ free_action_row(parser[i]);
+
+ FREE(parser);
+}
- FREE(parser);
+#ifdef NO_LEAKS
+void
+mkpar_leaks(void)
+{
+ DO_FREE(defred);
+ DO_FREE(rules_used);
+ DO_FREE(SRconflicts);
+ DO_FREE(RRconflicts);
}
+#endif
--- /dev/null
+/* $NetBSD: output.c,v 1.8 2011/09/10 21:29:04 christos Exp $ */
+/* Id: output.c,v 1.41 2011/09/08 09:25:40 tom Exp */
+
+#include "defs.h"
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: output.c,v 1.8 2011/09/10 21:29:04 christos Exp $");
+
+#define StaticOrR (rflag ? "" : "static ")
+#define CountLine(fp) (!rflag || ((fp) == code_file))
+
+static int nvectors;
+static int nentries;
+static Value_t **froms;
+static Value_t **tos;
+static Value_t *tally;
+static Value_t *width;
+static Value_t *state_count;
+static Value_t *order;
+static Value_t *base;
+static Value_t *pos;
+static int maxtable;
+static Value_t *table;
+static Value_t *check;
+static int lowzero;
+static int high;
+
+static void
+putc_code(FILE * fp, int c)
+{
+ if ((c == '\n') && (fp == code_file))
+ ++outline;
+ putc(c, fp);
+}
+
+static void
+putl_code(FILE * fp, const char *s)
+{
+ if (fp == code_file)
+ ++outline;
+ fputs(s, fp);
+}
+
+static void
+puts_code(FILE * fp, const char *s)
+{
+ fputs(s, fp);
+}
+
+static void
+write_code_lineno(FILE * fp)
+{
+ if (!lflag && (fp == code_file))
+ {
+ ++outline;
+ fprintf(fp, line_format, outline, code_file_name);
+ }
+}
+
+static void
+write_input_lineno(void)
+{
+ if (!lflag)
+ {
+ ++outline;
+ fprintf(code_file, line_format, lineno, input_file_name);
+ }
+}
+
+static void
+define_prefixed(FILE * fp, const char *name)
+{
+ int bump_line = CountLine(fp);
+ if (bump_line)
+ ++outline;
+ fprintf(fp, "\n");
+
+ if (bump_line)
+ ++outline;
+ fprintf(fp, "#ifndef %s\n", name);
+
+ if (bump_line)
+ ++outline;
+ fprintf(fp, "#define %-10s %s%s\n", name, symbol_prefix, name + 2);
+
+ if (bump_line)
+ ++outline;
+ fprintf(fp, "#endif /* %s */\n", name);
+}
+
+static void
+output_prefix(FILE * fp)
+{
+ if (symbol_prefix == NULL)
+ {
+ symbol_prefix = "yy";
+ }
+ else
+ {
+ define_prefixed(fp, "yyparse");
+ define_prefixed(fp, "yylex");
+ define_prefixed(fp, "yyerror");
+ define_prefixed(fp, "yychar");
+ define_prefixed(fp, "yyval");
+ define_prefixed(fp, "yylval");
+ define_prefixed(fp, "yydebug");
+ define_prefixed(fp, "yynerrs");
+ define_prefixed(fp, "yyerrflag");
+ define_prefixed(fp, "yylhs");
+ define_prefixed(fp, "yylen");
+ define_prefixed(fp, "yydefred");
+ define_prefixed(fp, "yydgoto");
+ define_prefixed(fp, "yysindex");
+ define_prefixed(fp, "yyrindex");
+ define_prefixed(fp, "yygindex");
+ define_prefixed(fp, "yytable");
+ define_prefixed(fp, "yycheck");
+ define_prefixed(fp, "yyname");
+ define_prefixed(fp, "yyrule");
+ }
+ if (CountLine(fp))
+ ++outline;
+ fprintf(fp, "#define YYPREFIX \"%s\"\n", symbol_prefix);
+}
+
+static void
+output_newline(void)
+{
+ if (!rflag)
+ ++outline;
+ putc('\n', output_file);
+}
+
+static void
+output_line(const char *value)
+{
+ fputs(value, output_file);
+ output_newline();
+}
+
+static void
+output_int(int value)
+{
+ fprintf(output_file, "%5d,", value);
+}
+
+static void
+start_int_table(const char *name, int value)
+{
+ int need = 34 - (int)(strlen(symbol_prefix) + strlen(name));
+
+ if (need < 6)
+ need = 6;
+ fprintf(output_file,
+ "%sconst short %s%s[] = {%*d,",
+ StaticOrR, symbol_prefix, name, need, value);
+}
+
+static void
+start_str_table(const char *name)
+{
+ fprintf(output_file,
+ "%sconst char *%s%s[] = {",
+ StaticOrR, "yy", name);
+ output_newline();
+}
+
+static void
+end_table(void)
+{
+ output_newline();
+ output_line("};");
+}
+
+static void
+output_rule_data(void)
+{
+ int i;
+ int j;
+
+ start_int_table("lhs", symbol_value[start_symbol]);
+
+ j = 10;
+ for (i = 3; i < nrules; i++)
+ {
+ if (j >= 10)
+ {
+ output_newline();
+ j = 1;
+ }
+ else
+ ++j;
+
+ output_int(symbol_value[rlhs[i]]);
+ }
+ end_table();
+
+ start_int_table("len", 2);
+
+ j = 10;
+ for (i = 3; i < nrules; i++)
+ {
+ if (j >= 10)
+ {
+ output_newline();
+ j = 1;
+ }
+ else
+ j++;
+
+ output_int(rrhs[i + 1] - rrhs[i] - 1);
+ }
+ end_table();
+}
+
+static void
+output_yydefred(void)
+{
+ int i, j;
+
+ start_int_table("defred", (defred[0] ? defred[0] - 2 : 0));
+
+ j = 10;
+ for (i = 1; i < nstates; i++)
+ {
+ if (j < 10)
+ ++j;
+ else
+ {
+ output_newline();
+ j = 1;
+ }
+
+ output_int((defred[i] ? defred[i] - 2 : 0));
+ }
+
+ end_table();
+}
+
+static void
+token_actions(void)
+{
+ int i, j;
+ Value_t shiftcount, reducecount;
+ int max, min;
+ Value_t *actionrow, *r, *s;
+ action *p;
+
+ actionrow = NEW2(2 * ntokens, Value_t);
+ for (i = 0; i < nstates; ++i)
+ {
+ if (parser[i])
+ {
+ for (j = 0; j < 2 * ntokens; ++j)
+ actionrow[j] = 0;
+
+ shiftcount = 0;
+ reducecount = 0;
+ for (p = parser[i]; p; p = p->next)
+ {
+ if (p->suppressed == 0)
+ {
+ if (p->action_code == SHIFT)
+ {
+ ++shiftcount;
+ actionrow[p->symbol] = p->number;
+ }
+ else if (p->action_code == REDUCE && p->number != defred[i])
+ {
+ ++reducecount;
+ actionrow[p->symbol + ntokens] = p->number;
+ }
+ }
+ }
+
+ tally[i] = shiftcount;
+ tally[nstates + i] = reducecount;
+ width[i] = 0;
+ width[nstates + i] = 0;
+ if (shiftcount > 0)
+ {
+ froms[i] = r = NEW2(shiftcount, Value_t);
+ tos[i] = s = NEW2(shiftcount, Value_t);
+ min = MAXSHORT;
+ max = 0;
+ for (j = 0; j < ntokens; ++j)
+ {
+ if (actionrow[j])
+ {
+ if (min > symbol_value[j])
+ min = symbol_value[j];
+ if (max < symbol_value[j])
+ max = symbol_value[j];
+ *r++ = symbol_value[j];
+ *s++ = actionrow[j];
+ }
+ }
+ width[i] = (Value_t) (max - min + 1);
+ }
+ if (reducecount > 0)
+ {
+ froms[nstates + i] = r = NEW2(reducecount, Value_t);
+ tos[nstates + i] = s = NEW2(reducecount, Value_t);
+ min = MAXSHORT;
+ max = 0;
+ for (j = 0; j < ntokens; ++j)
+ {
+ if (actionrow[ntokens + j])
+ {
+ if (min > symbol_value[j])
+ min = symbol_value[j];
+ if (max < symbol_value[j])
+ max = symbol_value[j];
+ *r++ = symbol_value[j];
+ *s++ = (Value_t) (actionrow[ntokens + j] - 2);
+ }
+ }
+ width[nstates + i] = (Value_t) (max - min + 1);
+ }
+ }
+ }
+ FREE(actionrow);
+}
+
+static int
+default_goto(int symbol)
+{
+ int i;
+ int m;
+ int n;
+ int default_state;
+ int max;
+
+ m = goto_map[symbol];
+ n = goto_map[symbol + 1];
+
+ if (m == n)
+ return (0);
+
+ for (i = 0; i < nstates; i++)
+ state_count[i] = 0;
+
+ for (i = m; i < n; i++)
+ state_count[to_state[i]]++;
+
+ max = 0;
+ default_state = 0;
+ for (i = 0; i < nstates; i++)
+ {
+ if (state_count[i] > max)
+ {
+ max = state_count[i];
+ default_state = i;
+ }
+ }
+
+ return (default_state);
+}
+
+static void
+save_column(int symbol, int default_state)
+{
+ int i;
+ int m;
+ int n;
+ Value_t *sp;
+ Value_t *sp1;
+ Value_t *sp2;
+ Value_t count;
+ int symno;
+
+ m = goto_map[symbol];
+ n = goto_map[symbol + 1];
+
+ count = 0;
+ for (i = m; i < n; i++)
+ {
+ if (to_state[i] != default_state)
+ ++count;
+ }
+ if (count == 0)
+ return;
+
+ symno = symbol_value[symbol] + 2 * nstates;
+
+ froms[symno] = sp1 = sp = NEW2(count, Value_t);
+ tos[symno] = sp2 = NEW2(count, Value_t);
+
+ for (i = m; i < n; i++)
+ {
+ if (to_state[i] != default_state)
+ {
+ *sp1++ = from_state[i];
+ *sp2++ = to_state[i];
+ }
+ }
+
+ tally[symno] = count;
+ width[symno] = (Value_t) (sp1[-1] - sp[0] + 1);
+}
+
+static void
+goto_actions(void)
+{
+ int i, j, k;
+
+ state_count = NEW2(nstates, Value_t);
+
+ k = default_goto(start_symbol + 1);
+ start_int_table("dgoto", k);
+ save_column(start_symbol + 1, k);
+
+ j = 10;
+ for (i = start_symbol + 2; i < nsyms; i++)
+ {
+ if (j >= 10)
+ {
+ output_newline();
+ j = 1;
+ }
+ else
+ ++j;
+
+ k = default_goto(i);
+ output_int(k);
+ save_column(i, k);
+ }
+
+ end_table();
+ FREE(state_count);
+}
+
+static void
+sort_actions(void)
+{
+ Value_t i;
+ int j;
+ int k;
+ int t;
+ int w;
+
+ order = NEW2(nvectors, Value_t);
+ nentries = 0;
+
+ for (i = 0; i < nvectors; i++)
+ {
+ if (tally[i] > 0)
+ {
+ t = tally[i];
+ w = width[i];
+ j = nentries - 1;
+
+ while (j >= 0 && (width[order[j]] < w))
+ j--;
+
+ while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
+ j--;
+
+ for (k = nentries - 1; k > j; k--)
+ order[k + 1] = order[k];
+
+ order[j + 1] = i;
+ nentries++;
+ }
+ }
+}
+
+/* The function matching_vector determines if the vector specified by */
+/* the input parameter matches a previously considered vector. The */
+/* test at the start of the function checks if the vector represents */
+/* a row of shifts over terminal symbols or a row of reductions, or a */
+/* column of shifts over a nonterminal symbol. Berkeley Yacc does not */
+/* check if a column of shifts over a nonterminal symbols matches a */
+/* previously considered vector. Because of the nature of LR parsing */
+/* tables, no two columns can match. Therefore, the only possible */
+/* match would be between a row and a column. Such matches are */
+/* unlikely. Therefore, to save time, no attempt is made to see if a */
+/* column matches a previously considered vector. */
+/* */
+/* Matching_vector is poorly designed. The test could easily be made */
+/* faster. Also, it depends on the vectors being in a specific */
+/* order. */
+
+static int
+matching_vector(int vector)
+{
+ int i;
+ int j;
+ int k;
+ int t;
+ int w;
+ int match;
+ int prev;
+
+ i = order[vector];
+ if (i >= 2 * nstates)
+ return (-1);
+
+ t = tally[i];
+ w = width[i];
+
+ for (prev = vector - 1; prev >= 0; prev--)
+ {
+ j = order[prev];
+ if (width[j] != w || tally[j] != t)
+ return (-1);
+
+ match = 1;
+ for (k = 0; match && k < t; k++)
+ {
+ if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k])
+ match = 0;
+ }
+
+ if (match)
+ return (j);
+ }
+
+ return (-1);
+}
+
+static int
+pack_vector(int vector)
+{
+ int i, j, k, l;
+ int t;
+ int loc;
+ int ok;
+ Value_t *from;
+ Value_t *to;
+ int newmax;
+
+ i = order[vector];
+ t = tally[i];
+ assert(t);
+
+ from = froms[i];
+ to = tos[i];
+
+ j = lowzero - from[0];
+ for (k = 1; k < t; ++k)
+ if (lowzero - from[k] > j)
+ j = lowzero - from[k];
+ for (;; ++j)
+ {
+ if (j == 0)
+ continue;
+ ok = 1;
+ for (k = 0; ok && k < t; k++)
+ {
+ loc = j + from[k];
+ if (loc >= maxtable - 1)
+ {
+ if (loc >= MAXTABLE - 1)
+ fatal("maximum table size exceeded");
+
+ newmax = maxtable;
+ do
+ {
+ newmax += 200;
+ }
+ while (newmax <= loc);
+
+ table = (Value_t *) REALLOC(table, (unsigned)newmax * sizeof(Value_t));
+ NO_SPACE(table);
+
+ check = (Value_t *) REALLOC(check, (unsigned)newmax * sizeof(Value_t));
+ NO_SPACE(check);
+
+ for (l = maxtable; l < newmax; ++l)
+ {
+ table[l] = 0;
+ check[l] = -1;
+ }
+ maxtable = newmax;
+ }
+
+ if (check[loc] != -1)
+ ok = 0;
+ }
+ for (k = 0; ok && k < vector; k++)
+ {
+ if (pos[k] == j)
+ ok = 0;
+ }
+ if (ok)
+ {
+ for (k = 0; k < t; k++)
+ {
+ loc = j + from[k];
+ table[loc] = to[k];
+ check[loc] = from[k];
+ if (loc > high)
+ high = loc;
+ }
+
+ while (check[lowzero] != -1)
+ ++lowzero;
+
+ return (j);
+ }
+ }
+}
+
+static void
+pack_table(void)
+{
+ int i;
+ Value_t place;
+ int state;
+
+ base = NEW2(nvectors, Value_t);
+ pos = NEW2(nentries, Value_t);
+
+ maxtable = 1000;
+ table = NEW2(maxtable, Value_t);
+ check = NEW2(maxtable, Value_t);
+
+ lowzero = 0;
+ high = 0;
+
+ for (i = 0; i < maxtable; i++)
+ check[i] = -1;
+
+ for (i = 0; i < nentries; i++)
+ {
+ state = matching_vector(i);
+
+ if (state < 0)
+ place = (Value_t) pack_vector(i);
+ else
+ place = base[state];
+
+ pos[i] = place;
+ base[order[i]] = place;
+ }
+
+ for (i = 0; i < nvectors; i++)
+ {
+ if (froms[i])
+ FREE(froms[i]);
+ if (tos[i])
+ FREE(tos[i]);
+ }
+
+ FREE(froms);
+ FREE(tos);
+ FREE(pos);
+}
+
+static void
+output_base(void)
+{
+ int i, j;
+
+ start_int_table("sindex", base[0]);
+
+ j = 10;
+ for (i = 1; i < nstates; i++)
+ {
+ if (j >= 10)
+ {
+ output_newline();
+ j = 1;
+ }
+ else
+ ++j;
+
+ output_int(base[i]);
+ }
+
+ end_table();
+
+ start_int_table("rindex", base[nstates]);
+
+ j = 10;
+ for (i = nstates + 1; i < 2 * nstates; i++)
+ {
+ if (j >= 10)
+ {
+ output_newline();
+ j = 1;
+ }
+ else
+ ++j;
+
+ output_int(base[i]);
+ }
+
+ end_table();
+
+ start_int_table("gindex", base[2 * nstates]);
+
+ j = 10;
+ for (i = 2 * nstates + 1; i < nvectors - 1; i++)
+ {
+ if (j >= 10)
+ {
+ output_newline();
+ j = 1;
+ }
+ else
+ ++j;
+
+ output_int(base[i]);
+ }
+
+ end_table();
+ FREE(base);
+}
+
+static void
+output_table(void)
+{
+ int i;
+ int j;
+
+ ++outline;
+ fprintf(code_file, "#define YYTABLESIZE %d\n", high);
+ start_int_table("table", table[0]);
+
+ j = 10;
+ for (i = 1; i <= high; i++)
+ {
+ if (j >= 10)
+ {
+ output_newline();
+ j = 1;
+ }
+ else
+ ++j;
+
+ output_int(table[i]);
+ }
+
+ end_table();
+ FREE(table);
+}
+
+static void
+output_check(void)
+{
+ int i;
+ int j;
+
+ start_int_table("check", check[0]);
+
+ j = 10;
+ for (i = 1; i <= high; i++)
+ {
+ if (j >= 10)
+ {
+ output_newline();
+ j = 1;
+ }
+ else
+ ++j;
+
+ output_int(check[i]);
+ }
+
+ end_table();
+ FREE(check);
+}
+
+static void
+output_actions(void)
+{
+ nvectors = 2 * nstates + nvars;
+
+ froms = NEW2(nvectors, Value_t *);
+ tos = NEW2(nvectors, Value_t *);
+ tally = NEW2(nvectors, Value_t);
+ width = NEW2(nvectors, Value_t);
+
+ token_actions();
+ FREE(lookaheads);
+ FREE(LA);
+ FREE(LAruleno);
+ FREE(accessing_symbol);
+
+ goto_actions();
+ FREE(goto_map + ntokens);
+ FREE(from_state);
+ FREE(to_state);
+
+ sort_actions();
+ pack_table();
+ output_base();
+ output_table();
+ output_check();
+}
+
+static int
+is_C_identifier(char *name)
+{
+ char *s;
+ int c;
+
+ s = name;
+ c = *s;
+ if (c == '"')
+ {
+ c = *++s;
+ if (!isalpha(c) && c != '_' && c != '$')
+ return (0);
+ while ((c = *++s) != '"')
+ {
+ if (!isalnum(c) && c != '_' && c != '$')
+ return (0);
+ }
+ return (1);
+ }
+
+ if (!isalpha(c) && c != '_' && c != '$')
+ return (0);
+ while ((c = *++s) != 0)
+ {
+ if (!isalnum(c) && c != '_' && c != '$')
+ return (0);
+ }
+ return (1);
+}
+
+static void
+output_defines(FILE * fp)
+{
+ int c, i;
+ char *s;
+
+ for (i = 2; i < ntokens; ++i)
+ {
+ s = symbol_name[i];
+ if (is_C_identifier(s))
+ {
+ fprintf(fp, "#define ");
+ c = *s;
+ if (c == '"')
+ {
+ while ((c = *++s) != '"')
+ {
+ putc(c, fp);
+ }
+ }
+ else
+ {
+ do
+ {
+ putc(c, fp);
+ }
+ while ((c = *++s) != 0);
+ }
+ if (fp == code_file)
+ ++outline;
+ fprintf(fp, " %d\n", symbol_value[i]);
+ }
+ }
+
+ if (fp == code_file)
+ ++outline;
+ if (fp != defines_file || iflag)
+ fprintf(fp, "#define YYERRCODE %d\n", symbol_value[1]);
+
+ if (fp == defines_file || (iflag && !dflag))
+ {
+ if (unionized)
+ {
+ rewind(union_file);
+ while ((c = getc(union_file)) != EOF)
+ putc(c, fp);
+ fprintf(fp, "extern YYSTYPE %slval;\n", symbol_prefix);
+ }
+ }
+}
+
+static void
+output_stored_text(FILE * fp)
+{
+ int c;
+ FILE *in;
+
+ rewind(text_file);
+ if (text_file == NULL)
+ open_error("text_file");
+ in = text_file;
+ if ((c = getc(in)) == EOF)
+ return;
+ putc_code(fp, c);
+ while ((c = getc(in)) != EOF)
+ {
+ putc_code(fp, c);
+ }
+ write_code_lineno(fp);
+}
+
+static void
+output_debug(void)
+{
+ int i, j, k, max;
+ const char **symnam;
+ const char *s;
+
+ ++outline;
+ fprintf(code_file, "#define YYFINAL %d\n", final_state);
+
+ putl_code(code_file, "#ifndef YYDEBUG\n");
+ ++outline;
+ fprintf(code_file, "#define YYDEBUG %d\n", tflag);
+ putl_code(code_file, "#endif\n");
+
+ if (rflag)
+ {
+ fprintf(output_file, "#ifndef YYDEBUG\n");
+ fprintf(output_file, "#define YYDEBUG %d\n", tflag);
+ fprintf(output_file, "#endif\n");
+ }
+
+ max = 0;
+ for (i = 2; i < ntokens; ++i)
+ if (symbol_value[i] > max)
+ max = symbol_value[i];
+
+ ++outline;
+ fprintf(code_file, "#define YYMAXTOKEN %d\n", max);
+
+ symnam = (const char **)MALLOC((unsigned)(max + 1) * sizeof(char *));
+ NO_SPACE(symnam);
+
+ /* Note that it is not necessary to initialize the element */
+ /* symnam[max]. */
+ for (i = 0; i < max; ++i)
+ symnam[i] = 0;
+ for (i = ntokens - 1; i >= 2; --i)
+ symnam[symbol_value[i]] = symbol_name[i];
+ symnam[0] = "end-of-file";
+
+ output_line("#if YYDEBUG");
+
+ start_str_table("name");
+ j = 80;
+ for (i = 0; i <= max; ++i)
+ {
+ if ((s = symnam[i]) != 0)
+ {
+ if (s[0] == '"')
+ {
+ k = 7;
+ while (*++s != '"')
+ {
+ ++k;
+ if (*s == '\\')
+ {
+ k += 2;
+ if (*++s == '\\')
+ ++k;
+ }
+ }
+ j += k;
+ if (j > 80)
+ {
+ output_newline();
+ j = k;
+ }
+ fprintf(output_file, "\"\\\"");
+ s = symnam[i];
+ while (*++s != '"')
+ {
+ if (*s == '\\')
+ {
+ fprintf(output_file, "\\\\");
+ if (*++s == '\\')
+ fprintf(output_file, "\\\\");
+ else
+ putc(*s, output_file);
+ }
+ else
+ putc(*s, output_file);
+ }
+ fprintf(output_file, "\\\"\",");
+ }
+ else if (s[0] == '\'')
+ {
+ if (s[1] == '"')
+ {
+ j += 7;
+ if (j > 80)
+ {
+ output_newline();
+ j = 7;
+ }
+ fprintf(output_file, "\"'\\\"'\",");
+ }
+ else
+ {
+ k = 5;
+ while (*++s != '\'')
+ {
+ ++k;
+ if (*s == '\\')
+ {
+ k += 2;
+ if (*++s == '\\')
+ ++k;
+ }
+ }
+ j += k;
+ if (j > 80)
+ {
+ output_newline();
+ j = k;
+ }
+ fprintf(output_file, "\"'");
+ s = symnam[i];
+ while (*++s != '\'')
+ {
+ if (*s == '\\')
+ {
+ fprintf(output_file, "\\\\");
+ if (*++s == '\\')
+ fprintf(output_file, "\\\\");
+ else
+ putc(*s, output_file);
+ }
+ else
+ putc(*s, output_file);
+ }
+ fprintf(output_file, "'\",");
+ }
+ }
+ else
+ {
+ k = (int)strlen(s) + 3;
+ j += k;
+ if (j > 80)
+ {
+ output_newline();
+ j = k;
+ }
+ putc('"', output_file);
+ do
+ {
+ putc(*s, output_file);
+ }
+ while (*++s);
+ fprintf(output_file, "\",");
+ }
+ }
+ else
+ {
+ j += 2;
+ if (j > 80)
+ {
+ output_newline();
+ j = 2;
+ }
+ fprintf(output_file, "0,");
+ }
+ }
+ end_table();
+ FREE(symnam);
+
+ start_str_table("rule");
+ for (i = 2; i < nrules; ++i)
+ {
+ fprintf(output_file, "\"%s :", symbol_name[rlhs[i]]);
+ for (j = rrhs[i]; ritem[j] > 0; ++j)
+ {
+ s = symbol_name[ritem[j]];
+ if (s[0] == '"')
+ {
+ fprintf(output_file, " \\\"");
+ while (*++s != '"')
+ {
+ if (*s == '\\')
+ {
+ if (s[1] == '\\')
+ fprintf(output_file, "\\\\\\\\");
+ else
+ fprintf(output_file, "\\\\%c", s[1]);
+ ++s;
+ }
+ else
+ putc(*s, output_file);
+ }
+ fprintf(output_file, "\\\"");
+ }
+ else if (s[0] == '\'')
+ {
+ if (s[1] == '"')
+ fprintf(output_file, " '\\\"'");
+ else if (s[1] == '\\')
+ {
+ if (s[2] == '\\')
+ fprintf(output_file, " '\\\\\\\\");
+ else
+ fprintf(output_file, " '\\\\%c", s[2]);
+ s += 2;
+ while (*++s != '\'')
+ putc(*s, output_file);
+ putc('\'', output_file);
+ }
+ else
+ fprintf(output_file, " '%c'", s[1]);
+ }
+ else
+ fprintf(output_file, " %s", s);
+ }
+ fprintf(output_file, "\",");
+ output_newline();
+ }
+
+ end_table();
+ output_line("#endif");
+}
+
+static void
+output_pure_parser(FILE * fp)
+{
+ putc_code(fp, '\n');
+
+ if (fp == code_file)
+ outline += 1;
+ fprintf(fp, "#define YYPURE %d\n", pure_parser);
+ putc_code(fp, '\n');
+}
+
+static void
+output_stype(FILE * fp)
+{
+ if (!unionized && ntags == 0)
+ {
+ putc_code(fp, '\n');
+ putl_code(fp, "#ifndef YYSTYPE\n");
+ putl_code(fp, "typedef int YYSTYPE;\n");
+ putl_code(fp, "#endif\n");
+ }
+}
+
+static void
+output_trailing_text(void)
+{
+ int c, last;
+ FILE *in;
+
+ if (line == 0)
+ return;
+
+ in = input_file;
+ c = *cptr;
+ if (c == '\n')
+ {
+ ++lineno;
+ if ((c = getc(in)) == EOF)
+ return;
+ write_input_lineno();
+ putc_code(code_file, c);
+ last = c;
+ }
+ else
+ {
+ write_input_lineno();
+ do
+ {
+ putc_code(code_file, c);
+ }
+ while ((c = *++cptr) != '\n');
+ putc_code(code_file, c);
+ last = '\n';
+ }
+
+ while ((c = getc(in)) != EOF)
+ {
+ putc_code(code_file, c);
+ last = c;
+ }
+
+ if (last != '\n')
+ {
+ putc_code(code_file, '\n');
+ }
+ write_code_lineno(code_file);
+}
+
+static void
+output_semantic_actions(void)
+{
+ int c, last;
+
+ rewind(action_file);
+ if ((c = getc(action_file)) == EOF)
+ return;
+
+ last = c;
+ putc_code(code_file, c);
+ while ((c = getc(action_file)) != EOF)
+ {
+ putc_code(code_file, c);
+ last = c;
+ }
+
+ if (last != '\n')
+ {
+ putc_code(code_file, '\n');
+ }
+
+ write_code_lineno(code_file);
+}
+
+static void
+output_parse_decl(FILE * fp)
+{
+ putl_code(fp, "\n");
+ putl_code(fp, "/* compatibility with bison */\n");
+ putl_code(fp, "#ifdef YYPARSE_PARAM\n");
+ putl_code(fp, "/* compatibility with FreeBSD */\n");
+ putl_code(fp, "# ifdef YYPARSE_PARAM_TYPE\n");
+ putl_code(fp,
+ "# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)\n");
+ putl_code(fp, "# else\n");
+ putl_code(fp, "# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)\n");
+ putl_code(fp, "# endif\n");
+ putl_code(fp, "#else\n");
+
+ puts_code(fp, "# define YYPARSE_DECL() yyparse(");
+ if (!parse_param)
+ puts_code(fp, "void");
+ else
+ {
+ param *p;
+ for (p = parse_param; p; p = p->next)
+ fprintf(fp, "%s %s%s%s", p->type, p->name, p->type2,
+ p->next ? ", " : "");
+ }
+ putl_code(fp, ")\n");
+
+ putl_code(fp, "#endif\n");
+}
+
+static void
+output_lex_decl(FILE * fp)
+{
+ putl_code(fp, "\n");
+ putl_code(fp, "/* Parameters sent to lex. */\n");
+ putl_code(fp, "#ifdef YYLEX_PARAM\n");
+ if (pure_parser)
+ {
+ putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, "
+ "void *YYLEX_PARAM)\n");
+ putl_code(fp, "# define YYLEX yylex(&yylval, YYLEX_PARAM)\n");
+ }
+ else
+ {
+ putl_code(fp, "# define YYLEX_DECL() yylex(void *YYLEX_PARAM)\n");
+ putl_code(fp, "# define YYLEX yylex(YYLEX_PARAM)\n");
+ }
+ putl_code(fp, "#else\n");
+ if (pure_parser && lex_param)
+ {
+ param *p;
+ puts_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, ");
+ for (p = lex_param; p; p = p->next)
+ fprintf(fp, "%s %s%s%s", p->type, p->name, p->type2,
+ p->next ? ", " : "");
+ putl_code(fp, ")\n");
+
+ puts_code(fp, "# define YYLEX yylex(&yylval, ");
+ for (p = lex_param; p; p = p->next)
+ fprintf(fp, "%s%s", p->name, p->next ? ", " : "");
+ putl_code(fp, ")\n");
+ }
+ else if (pure_parser)
+ {
+ putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval)\n");
+ putl_code(fp, "# define YYLEX yylex(&yylval)\n");
+ }
+ else if (lex_param)
+ {
+ param *p;
+ puts_code(fp, "# define YYLEX_DECL() yylex(");
+ for (p = lex_param; p; p = p->next)
+ fprintf(fp, "%s %s%s%s", p->type, p->name, p->type2,
+ p->next ? ", " : "");
+ putl_code(fp, ")\n");
+
+ puts_code(fp, "# define YYLEX yylex(");
+ for (p = lex_param; p; p = p->next)
+ fprintf(fp, "%s%s", p->name, p->next ? ", " : "");
+ putl_code(fp, ")\n");
+ }
+ else
+ {
+ putl_code(fp, "# define YYLEX_DECL() yylex(void)\n");
+ putl_code(fp, "# define YYLEX yylex()\n");
+ }
+ putl_code(fp, "#endif\n");
+}
+
+static void
+output_error_decl(FILE * fp)
+{
+ putl_code(fp, "\n");
+ putl_code(fp, "/* Parameters sent to yyerror. */\n");
+ if (parse_param)
+ {
+ param *p;
+
+ fprintf(fp, "#define YYERROR_DECL() yyerror(");
+ for (p = parse_param; p; p = p->next)
+ fprintf(fp, "%s %s%s, ", p->type, p->name, p->type2);
+ putl_code(fp, "const char *s)\n");
+
+ puts_code(fp, "#define YYERROR_CALL(msg) yyerror(");
+
+ for (p = parse_param; p; p = p->next)
+ fprintf(fp, "%s, ", p->name);
+
+ putl_code(fp, "msg)\n");
+ }
+ else
+ {
+ putl_code(fp, "#define YYERROR_DECL() yyerror(const char *s)\n");
+ putl_code(fp, "#define YYERROR_CALL(msg) yyerror(msg)\n");
+ }
+}
+
+static void
+free_itemsets(void)
+{
+ core *cp, *next;
+
+ FREE(state_table);
+ for (cp = first_state; cp; cp = next)
+ {
+ next = cp->next;
+ FREE(cp);
+ }
+}
+
+static void
+free_shifts(void)
+{
+ shifts *sp, *next;
+
+ FREE(shift_table);
+ for (sp = first_shift; sp; sp = next)
+ {
+ next = sp->next;
+ FREE(sp);
+ }
+}
+
+static void
+free_reductions(void)
+{
+ reductions *rp, *next;
+
+ FREE(reduction_table);
+ for (rp = first_reduction; rp; rp = next)
+ {
+ next = rp->next;
+ FREE(rp);
+ }
+}
+
+static void
+output_yyerror_call(const char *msg)
+{
+ FILE *fp = code_file;
+
+ puts_code(fp, " yyerror(");
+ if (parse_param)
+ {
+ param *p;
+ for (p = parse_param; p; p = p->next)
+ fprintf(fp, "%s, ", p->name);
+ }
+ puts_code(fp, "\"");
+ puts_code(fp, msg);
+ putl_code(fp, "\");\n");
+}
+
+static void
+output_externs(FILE * fp, const char *const section[])
+{
+ int c;
+ int i;
+ const char *s;
+
+ for (i = 0; (s = section[i]) != 0; ++i)
+ {
+ if (*s && *s != '#')
+ fputs("extern\t", fp);
+ while ((c = *s) != 0)
+ {
+ putc(c, fp);
+ ++s;
+ }
+ if (fp == code_file)
+ ++outline;
+ putc('\n', fp);
+ }
+}
+
+void
+output(void)
+{
+ FILE *fp;
+
+ free_itemsets();
+ free_shifts();
+ free_reductions();
+
+ if (iflag)
+ {
+ ++outline;
+ fprintf(code_file, "#include \"%s\"\n", externs_file_name);
+ fp = externs_file;
+ }
+ else
+ fp = code_file;
+
+ output_prefix(iflag ? externs_file : output_file);
+ output_pure_parser(fp);
+ output_stored_text(fp);
+ output_stype(fp);
+ output_parse_decl(fp);
+ output_lex_decl(fp);
+ output_error_decl(fp);
+ write_section(fp, xdecls);
+
+ if (iflag)
+ {
+ output_externs(externs_file, global_vars);
+ if (!pure_parser)
+ output_externs(externs_file, impure_vars);
+ }
+
+ if (iflag)
+ {
+ ++outline;
+ fprintf(code_file, "#include \"%s\"\n", defines_file_name);
+ if (!dflag)
+ output_defines(externs_file);
+ }
+ else
+ {
+ putc_code(code_file, '\n');
+ output_defines(code_file);
+ }
+
+ if (dflag)
+ output_defines(defines_file);
+
+ output_rule_data();
+ output_yydefred();
+ output_actions();
+ free_parser();
+ output_debug();
+ if (rflag)
+ {
+ output_prefix(code_file);
+ write_section(code_file, xdecls);
+ write_section(code_file, tables);
+ }
+ write_section(code_file, global_vars);
+ if (!pure_parser)
+ {
+ write_section(code_file, impure_vars);
+ }
+ write_section(code_file, hdr_defs);
+ if (!pure_parser)
+ {
+ write_section(code_file, hdr_vars);
+ }
+ output_trailing_text();
+ write_section(code_file, body_1);
+ if (pure_parser)
+ {
+ write_section(code_file, body_vars);
+ }
+ write_section(code_file, body_2);
+ output_yyerror_call("syntax error");
+ write_section(code_file, body_3);
+ output_semantic_actions();
+ write_section(code_file, trailer);
+ output_yyerror_call("yacc stack overflow");
+ write_section(code_file, trailer_2);
+}
+
+#ifdef NO_LEAKS
+void
+output_leaks(void)
+{
+ DO_FREE(tally);
+ DO_FREE(width);
+ DO_FREE(order);
+}
+#endif
--- /dev/null
+Summary: byacc - public domain Berkeley LALR Yacc parser generator
+%define AppProgram byacc
+%define AppVersion 20110908
+%define UseProgram yacc
+# $XTermId: byacc.spec,v 1.10 2011/09/08 09:45:02 tom Exp $
+Name: %{AppProgram}
+Version: %{AppVersion}
+Release: 1
+License: Public Domain, MIT
+Group: Applications/Development
+URL: ftp://invisible-island.net/%{AppProgram}
+Source0: %{AppProgram}-%{AppVersion}.tgz
+Packager: Thomas Dickey <dickey@invisible-island.net>
+
+%description
+This package provides a parser generator utility that reads a grammar
+specification from a file and generates an LR(1) parser for it. The
+parsers consist of a set of LALR(1) parsing tables and a driver
+routine written in the C programming language. It has a public domain
+license which includes the generated C.
+
+%prep
+
+%setup -q -n %{AppProgram}-%{AppVersion}
+
+%build
+
+INSTALL_PROGRAM='${INSTALL}' \
+ ./configure \
+ --program-prefix=b \
+ --target %{_target_platform} \
+ --prefix=%{_prefix} \
+ --bindir=%{_bindir} \
+ --libdir=%{_libdir} \
+ --mandir=%{_mandir}
+
+make
+
+%install
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+
+make install DESTDIR=$RPM_BUILD_ROOT
+( cd $RPM_BUILD_ROOT%{_bindir} && ln -s %{AppProgram} %{UseProgram} )
+
+strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram}
+
+%clean
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%{_prefix}/bin/%{AppProgram}
+%{_prefix}/bin/%{UseProgram}
+%{_mandir}/man1/%{AppProgram}.*
+
+%changelog
+# each patch should add its ChangeLog entries here
+
+* Sun Jun 06 2010 Thomas Dickey
+- initial version
--- /dev/null
+byacc (20110908) unstable; urgency=low
+
+ * add "-i" option.
+ * add error-check in reader.c
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Mon, 05 Sep 2011 20:05:51 -0400
+
+byacc (20101229) unstable; urgency=low
+
+ * fixes from Christos Zoulos
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Wed, 29 Dec 2010 13:03:50 -0500
+
+byacc (20101226) unstable; urgency=low
+
+ * portability fix for MinGW
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sat, 25 Dec 2010 19:37:54 -0500
+
+byacc (20101127) unstable; urgency=low
+
+ * corrected yyerror use of %parse-param data
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sat, 27 Nov 2010 12:32:00 -0500
+
+byacc (20101126) unstable; urgency=low
+
+ * additional fix to generated code to avoid symbol conflict
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Fri, 26 Nov 2010 04:23:08 -0500
+
+byacc (20101124) unstable; urgency=low
+
+ * amend fix for Red Hat #112617 to restore warning message.
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Mon, 22 Nov 2010 08:21:23 -0500
+
+byacc (20101122) unstable; urgency=low
+
+ * fix for generated header to avoid symbol conflict
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Mon, 22 Nov 2010 08:21:23 -0500
+
+byacc (20100610) unstable; urgency=low
+
+ * Add package scripts to upstream source, for test-builds.
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Thu, 10 Jun 2010 08:59:11 -0400
+
+byacc (20100216-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/source/format: Added using format "3.0 (quilt)"
+
+ -- Dave Beckett <dajobe@debian.org> Tue, 20 Apr 2010 12:56:11 -0700
+
+byacc (20091027-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/control:
+ - Updated to policy 3.8.4
+ - Add ${misc:Depends}
+
+ -- Dave Beckett <dajobe@debian.org> Tue, 02 Feb 2010 21:36:34 -0800
+
+byacc (20090221-1) unstable; urgency=low
+
+ * New upstream release
+
+ -- Dave Beckett <dajobe@debian.org> Thu, 26 Feb 2009 21:06:20 -0800
+
+byacc (20080826-1) unstable; urgency=high
+
+ * New upstream release
+ * debian/patches/02-skeleton.patch: Removed - merged upstream
+ * debian/control: Updated to policy 3.8.0
+ * debian/preinst, debian/postrm: removed - empty (lintian)
+ * debian/watch: version 3 and make FTP passive
+ * Acknowledge NMU - thanks.
+
+ -- Dave Beckett <dajobe@debian.org> Wed, 11 Sep 2008 23:58:00 -0700
+
+byacc (20070509-1.1) unstable; urgency=high
+
+ * Non-maintainer upload.
+ * Fix stack overflow in skeleton.c with upstream patch.
+ Closes: #491182 aka CVE-2008-3196
+
+ -- Thomas Viehmann <tv@beamnet.de> Sun, 24 Aug 2008 23:13:07 +0200
+
+byacc (20070509-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/watch: Fix to use passive FTP
+ * debian/compat: added instead of use of DH_COMPAT in debian/rules
+
+ -- Dave Beckett <dajobe@debian.org> Tue, 26 Jun 2007 22:39:45 -0700
+
+byacc (20050813-1) unstable; urgency=low
+
+ * New upstream release:
+ - Do not close union_file for -d option (Closes: #322858)
+
+ -- Dave Beckett <dajobe@debian.org> Sun, 14 Aug 2005 10:14:12 +0100
+
+byacc (20050505-1) unstable; urgency=low
+
+ * New maintainer (Closes: #321377)
+ * Switch to new upstream and new source (Closes: #240662)
+ * debian/copyright: Update to new upstream and add source information
+ (Closes: #166300)
+ * Acknowledge fix in NMUs (Closes: #283174)
+ * New manual page does not have the formatting problem (Closes: #100947)
+ * Added debian/watch file.
+
+ -- Dave Beckett <dajobe@debian.org> Fri, 5 Aug 2005 22:50:20 +0100
+
+byacc (1.9.1-1.1) unstable; urgency=low
+
+ * Remove alternative in prerm. Closes: #283174
+
+ -- LaMont Jones <lamont@debian.org> Fri, 26 Nov 2004 18:49:09 -0700
+
+byacc (1.9.1-1) unstable; urgency=low
+
+ * Maintainer upload.
+ * Fixed alternatives entry, closes: Bug#146195;
+ * Changed priority to "extra" at behest of Daniel Bungert,
+ closes: Bug#142271.
+ * Fixed awful packaging error which meant the test/ directory was excluded
+ from the orig.tar.gz.
+
+ -- Jason Henry Parker <henry@debian.org> Fri, 27 Sep 2002 16:25:27 -0400
+
+byacc (1.9-13.1) unstable; urgency=low
+
+ * Non-maintainer upload
+ * Removed erraneous escapes in manpage - some data wasn't visable,
+ closes: Bug#100947
+ * Alternatives entry added, closes: Bug#113168
+ * Standards-version: 3.5.6
+ * Maintainer script cleaning
+
+ -- Daniel Bungert <drb@debian.org> Fri, 29 Mar 2002 16:58:30 -0500
+
+byacc (1.9-13) unstable; urgency=low
+
+ * Applied patch from "Randolph Chung" <tausq@debian.org> to fix build problems
+ on ia64, closes: Bug#91966
+
+ -- Jason Henry Parker <henry@debian.org> Thu, 29 Mar 2001 21:41:19 +1000
+
+byacc (1.9-12) unstable; urgency=low
+
+ * Updated to latest version of debhelper, and Standards-Version: 3.2.1.0, closes: Bug#81444
+ * Added Build-Depends: debhelper, closes: Bug#70207
+ * Removed mktemp() calls in main.c
+
+ -- Jason Henry Parker <henry@debian.org> Mon, 18 Dec 2000 08:02:54 +1000
+
+byacc (1.9-11.7) unstable; urgency=low
+
+ * New maintainer.
+ * Updated to dh_make and standards version 2.4.0.0, no lintian errors
+ or warnings.
+ * Added several more files from the upstream distribution to
+ /usr/doc/byacc.
+
+ -- Jason Henry Parker <henry@debian.org> Sat, 2 Jan 1999 03:04:17 +1000
+
+byacc (1.9-11.6) unstable; urgency=low
+
+ * Patch by <mdorman@law.miami.edu> to remove some
+ superfluous files that can interfere with the build process on other
+ architectures. (Bug #21607).
+
+ -- Vincent Renardias <vincent@waw.com> Fri, 24 Apr 1998 19:56:58 +0200
+
+byacc (1.9-11.5) unstable; urgency=low
+
+ * Added 'binary-arch' target in debian/rules (Bug #12742).
+
+ -- Vincent Renardias <vincent@waw.com> Sun, 9 Nov 1997 23:37:31 +0100
+
+byacc (1.9-11.4) unstable; urgency=low
+
+ * Cosmetic change (Fix bug #9623).
+
+ -- Vincent Renardias <vincent@waw.com> Fri, 9 May 1997 16:30:24 +0200
+
+byacc (1.9-11.3) unstable; urgency=low
+
+ * Rebuilt with libc6.
+
+ -- Debian QA Group <debian-qa@lists.debian.org> Thu, 1 May 1997 22:02:04 +0200
+
+byacc (1.9-11.2) unstable; urgency=low
+
+ * Orphaned the package at his maintainer's request (dgregor@coil.com).
+
+ -- Debian QA Group <debian-qa@lists.debian.org> Sun, 20 Apr 1997 20:03:03 +0200
+
+byacc (1.9-11.1) unstable; urgency=low
+
+ * Converted to new source format (Fixes #8085).
+ * Compressed manpage.
+ * Fixed to allow compilation on non-i386 (Fixes #3361).
+ * Added extended description (Fixes #3567).
+ * Added diversion to avoid conflict with bison (Fixes #8086).
+
+ -- Vincent Renardias <vincent@waw.com> Sun, 20 Apr 1997 15:59:28 +0200
--- /dev/null
+Source: byacc
+Maintainer: Dave Beckett <dajobe@debian.org>
+Section: devel
+Priority: extra
+Standards-Version: 3.8.4
+Build-Depends: debhelper (>= 5)
+Homepage: http://invisible-island.net/byacc/
+
+Package: byacc
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: public domain Berkeley LALR Yacc parser generator
+ This package provides a parser generator utility that reads a grammar
+ specification from a file and generates an LR(1) parser for it. The
+ parsers consist of a set of LALR(1) parsing tables and a driver
+ routine written in the C programming language. It has a public domain
+ license which includes the generated C.
--- /dev/null
+Upstream source http://dickey.his.com/byacc/byacc.html
+
+Berkeley Yacc is in the public domain; changes made to it by the current
+maintainer are likewise unrestricted. That applies to most of the files.
+A few files (currently those related to autoconf scripting) have other
+licenses as noted here.
+
+Current byacc upstream maintainer: Thomas Dickey <dickey@invisible-island.net>
+
+Public domain notice and no warranty:
+-------------------------------------------------------------------------------
+ Berkeley Yacc is an LALR(1) parser generator. Berkeley Yacc has been made
+as compatible as possible with AT&T Yacc. Berkeley Yacc can accept any input
+specification that conforms to the AT&T Yacc documentation. Specifications
+that take advantage of undocumented features of AT&T Yacc will probably be
+rejected.
+
+ Berkeley Yacc is distributed with no warranty whatever. The code
+is certain to contain errors. Neither the author nor any contributor
+takes responsibility for any consequences of its use.
+
+ Berkeley Yacc is in the public domain. The data structures and algorithms
+used in Berkeley Yacc are all either taken from documents available to the
+general public or are inventions of the author. Anyone may freely distribute
+source or binary forms of Berkeley Yacc whether unchanged or modified.
+Distributers may charge whatever fees they can obtain for Berkeley Yacc.
+Programs generated by Berkeley Yacc may be distributed freely.
+
+ Please report bugs to
+
+ robert.corbett@eng.Sun.COM
+
+Include a small example if possible. Please include the banner string from
+skeleton.c with the bug report. Do not expect rapid responses.
+-------------------------------------------------------------------------------
+
+Files: aclocal.m4
+Licence: other-BSD
+Copyright: 2004-2009,2010 by Thomas E. Dickey
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, distribute with modifications, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above copyright
+ holders shall not be used in advertising or otherwise to promote the
+ sale, use or other dealings in this Software without prior written
+ authorization.
+
+Files: install-sh
+Copyright: 1994 X Consortium
+Licence: other-BSD
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to
+ deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+ TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name of the X Consortium shall not
+ be used in advertising or otherwise to promote the sale, use or other deal-
+ ings in this Software without prior written authorization from the X Consor-
+ tium.
+
+ FSF changes to this file are in the public domain.
+
+ Calling this script install-sh is preferred over install.sh, to prevent
+ `make' implicit rules from creating a file called install from it
+ when there is no Makefile.
+
+ This script is compatible with the BSD install script, but was written
+ from scratch. It can only install one file at a time, a restriction
+ shared with many OS's install programs.
+
+Files: debian/*
+Copyright: 2010 Thomas E. Dickey
+Licence: other-BSD
+ Permission to use, copy, modify, and distribute this software and its
+ documentation for any purpose and without fee is hereby granted,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation, and that the name of the above listed
+ copyright holder(s) not be used in advertising or publicity pertaining
+ to distribution of the software without specific, written prior
+ permission.
+
+ THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+ TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+ LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in '/usr/share/common-licenses/GPL-2'
--- /dev/null
+README
+ACKNOWLEDGEMENTS
+NEW_FEATURES
+NOTES
--- /dev/null
+#! /bin/sh
+# postinst script for byacc
+
+set -e
+
+if [ $1 != "upgrade" ] ; then
+ update-alternatives \
+ --install /usr/bin/yacc yacc /usr/bin/byacc 80 \
+ --slave /usr/share/man/man1/yacc.1.gz yaccman \
+ /usr/share/man/man1/byacc.1.gz
+fi
+
+#DEBHELPER#
+
+exit 0
--- /dev/null
+#! /bin/sh
+# prerm script for byacc
+
+set -e
+
+if [ $1 != "upgrade" ]; then
+ update-alternatives --remove yacc /usr/bin/byacc
+fi
+
+#DEBHELPER#
+
+exit 0
--- /dev/null
+#!/usr/bin/make -f
+# MAde with the aid of dh_make, by Craig Small
+# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
+# Some lines taken from debmake, by Cristoph Lameter.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+CFLAGS =
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+
+ CFLAGS="$(CFLAGS)" ./configure \
+ --host=$(DEB_HOST_GNU_TYPE) \
+ --build=$(DEB_BUILD_GNU_TYPE) \
+ --prefix=/usr \
+ --mandir=\$${prefix}/share/man \
+ --sysconfdir=/etc \
+ --program-transform-name='s,^,b,'
+
+ touch configure-stamp
+
+build: build-stamp
+build-stamp: configure-stamp
+ dh_testdir
+
+ $(MAKE)
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+
+ [ ! -f Makefile ] || $(MAKE) clean
+
+ rm -f configure-stamp build-stamp install-stamp \
+ config.cache config.h config.status config.log makefile
+
+ rm -f *.o yacc
+
+ dh_clean
+
+install: install-stamp
+install-stamp: build-stamp
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ $(MAKE) install DESTDIR=$(CURDIR)/debian/byacc
+
+ touch install-stamp
+
+# Build architecture-independent files here.
+binary-indep: build install
+# No binary-indep target.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installexamples
+ dh_installchangelogs CHANGES
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install install-stamp
--- /dev/null
+3.0 (quilt)
--- /dev/null
+version=3
+
+opts=passive ftp://invisible-island.net/byacc/byacc-(\d+)\.tgz \
+ debian uupdate
--- /dev/null
+Berkeley Yacc (byacc) is a LALR(1) parser generator. Berkeley Yacc
+has been made as compatible as possible with AT&T Yacc. Berkeley
+Yacc can accept any input specification that conforms to the AT&T
+Yacc documentation.
+
+Some programs depend on a byacc (instead of bison).
--- /dev/null
+# $NetBSD: Makefile,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
+#
+
+DISTNAME= byacc-20050813
+PKGREVISION= 1
+CATEGORIES= devel
+MASTER_SITES= ftp://invisible-island.net/byacc/
+EXTRACT_SUFX= .tgz
+
+MAINTAINER= pkgsrc-users@NetBSD.org
+HOMEPAGE= http://dickey.his.com/byacc/byacc.html
+COMMENT= Berkeley Yacc
+
+PKG_DESTDIR_SUPPORT= user-destdir
+
+GNU_CONFIGURE= YES
+MAKE_FILE= makefile
+
+.include "../../mk/bsd.pkg.mk"
--- /dev/null
+@comment $NetBSD: PLIST,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
+bin/yacc
+man/man1/yacc.1
--- /dev/null
+$NetBSD: distinfo,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
+
+SHA1 (byacc-20050813.tgz) = 3258494f3422eb3150944c1823af1c9c2c386062
+RMD160 (byacc-20050813.tgz) = 3ee159857a79025a83e2b0807577925fe460f816
+Size (byacc-20050813.tgz) = 138684 bytes
+SHA1 (patch-aa) = decae78775a5e0f1e1f7aaaa258da53903aa1f7a
-/* $NetBSD: reader.c,v 1.18 2009/04/14 09:41:31 lukem Exp $ */
+/* $NetBSD: reader.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
+/* Id: reader.c,v 1.33 2011/09/06 22:56:53 tom Exp */
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
+#include "defs.h"
#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91";
-#else
-__RCSID("$NetBSD: reader.c,v 1.18 2009/04/14 09:41:31 lukem Exp $");
-#endif
-#endif /* not lint */
-
-#include "defs.h"
+__RCSID("$NetBSD: reader.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
/* The line size must be a positive integer. One hundred was chosen */
/* because few lines in Yacc input grammars exceed 100 characters. */
/* Note that if a line exceeds LINESIZE characters, the line buffer */
-/* will be expanded to accommodate it. */
+/* will be expanded to accomodate it. */
#define LINESIZE 100
-int ntags;
-char unionized;
-char *cptr, *line;
+#define L_CURL '{'
+#define R_CURL '}'
+
+static void start_rule(bucket *bp, int s_lineno);
static char *cache;
static int cinc, cache_size;
+int ntags;
static int tagmax;
static char **tag_table;
static char saw_eof;
+char unionized;
+char *cptr, *line;
static int linesize;
static bucket *goal;
+static Value_t prec;
static int gensym;
static char last_was_action;
static int maxrules;
static bucket **plhs;
-static int name_pool_size;
+static size_t name_pool_size;
static char *name_pool;
-static void cachec(int);
-static void get_line(void);
-static char * dup_line(void);
-static void skip_comment(void);
-static int nextc(void);
-static int keyword(void);
-static void copy_ident(void);
-static void copy_text(void);
-static void copy_union(void);
-static int hexval(int);
-static bucket * get_literal(void);
-static int is_reserved(char *);
-static bucket * get_name(void);
-static int get_number(void);
-static char * get_tag(void);
-static void declare_tokens(int);
-static void declare_types(void);
-static void declare_start(void);
-static void handle_expect(void);
-static void read_declarations(void);
-static void initialize_grammar(void);
-static void expand_items(void);
-static void expand_rules(void);
-static void advance_to_start(void);
-static void start_rule(bucket *, int);
-static void end_rule(void);
-static void insert_empty_rule(void);
-static void add_symbol(void);
-static void copy_action(void);
-static int mark_symbol(void);
-static void read_grammar(void);
-static void free_tags(void);
-static void pack_names(void);
-static void check_symbols(void);
-static void pack_symbols(void);
-static void pack_grammar(void);
-static void print_grammar(void);
-
-
-static const char line_format[] = "#line %d \"%s\"\n";
+char line_format[] = "#line %d \"%s\"\n";
+
+param *lex_param;
+param *parse_param;
static void
cachec(int c)
{
cache_size += 256;
cache = REALLOC(cache, cache_size);
- if (cache == 0) no_space();
+ NO_SPACE(cache);
}
- cache[cinc] = c;
+ cache[cinc] = (char)c;
++cinc;
}
if (saw_eof || (c = getc(f)) == EOF)
{
- if (line) { FREE(line); line = 0; }
+ if (line)
+ {
+ FREE(line);
+ line = 0;
+ }
cptr = 0;
saw_eof = 1;
return;
if (line == 0 || linesize != (LINESIZE + 1))
{
- if (line) FREE(line);
+ if (line)
+ FREE(line);
linesize = LINESIZE + 1;
line = MALLOC(linesize);
- if (line == 0) no_space();
+ NO_SPACE(line);
}
i = 0;
++lineno;
for (;;)
{
- line[i] = c;
- if (c == '\n') { cptr = line; return; }
+ line[i] = (char)c;
+ if (c == '\n')
+ {
+ cptr = line;
+ return;
+ }
if (++i >= linesize)
{
linesize += LINESIZE;
line = REALLOC(line, linesize);
- if (line == 0) no_space();
+ NO_SPACE(line);
}
c = getc(f);
- if (c == EOF)
+ if (c == EOF)
{
line[i] = '\n';
saw_eof = 1;
}
}
-
static char *
dup_line(void)
{
char *p, *s, *t;
- if (line == 0) return (0);
+ if (line == 0)
+ return (0);
s = line;
- while (*s != '\n') ++s;
+ while (*s != '\n')
+ ++s;
p = MALLOC(s - line + 1);
- if (p == 0) no_space();
+ NO_SPACE(p);
s = line;
t = p;
- while ((*t++ = *s++) != '\n') continue;
+ while ((*t++ = *s++) != '\n')
+ continue;
return (p);
}
-
static void
skip_comment(void)
{
}
}
-
static int
nextc(void)
{
{
case '\n':
get_line();
- if (line == 0) return (EOF);
+ if (line == 0)
+ return (EOF);
s = cptr;
break;
else if (s[1] == '/')
{
get_line();
- if (line == 0) return (EOF);
+ if (line == 0)
+ return (EOF);
s = cptr;
break;
}
- /* fall through */
+ /* FALLTHRU */
default:
cptr = s;
}
}
+/*
+ * Compare keyword to cached token, treating '_' and '-' the same. Some
+ * grammars rely upon this misfeature.
+ */
+static int
+matchec(const char *name)
+{
+ const char *p = cache;
+ const char *q = name;
+ int code = 0; /* assume mismatch */
+
+ while (*p != '\0' && *q != '\0')
+ {
+ char a = *p++;
+ char b = *q++;
+ if (a == '_')
+ a = '-';
+ if (b == '_')
+ b = '-';
+ if (a != b)
+ break;
+ if (*p == '\0' && *q == '\0')
+ {
+ code = 1;
+ break;
+ }
+ }
+ return code;
+}
static int
keyword(void)
{
- unsigned char c;
+ int c;
char *t_cptr = cptr;
c = *++cptr;
{
if (isalpha(c))
{
- if (isupper(c)) c = tolower(c);
+ if (isupper(c))
+ c = tolower(c);
cachec(c);
}
- else if (isdigit(c) || c == '_' || c == '.' || c == '$')
+ else if (isdigit(c)
+ || c == '-'
+ || c == '_'
+ || c == '.'
+ || c == '$')
+ {
cachec(c);
+ }
else
+ {
break;
+ }
c = *++cptr;
}
cachec(NUL);
- if (strcmp(cache, "token") == 0 || strcmp(cache, "term") == 0)
+ if (matchec("token") || matchec("term"))
return (TOKEN);
- if (strcmp(cache, "type") == 0)
+ if (matchec("type"))
return (TYPE);
- if (strcmp(cache, "left") == 0)
+ if (matchec("left"))
return (LEFT);
- if (strcmp(cache, "right") == 0)
+ if (matchec("right"))
return (RIGHT);
- if (strcmp(cache, "nonassoc") == 0 || strcmp(cache, "binary") == 0)
+ if (matchec("nonassoc") || matchec("binary"))
return (NONASSOC);
- if (strcmp(cache, "start") == 0)
+ if (matchec("start"))
return (START);
- if (strcmp(cache, "union") == 0)
+ if (matchec("union"))
return (UNION);
- if (strcmp(cache, "ident") == 0)
+ if (matchec("ident"))
return (IDENT);
- if (strcmp(cache, "expect") == 0)
+ if (matchec("expect"))
return (EXPECT);
+ if (matchec("expect-rr"))
+ return (EXPECT_RR);
+ if (matchec("pure-parser"))
+ return (PURE_PARSER);
+ if (matchec("parse-param"))
+ return (PARSE_PARAM);
+ if (matchec("lex-param"))
+ return (LEX_PARAM);
+ if (matchec("yacc"))
+ return (POSIX_YACC);
}
else
{
++cptr;
- if (c == '{')
+ if (c == L_CURL)
return (TEXT);
if (c == '%' || c == '\\')
return (MARK);
return (NONASSOC);
}
syntax_error(lineno, line, t_cptr);
- /*NOTREACHED*/
- exit(1);
+ /*NOTREACHED */
}
FILE *f = output_file;
c = nextc();
- if (c == EOF) unexpected_EOF();
- if (c != '"') syntax_error(lineno, line, cptr);
+ if (c == EOF)
+ unexpected_EOF();
+ if (c != '"')
+ syntax_error(lineno, line, cptr);
++outline;
fprintf(f, "#ident \"");
for (;;)
}
}
-
static void
copy_text(void)
{
if (line == 0)
unterminated_text(t_lineno, t_line, t_cptr);
}
- if (!lflag) fprintf(f, line_format, lineno, input_file_name);
+ if (!lflag)
+ fprintf(f, line_format, lineno, input_file_name);
-loop:
+ loop:
c = *cptr++;
switch (c)
{
case '\n':
- next_line:
+ next_line:
putc('\n', f);
need_newline = 0;
get_line();
- if (line) goto loop;
+ if (line)
+ goto loop;
unterminated_text(t_lineno, t_line, t_cptr);
case '\'':
case '%':
case '\\':
- if (*cptr == '}')
+ if (*cptr == R_CURL)
{
- if (need_newline) putc('\n', f);
+ if (need_newline)
+ putc('\n', f);
++cptr;
FREE(t_line);
return;
}
- /* fall through */
+ /* FALLTHRU */
default:
putc(c, f);
}
}
+static void
+puts_both(const char *s)
+{
+ fputs(s, text_file);
+ if (dflag)
+ fputs(s, union_file);
+}
+
+static void
+putc_both(int c)
+{
+ putc(c, text_file);
+ if (dflag)
+ putc(c, union_file);
+}
static void
copy_union(void)
char *u_line = dup_line();
char *u_cptr = u_line + (cptr - line - 6);
- if (unionized) over_unionized(cptr - 6);
+ if (unionized)
+ over_unionized(cptr - 6);
unionized = 1;
if (!lflag)
fprintf(text_file, line_format, lineno, input_file_name);
- fprintf(text_file, "typedef union");
- if (dflag) fprintf(union_file, "typedef union");
+ puts_both("#ifdef YYSTYPE\n");
+ puts_both("#undef YYSTYPE_IS_DECLARED\n");
+ puts_both("#define YYSTYPE_IS_DECLARED 1\n");
+ puts_both("#endif\n");
+ puts_both("#ifndef YYSTYPE_IS_DECLARED\n");
+ puts_both("#define YYSTYPE_IS_DECLARED 1\n");
+ puts_both("typedef union");
depth = 0;
-loop:
+ loop:
c = *cptr++;
- putc(c, text_file);
- if (dflag) putc(c, union_file);
+ putc_both(c);
switch (c)
{
case '\n':
- next_line:
+ next_line:
get_line();
- if (line == 0) unterminated_union(u_lineno, u_line, u_cptr);
+ if (line == 0)
+ unterminated_union(u_lineno, u_line, u_cptr);
goto loop;
- case '{':
+ case L_CURL:
++depth;
goto loop;
- case '}':
+ case R_CURL:
if (--depth == 0)
{
- fprintf(text_file, " YYSTYPE;\n");
+ puts_both(" YYSTYPE;\n");
+ puts_both("#endif /* !YYSTYPE_IS_DECLARED */\n");
FREE(u_line);
return;
}
for (;;)
{
c = *cptr++;
- putc(c, text_file);
- if (dflag) putc(c, union_file);
+ putc_both(c);
if (c == quote)
{
FREE(s_line);
if (c == '\\')
{
c = *cptr++;
- putc(c, text_file);
- if (dflag) putc(c, union_file);
+ putc_both(c);
if (c == '\n')
{
get_line();
c = *cptr;
if (c == '/')
{
- putc('*', text_file);
- if (dflag) putc('*', union_file);
+ putc_both('*');
while ((c = *++cptr) != '\n')
{
if (c == '*' && cptr[1] == '/')
{
- fprintf(text_file, "* ");
- if (dflag) fprintf(union_file, "* ");
+ puts_both("* ");
}
else
{
- putc(c, text_file);
- if (dflag) putc(c, union_file);
+ putc_both(c);
}
}
- fprintf(text_file, "*/\n");
- if (dflag) fprintf(union_file, "*/\n");
+ puts_both("*/\n");
goto next_line;
}
if (c == '*')
char *c_line = dup_line();
char *c_cptr = c_line + (cptr - line - 1);
- putc('*', text_file);
- if (dflag) putc('*', union_file);
+ putc_both('*');
++cptr;
for (;;)
{
c = *cptr++;
- putc(c, text_file);
- if (dflag) putc(c, union_file);
+ putc_both(c);
if (c == '*' && *cptr == '/')
{
- putc('/', text_file);
- if (dflag) putc('/', union_file);
+ putc_both('/');
++cptr;
FREE(c_line);
goto loop;
}
}
+/*
+ * Keep a linked list of parameters
+ */
+static void
+copy_param(int k)
+{
+ char *buf;
+ int c;
+ param *head, *p;
+ int i;
+ int name, type2;
+
+ c = nextc();
+ if (c == EOF)
+ unexpected_EOF();
+ if (c != '{')
+ goto out;
+ cptr++;
+
+ c = nextc();
+ if (c == EOF)
+ unexpected_EOF();
+ if (c == '}')
+ goto out;
+
+ buf = MALLOC(linesize);
+ NO_SPACE(buf);
+
+ for (i = 0; (c = *cptr++) != '}'; i++)
+ {
+ if (c == '\0')
+ missing_brace();
+ if (c == EOF)
+ unexpected_EOF();
+ buf[i] = (char)c;
+ }
+
+ if (i == 0)
+ goto out;
+
+ buf[i--] = '\0';
+ while (i >= 0 && isspace(UCH(buf[i])))
+ buf[i--] = '\0';
+
+ if (buf[i] == ']')
+ {
+ int level = 1;
+ while (i >= 0 && level > 0 && buf[i] != '[')
+ {
+ if (buf[i] == ']')
+ ++level;
+ else if (buf[i] == '[')
+ --level;
+ i--;
+ }
+ if (i <= 0)
+ unexpected_EOF();
+ type2 = i--;
+ }
+ else
+ {
+ type2 = i + 1;
+ }
+
+ while (i >= 0 && (isalnum(UCH(buf[i])) ||
+ UCH(buf[i]) == '_'))
+ i--;
+
+ if (!isspace(UCH(buf[i])) && buf[i] != '*')
+ goto out;
+
+ name = i + 1;
+
+ p = MALLOC(sizeof(*p));
+ NO_SPACE(p);
+
+ p->type2 = strdup(buf + type2);
+ NO_SPACE(p->type2);
+
+ buf[type2] = '\0';
+
+ p->name = strdup(buf + name);
+ NO_SPACE(p->name);
+
+ buf[name] = '\0';
+ p->type = buf;
+
+ if (k == LEX_PARAM)
+ head = lex_param;
+ else
+ head = parse_param;
+
+ if (head != NULL)
+ {
+ while (head->next)
+ head = head->next;
+ head->next = p;
+ }
+ else
+ {
+ if (k == LEX_PARAM)
+ lex_param = p;
+ else
+ parse_param = p;
+ }
+ p->next = NULL;
+ return;
+
+ out:
+ syntax_error(lineno, line, cptr);
+}
static int
hexval(int c)
return (-1);
}
-
static bucket *
get_literal(void)
{
for (;;)
{
c = *cptr++;
- if (c == quote) break;
- if (c == '\n') unterminated_string(s_lineno, s_line, s_cptr);
+ if (c == quote)
+ break;
+ if (c == '\n')
+ unterminated_string(s_lineno, s_line, s_cptr);
if (c == '\\')
{
char *c_cptr = cptr - 1;
{
case '\n':
get_line();
- if (line == 0) unterminated_string(s_lineno, s_line, s_cptr);
+ if (line == 0)
+ unterminated_string(s_lineno, s_line, s_cptr);
continue;
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
n = c - '0';
c = *cptr;
if (IS_OCTAL(c))
++cptr;
}
}
- if (n > MAXCHAR) illegal_character(c_cptr);
+ if (n > MAXCHAR)
+ illegal_character(c_cptr);
c = n;
- break;
+ break;
case 'x':
c = *cptr++;
{
c = *cptr;
i = hexval(c);
- if (i < 0 || i >= 16) break;
+ if (i < 0 || i >= 16)
+ break;
++cptr;
n = (n << 4) + i;
- if (n > MAXCHAR) illegal_character(c_cptr);
+ if (n > MAXCHAR)
+ illegal_character(c_cptr);
}
c = n;
break;
- case 'a': c = 7; break;
- case 'b': c = '\b'; break;
- case 'f': c = '\f'; break;
- case 'n': c = '\n'; break;
- case 'r': c = '\r'; break;
- case 't': c = '\t'; break;
- case 'v': c = '\v'; break;
+ case 'a':
+ c = 7;
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'v':
+ c = '\v';
+ break;
}
}
cachec(c);
n = cinc;
s = MALLOC(n);
- if (s == 0) no_space();
-
+ NO_SPACE(s);
+
for (i = 0; i < n; ++i)
s[i] = cache[i];
for (i = 0; i < n; ++i)
{
- c = ((unsigned char *)s)[i];
+ c = UCH(s[i]);
if (c == '\\' || c == cache[0])
{
cachec('\\');
cachec('\\');
switch (c)
{
- case 7: cachec('a'); break;
- case '\b': cachec('b'); break;
- case '\f': cachec('f'); break;
- case '\n': cachec('n'); break;
- case '\r': cachec('r'); break;
- case '\t': cachec('t'); break;
- case '\v': cachec('v'); break;
+ case 7:
+ cachec('a');
+ break;
+ case '\b':
+ cachec('b');
+ break;
+ case '\f':
+ cachec('f');
+ break;
+ case '\n':
+ cachec('n');
+ break;
+ case '\r':
+ cachec('r');
+ break;
+ case '\t':
+ cachec('t');
+ break;
+ case '\v':
+ cachec('v');
+ break;
default:
cachec(((c >> 6) & 7) + '0');
cachec(((c >> 3) & 7) + '0');
bp = lookup(cache);
bp->class = TERM;
if (n == 1 && bp->value == UNDEFINED)
- bp->value = *(unsigned char *)s;
+ bp->value = UCH(*s);
FREE(s);
return (bp);
}
-
static int
is_reserved(char *name)
{
char *s;
if (strcmp(name, ".") == 0 ||
- strcmp(name, "$accept") == 0 ||
- strcmp(name, "$end") == 0)
+ strcmp(name, "$accept") == 0 ||
+ strcmp(name, "$end") == 0)
return (1);
- if (name[0] == '$' && name[1] == '$' && isdigit((unsigned char)name[2]))
+ if (name[0] == '$' && name[1] == '$' && isdigit(UCH(name[2])))
{
s = name + 3;
- while (isdigit((unsigned char)*s)) ++s;
- if (*s == NUL) return (1);
+ while (isdigit(UCH(*s)))
+ ++s;
+ if (*s == NUL)
+ return (1);
}
return (0);
}
-
static bucket *
get_name(void)
{
cachec(c);
cachec(NUL);
- if (is_reserved(cache)) used_reserved(cache);
+ if (is_reserved(cache))
+ used_reserved(cache);
return (lookup(cache));
}
-
-static int
+static Value_t
get_number(void)
{
int c;
- int n;
+ Value_t n;
n = 0;
for (c = *cptr; isdigit(c); c = *++cptr)
- n = 10*n + (c - '0');
+ n = (Value_t) (10 * n + (c - '0'));
return (n);
}
-
static char *
get_tag(void)
{
++cptr;
c = nextc();
- if (c == EOF) unexpected_EOF();
+ if (c == EOF)
+ unexpected_EOF();
if (!isalpha(c) && c != '_' && c != '$')
illegal_tag(t_lineno, t_line, t_cptr);
cinc = 0;
- do { cachec(c); c = *++cptr; } while (IS_IDENT(c));
+ do
+ {
+ cachec(c);
+ c = *++cptr;
+ }
+ while (IS_IDENT(c));
cachec(NUL);
c = nextc();
- if (c == EOF) unexpected_EOF();
+ if (c == EOF)
+ unexpected_EOF();
if (c != '>')
illegal_tag(t_lineno, t_line, t_cptr);
- FREE(t_line);
++cptr;
for (i = 0; i < ntags; ++i)
{
if (strcmp(cache, tag_table[i]) == 0)
+ {
+ FREE(t_line);
return (tag_table[i]);
+ }
}
if (ntags >= tagmax)
{
tagmax += 16;
tag_table = (char **)
- (tag_table ? REALLOC(tag_table, tagmax*sizeof(char *))
- : MALLOC(tagmax*sizeof(char *)));
- if (tag_table == 0) no_space();
+ (tag_table
+ ? REALLOC(tag_table, (unsigned)tagmax * sizeof(char *))
+ : MALLOC((unsigned)tagmax * sizeof(char *)));
+ NO_SPACE(tag_table);
}
s = MALLOC(cinc);
- if (s == 0) no_space();
+ NO_SPACE(s);
+
strcpy(s, cache);
tag_table[ntags] = s;
++ntags;
+ FREE(t_line);
return (s);
}
-
static void
declare_tokens(int assoc)
{
int c;
bucket *bp;
- int value;
+ Value_t value;
char *tag = 0;
- static int prec;
- if (assoc != TOKEN) ++prec;
+ if (assoc != TOKEN)
+ ++prec;
c = nextc();
- if (c == EOF) unexpected_EOF();
+ if (c == EOF)
+ unexpected_EOF();
if (c == '<')
{
tag = get_tag();
c = nextc();
- if (c == EOF) unexpected_EOF();
+ if (c == EOF)
+ unexpected_EOF();
}
for (;;)
else
return;
- if (bp == goal) tokenized_start(bp->name);
+ if (bp == goal)
+ tokenized_start(bp->name);
bp->class = TERM;
if (tag)
{
if (bp->prec && prec != bp->prec)
reprec_warning(bp->name);
- bp->assoc = assoc;
+ bp->assoc = (Assoc_t) assoc;
bp->prec = prec;
}
c = nextc();
- if (c == EOF) unexpected_EOF();
- value = UNDEFINED;
+ if (c == EOF)
+ unexpected_EOF();
+
if (isdigit(c))
{
value = get_number();
revalued_warning(bp->name);
bp->value = value;
c = nextc();
- if (c == EOF) unexpected_EOF();
+ if (c == EOF)
+ unexpected_EOF();
}
}
}
+/*
+ * %expect requires special handling
+ * as it really isn't part of the yacc
+ * grammar only a flag for yacc proper.
+ */
+static void
+declare_expect(int assoc)
+{
+ int c;
+
+ if (assoc != EXPECT && assoc != EXPECT_RR)
+ ++prec;
+
+ /*
+ * Stay away from nextc - doesn't
+ * detect EOL and will read to EOF.
+ */
+ c = *++cptr;
+ if (c == EOF)
+ unexpected_EOF();
+
+ for (;;)
+ {
+ if (isdigit(c))
+ {
+ if (assoc == EXPECT)
+ SRexpect = get_number();
+ else
+ RRexpect = get_number();
+ break;
+ }
+ /*
+ * Looking for number before EOL.
+ * Spaces, tabs, and numbers are ok,
+ * words, punc., etc. are syntax errors.
+ */
+ else if (c == '\n' || isalpha(c) || !isspace(c))
+ {
+ syntax_error(lineno, line, cptr);
+ }
+ else
+ {
+ c = *++cptr;
+ if (c == EOF)
+ unexpected_EOF();
+ }
+ }
+}
static void
declare_types(void)
char *tag;
c = nextc();
- if (c == EOF) unexpected_EOF();
- if (c != '<') syntax_error(lineno, line, cptr);
+ if (c == EOF)
+ unexpected_EOF();
+ if (c != '<')
+ syntax_error(lineno, line, cptr);
tag = get_tag();
for (;;)
}
}
-
static void
declare_start(void)
{
bucket *bp;
c = nextc();
- if (c == EOF) unexpected_EOF();
+ if (c == EOF)
+ unexpected_EOF();
if (!isalpha(c) && c != '_' && c != '.' && c != '$')
syntax_error(lineno, line, cptr);
bp = get_name();
goal = bp;
}
-
-static void
-handle_expect(void)
-{
- int c;
- int num;
-
- c = nextc();
- if (c == EOF) unexpected_EOF();
- if (!isdigit(c))
- syntax_error(lineno, line, cptr);
- num = get_number();
- if (num == 1)
- fprintf (stderr, "%s: Expect 1 shift/reduce conflict.\n", myname);
- else
- fprintf (stderr, "%s: Expect %d shift/reduce conflicts.\n", myname, num);
-}
-
-
static void
read_declarations(void)
{
cache_size = 256;
cache = MALLOC(cache_size);
- if (cache == 0) no_space();
+ NO_SPACE(cache);
for (;;)
{
c = nextc();
- if (c == EOF) unexpected_EOF();
- if (c != '%') syntax_error(lineno, line, cptr);
+ if (c == EOF)
+ unexpected_EOF();
+ if (c != '%')
+ syntax_error(lineno, line, cptr);
switch (k = keyword())
{
case MARK:
declare_tokens(k);
break;
+ case EXPECT:
+ case EXPECT_RR:
+ declare_expect(k);
+ break;
+
case TYPE:
declare_types();
break;
declare_start();
break;
- case EXPECT:
- handle_expect();
+ case PURE_PARSER:
+ pure_parser = 1;
+ break;
+
+ case PARSE_PARAM:
+ case LEX_PARAM:
+ copy_param(k);
+ break;
+
+ case POSIX_YACC:
+ /* noop for bison compatibility. byacc is already designed to be posix
+ * yacc compatible. */
break;
}
}
}
-
static void
initialize_grammar(void)
{
nitems = 4;
maxitems = 300;
- pitem = (bucket **) MALLOC(maxitems*sizeof(bucket *));
- if (pitem == 0) no_space();
+
+ pitem = (bucket **)MALLOC((unsigned)maxitems * sizeof(bucket *));
+ NO_SPACE(pitem);
+
pitem[0] = 0;
pitem[1] = 0;
pitem[2] = 0;
nrules = 3;
maxrules = 100;
- plhs = (bucket **) MALLOC(maxrules*sizeof(bucket *));
- if (plhs == 0) no_space();
+
+ plhs = (bucket **)MALLOC((unsigned)maxrules * sizeof(bucket *));
+ NO_SPACE(plhs);
+
plhs[0] = 0;
plhs[1] = 0;
plhs[2] = 0;
- rprec = (short *) MALLOC(maxrules*sizeof(short));
- if (rprec == 0) no_space();
+
+ rprec = (short *)MALLOC((unsigned)maxrules * sizeof(short));
+ NO_SPACE(rprec);
+
rprec[0] = 0;
rprec[1] = 0;
rprec[2] = 0;
- rassoc = (char *) MALLOC(maxrules*sizeof(char));
- if (rassoc == 0) no_space();
+
+ rassoc = (char *)MALLOC((unsigned)maxrules * sizeof(char));
+ NO_SPACE(rassoc);
+
rassoc[0] = TOKEN;
rassoc[1] = TOKEN;
rassoc[2] = TOKEN;
}
-
static void
expand_items(void)
{
maxitems += 300;
- pitem = (bucket **) REALLOC(pitem, maxitems*sizeof(bucket *));
- if (pitem == 0) no_space();
+ pitem = (bucket **)REALLOC(pitem, (unsigned)maxitems * sizeof(bucket *));
+ NO_SPACE(pitem);
}
-
static void
expand_rules(void)
{
maxrules += 100;
- plhs = (bucket **) REALLOC(plhs, maxrules*sizeof(bucket *));
- if (plhs == 0) no_space();
- rprec = (short *) REALLOC(rprec, maxrules*sizeof(short));
- if (rprec == 0) no_space();
- rassoc = (char *) REALLOC(rassoc, maxrules*sizeof(char));
- if (rassoc == 0) no_space();
-}
+ plhs = (bucket **)REALLOC(plhs, (unsigned)maxrules * sizeof(bucket *));
+ NO_SPACE(plhs);
+
+ rprec = (short *)REALLOC(rprec, (unsigned)maxrules * sizeof(short));
+ NO_SPACE(rprec);
+
+ rassoc = (char *)REALLOC(rassoc, (unsigned)maxrules * sizeof(char));
+ NO_SPACE(rassoc);
+}
static void
advance_to_start(void)
for (;;)
{
c = nextc();
- if (c != '%') break;
+ if (c != '%')
+ break;
s_cptr = cptr;
switch (keyword())
{
s_lineno = lineno;
c = nextc();
- if (c == EOF) unexpected_EOF();
- if (c != ':') syntax_error(lineno, line, cptr);
+ if (c == EOF)
+ unexpected_EOF();
+ if (c != ':')
+ syntax_error(lineno, line, cptr);
start_rule(bp, s_lineno);
++cptr;
}
-
static void
start_rule(bucket *bp, int s_lineno)
{
rassoc[nrules] = TOKEN;
}
-
static void
end_rule(void)
{
if (!last_was_action && plhs[nrules]->tag)
{
- for (i = nitems - 1; pitem[i]; --i) continue;
- if (pitem[i+1] == 0 || pitem[i+1]->tag != plhs[nrules]->tag)
+ if (pitem[nitems - 1])
+ {
+ for (i = nitems - 1; (i > 0) && pitem[i]; --i)
+ continue;
+ if (pitem[i + 1] == 0 || pitem[i + 1]->tag != plhs[nrules]->tag)
+ default_action_warning();
+ }
+ else
+ {
default_action_warning();
+ }
}
last_was_action = 0;
- if (nitems >= maxitems) expand_items();
+ if (nitems >= maxitems)
+ expand_items();
pitem[nitems] = 0;
++nitems;
++nrules;
}
-
static void
insert_empty_rule(void)
{
bucket *bp, **bpp;
assert(cache);
- snprintf(cache, cache_size, "$$%d", ++gensym);
+ sprintf(cache, "$$%d", ++gensym);
bp = make_bucket(cache);
last_symbol->next = bp;
last_symbol = bp;
expand_items();
bpp = pitem + nitems - 1;
*bpp-- = bp;
- while ((bpp[0] = bpp[-1])) --bpp;
+ while ((bpp[0] = bpp[-1]) != 0)
+ --bpp;
if (++nrules >= maxrules)
expand_rules();
- plhs[nrules] = plhs[nrules-1];
- plhs[nrules-1] = bp;
- rprec[nrules] = rprec[nrules-1];
- rprec[nrules-1] = 0;
- rassoc[nrules] = rassoc[nrules-1];
- rassoc[nrules-1] = TOKEN;
+ plhs[nrules] = plhs[nrules - 1];
+ plhs[nrules - 1] = bp;
+ rprec[nrules] = rprec[nrules - 1];
+ rprec[nrules - 1] = 0;
+ rassoc[nrules] = rassoc[nrules - 1];
+ rassoc[nrules - 1] = TOKEN;
}
-
static void
add_symbol(void)
{
if (++nitems > maxitems)
expand_items();
- pitem[nitems-1] = bp;
+ pitem[nitems - 1] = bp;
}
+static char *
+after_blanks(char *s)
+{
+ while (*s != '\0' && isspace(UCH(*s)))
+ ++s;
+ return s;
+}
static void
copy_action(void)
fprintf(f, "case %d:\n", nrules - 2);
if (!lflag)
fprintf(f, line_format, lineno, input_file_name);
- if (*cptr == '=') ++cptr;
+ if (*cptr == '=')
+ ++cptr;
+
+ /* avoid putting curly-braces in first column, to ease editing */
+ if (*after_blanks(cptr) == L_CURL)
+ {
+ putc('\t', f);
+ cptr = after_blanks(cptr);
+ }
n = 0;
- for (i = nitems - 1; pitem[i]; --i) ++n;
+ for (i = nitems - 1; pitem[i]; --i)
+ ++n;
depth = 0;
-loop:
+ loop:
c = *cptr;
if (c == '$')
{
else if (isdigit(c))
{
i = get_number();
- if (i > n) dollar_warning(d_lineno, i);
- fprintf(f, "yyvsp[%d].%s", i - n, tag);
+ if (i > n)
+ dollar_warning(d_lineno, i);
+ fprintf(f, "yystack.l_mark[%d].%s", i - n, tag);
FREE(d_line);
goto loop;
}
- else if (c == '-' && isdigit((unsigned char)cptr[1]))
+ else if (c == '-' && isdigit(UCH(cptr[1])))
{
++cptr;
i = -get_number() - n;
- fprintf(f, "yyvsp[%d].%s", i, tag);
+ fprintf(f, "yystack.l_mark[%d].%s", i, tag);
FREE(d_line);
goto loop;
}
if (ntags)
{
tag = plhs[nrules]->tag;
- if (tag == 0) untyped_lhs();
+ if (tag == 0)
+ untyped_lhs();
fprintf(f, "yyval.%s", tag);
}
else
cptr += 2;
goto loop;
}
- else if (isdigit((unsigned char)cptr[1]))
+ else if (isdigit(UCH(cptr[1])))
{
++cptr;
i = get_number();
if (i <= 0 || i > n)
unknown_rhs(i);
tag = pitem[nitems + i - n - 1]->tag;
- if (tag == 0) untyped_rhs(i, pitem[nitems + i - n - 1]->name);
- fprintf(f, "yyvsp[%d].%s", i - n, tag);
+ if (tag == 0)
+ untyped_rhs(i, pitem[nitems + i - n - 1]->name);
+ fprintf(f, "yystack.l_mark[%d].%s", i - n, tag);
}
else
{
if (i > n)
dollar_warning(lineno, i);
- fprintf(f, "yyvsp[%d]", i - n);
+ fprintf(f, "yystack.l_mark[%d]", i - n);
}
goto loop;
}
i = get_number();
if (ntags)
unknown_rhs(-i);
- fprintf(f, "yyvsp[%d]", -i - n);
+ fprintf(f, "yystack.l_mark[%d]", -i - n);
goto loop;
}
}
{
putc(c, f);
c = *++cptr;
- } while (isalnum(c) || c == '_' || c == '$');
+ }
+ while (isalnum(c) || c == '_' || c == '$');
goto loop;
}
putc(c, f);
switch (c)
{
case '\n':
- next_line:
+ next_line:
get_line();
- if (line) goto loop;
+ if (line)
+ goto loop;
unterminated_action(a_lineno, a_line, a_cptr);
case ';':
- if (depth > 0) goto loop;
+ if (depth > 0)
+ goto loop;
fprintf(f, "\nbreak;\n");
- FREE(a_line);
+ free(a_line);
return;
- case '{':
+ case L_CURL:
++depth;
goto loop;
- case '}':
- if (--depth > 0) goto loop;
+ case R_CURL:
+ if (--depth > 0)
+ goto loop;
fprintf(f, "\nbreak;\n");
- FREE(a_line);
+ free(a_line);
return;
case '\'':
}
}
-
static int
mark_symbol(void)
{
int c;
bucket *bp;
- bp = NULL;
-
c = cptr[1];
if (c == '%' || c == '\\')
{
else
{
syntax_error(lineno, line, cptr);
- /*NOTREACHED*/
+ /*NOTREACHED */
}
if (rprec[nrules] != UNDEFINED && bp->prec != rprec[nrules])
return (0);
}
-
static void
read_grammar(void)
{
for (;;)
{
c = nextc();
- if (c == EOF) break;
- if (isalpha(c) || c == '_' || c == '.' || c == '$' || c == '\'' ||
- c == '"')
+ if (c == EOF)
+ break;
+ if (isalpha(c)
+ || c == '_'
+ || c == '.'
+ || c == '$'
+ || c == '\''
+ || c == '"')
add_symbol();
- else if (c == '{' || c == '=')
+ else if (c == L_CURL || c == '=')
copy_action();
else if (c == '|')
{
end_rule();
- start_rule(plhs[nrules-1], 0);
+ start_rule(plhs[nrules - 1], 0);
++cptr;
}
else if (c == '%')
{
- if (mark_symbol()) break;
+ if (mark_symbol())
+ break;
}
else
syntax_error(lineno, line, cptr);
end_rule();
}
-
static void
free_tags(void)
{
int i;
- if (tag_table == 0) return;
+ if (tag_table == 0)
+ return;
for (i = 0; i < ntags; ++i)
{
FREE(tag_table);
}
-
static void
pack_names(void)
{
bucket *bp;
char *p, *s, *t;
- name_pool_size = 13; /* 13 == sizeof("$end") + sizeof("$accept") */
+ name_pool_size = 13; /* 13 == sizeof("$end") + sizeof("$accept") */
for (bp = first_symbol; bp; bp = bp->next)
name_pool_size += strlen(bp->name) + 1;
+
name_pool = MALLOC(name_pool_size);
- if (name_pool == 0) no_space();
+ NO_SPACE(name_pool);
strlcpy(name_pool, "$accept", name_pool_size);
- strlcpy(name_pool+8, "$end", name_pool_size - 8);
+ strlcpy(name_pool + 8, "$end", name_pool_size - 8);
t = name_pool + 13;
for (bp = first_symbol; bp; bp = bp->next)
{
p = t;
s = bp->name;
- while ((*t++ = *s++) != '\0') continue;
+ while ((*t++ = *s++) != 0)
+ continue;
FREE(bp->name);
bp->name = p;
}
}
-
static void
check_symbols(void)
{
}
}
+static void
+protect_string(char *src, char **des)
+{
+ unsigned len;
+ char *s;
+ char *d;
+
+ *des = src;
+ if (src)
+ {
+ len = 1;
+ s = src;
+ while (*s)
+ {
+ if ('\\' == *s || '"' == *s)
+ len++;
+ s++;
+ len++;
+ }
+
+ *des = d = (char *)MALLOC(len);
+ NO_SPACE(d);
+
+ s = src;
+ while (*s)
+ {
+ if ('\\' == *s || '"' == *s)
+ *d++ = '\\';
+ *d++ = *s++;
+ }
+ *d = '\0';
+ }
+}
static void
pack_symbols(void)
{
bucket *bp;
bucket **v;
- int i, j, k, n;
+ Value_t i, j, k, n;
nsyms = 2;
ntokens = 1;
for (bp = first_symbol; bp; bp = bp->next)
{
++nsyms;
- if (bp->class == TERM) ++ntokens;
+ if (bp->class == TERM)
+ ++ntokens;
}
- start_symbol = ntokens;
+ start_symbol = (Value_t) ntokens;
nvars = nsyms - ntokens;
- symbol_name = (char **) MALLOC(nsyms*sizeof(char *));
- if (symbol_name == 0) no_space();
- symbol_value = (short *) MALLOC(nsyms*sizeof(short));
- if (symbol_value == 0) no_space();
- symbol_prec = (short *) MALLOC(nsyms*sizeof(short));
- if (symbol_prec == 0) no_space();
+ symbol_name = (char **)MALLOC((unsigned)nsyms * sizeof(char *));
+ NO_SPACE(symbol_name);
+
+ symbol_value = (short *)MALLOC((unsigned)nsyms * sizeof(short));
+ NO_SPACE(symbol_value);
+
+ symbol_prec = (short *)MALLOC((unsigned)nsyms * sizeof(short));
+ NO_SPACE(symbol_prec);
+
symbol_assoc = MALLOC(nsyms);
- if (symbol_assoc == 0) no_space();
+ NO_SPACE(symbol_assoc);
- v = (bucket **) MALLOC(nsyms*sizeof(bucket *));
- if (v == 0) no_space();
+ v = (bucket **)MALLOC((unsigned)nsyms * sizeof(bucket *));
+ NO_SPACE(v);
v[0] = 0;
v[start_symbol] = 0;
i = 1;
- j = start_symbol + 1;
+ j = (Value_t) (start_symbol + 1);
for (bp = first_symbol; bp; bp = bp->next)
{
if (bp->class == TERM)
for (i = 1; i < ntokens; ++i)
v[i]->index = i;
- goal->index = start_symbol + 1;
- k = start_symbol + 2;
+ goal->index = (Index_t) (start_symbol + 1);
+ k = (Value_t) (start_symbol + 2);
while (++i < nsyms)
if (v[i] != goal)
{
goal->value = 0;
k = 1;
- for (i = start_symbol + 1; i < nsyms; ++i)
+ for (i = (Value_t) (start_symbol + 1); i < nsyms; ++i)
{
if (v[i] != goal)
{
n = v[i]->value;
if (n > 256)
{
- for (j = k++; j > 0 && symbol_value[j-1] > n; --j)
- symbol_value[j] = symbol_value[j-1];
+ for (j = k++; j > 0 && symbol_value[j - 1] > n; --j)
+ symbol_value[j] = symbol_value[j - 1];
symbol_value[j] = n;
}
}
+ assert(v[1] != 0);
+
if (v[1]->value == UNDEFINED)
v[1]->value = 256;
{
while (j < k && n == symbol_value[j])
{
- while (++j < k && n == symbol_value[j]) continue;
+ while (++j < k && n == symbol_value[j])
+ continue;
++n;
}
v[i]->value = n;
symbol_assoc[k] = v[i]->assoc;
}
+ if (gflag)
+ {
+ symbol_pname = (char **)MALLOC((unsigned)nsyms * sizeof(char *));
+ NO_SPACE(symbol_pname);
+
+ for (i = 0; i < nsyms; ++i)
+ protect_string(symbol_name[i], &(symbol_pname[i]));
+ }
+
FREE(v);
}
-
static void
pack_grammar(void)
{
- int i, j;
- int assoc, prec;
-
- ritem = (short *) MALLOC(nitems*sizeof(short));
- if (ritem == 0) no_space();
- rlhs = (short *) MALLOC(nrules*sizeof(short));
- if (rlhs == 0) no_space();
- rrhs = (short *) MALLOC((nrules+1)*sizeof(short));
- if (rrhs == 0) no_space();
- rprec = (short *) REALLOC(rprec, nrules*sizeof(short));
- if (rprec == 0) no_space();
+ int i;
+ Value_t j;
+ Assoc_t assoc;
+ Value_t prec2;
+
+ ritem = (short *)MALLOC((unsigned)nitems * sizeof(short));
+ NO_SPACE(ritem);
+
+ rlhs = (short *)MALLOC((unsigned)nrules * sizeof(short));
+ NO_SPACE(rlhs);
+
+ rrhs = (short *)MALLOC((unsigned)(nrules + 1) * sizeof(short));
+ NO_SPACE(rrhs);
+
+ rprec = (short *)REALLOC(rprec, (unsigned)nrules * sizeof(short));
+ NO_SPACE(rprec);
+
rassoc = REALLOC(rassoc, nrules);
- if (rassoc == 0) no_space();
+ NO_SPACE(rassoc);
ritem[0] = -1;
ritem[1] = goal->index;
rlhs[i] = plhs[i]->index;
rrhs[i] = j;
assoc = TOKEN;
- prec = 0;
+ prec2 = 0;
while (pitem[j])
{
ritem[j] = pitem[j]->index;
if (pitem[j]->class == TERM)
{
- prec = pitem[j]->prec;
+ prec2 = pitem[j]->prec;
assoc = pitem[j]->assoc;
}
++j;
}
- ritem[j] = -i;
+ ritem[j] = (Value_t) - i;
++j;
if (rprec[i] == UNDEFINED)
{
- rprec[i] = prec;
+ rprec[i] = prec2;
rassoc[i] = assoc;
}
}
FREE(pitem);
}
-
static void
print_grammar(void)
{
- int i, j, k;
- int spacing;
+ int i, k;
+ size_t j, spacing = 0;
FILE *f = verbose_file;
- spacing = 0;
-
- if (!vflag) return;
+ if (!vflag)
+ return;
k = 1;
for (i = 2; i < nrules; ++i)
{
- if (rlhs[i] != rlhs[i-1])
+ if (rlhs[i] != rlhs[i - 1])
{
- if (i != 2) fprintf(f, "\n");
+ if (i != 2)
+ fprintf(f, "\n");
fprintf(f, "%4d %s :", i - 2, symbol_name[rlhs[i]]);
spacing = strlen(symbol_name[rlhs[i]]) + 1;
}
{
fprintf(f, "%4d ", i - 2);
j = spacing;
- while (--j >= 0) putc(' ', f);
+ while (j-- != 0)
+ putc(' ', f);
putc('|', f);
}
}
}
-
void
reader(void)
{
- write_section(banner);
+ write_section(code_file, banner);
create_symbol_table();
read_declarations();
read_grammar();
free_symbols();
print_grammar();
}
+
+#ifdef NO_LEAKS
+static param *
+free_declarations(param * list)
+{
+ while (list != 0)
+ {
+ param *next = list->next;
+ free(list->type);
+ free(list->name);
+ free(list->type2);
+ free(list);
+ list = next;
+ }
+ return list;
+}
+
+void
+reader_leaks(void)
+{
+ lex_param = free_declarations(lex_param);
+ parse_param = free_declarations(parse_param);
+
+ DO_FREE(line);
+ DO_FREE(rrhs);
+ DO_FREE(rlhs);
+ DO_FREE(rprec);
+ DO_FREE(ritem);
+ DO_FREE(rassoc);
+ DO_FREE(cache);
+ DO_FREE(name_pool);
+ DO_FREE(symbol_name);
+ DO_FREE(symbol_prec);
+ DO_FREE(symbol_assoc);
+ DO_FREE(symbol_value);
+}
+#endif
-/* $NetBSD: skeleton.c,v 1.29 2008/07/18 14:25:37 drochner Exp $ */
+/* $NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $ */
+/* Id: skeleton.c,v 1.31 2011/09/07 09:37:59 tom Exp */
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
+#include "defs.h"
#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)skeleton.c 5.8 (Berkeley) 4/29/95";
-#else
-__RCSID("$NetBSD: skeleton.c,v 1.29 2008/07/18 14:25:37 drochner Exp $");
-#endif /* 0 */
-#endif /* not lint */
-
-#include "defs.h"
+__RCSID("$NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $");
/* The definition of yysccsid in the banner should be replaced with */
/* a #pragma ident directive if the target C compiler supports */
/* the body either are not useful outside of semantic actions or */
/* are conditional. */
-const char * const banner[] =
+const char *const banner[] =
{
- "#include <stdlib.h>",
"#ifndef lint",
- "#if 0",
- "static char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";",
- "#else",
- "#if defined(__NetBSD__) && defined(__IDSTRING)",
- "__IDSTRING(yyrcsid, \"$NetBSD: skeleton.c,v 1.29 2008/07/18 14:25:37 drochner Exp $\");",
- "#endif /* __NetBSD__ && __IDSTRING */",
- "#endif /* 0 */",
- "#endif /* lint */",
+ "static const char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";",
+ "#endif",
+ "",
+ "#ifdef _LIBC",
+ "#include \"namespace.h\"",
+ "#endif",
+ "#include <stdlib.h>",
+ "#include <string.h>",
+ "",
"#define YYBYACC 1",
- "#define YYMAJOR 1",
- "#define YYMINOR 9",
- "#define YYLEX yylex()",
- "#define YYEMPTY -1",
- "#define yyclearin (yychar=(YYEMPTY))",
- "#define yyerrok (yyerrflag=0)",
- "#define YYRECOVERING (yyerrflag!=0)",
+ CONCAT1("#define YYMAJOR ", YYMAJOR),
+ CONCAT1("#define YYMINOR ", YYMINOR),
+#ifdef YYPATCH
+ CONCAT1("#define YYPATCH ", YYPATCH),
+#endif
+ "",
+ "#define YYEMPTY (-1)",
+ "#define yyclearin (yychar = YYEMPTY)",
+ "#define yyerrok (yyerrflag = 0)",
+ "#define YYRECOVERING() (yyerrflag != 0)",
+ "",
0
};
+const char *const xdecls[] =
+{
+ "",
+ "extern int YYPARSE_DECL();",
+#ifdef notdef
+ "extern int YYLEX_DECL();",
+#endif
+ "",
+ 0
+};
-const char * const tables[] =
+const char *const tables[] =
{
- "extern const short yylhs[];",
- "extern const short yylen[];",
- "extern const short yydefred[];",
- "extern const short yydgoto[];",
- "extern const short yysindex[];",
- "extern const short yyrindex[];",
- "extern const short yygindex[];",
- "extern const short yytable[];",
- "extern const short yycheck[];",
+ "extern short yylhs[];",
+ "extern short yylen[];",
+ "extern short yydefred[];",
+ "extern short yydgoto[];",
+ "extern short yysindex[];",
+ "extern short yyrindex[];",
+ "extern short yygindex[];",
+ "extern short yytable[];",
+ "extern short yycheck[];",
+ "",
"#if YYDEBUG",
- "extern const char * const yyname[];",
- "extern const char * const yyrule[];",
+ "extern char *yyname[];",
+ "extern char *yyrule[];",
"#endif",
0
};
+const char *const global_vars[] =
+{
+ "",
+ "int yydebug;",
+ "int yynerrs;",
+ 0
+};
+
+const char *const impure_vars[] =
+{
+ "",
+ "int yyerrflag;",
+ "int yychar;",
+ "YYSTYPE yyval;",
+ "YYSTYPE yylval;",
+ 0
+};
-const char * const header[] =
+const char *const hdr_defs[] =
{
+ "",
+ "/* define the initial stack-sizes */",
"#ifdef YYSTACKSIZE",
"#undef YYMAXDEPTH",
- "#define YYMAXDEPTH YYSTACKSIZE",
+ "#define YYMAXDEPTH YYSTACKSIZE",
"#else",
"#ifdef YYMAXDEPTH",
"#define YYSTACKSIZE YYMAXDEPTH",
"#else",
- "#define YYSTACKSIZE 10000",
- "#define YYMAXDEPTH 10000",
+ "#define YYSTACKSIZE 500",
+ "#define YYMAXDEPTH 500",
"#endif",
"#endif",
- "#define YYINITSTACKSIZE 200",
- "int yydebug;",
- "int yynerrs;",
- "int yyerrflag;",
- "int yychar;",
- "short *yyssp;",
- "YYSTYPE *yyvsp;",
- "YYSTYPE yyval;",
- "static YYSTYPE yyvalzero;", /* no "const", must compile as C++ */
- "YYSTYPE yylval;",
- "short *yyss;",
- "short *yysslim;",
- "YYSTYPE *yyvs;",
- "int yystacksize;",
- "int yyparse(void);",
+ "",
+ "#define YYINITSTACKSIZE 500",
+ "",
+ "typedef struct {",
+ " unsigned stacksize;",
+ " short *s_base;",
+ " short *s_mark;",
+ " short *s_last;",
+ " YYSTYPE *l_base;",
+ " YYSTYPE *l_mark;",
+ "} YYSTACKDATA;",
0
};
+const char *const hdr_vars[] =
+{
+ "/* variables for the parser stack */",
+ "static YYSTACKDATA yystack;",
+ 0
+};
+
+const char *const body_vars[] =
+{
+ " int yyerrflag;",
+ " int yychar;",
+ " YYSTYPE yyval;",
+ " YYSTYPE yylval;",
+ "",
+ " /* variables for the parser stack */",
+ " YYSTACKDATA yystack;",
+ 0
+};
-const char * const body[] =
+const char *const body_1[] =
{
+ "",
+ "#if YYDEBUG",
+ "#include <stdio.h> /* needed for printf */",
+ "#endif",
+ "",
+ "#include <stdlib.h> /* needed for malloc, etc */",
+ "#include <string.h> /* needed for memset */",
+ "",
"/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
- "static int yygrowstack(void);",
- "static int yygrowstack(void)",
+ "static int yygrowstack(YYSTACKDATA *data)",
"{",
- " int newsize, i;",
+ " int i;",
+ " unsigned newsize;",
" short *newss;",
" YYSTYPE *newvs;",
"",
- " if ((newsize = yystacksize) == 0)",
+ " if ((newsize = data->stacksize) == 0)",
" newsize = YYINITSTACKSIZE;",
" else if (newsize >= YYMAXDEPTH)",
" return -1;",
" else if ((newsize *= 2) > YYMAXDEPTH)",
" newsize = YYMAXDEPTH;",
- " i = yyssp - yyss;",
- " if ((newss = (short *)realloc(yyss, newsize * sizeof *newss)) == NULL)",
+ "",
+ " i = data->s_mark - data->s_base;",
+ " newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));",
+ " if (newss == 0)",
" return -1;",
- " yyss = newss;",
- " yyssp = newss + i;",
- " if ((newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs)) == NULL)",
+ "",
+ " data->s_base = newss;",
+ " data->s_mark = newss + i;",
+ "",
+ " newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
+ " if (newvs == 0)",
" return -1;",
- " yyvs = newvs;",
- " yyvsp = newvs + i;",
- " yystacksize = newsize;",
- " yysslim = yyss + newsize - 1;",
+ "",
+ " data->l_base = newvs;",
+ " data->l_mark = newvs + i;",
+ "",
+ " data->stacksize = newsize;",
+ " data->s_last = data->s_base + newsize - 1;",
" return 0;",
"}",
"",
- "#define YYABORT goto yyabort",
+ "#if YYPURE || defined(YY_NO_LEAKS)",
+ "static void yyfreestack(YYSTACKDATA *data)",
+ "{",
+ " free(data->s_base);",
+ " free(data->l_base);",
+ " memset(data, 0, sizeof(*data));",
+ "}",
+ "#else",
+ "#define yyfreestack(data) /* nothing */",
+ "#endif",
+ "",
+ "#define YYABORT goto yyabort",
"#define YYREJECT goto yyabort",
"#define YYACCEPT goto yyaccept",
- "#define YYERROR goto yyerrlab",
+ "#define YYERROR goto yyerrlab",
+ "",
"int",
- "yyparse(void)",
+ "YYPARSE_DECL()",
"{",
+ 0
+};
+
+const char *const body_2[] =
+{
" int yym, yyn, yystate;",
"#if YYDEBUG",
" const char *yys;",
"",
- " if ((yys = getenv(\"YYDEBUG\")) != NULL)",
+ " if ((yys = getenv(\"YYDEBUG\")) != 0)",
" {",
" yyn = *yys;",
" if (yyn >= '0' && yyn <= '9')",
"",
" yynerrs = 0;",
" yyerrflag = 0;",
- " yychar = (-1);",
+ " yychar = YYEMPTY;",
+ " yystate = 0;",
+ "",
+ "#if YYPURE",
+ " memset(&yystack, 0, sizeof(yystack));",
+ "#endif",
"",
- " if (yyss == NULL && yygrowstack()) goto yyoverflow;",
- " yyssp = yyss;",
- " yyvsp = yyvs;",
- " *yyssp = yystate = 0;",
+ " if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;",
+ " yystack.s_mark = yystack.s_base;",
+ " yystack.l_mark = yystack.l_base;",
+ " yystate = 0;",
+ " *yystack.s_mark = 0;",
"",
"yyloop:",
" if ((yyn = yydefred[yystate]) != 0) goto yyreduce;",
" if (yychar < 0)",
" {",
- " if ((yychar = yylex()) < 0) yychar = 0;",
+ " if ((yychar = YYLEX) < 0) yychar = 0;",
"#if YYDEBUG",
" if (yydebug)",
" {",
" printf(\"%sdebug: state %d, shifting to state %d\\n\",",
" YYPREFIX, yystate, yytable[yyn]);",
"#endif",
- " if (yyssp >= yysslim && yygrowstack())",
+ " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))",
" {",
" goto yyoverflow;",
" }",
- " *++yyssp = yystate = yytable[yyn];",
- " *++yyvsp = yylval;",
- " yychar = (-1);",
+ " yystate = yytable[yyn];",
+ " *++yystack.s_mark = yytable[yyn];",
+ " *++yystack.l_mark = yylval;",
+ " yychar = YYEMPTY;",
" if (yyerrflag > 0) --yyerrflag;",
" goto yyloop;",
" }",
" goto yyreduce;",
" }",
" if (yyerrflag) goto yyinrecovery;",
- " goto yynewerror;",
- "yynewerror:",
- " yyerror(\"syntax error\");",
+ "",
+ 0
+};
+
+const char *const body_3[] =
+{
+ "",
" goto yyerrlab;",
+ "",
"yyerrlab:",
" ++yynerrs;",
+ "",
"yyinrecovery:",
" if (yyerrflag < 3)",
" {",
" yyerrflag = 3;",
" for (;;)",
" {",
- " if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&",
+ " if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&",
" yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)",
" {",
"#if YYDEBUG",
" if (yydebug)",
" printf(\"%sdebug: state %d, error recovery shifting\\",
- " to state %d\\n\", YYPREFIX, *yyssp, yytable[yyn]);",
+ " to state %d\\n\", YYPREFIX, *yystack.s_mark, yytable[yyn]);",
"#endif",
- " if (yyssp >= yysslim && yygrowstack())",
+ " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))",
" {",
" goto yyoverflow;",
" }",
- " *++yyssp = yystate = yytable[yyn];",
- " *++yyvsp = yylval;",
+ " yystate = yytable[yyn];",
+ " *++yystack.s_mark = yytable[yyn];",
+ " *++yystack.l_mark = yylval;",
" goto yyloop;",
" }",
" else",
" if (yydebug)",
" printf(\"%sdebug: error recovery discarding state %d\
\\n\",",
- " YYPREFIX, *yyssp);",
+ " YYPREFIX, *yystack.s_mark);",
"#endif",
- " if (yyssp <= yyss) goto yyabort;",
- " --yyssp;",
- " --yyvsp;",
+ " if (yystack.s_mark <= yystack.s_base) goto yyabort;",
+ " --yystack.s_mark;",
+ " --yystack.l_mark;",
" }",
" }",
" }",
" YYPREFIX, yystate, yychar, yys);",
" }",
"#endif",
- " yychar = (-1);",
+ " yychar = YYEMPTY;",
" goto yyloop;",
" }",
+ "",
"yyreduce:",
"#if YYDEBUG",
" if (yydebug)",
"#endif",
" yym = yylen[yyn];",
" if (yym)",
- " yyval = yyvsp[1-yym];",
+ " yyval = yystack.l_mark[1-yym];",
" else",
- " yyval = yyvalzero;",
+ " memset(&yyval, 0, sizeof yyval);",
" switch (yyn)",
" {",
0
};
-
-const char * const trailer[] =
+const char *const trailer[] =
{
" }",
- " yyssp -= yym;",
- " yystate = *yyssp;",
- " yyvsp -= yym;",
+ " yystack.s_mark -= yym;",
+ " yystate = *yystack.s_mark;",
+ " yystack.l_mark -= yym;",
" yym = yylhs[yyn];",
" if (yystate == 0 && yym == 0)",
" {",
" state %d\\n\", YYPREFIX, YYFINAL);",
"#endif",
" yystate = YYFINAL;",
- " *++yyssp = YYFINAL;",
- " *++yyvsp = yyval;",
+ " *++yystack.s_mark = YYFINAL;",
+ " *++yystack.l_mark = yyval;",
" if (yychar < 0)",
" {",
- " if ((yychar = yylex()) < 0) yychar = 0;",
+ " if ((yychar = YYLEX) < 0) yychar = 0;",
"#if YYDEBUG",
" if (yydebug)",
" {",
"#if YYDEBUG",
" if (yydebug)",
" printf(\"%sdebug: after reduction, shifting from state %d \\",
- "to state %d\\n\", YYPREFIX, *yyssp, yystate);",
+ "to state %d\\n\", YYPREFIX, *yystack.s_mark, yystate);",
"#endif",
- " if (yyssp >= yysslim && yygrowstack())",
+ " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))",
" {",
" goto yyoverflow;",
" }",
- " *++yyssp = yystate;",
- " *++yyvsp = yyval;",
+ " *++yystack.s_mark = (short) yystate;",
+ " *++yystack.l_mark = yyval;",
" goto yyloop;",
+ "",
"yyoverflow:",
- " yyerror(\"yacc stack overflow\");",
+ 0
+};
+
+const char *const trailer_2[] =
+{
+ "",
"yyabort:",
+ " yyfreestack(&yystack);",
" return (1);",
+ "",
"yyaccept:",
+ " yyfreestack(&yystack);",
" return (0);",
"}",
0
};
-
void
-write_section(const char * const section[])
+write_section(FILE * fp, const char *const section[])
{
int c;
int i;
const char *s;
- FILE *f;
- f = code_file;
- for (i = 0; (s = section[i]); ++i)
+ for (i = 0; (s = section[i]) != 0; ++i)
{
- ++outline;
- while ((c = *s) != '\0')
+ while ((c = *s) != 0)
{
- putc(c, f);
+ putc(c, fp);
++s;
}
- putc('\n', f);
+ if (fp == code_file)
+ ++outline;
+ putc('\n', fp);
}
}
--- /dev/null
+/* $NetBSD: symtab.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
+/* Id: symtab.c,v 1.9 2010/11/24 15:12:29 tom Exp */
+
+#include "defs.h"
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: symtab.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
+
+/* TABLE_SIZE is the number of entries in the symbol table. */
+/* TABLE_SIZE must be a power of two. */
+
+#define TABLE_SIZE 1024
+
+static bucket **symbol_table = 0;
+bucket *first_symbol;
+bucket *last_symbol;
+
+static int
+hash(const char *name)
+{
+ const char *s;
+ int c, k;
+
+ assert(name && *name);
+ s = name;
+ k = *s;
+ while ((c = *++s) != 0)
+ k = (31 * k + c) & (TABLE_SIZE - 1);
+
+ return (k);
+}
+
+bucket *
+make_bucket(const char *name)
+{
+ bucket *bp;
+
+ assert(name != 0);
+
+ bp = (bucket *)MALLOC(sizeof(bucket));
+ NO_SPACE(bp);
+
+ bp->link = 0;
+ bp->next = 0;
+
+ bp->name = MALLOC(strlen(name) + 1);
+ NO_SPACE(bp->name);
+
+ bp->tag = 0;
+ bp->value = UNDEFINED;
+ bp->index = 0;
+ bp->prec = 0;
+ bp->class = UNKNOWN;
+ bp->assoc = TOKEN;
+ strcpy(bp->name, name);
+
+ return (bp);
+}
+
+bucket *
+lookup(const char *name)
+{
+ bucket *bp, **bpp;
+
+ bpp = symbol_table + hash(name);
+ bp = *bpp;
+
+ while (bp)
+ {
+ if (strcmp(name, bp->name) == 0)
+ return (bp);
+ bpp = &bp->link;
+ bp = *bpp;
+ }
+
+ *bpp = bp = make_bucket(name);
+ last_symbol->next = bp;
+ last_symbol = bp;
+
+ return (bp);
+}
+
+void
+create_symbol_table(void)
+{
+ int i;
+ bucket *bp;
+
+ symbol_table = (bucket **)MALLOC(TABLE_SIZE * sizeof(bucket *));
+ NO_SPACE(symbol_table);
+
+ for (i = 0; i < TABLE_SIZE; i++)
+ symbol_table[i] = 0;
+
+ bp = make_bucket("error");
+ bp->index = 1;
+ bp->class = TERM;
+
+ first_symbol = bp;
+ last_symbol = bp;
+ symbol_table[hash("error")] = bp;
+}
+
+void
+free_symbol_table(void)
+{
+ FREE(symbol_table);
+ symbol_table = 0;
+}
+
+void
+free_symbols(void)
+{
+ bucket *p, *q;
+
+ for (p = first_symbol; p; p = q)
+ {
+ q = p->next;
+ FREE(p);
+ }
+}
--- /dev/null
+-- $Id: README,v 1.2 2009/10/29 00:56:20 christos Exp $
+
+The files in this directory are input (.y) and output (.output, .tab.c, .tab.h)
+examples.
--- /dev/null
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+\f
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
--- /dev/null
+/* $NetBSD: calc.tab.c,v 1.1.1.4 2011/09/10 21:22:03 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse calc_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_"
+
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+#line 106 "calc.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+static const short calc_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short calc_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short calc_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const short calc_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short calc_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const short calc_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const short calc_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const short calc_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const short calc_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 63 "calc.y"
+ /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 345 "calc.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 25 "calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 29 "calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 31 "calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 35 "calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 37 "calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 39 "calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 41 "calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 43 "calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 45 "calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 47 "calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 49 "calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 51 "calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 53 "calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 58 "calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 60 "calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 611 "calc.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: calc.tab.h,v 1.1.1.3 2011/09/10 21:22:06 christos Exp $ */
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
--- /dev/null
+/* $NetBSD: calc.y,v 1.1.1.4 2011/09/10 21:22:08 christos Exp $ */
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
--- /dev/null
+ 0 $accept : line $end
+
+ 1 lines :
+ 2 | lines line
+
+ 3 line : dexp '\n'
+ 4 | vexp '\n'
+ 5 | DREG '=' dexp '\n'
+ 6 | VREG '=' vexp '\n'
+ 7 | error '\n'
+
+ 8 dexp : CONST
+ 9 | DREG
+ 10 | dexp '+' dexp
+ 11 | dexp '-' dexp
+ 12 | dexp '*' dexp
+ 13 | dexp '/' dexp
+ 14 | '-' dexp
+ 15 | '(' dexp ')'
+
+ 16 vexp : dexp
+ 17 | '(' dexp ',' dexp ')'
+ 18 | VREG
+ 19 | vexp '+' vexp
+ 20 | dexp '+' vexp
+ 21 | vexp '-' vexp
+ 22 | dexp '-' vexp
+ 23 | vexp '*' vexp
+ 24 | dexp '*' vexp
+ 25 | vexp '/' vexp
+ 26 | dexp '/' vexp
+ 27 | '-' vexp
+ 28 | '(' vexp ')'
+\f
+state 0
+ $accept : . line $end (0)
+
+ error shift 1
+ DREG shift 2
+ VREG shift 3
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ line goto 7
+ dexp goto 8
+ vexp goto 9
+
+
+state 1
+ line : error . '\n' (7)
+
+ '\n' shift 10
+ . error
+
+
+state 2
+ line : DREG . '=' dexp '\n' (5)
+ dexp : DREG . (9)
+
+ '=' shift 11
+ '+' reduce 9
+ '-' reduce 9
+ '*' reduce 9
+ '/' reduce 9
+ '\n' reduce 9
+
+
+state 3
+ line : VREG . '=' vexp '\n' (6)
+ vexp : VREG . (18)
+
+ '=' shift 12
+ '+' reduce 18
+ '-' reduce 18
+ '*' reduce 18
+ '/' reduce 18
+ '\n' reduce 18
+
+
+state 4
+ dexp : CONST . (8)
+
+ . reduce 8
+
+
+state 5
+ dexp : '-' . dexp (14)
+ vexp : '-' . vexp (27)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 15
+ vexp goto 16
+
+
+state 6
+ dexp : '(' . dexp ')' (15)
+ vexp : '(' . dexp ',' dexp ')' (17)
+ vexp : '(' . vexp ')' (28)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 17
+ vexp goto 18
+
+
+state 7
+ $accept : line . $end (0)
+
+ $end accept
+
+
+8: shift/reduce conflict (shift 19, reduce 16) on '+'
+8: shift/reduce conflict (shift 20, reduce 16) on '-'
+8: shift/reduce conflict (shift 21, reduce 16) on '*'
+8: shift/reduce conflict (shift 22, reduce 16) on '/'
+8: shift/reduce conflict (shift 23, reduce 16) on '\n'
+state 8
+ line : dexp . '\n' (3)
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '+' shift 19
+ '-' shift 20
+ '*' shift 21
+ '/' shift 22
+ '\n' shift 23
+
+
+state 9
+ line : vexp . '\n' (4)
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '+' shift 24
+ '-' shift 25
+ '*' shift 26
+ '/' shift 27
+ '\n' shift 28
+ . error
+
+
+state 10
+ line : error '\n' . (7)
+
+ . reduce 7
+
+
+state 11
+ line : DREG '=' . dexp '\n' (5)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 31
+
+
+state 12
+ line : VREG '=' . vexp '\n' (6)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 33
+
+
+state 13
+ dexp : DREG . (9)
+
+ . reduce 9
+
+
+state 14
+ vexp : VREG . (18)
+
+ . reduce 18
+
+
+15: reduce/reduce conflict (reduce 14, reduce 16) on '+'
+15: reduce/reduce conflict (reduce 14, reduce 16) on '-'
+15: reduce/reduce conflict (reduce 14, reduce 16) on '*'
+15: reduce/reduce conflict (reduce 14, reduce 16) on '/'
+15: reduce/reduce conflict (reduce 14, reduce 16) on '\n'
+15: reduce/reduce conflict (reduce 14, reduce 16) on ')'
+state 15
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : '-' dexp . (14)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ . reduce 14
+
+
+state 16
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+ vexp : '-' vexp . (27)
+
+ . reduce 27
+
+
+17: shift/reduce conflict (shift 19, reduce 16) on '+'
+17: shift/reduce conflict (shift 20, reduce 16) on '-'
+17: shift/reduce conflict (shift 21, reduce 16) on '*'
+17: shift/reduce conflict (shift 22, reduce 16) on '/'
+17: shift/reduce conflict (shift 34, reduce 16) on ')'
+state 17
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : '(' dexp . ')' (15)
+ vexp : dexp . (16)
+ vexp : '(' dexp . ',' dexp ')' (17)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '+' shift 19
+ '-' shift 20
+ '*' shift 21
+ '/' shift 22
+ ')' shift 34
+ ',' shift 35
+
+
+state 18
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+ vexp : '(' vexp . ')' (28)
+
+ '+' shift 24
+ '-' shift 25
+ '*' shift 26
+ '/' shift 27
+ ')' shift 36
+ . error
+
+
+state 19
+ dexp : dexp '+' . dexp (10)
+ vexp : dexp '+' . vexp (20)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 37
+ vexp goto 38
+
+
+state 20
+ dexp : dexp '-' . dexp (11)
+ vexp : dexp '-' . vexp (22)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 39
+ vexp goto 40
+
+
+state 21
+ dexp : dexp '*' . dexp (12)
+ vexp : dexp '*' . vexp (24)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 41
+ vexp goto 42
+
+
+state 22
+ dexp : dexp '/' . dexp (13)
+ vexp : dexp '/' . vexp (26)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 43
+ vexp goto 44
+
+
+state 23
+ line : dexp '\n' . (3)
+
+ . reduce 3
+
+
+state 24
+ vexp : vexp '+' . vexp (19)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 45
+
+
+state 25
+ vexp : vexp '-' . vexp (21)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 46
+
+
+state 26
+ vexp : vexp '*' . vexp (23)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 47
+
+
+state 27
+ vexp : vexp '/' . vexp (25)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 48
+
+
+state 28
+ line : vexp '\n' . (4)
+
+ . reduce 4
+
+
+state 29
+ dexp : '-' . dexp (14)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 49
+
+
+state 30
+ dexp : '(' . dexp ')' (15)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 50
+
+
+state 31
+ line : DREG '=' dexp . '\n' (5)
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+
+ '+' shift 51
+ '-' shift 52
+ '*' shift 53
+ '/' shift 54
+ '\n' shift 55
+ . error
+
+
+32: shift/reduce conflict (shift 19, reduce 16) on '+'
+32: shift/reduce conflict (shift 20, reduce 16) on '-'
+32: shift/reduce conflict (shift 21, reduce 16) on '*'
+32: shift/reduce conflict (shift 22, reduce 16) on '/'
+state 32
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '+' shift 19
+ '-' shift 20
+ '*' shift 21
+ '/' shift 22
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 33
+ line : VREG '=' vexp . '\n' (6)
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '+' shift 24
+ '-' shift 25
+ '*' shift 26
+ '/' shift 27
+ '\n' shift 56
+ . error
+
+
+state 34
+ dexp : '(' dexp ')' . (15)
+
+ . reduce 15
+
+
+state 35
+ vexp : '(' dexp ',' . dexp ')' (17)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 57
+
+
+state 36
+ vexp : '(' vexp ')' . (28)
+
+ . reduce 28
+
+
+37: reduce/reduce conflict (reduce 10, reduce 16) on '+'
+37: reduce/reduce conflict (reduce 10, reduce 16) on '-'
+37: shift/reduce conflict (shift 21, reduce 16) on '*'
+37: shift/reduce conflict (shift 22, reduce 16) on '/'
+37: reduce/reduce conflict (reduce 10, reduce 16) on '\n'
+37: reduce/reduce conflict (reduce 10, reduce 16) on ')'
+state 37
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp '+' dexp . (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '*' shift 21
+ '/' shift 22
+ '+' reduce 10
+ '-' reduce 10
+ '\n' reduce 10
+ ')' reduce 10
+ ',' reduce 10
+
+
+state 38
+ vexp : vexp . '+' vexp (19)
+ vexp : dexp '+' vexp . (20)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '*' shift 26
+ '/' shift 27
+ '+' reduce 20
+ '-' reduce 20
+ '\n' reduce 20
+ ')' reduce 20
+
+
+39: reduce/reduce conflict (reduce 11, reduce 16) on '+'
+39: reduce/reduce conflict (reduce 11, reduce 16) on '-'
+39: shift/reduce conflict (shift 21, reduce 16) on '*'
+39: shift/reduce conflict (shift 22, reduce 16) on '/'
+39: reduce/reduce conflict (reduce 11, reduce 16) on '\n'
+39: reduce/reduce conflict (reduce 11, reduce 16) on ')'
+state 39
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp '-' dexp . (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '*' shift 21
+ '/' shift 22
+ '+' reduce 11
+ '-' reduce 11
+ '\n' reduce 11
+ ')' reduce 11
+ ',' reduce 11
+
+
+state 40
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : dexp '-' vexp . (22)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '*' shift 26
+ '/' shift 27
+ '+' reduce 22
+ '-' reduce 22
+ '\n' reduce 22
+ ')' reduce 22
+
+
+41: reduce/reduce conflict (reduce 12, reduce 16) on '+'
+41: reduce/reduce conflict (reduce 12, reduce 16) on '-'
+41: reduce/reduce conflict (reduce 12, reduce 16) on '*'
+41: reduce/reduce conflict (reduce 12, reduce 16) on '/'
+41: reduce/reduce conflict (reduce 12, reduce 16) on '\n'
+41: reduce/reduce conflict (reduce 12, reduce 16) on ')'
+state 41
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp '*' dexp . (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ . reduce 12
+
+
+state 42
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : dexp '*' vexp . (24)
+ vexp : vexp . '/' vexp (25)
+
+ . reduce 24
+
+
+43: reduce/reduce conflict (reduce 13, reduce 16) on '+'
+43: reduce/reduce conflict (reduce 13, reduce 16) on '-'
+43: reduce/reduce conflict (reduce 13, reduce 16) on '*'
+43: reduce/reduce conflict (reduce 13, reduce 16) on '/'
+43: reduce/reduce conflict (reduce 13, reduce 16) on '\n'
+43: reduce/reduce conflict (reduce 13, reduce 16) on ')'
+state 43
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : dexp '/' dexp . (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ . reduce 13
+
+
+state 44
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+ vexp : dexp '/' vexp . (26)
+
+ . reduce 26
+
+
+state 45
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp '+' vexp . (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '*' shift 26
+ '/' shift 27
+ '+' reduce 19
+ '-' reduce 19
+ '\n' reduce 19
+ ')' reduce 19
+
+
+state 46
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp '-' vexp . (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '*' shift 26
+ '/' shift 27
+ '+' reduce 21
+ '-' reduce 21
+ '\n' reduce 21
+ ')' reduce 21
+
+
+state 47
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp '*' vexp . (23)
+ vexp : vexp . '/' vexp (25)
+
+ . reduce 23
+
+
+state 48
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+ vexp : vexp '/' vexp . (25)
+
+ . reduce 25
+
+
+state 49
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : '-' dexp . (14)
+
+ . reduce 14
+
+
+state 50
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : '(' dexp . ')' (15)
+
+ '+' shift 51
+ '-' shift 52
+ '*' shift 53
+ '/' shift 54
+ ')' shift 34
+ . error
+
+
+state 51
+ dexp : dexp '+' . dexp (10)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 58
+
+
+state 52
+ dexp : dexp '-' . dexp (11)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 59
+
+
+state 53
+ dexp : dexp '*' . dexp (12)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 60
+
+
+state 54
+ dexp : dexp '/' . dexp (13)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 61
+
+
+state 55
+ line : DREG '=' dexp '\n' . (5)
+
+ . reduce 5
+
+
+state 56
+ line : VREG '=' vexp '\n' . (6)
+
+ . reduce 6
+
+
+state 57
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : '(' dexp ',' dexp . ')' (17)
+
+ '+' shift 51
+ '-' shift 52
+ '*' shift 53
+ '/' shift 54
+ ')' shift 62
+ . error
+
+
+state 58
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp '+' dexp . (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+
+ '*' shift 53
+ '/' shift 54
+ '+' reduce 10
+ '-' reduce 10
+ '\n' reduce 10
+ ')' reduce 10
+
+
+state 59
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp '-' dexp . (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+
+ '*' shift 53
+ '/' shift 54
+ '+' reduce 11
+ '-' reduce 11
+ '\n' reduce 11
+ ')' reduce 11
+
+
+state 60
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp '*' dexp . (12)
+ dexp : dexp . '/' dexp (13)
+
+ . reduce 12
+
+
+state 61
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : dexp '/' dexp . (13)
+
+ . reduce 13
+
+
+state 62
+ vexp : '(' dexp ',' dexp ')' . (17)
+
+ . reduce 17
+
+
+Rules never reduced:
+ lines : (1)
+ lines : lines line (2)
+
+
+State 8 contains 5 shift/reduce conflicts.
+State 15 contains 6 reduce/reduce conflicts.
+State 17 contains 5 shift/reduce conflicts.
+State 32 contains 4 shift/reduce conflicts.
+State 37 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts.
+State 39 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts.
+State 41 contains 6 reduce/reduce conflicts.
+State 43 contains 6 reduce/reduce conflicts.
+
+
+15 terminals, 5 nonterminals
+29 grammar rules, 63 states
--- /dev/null
+/* $NetBSD: calc1.tab.c,v 1.1.1.3 2011/09/10 21:22:08 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse calc1_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc1_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc1_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc1_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc1_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc1_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc1_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc1_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc1_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc1_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc1_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc1_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc1_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc1_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc1_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc1_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc1_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc1_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc1_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc1_rule
+#endif /* yyrule */
+#define YYPREFIX "calc1_"
+
+#define YYPURE 0
+
+#line 2 "calc1.y"
+
+/* http://dinosaur.compilertools.net/yacc/index.html */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+
+typedef struct interval
+{
+ double lo, hi;
+}
+INTERVAL;
+
+INTERVAL vmul(double, double, INTERVAL);
+INTERVAL vdiv(double, double, INTERVAL);
+
+int dcheck(INTERVAL);
+
+double dreg[26];
+INTERVAL vreg[26];
+
+#line 28 "calc1.y"
+#ifdef YYSTYPE
+#undef YYSTYPE_IS_DECLARED
+#define YYSTYPE_IS_DECLARED 1
+#endif
+#ifndef YYSTYPE_IS_DECLARED
+#define YYSTYPE_IS_DECLARED 1
+typedef union
+{
+ int ival;
+ double dval;
+ INTERVAL vval;
+} YYSTYPE;
+#endif /* !YYSTYPE_IS_DECLARED */
+#line 136 "calc1.tab.c"
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
+#define DREG 257
+#define VREG 258
+#define CONST 259
+#define UMINUS 260
+#define YYERRCODE 256
+static const short calc1_lhs[] = { -1,
+ 3, 3, 0, 0, 0, 0, 0, 1, 1, 1,
+ 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2,
+};
+static const short calc1_len[] = { 2,
+ 0, 2, 2, 2, 4, 4, 2, 1, 1, 3,
+ 3, 3, 3, 2, 3, 1, 5, 1, 3, 3,
+ 3, 3, 3, 3, 3, 3, 2, 3,
+};
+static const short calc1_defred[] = { 0,
+ 0, 0, 0, 8, 0, 0, 0, 0, 0, 7,
+ 0, 0, 9, 18, 14, 27, 0, 0, 0, 0,
+ 0, 0, 3, 0, 0, 0, 0, 4, 0, 0,
+ 0, 0, 0, 15, 0, 28, 0, 0, 0, 0,
+ 12, 24, 13, 26, 0, 0, 23, 25, 14, 0,
+ 0, 0, 0, 0, 5, 6, 0, 0, 0, 12,
+ 13, 17,
+};
+static const short calc1_dgoto[] = { 7,
+ 32, 9, 0,
+};
+static const short calc1_sindex[] = { -40,
+ -8, -48, -47, 0, -37, -37, 0, 2, 17, 0,
+ -34, -37, 0, 0, 0, 0, -25, 90, -37, -37,
+ -37, -37, 0, -37, -37, -37, -37, 0, -34, -34,
+ 25, 125, 31, 0, -34, 0, -11, 37, -11, 37,
+ 0, 0, 0, 0, 37, 37, 0, 0, 0, 111,
+ -34, -34, -34, -34, 0, 0, 118, 69, 69, 0,
+ 0, 0,
+};
+static const short calc1_rindex[] = { 0,
+ 0, 38, 44, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, -9, 0, 0, 0, 0, 51, -3, 56, 61,
+ 0, 0, 0, 0, 67, 72, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 78, 83, 0,
+ 0, 0,
+};
+static const short calc1_gindex[] = { 0,
+ 4, 124, 0,
+};
+#define YYTABLESIZE 225
+static const short calc1_table[] = { 6,
+ 16, 10, 6, 8, 5, 30, 20, 5, 15, 17,
+ 29, 23, 11, 12, 31, 34, 21, 19, 35, 20,
+ 0, 22, 37, 39, 41, 43, 28, 0, 0, 0,
+ 21, 16, 49, 50, 55, 22, 0, 20, 57, 20,
+ 56, 20, 0, 21, 19, 0, 20, 9, 22, 0,
+ 0, 0, 0, 18, 58, 59, 60, 61, 26, 24,
+ 10, 25, 0, 27, 0, 11, 53, 51, 0, 52,
+ 22, 54, 26, 24, 0, 25, 19, 27, 26, 9,
+ 9, 21, 9, 27, 9, 18, 18, 10, 18, 0,
+ 18, 10, 11, 10, 10, 10, 11, 0, 11, 11,
+ 11, 22, 0, 22, 0, 22, 0, 19, 0, 19,
+ 53, 19, 21, 0, 21, 54, 21, 0, 10, 0,
+ 10, 0, 10, 11, 0, 11, 0, 11, 16, 18,
+ 36, 26, 24, 0, 25, 33, 27, 0, 0, 0,
+ 0, 0, 38, 40, 42, 44, 0, 45, 46, 47,
+ 48, 34, 53, 51, 0, 52, 0, 54, 62, 53,
+ 51, 0, 52, 0, 54, 0, 21, 19, 0, 20,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 2, 3, 4, 13,
+ 14, 4, 13, 0, 4,
+};
+static const short calc1_check[] = { 40,
+ 10, 10, 40, 0, 45, 40, 10, 45, 5, 6,
+ 45, 10, 61, 61, 11, 41, 42, 43, 44, 45,
+ -1, 47, 19, 20, 21, 22, 10, -1, -1, -1,
+ 42, 41, 29, 30, 10, 47, -1, 41, 35, 43,
+ 10, 45, -1, 42, 43, -1, 45, 10, 47, -1,
+ -1, -1, -1, 10, 51, 52, 53, 54, 42, 43,
+ 10, 45, -1, 47, -1, 10, 42, 43, -1, 45,
+ 10, 47, 42, 43, -1, 45, 10, 47, 42, 42,
+ 43, 10, 45, 47, 47, 42, 43, 10, 45, -1,
+ 47, 41, 10, 43, 44, 45, 41, -1, 43, 44,
+ 45, 41, -1, 43, -1, 45, -1, 41, -1, 43,
+ 42, 45, 41, -1, 43, 47, 45, -1, 41, -1,
+ 43, -1, 45, 41, -1, 43, -1, 45, 5, 6,
+ 41, 42, 43, -1, 45, 12, 47, -1, -1, -1,
+ -1, -1, 19, 20, 21, 22, -1, 24, 25, 26,
+ 27, 41, 42, 43, -1, 45, -1, 47, 41, 42,
+ 43, -1, 45, -1, 47, -1, 42, 43, -1, 45,
+ -1, 47, -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, 256, 257, 258, 259, 257,
+ 258, 259, 257, -1, 259,
+};
+#define YYFINAL 7
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 260
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,
+0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,"DREG","VREG","CONST","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : line",
+"lines :",
+"lines : lines line",
+"line : dexp '\\n'",
+"line : vexp '\\n'",
+"line : DREG '=' dexp '\\n'",
+"line : VREG '=' vexp '\\n'",
+"line : error '\\n'",
+"dexp : CONST",
+"dexp : DREG",
+"dexp : dexp '+' dexp",
+"dexp : dexp '-' dexp",
+"dexp : dexp '*' dexp",
+"dexp : dexp '/' dexp",
+"dexp : '-' dexp",
+"dexp : '(' dexp ')'",
+"vexp : dexp",
+"vexp : '(' dexp ',' dexp ')'",
+"vexp : VREG",
+"vexp : vexp '+' vexp",
+"vexp : dexp '+' vexp",
+"vexp : vexp '-' vexp",
+"vexp : dexp '-' vexp",
+"vexp : vexp '*' vexp",
+"vexp : dexp '*' vexp",
+"vexp : vexp '/' vexp",
+"vexp : dexp '/' vexp",
+"vexp : '-' vexp",
+"vexp : '(' vexp ')'",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 173 "calc1.y"
+ /* beginning of subroutines section */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+#define BSZ 50 /* buffer size for floating point numbers */
+
+ /* lexical analysis */
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ int c;
+
+ while ((c = getchar()) == ' ')
+ { /* skip over blanks */
+ }
+
+ if (isupper(c))
+ {
+ yylval.ival = c - 'A';
+ return (VREG);
+ }
+ if (islower(c))
+ {
+ yylval.ival = c - 'a';
+ return (DREG);
+ }
+
+ if (isdigit(c) || c == '.')
+ {
+ /* gobble up digits, points, exponents */
+ char buf[BSZ + 1], *cp = buf;
+ int dot = 0, expr = 0;
+
+ for (; (cp - buf) < BSZ; ++cp, c = getchar())
+ {
+
+ *cp = c;
+ if (isdigit(c))
+ continue;
+ if (c == '.')
+ {
+ if (dot++ || expr)
+ return ('.'); /* will cause syntax error */
+ continue;
+ }
+
+ if (c == 'e')
+ {
+ if (expr++)
+ return ('e'); /* will cause syntax error */
+ continue;
+ }
+
+ /* end of number */
+ break;
+ }
+ *cp = '\0';
+
+ if ((cp - buf) >= BSZ)
+ printf("constant too long: truncated\n");
+ else
+ ungetc(c, stdin); /* push back last char read */
+ yylval.dval = atof(buf);
+ return (CONST);
+ }
+ return (c);
+}
+
+static INTERVAL
+hilo(double a, double b, double c, double d)
+{
+ /* returns the smallest interval containing a, b, c, and d */
+ /* used by *, / routines */
+ INTERVAL v;
+
+ if (a > b)
+ {
+ v.hi = a;
+ v.lo = b;
+ }
+ else
+ {
+ v.hi = b;
+ v.lo = a;
+ }
+
+ if (c > d)
+ {
+ if (c > v.hi)
+ v.hi = c;
+ if (d < v.lo)
+ v.lo = d;
+ }
+ else
+ {
+ if (d > v.hi)
+ v.hi = d;
+ if (c < v.lo)
+ v.lo = c;
+ }
+ return (v);
+}
+
+INTERVAL
+vmul(double a, double b, INTERVAL v)
+{
+ return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
+}
+
+int
+dcheck(INTERVAL v)
+{
+ if (v.hi >= 0. && v.lo <= 0.)
+ {
+ printf("divisor interval contains 0.\n");
+ return (1);
+ }
+ return (0);
+}
+
+INTERVAL
+vdiv(double a, double b, INTERVAL v)
+{
+ return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
+}
+#line 484 "calc1.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 54 "calc1.y"
+ {
+ (void) printf("%15.8f\n", yystack.l_mark[-1].dval);
+ }
+break;
+case 4:
+#line 58 "calc1.y"
+ {
+ (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
+ }
+break;
+case 5:
+#line 62 "calc1.y"
+ {
+ dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
+ }
+break;
+case 6:
+#line 66 "calc1.y"
+ {
+ vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
+ }
+break;
+case 7:
+#line 70 "calc1.y"
+ {
+ yyerrok;
+ }
+break;
+case 9:
+#line 77 "calc1.y"
+ {
+ yyval.dval = dreg[yystack.l_mark[0].ival];
+ }
+break;
+case 10:
+#line 81 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
+ }
+break;
+case 11:
+#line 85 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
+ }
+break;
+case 12:
+#line 89 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
+ }
+break;
+case 13:
+#line 93 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
+ }
+break;
+case 14:
+#line 97 "calc1.y"
+ {
+ yyval.dval = -yystack.l_mark[0].dval;
+ }
+break;
+case 15:
+#line 101 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-1].dval;
+ }
+break;
+case 16:
+#line 107 "calc1.y"
+ {
+ yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
+ }
+break;
+case 17:
+#line 111 "calc1.y"
+ {
+ yyval.vval.lo = yystack.l_mark[-3].dval;
+ yyval.vval.hi = yystack.l_mark[-1].dval;
+ if ( yyval.vval.lo > yyval.vval.hi )
+ {
+ (void) printf("interval out of order\n");
+ YYERROR;
+ }
+ }
+break;
+case 18:
+#line 121 "calc1.y"
+ {
+ yyval.vval = vreg[yystack.l_mark[0].ival];
+ }
+break;
+case 19:
+#line 125 "calc1.y"
+ {
+ yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
+ yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
+ }
+break;
+case 20:
+#line 130 "calc1.y"
+ {
+ yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
+ yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
+ }
+break;
+case 21:
+#line 135 "calc1.y"
+ {
+ yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
+ yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
+ }
+break;
+case 22:
+#line 140 "calc1.y"
+ {
+ yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
+ yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
+ }
+break;
+case 23:
+#line 145 "calc1.y"
+ {
+ yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
+ }
+break;
+case 24:
+#line 149 "calc1.y"
+ {
+ yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
+ }
+break;
+case 25:
+#line 153 "calc1.y"
+ {
+ if (dcheck(yystack.l_mark[0].vval)) YYERROR;
+ yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
+ }
+break;
+case 26:
+#line 158 "calc1.y"
+ {
+ if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
+ yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
+ }
+break;
+case 27:
+#line 163 "calc1.y"
+ {
+ yyval.vval.hi = -yystack.l_mark[0].vval.lo;
+ yyval.vval.lo = -yystack.l_mark[0].vval.hi;
+ }
+break;
+case 28:
+#line 168 "calc1.y"
+ {
+ yyval.vval = yystack.l_mark[-1].vval;
+ }
+break;
+#line 853 "calc1.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: calc1.tab.h,v 1.1.1.3 2011/09/10 21:22:10 christos Exp $ */
+
+#define DREG 257
+#define VREG 258
+#define CONST 259
+#define UMINUS 260
+#ifdef YYSTYPE
+#undef YYSTYPE_IS_DECLARED
+#define YYSTYPE_IS_DECLARED 1
+#endif
+#ifndef YYSTYPE_IS_DECLARED
+#define YYSTYPE_IS_DECLARED 1
+typedef union
+{
+ int ival;
+ double dval;
+ INTERVAL vval;
+} YYSTYPE;
+#endif /* !YYSTYPE_IS_DECLARED */
+extern YYSTYPE calc1_lval;
--- /dev/null
+/* $NetBSD: calc1.y,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
+
+%{
+
+/* http://dinosaur.compilertools.net/yacc/index.html */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+
+typedef struct interval
+{
+ double lo, hi;
+}
+INTERVAL;
+
+INTERVAL vmul(double, double, INTERVAL);
+INTERVAL vdiv(double, double, INTERVAL);
+
+int dcheck(INTERVAL);
+
+double dreg[26];
+INTERVAL vreg[26];
+
+%}
+%expect 18
+
+%start line
+%union
+{
+ int ival;
+ double dval;
+ INTERVAL vval;
+}
+
+%token <ival> DREG VREG /* indices into dreg, vreg arrays */
+%token <dval> CONST /* floating point constant */
+
+%type <dval> dexp /* expression */
+%type <vval> vexp /* interval expression */
+
+ /* precedence information about the operators */
+
+%left '+' '-'
+%left '*' '/'
+%left UMINUS /* precedence for unary minus */
+
+%% /* beginning of rules section */
+
+lines : /* empty */
+ | lines line
+ ;
+
+line : dexp '\n'
+ {
+ (void) printf("%15.8f\n", $1);
+ }
+ | vexp '\n'
+ {
+ (void) printf("(%15.8f, %15.8f)\n", $1.lo, $1.hi);
+ }
+ | DREG '=' dexp '\n'
+ {
+ dreg[$1] = $3;
+ }
+ | VREG '=' vexp '\n'
+ {
+ vreg[$1] = $3;
+ }
+ | error '\n'
+ {
+ yyerrok;
+ }
+ ;
+
+dexp : CONST
+ | DREG
+ {
+ $$ = dreg[$1];
+ }
+ | dexp '+' dexp
+ {
+ $$ = $1 + $3;
+ }
+ | dexp '-' dexp
+ {
+ $$ = $1 - $3;
+ }
+ | dexp '*' dexp
+ {
+ $$ = $1 * $3;
+ }
+ | dexp '/' dexp
+ {
+ $$ = $1 / $3;
+ }
+ | '-' dexp %prec UMINUS
+ {
+ $$ = -$2;
+ }
+ | '(' dexp ')'
+ {
+ $$ = $2;
+ }
+ ;
+
+vexp : dexp
+ {
+ $$.hi = $$.lo = $1;
+ }
+ | '(' dexp ',' dexp ')'
+ {
+ $$.lo = $2;
+ $$.hi = $4;
+ if ( $$.lo > $$.hi )
+ {
+ (void) printf("interval out of order\n");
+ YYERROR;
+ }
+ }
+ | VREG
+ {
+ $$ = vreg[$1];
+ }
+ | vexp '+' vexp
+ {
+ $$.hi = $1.hi + $3.hi;
+ $$.lo = $1.lo + $3.lo;
+ }
+ | dexp '+' vexp
+ {
+ $$.hi = $1 + $3.hi;
+ $$.lo = $1 + $3.lo;
+ }
+ | vexp '-' vexp
+ {
+ $$.hi = $1.hi - $3.lo;
+ $$.lo = $1.lo - $3.hi;
+ }
+ | dexp '-' vexp
+ {
+ $$.hi = $1 - $3.lo;
+ $$.lo = $1 - $3.hi;
+ }
+ | vexp '*' vexp
+ {
+ $$ = vmul( $1.lo, $1.hi, $3 );
+ }
+ | dexp '*' vexp
+ {
+ $$ = vmul ($1, $1, $3 );
+ }
+ | vexp '/' vexp
+ {
+ if (dcheck($3)) YYERROR;
+ $$ = vdiv ( $1.lo, $1.hi, $3 );
+ }
+ | dexp '/' vexp
+ {
+ if (dcheck ( $3 )) YYERROR;
+ $$ = vdiv ($1, $1, $3 );
+ }
+ | '-' vexp %prec UMINUS
+ {
+ $$.hi = -$2.lo;
+ $$.lo = -$2.hi;
+ }
+ | '(' vexp ')'
+ {
+ $$ = $2;
+ }
+ ;
+
+%% /* beginning of subroutines section */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+#define BSZ 50 /* buffer size for floating point numbers */
+
+ /* lexical analysis */
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ int c;
+
+ while ((c = getchar()) == ' ')
+ { /* skip over blanks */
+ }
+
+ if (isupper(c))
+ {
+ yylval.ival = c - 'A';
+ return (VREG);
+ }
+ if (islower(c))
+ {
+ yylval.ival = c - 'a';
+ return (DREG);
+ }
+
+ if (isdigit(c) || c == '.')
+ {
+ /* gobble up digits, points, exponents */
+ char buf[BSZ + 1], *cp = buf;
+ int dot = 0, expr = 0;
+
+ for (; (cp - buf) < BSZ; ++cp, c = getchar())
+ {
+
+ *cp = c;
+ if (isdigit(c))
+ continue;
+ if (c == '.')
+ {
+ if (dot++ || expr)
+ return ('.'); /* will cause syntax error */
+ continue;
+ }
+
+ if (c == 'e')
+ {
+ if (expr++)
+ return ('e'); /* will cause syntax error */
+ continue;
+ }
+
+ /* end of number */
+ break;
+ }
+ *cp = '\0';
+
+ if ((cp - buf) >= BSZ)
+ printf("constant too long: truncated\n");
+ else
+ ungetc(c, stdin); /* push back last char read */
+ yylval.dval = atof(buf);
+ return (CONST);
+ }
+ return (c);
+}
+
+static INTERVAL
+hilo(double a, double b, double c, double d)
+{
+ /* returns the smallest interval containing a, b, c, and d */
+ /* used by *, / routines */
+ INTERVAL v;
+
+ if (a > b)
+ {
+ v.hi = a;
+ v.lo = b;
+ }
+ else
+ {
+ v.hi = b;
+ v.lo = a;
+ }
+
+ if (c > d)
+ {
+ if (c > v.hi)
+ v.hi = c;
+ if (d < v.lo)
+ v.lo = d;
+ }
+ else
+ {
+ if (d > v.hi)
+ v.hi = d;
+ if (c < v.lo)
+ v.lo = c;
+ }
+ return (v);
+}
+
+INTERVAL
+vmul(double a, double b, INTERVAL v)
+{
+ return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
+}
+
+int
+dcheck(INTERVAL v)
+{
+ if (v.hi >= 0. && v.lo <= 0.)
+ {
+ printf("divisor interval contains 0.\n");
+ return (1);
+ }
+ return (0);
+}
+
+INTERVAL
+vdiv(double a, double b, INTERVAL v)
+{
+ return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
+}
--- /dev/null
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+\f
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
--- /dev/null
+/* $NetBSD: calc2.tab.c,v 1.1.1.3 2011/09/10 21:22:08 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse calc2_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc2_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc2_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc2_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc2_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc2_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc2_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc2_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc2_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc2_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc2_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc2_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc2_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc2_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc2_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc2_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc2_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc2_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc2_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc2_rule
+#endif /* yyrule */
+#define YYPREFIX "calc2_"
+
+#define YYPURE 0
+
+#line 7 "calc2.y"
+# include <stdio.h>
+# include <ctype.h>
+
+#line 103 "calc2.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(int regs[26], int * base)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(int * base)
+# define YYLEX yylex(base)
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
+#define YYERROR_CALL(msg) yyerror(regs, base, msg)
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+static const short calc2_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short calc2_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short calc2_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const short calc2_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short calc2_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const short calc2_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const short calc2_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const short calc2_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const short calc2_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 65 "calc2.y"
+ /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ int regs[26];
+ int base = 10;
+
+ while(!feof(stdin)) {
+ yyparse(regs, &base);
+ }
+ return 0;
+}
+
+static void
+YYERROR_DECL()
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(int *base)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = (c - '0') % (*base);
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 345 "calc2.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror(regs, base, "syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 27 "calc2.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 31 "calc2.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 33 "calc2.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 37 "calc2.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 39 "calc2.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 41 "calc2.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 43 "calc2.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 45 "calc2.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 47 "calc2.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 49 "calc2.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 51 "calc2.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 53 "calc2.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 55 "calc2.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 60 "calc2.y"
+ { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 62 "calc2.y"
+ { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 611 "calc2.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror(regs, base, "yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: calc2.tab.h,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
--- /dev/null
+/* $NetBSD: calc2.y,v 1.1.1.3 2011/09/10 21:22:06 christos Exp $ */
+
+%parse-param { int regs[26] }
+%parse-param { int *base }
+
+%lex-param { int *base }
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; (*base) = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = (*base) * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ int regs[26];
+ int base = 10;
+
+ while(!feof(stdin)) {
+ yyparse(regs, &base);
+ }
+ return 0;
+}
+
+static void
+YYERROR_DECL()
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(int *base)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = (c - '0') % (*base);
+ return ( DIGIT );
+ }
+ return( c );
+}
--- /dev/null
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+\f
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
--- /dev/null
+/* $NetBSD: calc3.tab.c,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse calc3_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc3_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc3_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc3_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc3_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc3_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc3_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc3_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc3_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc3_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc3_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc3_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc3_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc3_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc3_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc3_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc3_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc3_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc3_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc3_rule
+#endif /* yyrule */
+#define YYPREFIX "calc3_"
+
+#define YYPURE 1
+
+#line 9 "calc3.y"
+# include <stdio.h>
+# include <ctype.h>
+
+#line 103 "calc3.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(int regs[26], int * base)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
+# define YYLEX yylex(&yylval, YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, int * base)
+# define YYLEX yylex(&yylval, base)
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
+#define YYERROR_CALL(msg) yyerror(regs, base, msg)
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+static const short calc3_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short calc3_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short calc3_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const short calc3_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short calc3_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const short calc3_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const short calc3_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const short calc3_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const short calc3_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+#line 67 "calc3.y"
+ /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ int regs[26];
+ int base = 10;
+
+ while(!feof(stdin)) {
+ yyparse(regs, &base);
+ }
+ return 0;
+}
+
+static void
+YYERROR_DECL()
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+YYLEX_DECL()
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ *yylval = (c - 'a');
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ *yylval = (c - '0') % (*base);
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 338 "calc3.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yyerrflag;
+ int yychar;
+ YYSTYPE yyval;
+ YYSTYPE yylval;
+
+ /* variables for the parser stack */
+ YYSTACKDATA yystack;
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror(regs, base, "syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 29 "calc3.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 33 "calc3.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 35 "calc3.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 39 "calc3.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 41 "calc3.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 43 "calc3.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 45 "calc3.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 47 "calc3.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 49 "calc3.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 51 "calc3.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 53 "calc3.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 55 "calc3.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 57 "calc3.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 62 "calc3.y"
+ { yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 64 "calc3.y"
+ { yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 611 "calc3.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror(regs, base, "yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: calc3.tab.h,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
--- /dev/null
+/* $NetBSD: calc3.y,v 1.1.1.3 2011/09/10 21:22:07 christos Exp $ */
+
+%pure-parser
+
+%parse-param { int regs[26] }
+%parse-param { int *base }
+
+%lex-param { int *base }
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; (*base) = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = (*base) * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ int regs[26];
+ int base = 10;
+
+ while(!feof(stdin)) {
+ yyparse(regs, &base);
+ }
+ return 0;
+}
+
+static void
+YYERROR_DECL()
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+YYLEX_DECL()
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ *yylval = (c - 'a');
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ *yylval = (c - '0') % (*base);
+ return ( DIGIT );
+ }
+ return( c );
+}
--- /dev/null
+/* $NetBSD: code_calc.code.c,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#define YYPURE 0
+
+#line 2 "code_calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+#line 25 "code_calc.code.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+#define YYTABLESIZE 220
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+
+#ifndef yyparse
+#define yyparse calc_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_"
+
+extern int YYPARSE_DECL();
+extern short yylhs[];
+extern short yylen[];
+extern short yydefred[];
+extern short yydgoto[];
+extern short yysindex[];
+extern short yyrindex[];
+extern short yygindex[];
+extern short yytable[];
+extern short yycheck[];
+
+#if YYDEBUG
+extern char *yyname[];
+extern char *yyrule[];
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 63 "code_calc.y"
+ /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 245 "code_calc.code.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 25 "code_calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 29 "code_calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 31 "code_calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 35 "code_calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 37 "code_calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 39 "code_calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 41 "code_calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 43 "code_calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 45 "code_calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 47 "code_calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 49 "code_calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 51 "code_calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 53 "code_calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 58 "code_calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 60 "code_calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 511 "code_calc.code.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+\f
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
--- /dev/null
+/* $NetBSD: code_calc.tab.c,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
+
+
+#ifndef yyparse
+#define yyparse calc_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_"
+const short calc_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+const short calc_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+const short calc_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+const short calc_dgoto[] = { 1,
+ 7, 8, 9,
+};
+const short calc_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+const short calc_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+const short calc_gindex[] = { 0,
+ 0, 65, 0,
+};
+const short calc_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+const short calc_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, 256, 257, 258, 257, 258,
+};
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#if YYDEBUG
+const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
+};
+const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
--- /dev/null
+/* $NetBSD: code_calc.tab.h,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
--- /dev/null
+/* $NetBSD: code_calc.y,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
--- /dev/null
+/* $NetBSD: code_error.code.c,v 1.1.1.3 2011/09/10 21:22:06 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#define YYPURE 0
+
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
+#define YYERRCODE 256
+#define YYTABLESIZE 0
+#define YYFINAL 2
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 0
+
+#ifndef yyparse
+#define yyparse error_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex error_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror error_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar error_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval error_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval error_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug error_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs error_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag error_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs error_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen error_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred error_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto error_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex error_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex error_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex error_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable error_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck error_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname error_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule error_rule
+#endif /* yyrule */
+#define YYPREFIX "error_"
+
+extern int YYPARSE_DECL();
+extern short yylhs[];
+extern short yylen[];
+extern short yydefred[];
+extern short yydgoto[];
+extern short yysindex[];
+extern short yyrindex[];
+extern short yygindex[];
+extern short yytable[];
+extern short yycheck[];
+
+#if YYDEBUG
+extern char *yyname[];
+extern char *yyrule[];
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 4 "code_error.y"
+
+#include <stdio.h>
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main(void)
+{
+ printf("yyparse() = %d\n", yyparse());
+ return 0;
+}
+
+int
+yylex(void)
+{
+ return -1;
+}
+
+static void
+yyerror(const char* s)
+{
+ printf("%s\n", s);
+}
+#line 215 "code_error.code.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: code_error.tab.c,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
+
+
+#ifndef yyparse
+#define yyparse error_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex error_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror error_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar error_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval error_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval error_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug error_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs error_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag error_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs error_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen error_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred error_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto error_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex error_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex error_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex error_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable error_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck error_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname error_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule error_rule
+#endif /* yyrule */
+#define YYPREFIX "error_"
+const short error_lhs[] = { -1,
+ 0,
+};
+const short error_len[] = { 2,
+ 1,
+};
+const short error_defred[] = { 0,
+ 1, 0,
+};
+const short error_dgoto[] = { 2,
+};
+const short error_sindex[] = { -256,
+ 0, 0,
+};
+const short error_rindex[] = { 0,
+ 0, 0,
+};
+const short error_gindex[] = { 0,
+};
+const short error_table[] = { 1,
+};
+const short error_check[] = { 256,
+};
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#if YYDEBUG
+const char *yyname[] = {
+
+"end-of-file",
+};
+const char *yyrule[] = {
+"$accept : S",
+"S : error",
+
+};
+#endif
--- /dev/null
+/* $NetBSD: code_error.tab.h,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
+
--- /dev/null
+/* $NetBSD: code_error.y,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
+
+%%
+S: error
+%%
+
+#include <stdio.h>
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main(void)
+{
+ printf("yyparse() = %d\n", yyparse());
+ return 0;
+}
+
+int
+yylex(void)
+{
+ return -1;
+}
+
+static void
+yyerror(const char* s)
+{
+ printf("%s\n", s);
+}
--- /dev/null
+ 0 $accept : S $end
+
+ 1 S : error
+\f
+state 0
+ $accept : . S $end (0)
+
+ error shift 1
+ . error
+
+ S goto 2
+
+
+state 1
+ S : error . (1)
+
+ . reduce 1
+
+
+state 2
+ $accept : S . $end (0)
+
+ $end accept
+
+
+2 terminals, 2 nonterminals
+2 grammar rules, 3 states
--- /dev/null
+/* $NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $ */
+
+#ifndef lint
+/* static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; */
+static char rcsid[] = "$NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse error_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex error_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror error_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar error_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval error_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval error_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug error_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs error_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag error_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs error_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen error_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred error_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto error_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex error_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex error_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex error_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable error_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck error_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname error_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule error_rule
+#endif /* yyrule */
+#define YYPREFIX "error_"
+
+#define YYPURE 0
+
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
+#define YYERRCODE 256
+static const short error_lhs[] = { -1,
+ 0,
+};
+static const short error_len[] = { 2,
+ 1,
+};
+static const short error_defred[] = { 0,
+ 1, 0,
+};
+static const short error_dgoto[] = { 2,
+};
+static const short error_sindex[] = { -256,
+ 0, 0,
+};
+static const short error_rindex[] = { 0,
+ 0, 0,
+};
+static const short error_gindex[] = { 0,
+};
+#define YYTABLESIZE 0
+static const short error_table[] = { 1,
+};
+static const short error_check[] = { 256,
+};
+#define YYFINAL 2
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 0
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",
+};
+static const char *yyrule[] = {
+"$accept : S",
+"S : error",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 4 "error.y"
+
+#include <stdio.h>
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main(void)
+{
+ printf("yyparse() = %d\n", yyparse());
+ return 0;
+}
+
+int
+yylex(void)
+{
+ return -1;
+}
+
+static void
+yyerror(const char* s)
+{
+ printf("%s\n", s);
+}
+#line 233 "error.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: error.tab.h,v 1.3 2011/09/10 21:29:04 christos Exp $ */
--- /dev/null
+/* $NetBSD: error.y,v 1.1.1.4 2011/09/10 21:22:03 christos Exp $ */
+
+%%
+S: error
+%%
+
+#include <stdio.h>
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main(void)
+{
+ printf("yyparse() = %d\n", yyparse());
+ return 0;
+}
+
+int
+yylex(void)
+{
+ return -1;
+}
+
+static void
+yyerror(const char* s)
+{
+ printf("%s\n", s);
+}
+/* $NetBSD: ftp.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $ */
+
#ifndef lint
-/*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/
-static char rcsid[] = "$NetBSD: ftp.tab.c,v 1.7 2001/01/04 23:05:57 lukem Exp $";
+/* static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; */
+static char rcsid[] = "$NetBSD: ftp.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $";
#endif
+
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
-#define yyclearin (yychar=(-1))
-#define yyerrok (yyerrflag=0)
-#define YYRECOVERING (yyerrflag!=0)
-#define YYPREFIX "yy"
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse ftp_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex ftp_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror ftp_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar ftp_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval ftp_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval ftp_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug ftp_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs ftp_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag ftp_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs ftp_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen ftp_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred ftp_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto ftp_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex ftp_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex ftp_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex ftp_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable ftp_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck ftp_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname ftp_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule ftp_rule
+#endif /* yyrule */
+#define YYPREFIX "ftp_"
+
+#define YYPURE 0
+
#line 26 "ftp.y"
-#ifndef lint
-static char sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89";
-#endif /* not lint */
+/* sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89"; */
#include <sys/param.h>
#include <sys/socket.h>
#include <arpa/ftp.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <setjmp.h>
#include <syslog.h>
#include <sys/stat.h>
+#include <string.h>
#include <time.h>
+#include <assert.h>
extern struct sockaddr_in data_dest;
extern int logged_in;
extern int usedefault;
extern int transflag;
extern char tmpline[];
-char **glob();
+
+extern char **glob(char *);
+extern char *renamefrom(char *);
+extern void cwd(const char *);
+
+extern void dologout(int);
+extern void fatal(const char *);
+extern void makedir(const char *);
+extern void nack(const char *);
+extern void pass(const char *);
+extern void passive(void);
+extern void pwd(void);
+extern void removedir(char *);
+extern void renamecmd(char *, char *);
+extern void retrieve(const char *, const char *);
+extern void send_file_list(const char *);
+extern void statcmd(void);
+extern void statfilecmd(const char *);
+extern void store(char *, const char *, int);
+extern void user(const char *);
+
+extern void perror_reply(int, const char *, ...);
+extern void reply(int, const char *, ...);
+extern void lreply(int, const char *, ...);
static int cmd_type;
static int cmd_form;
char cbuf[512];
char *fromname;
-char *index();
-#line 60 "ftp.tab.c"
+
+
+static char * copy(const char *);
+
+static void
+yyerror(const char *msg)
+{
+ perror(msg);
+}
+#line 180 "ftp.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
#define A 257
#define B 258
#define C 259
#define CHMOD 318
#define LEXERR 319
#define YYERRCODE 256
-short yylhs[] = { -1,
+static const short ftp_lhs[] = { -1,
0, 0, 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,
6, 6, 6, 7, 7, 7, 8, 8, 8, 10,
14, 11, 9,
};
-short yylen[] = { 2,
+static const short ftp_len[] = { 2,
0, 2, 2, 4, 4, 4, 2, 4, 4, 4,
4, 8, 5, 5, 5, 3, 5, 3, 5, 5,
2, 5, 4, 2, 3, 5, 2, 4, 2, 5,
1, 3, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 0,
};
-short yydefred[] = { 1,
+static const short ftp_defred[] = { 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
73, 73, 73, 0, 73, 0, 0, 73, 73, 73,
73, 0, 0, 0, 0, 73, 73, 73, 73, 73,
0, 35, 72, 0, 40, 0, 0, 0, 37, 0,
0, 12, 0, 0, 38, 0, 0, 0, 52,
};
-short yydgoto[] = { 1,
+static const short ftp_dgoto[] = { 1,
34, 35, 71, 73, 75, 80, 84, 88, 45, 95,
184, 125, 157, 96,
};
-short yysindex[] = { 0,
+static const short ftp_sindex[] = { 0,
-224, -247, -239, -236, -232, -222, -204, -200, -181, -177,
0, 0, 0, -166, 0, -161, -199, 0, 0, 0,
0, -160, -159, -264, -158, 0, 0, 0, 0, 0,
-97, 0, 0, -95, 0, -96, -94, -92, 0, -152,
-93, 0, -91, -90, 0, -88, -87, -86, 0,
};
-short yyrindex[] = { 0,
+static const short ftp_rindex[] = { 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, -83, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-short yygindex[] = { 0,
+static const short ftp_gindex[] = { 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, -89,
-25, 35, 47, 0,
};
#define YYTABLESIZE 190
-short yytable[] = { 129,
+static const short ftp_table[] = { 129,
130, 131, 104, 134, 59, 60, 76, 136, 137, 77,
138, 78, 79, 105, 106, 107, 98, 99, 146, 123,
148, 149, 36, 124, 150, 151, 152, 46, 47, 37,
183, 185, 190, 187, 189, 188, 191, 192, 195, 194,
196, 0, 0, 198, 197, 73, 199, 49, 56, 58,
};
-short yycheck[] = { 89,
+static const short ftp_check[] = { 89,
90, 91, 305, 93, 269, 270, 257, 97, 98, 260,
100, 262, 263, 316, 317, 318, 269, 270, 108, 269,
110, 111, 270, 273, 114, 115, 116, 12, 13, 269,
#endif
#define YYMAXTOKEN 319
#if YYDEBUG
-char *yyname[] = {
+static const char *yyname[] = {
+
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
"DELE","CWD","LIST","NLST","SITE","STAT","HELP","NOOP","MKD","RMD","PWD","CDUP",
"STOU","SMNT","SYST","SIZE","MDTM","UMASK","IDLE","CHMOD","LEXERR",
};
-char *yyrule[] = {
+static const char *yyrule[] = {
"$accept : cmd_list",
"cmd_list :",
"cmd_list : cmd_list cmd",
"pathstring : STRING",
"octal_number : NUMBER",
"check_login :",
+
};
#endif
-#ifndef YYSTYPE
-typedef int YYSTYPE;
-#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
-#define YYMAXDEPTH YYSTACKSIZE
+#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
-#define YYMAXDEPTH 500
+#define YYMAXDEPTH 500
#endif
#endif
-int yydebug;
-int yynerrs;
-int yyerrflag;
-int yychar;
-short *yyssp;
-YYSTYPE *yyvsp;
-YYSTYPE yyval;
-YYSTYPE yylval;
-short yyss[YYSTACKSIZE];
-YYSTYPE yyvs[YYSTACKSIZE];
-#define yystacksize YYSTACKSIZE
-#line 658 "ftp.y"
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 689 "ftp.y"
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
extern jmp_buf errcatch;
+static void upper(char *);
+
#define CMD 0 /* beginning of command */
#define ARGS 1 /* expect miscellaneous arguments */
#define STR1 2 /* expect SP followed by STRING */
#define NSTR 8 /* Number followed by a string */
struct tab {
- char *name;
+ const char *name;
short token;
short state;
short implemented; /* 1 if command is implemented */
- char *help;
+ const char *help;
};
struct tab cmdtab[] = { /* In order defined in RFC 765 */
{ "STOU", STOU, STR1, 1, "<sp> file-name" },
{ "SIZE", SIZE, OSTR, 1, "<sp> path-name" },
{ "MDTM", MDTM, OSTR, 1, "<sp> path-name" },
- { NULL, 0, 0, 0, 0 }
+ { 0, 0, 0, 0, 0 }
};
struct tab sitetab[] = {
{ "IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]" },
{ "CHMOD", CHMOD, NSTR, 1, "<sp> mode <sp> file-name" },
{ "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
- { NULL, 0, 0, 0, 0 }
+ { 0, 0, 0, 0, 0 }
};
-struct tab *
-lookup(p, cmd)
- register struct tab *p;
- char *cmd;
+static struct tab *
+lookup(struct tab *p, char *cmd)
{
- for (; p->name != NULL; p++)
+ for (; p->name != 0; p++)
if (strcmp(cmd, p->name) == 0)
return (p);
return (0);
#include <arpa/telnet.h>
/*
- * getline - a hacked up version of fgets to ignore TELNET escape codes.
+ * get_line - a hacked up version of fgets to ignore TELNET escape codes.
*/
-char *
-getline(s, n, iop)
- char *s;
- register FILE *iop;
+static char *
+get_line(char *s, int n, FILE *iop)
{
- register c;
+ register int c;
register char *cs;
cs = s;
for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) {
*cs++ = tmpline[c];
if (tmpline[c] == '\n') {
- *cs++ = '\0';
+ *cs = '\0';
if (debug)
syslog(LOG_DEBUG, "command: %s", s);
tmpline[0] = '\0';
break;
}
if (c == EOF && cs == s)
- return (NULL);
- *cs++ = '\0';
+ return (0);
+ *cs = '\0';
if (debug)
syslog(LOG_DEBUG, "command: %s", s);
return (s);
}
-static int
-toolong()
+static void
+toolong(int sig)
{
time_t now;
- extern char *ctime();
- extern time_t time();
+ (void) sig;
reply(421,
"Timeout (%d seconds): closing control connection.", timeout);
(void) time(&now);
dologout(1);
}
-yylex()
+int
+yylex(void)
{
static int cpos, state;
register char *cp, *cp2;
register struct tab *p;
int n;
- char c, *strpbrk();
- char *copy();
+ char c;
for (;;) {
switch (state) {
case CMD:
(void) signal(SIGALRM, toolong);
(void) alarm((unsigned) timeout);
- if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) {
+ if (get_line(cbuf, sizeof(cbuf)-1, stdin) == 0) {
reply(221, "You could at least say goodbye.");
dologout(0);
}
(void) alarm(0);
#ifdef SETPROCTITLE
- if (strncasecmp(cbuf, "PASS", 4) != NULL)
+ if (strncasecmp(cbuf, "PASS", 4) != 0)
setproctitle("%s: %s", proctitle, cbuf);
#endif /* SETPROCTITLE */
- if ((cp = index(cbuf, '\r'))) {
+ if ((cp = strchr(cbuf, '\r'))) {
*cp++ = '\n';
*cp = '\0';
}
/* NOTREACHED */
}
state = p->state;
- *(char **)&yylval = p->name;
+ *(const char **)(&yylval) = p->name;
return (p->token);
}
break;
/* NOTREACHED */
}
state = p->state;
- *(char **)&yylval = p->name;
+ *(const char **)(&yylval) = p->name;
return (p->token);
}
state = CMD;
dostr1:
if (cbuf[cpos] == ' ') {
cpos++;
- state = state == OSTR ? STR2 : ++state;
+ if (state == OSTR)
+ state = STR2;
+ else
+ ++state;
return (SP);
}
break;
}
}
-upper(s)
- register char *s;
+static void
+upper(char *s)
{
while (*s != '\0') {
if (islower(*s))
}
}
-char *
-copy(s)
- char *s;
+static char *
+copy(const char *s)
{
char *p;
- extern char *malloc(), *strcpy();
- p = malloc((unsigned) strlen(s) + 1);
- if (p == NULL)
+ p = (char * )malloc(strlen(s) + 1);
+ if (p == 0)
fatal("Ran out of memory.");
- (void) strcpy(p, s);
+ else
+ (void) strcpy(p, s);
return (p);
}
-help(ctab, s)
- struct tab *ctab;
- char *s;
+static void
+help(struct tab *ctab, char *s)
{
register struct tab *c;
register int width, NCMDS;
- char *type;
+ const char *help_type;
if (ctab == sitetab)
- type = "SITE ";
+ help_type = "SITE ";
else
- type = "";
+ help_type = "";
width = 0, NCMDS = 0;
- for (c = ctab; c->name != NULL; c++) {
+ for (c = ctab; c->name != 0; c++) {
int len = strlen(c->name);
if (len > width)
int columns, lines;
lreply(214, "The following %scommands are recognized %s.",
- type, "(* =>'s unimplemented)");
+ help_type, "(* =>'s unimplemented)");
columns = 76 / width;
if (columns == 0)
columns = 1;
printf(" ");
for (j = 0; j < columns; j++) {
c = ctab + j * lines + i;
+ assert(c->name != 0);
printf("%s%c", c->name,
c->implemented ? ' ' : '*');
if (c + lines >= &ctab[NCMDS])
return;
}
if (c->implemented)
- reply(214, "Syntax: %s%s %s", type, c->name, c->help);
+ reply(214, "Syntax: %s%s %s", help_type, c->name, c->help);
else
- reply(214, "%s%-*s\t%s; unimplemented.", type, width,
+ reply(214, "%s%-*s\t%s; unimplemented.", help_type, width,
c->name, c->help);
}
-sizecmd(filename)
-char *filename;
+static void
+sizecmd(char *filename)
{
switch (type) {
case TYPE_L:
(stbuf.st_mode&S_IFMT) != S_IFREG)
reply(550, "%s: not a plain file.", filename);
else
- reply(213, "%llu", (long long)stbuf.st_size);
+#ifdef HAVE_LONG_LONG
+ reply(213, "%llu", (long long) stbuf.st_size);
+#else
+ reply(213, "%lu", stbuf.st_size);
+#endif
break;}
case TYPE_A: {
FILE *fin;
register int c, count;
struct stat stbuf;
fin = fopen(filename, "r");
- if (fin == NULL) {
+ if (fin == 0) {
perror_reply(550, filename);
return;
}
reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
}
}
-#line 908 "ftp.tab.c"
-#define YYABORT goto yyabort
+#line 1079 "ftp.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
-#define YYERROR goto yyerrlab
+#define YYERROR goto yyerrlab
+
int
-yyparse()
+YYPARSE_DECL()
{
- register int yym, yyn, yystate;
+ int yym, yyn, yystate;
#if YYDEBUG
- register char *yys;
- extern char *getenv();
+ const char *yys;
- if (yys = getenv("YYDEBUG"))
+ if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yynerrs = 0;
yyerrflag = 0;
- yychar = (-1);
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
- yyssp = yyss;
- yyvsp = yyvs;
- *yyssp = yystate = 0;
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
yyloop:
- if (yyn = yydefred[yystate]) goto yyreduce;
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
- if ((yychar = yylex()) < 0) yychar = 0;
+ if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
- if (yyssp >= yyss + yystacksize - 1)
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- yychar = (-1);
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
-#ifdef lint
- goto yynewerror;
-#endif
-yynewerror:
+
yyerror("syntax error");
-#ifdef lint
+
goto yyerrlab;
-#endif
+
yyerrlab:
++yynerrs;
+
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
- if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
- to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
- if (yyssp >= yyss + yystacksize - 1)
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
goto yyloop;
}
else
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
- YYPREFIX, *yyssp);
+ YYPREFIX, *yystack.s_mark);
#endif
- if (yyssp <= yyss) goto yyabort;
- --yyssp;
- --yyvsp;
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
}
}
}
YYPREFIX, yystate, yychar, yys);
}
#endif
- yychar = (-1);
+ yychar = YYEMPTY;
goto yyloop;
}
+
yyreduce:
#if YYDEBUG
if (yydebug)
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
- yyval = yyvsp[1-yym];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 2:
-#line 99 "ftp.y"
- {
+#line 132 "ftp.y"
+ {
fromname = (char *) 0;
}
break;
case 4:
-#line 106 "ftp.y"
- {
- user((char *) yyvsp[-1]);
- free((char *) yyvsp[-1]);
+#line 139 "ftp.y"
+ {
+ user((char *) yystack.l_mark[-1]);
+ free((char *) yystack.l_mark[-1]);
}
break;
case 5:
-#line 111 "ftp.y"
- {
- pass((char *) yyvsp[-1]);
- free((char *) yyvsp[-1]);
+#line 144 "ftp.y"
+ {
+ pass((char *) yystack.l_mark[-1]);
+ free((char *) yystack.l_mark[-1]);
}
break;
case 6:
-#line 116 "ftp.y"
- {
+#line 149 "ftp.y"
+ {
usedefault = 0;
if (pdata >= 0) {
(void) close(pdata);
}
break;
case 7:
-#line 125 "ftp.y"
- {
+#line 158 "ftp.y"
+ {
passive();
}
break;
case 8:
-#line 129 "ftp.y"
- {
+#line 162 "ftp.y"
+ {
switch (cmd_type) {
case TYPE_A:
}
break;
case 9:
-#line 164 "ftp.y"
- {
- switch (yyvsp[-1]) {
+#line 197 "ftp.y"
+ {
+ switch (yystack.l_mark[-1]) {
case STRU_F:
reply(200, "STRU F ok.");
}
break;
case 10:
-#line 176 "ftp.y"
- {
- switch (yyvsp[-1]) {
+#line 209 "ftp.y"
+ {
+ switch (yystack.l_mark[-1]) {
case MODE_S:
reply(200, "MODE S ok.");
}
break;
case 11:
-#line 188 "ftp.y"
- {
+#line 221 "ftp.y"
+ {
reply(202, "ALLO command ignored.");
}
break;
case 12:
-#line 192 "ftp.y"
- {
+#line 225 "ftp.y"
+ {
reply(202, "ALLO command ignored.");
}
break;
case 13:
-#line 196 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- retrieve((char *) 0, (char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 229 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ retrieve((char *) 0, (char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 14:
-#line 203 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- store((char *) yyvsp[-1], "w", 0);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 236 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ store((char *) yystack.l_mark[-1], "w", 0);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 15:
-#line 210 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- store((char *) yyvsp[-1], "a", 0);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 243 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ store((char *) yystack.l_mark[-1], "a", 0);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 16:
-#line 217 "ftp.y"
- {
- if (yyvsp[-1])
+#line 250 "ftp.y"
+ {
+ if (yystack.l_mark[-1])
send_file_list(".");
}
break;
case 17:
-#line 222 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- send_file_list((char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 255 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ send_file_list((char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 18:
-#line 229 "ftp.y"
- {
- if (yyvsp[-1])
+#line 262 "ftp.y"
+ {
+ if (yystack.l_mark[-1])
retrieve("/bin/ls -lgA", "");
}
break;
case 19:
-#line 234 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- retrieve("/bin/ls -lgA %s", (char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 267 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ retrieve("/bin/ls -lgA %s", (char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 20:
-#line 241 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- statfilecmd((char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 274 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ statfilecmd((char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 21:
-#line 248 "ftp.y"
- {
+#line 281 "ftp.y"
+ {
statcmd();
}
break;
case 22:
-#line 252 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- delete((char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 285 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ remove((char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 23:
-#line 259 "ftp.y"
- {
+#line 292 "ftp.y"
+ {
if (fromname) {
- renamecmd(fromname, (char *) yyvsp[-1]);
+ renamecmd(fromname, (char *) yystack.l_mark[-1]);
free(fromname);
fromname = (char *) 0;
} else {
reply(503, "Bad sequence of commands.");
}
- free((char *) yyvsp[-1]);
+ free((char *) yystack.l_mark[-1]);
}
break;
case 24:
-#line 270 "ftp.y"
- {
+#line 303 "ftp.y"
+ {
reply(225, "ABOR command successful.");
}
break;
case 25:
-#line 274 "ftp.y"
- {
- if (yyvsp[-1])
+#line 307 "ftp.y"
+ {
+ if (yystack.l_mark[-1])
cwd(pw->pw_dir);
}
break;
case 26:
-#line 279 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- cwd((char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 312 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ cwd((char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 27:
-#line 286 "ftp.y"
- {
+#line 319 "ftp.y"
+ {
help(cmdtab, (char *) 0);
}
break;
case 28:
-#line 290 "ftp.y"
- {
- register char *cp = (char *)yyvsp[-1];
+#line 323 "ftp.y"
+ {
+ register char *cp = (char *)yystack.l_mark[-1];
if (strncasecmp(cp, "SITE", 4) == 0) {
- cp = (char *)yyvsp[-1] + 4;
+ cp = (char *)yystack.l_mark[-1] + 4;
if (*cp == ' ')
cp++;
if (*cp)
else
help(sitetab, (char *) 0);
} else
- help(cmdtab, (char *) yyvsp[-1]);
+ help(cmdtab, (char *) yystack.l_mark[-1]);
}
break;
case 29:
-#line 305 "ftp.y"
- {
+#line 338 "ftp.y"
+ {
reply(200, "NOOP command successful.");
}
break;
case 30:
-#line 309 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- makedir((char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 342 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ makedir((char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 31:
-#line 316 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- removedir((char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 349 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ removedir((char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 32:
-#line 323 "ftp.y"
- {
- if (yyvsp[-1])
+#line 356 "ftp.y"
+ {
+ if (yystack.l_mark[-1])
pwd();
}
break;
case 33:
-#line 328 "ftp.y"
- {
- if (yyvsp[-1])
+#line 361 "ftp.y"
+ {
+ if (yystack.l_mark[-1])
cwd("..");
}
break;
case 34:
-#line 333 "ftp.y"
- {
+#line 366 "ftp.y"
+ {
help(sitetab, (char *) 0);
}
break;
case 35:
-#line 337 "ftp.y"
- {
- help(sitetab, (char *) yyvsp[-1]);
+#line 370 "ftp.y"
+ {
+ help(sitetab, (char *) yystack.l_mark[-1]);
}
break;
case 36:
-#line 341 "ftp.y"
- {
+#line 374 "ftp.y"
+ {
int oldmask;
- if (yyvsp[-1]) {
+ if (yystack.l_mark[-1]) {
oldmask = umask(0);
(void) umask(oldmask);
reply(200, "Current UMASK is %03o", oldmask);
}
break;
case 37:
-#line 351 "ftp.y"
- {
+#line 384 "ftp.y"
+ {
int oldmask;
- if (yyvsp[-3]) {
- if ((yyvsp[-1] == -1) || (yyvsp[-1] > 0777)) {
+ if (yystack.l_mark[-3]) {
+ if ((yystack.l_mark[-1] == -1) || (yystack.l_mark[-1] > 0777)) {
reply(501, "Bad UMASK value");
} else {
- oldmask = umask(yyvsp[-1]);
+ oldmask = umask(yystack.l_mark[-1]);
reply(200,
"UMASK set to %03o (was %03o)",
- yyvsp[-1], oldmask);
+ yystack.l_mark[-1], oldmask);
}
}
}
break;
case 38:
-#line 366 "ftp.y"
- {
- if (yyvsp[-5] && (yyvsp[-1] != NULL)) {
- if (yyvsp[-3] > 0777)
+#line 399 "ftp.y"
+ {
+ if (yystack.l_mark[-5] && (yystack.l_mark[-1] != 0)) {
+ if (yystack.l_mark[-3] > 0777)
reply(501,
"CHMOD: Mode value must be between 0 and 0777");
- else if (chmod((char *) yyvsp[-1], yyvsp[-3]) < 0)
- perror_reply(550, (char *) yyvsp[-1]);
+ else if (chmod((char *) yystack.l_mark[-1], yystack.l_mark[-3]) < 0)
+ perror_reply(550, (char *) yystack.l_mark[-1]);
else
reply(200, "CHMOD command successful.");
}
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 39:
-#line 380 "ftp.y"
- {
+#line 413 "ftp.y"
+ {
reply(200,
"Current IDLE time limit is %d seconds; max %d",
timeout, maxtimeout);
}
break;
case 40:
-#line 386 "ftp.y"
- {
- if (yyvsp[-1] < 30 || yyvsp[-1] > maxtimeout) {
+#line 419 "ftp.y"
+ {
+ if (yystack.l_mark[-1] < 30 || yystack.l_mark[-1] > maxtimeout) {
reply(501,
"Maximum IDLE time must be between 30 and %d seconds",
maxtimeout);
} else {
- timeout = yyvsp[-1];
+ timeout = yystack.l_mark[-1];
(void) alarm((unsigned) timeout);
reply(200,
"Maximum IDLE time set to %d seconds",
}
break;
case 41:
-#line 400 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- store((char *) yyvsp[-1], "w", 1);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 433 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ store((char *) yystack.l_mark[-1], "w", 1);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 42:
-#line 407 "ftp.y"
- {
+#line 440 "ftp.y"
+ {
#ifdef unix
#ifdef BSD
reply(215, "UNIX Type: L%d Version: BSD-%d",
}
break;
case 43:
-#line 428 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL)
- sizecmd((char *) yyvsp[-1]);
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+#line 461 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ sizecmd((char *) yystack.l_mark[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 44:
-#line 445 "ftp.y"
- {
- if (yyvsp[-3] && yyvsp[-1] != NULL) {
+#line 478 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0) {
struct stat stbuf;
- if (stat((char *) yyvsp[-1], &stbuf) < 0)
- perror_reply(550, "%s", (char *) yyvsp[-1]);
+ if (stat((char *) yystack.l_mark[-1], &stbuf) < 0)
+ perror_reply(550, "%s", (char *) yystack.l_mark[-1]);
else if ((stbuf.st_mode&S_IFMT) != S_IFREG) {
reply(550, "%s: not a plain file.",
- (char *) yyvsp[-1]);
+ (char *) yystack.l_mark[-1]);
} else {
register struct tm *t;
- struct tm *gmtime();
t = gmtime(&stbuf.st_mtime);
reply(213,
"%04d%02d%02d%02d%02d%02d",
t->tm_hour, t->tm_min, t->tm_sec);
}
}
- if (yyvsp[-1] != NULL)
- free((char *) yyvsp[-1]);
+ if (yystack.l_mark[-1] != 0)
+ free((char *) yystack.l_mark[-1]);
}
break;
case 45:
-#line 467 "ftp.y"
- {
+#line 500 "ftp.y"
+ {
reply(221, "Goodbye.");
dologout(0);
}
break;
case 46:
-#line 472 "ftp.y"
- {
+#line 505 "ftp.y"
+ {
yyerrok;
}
break;
case 47:
-#line 477 "ftp.y"
- {
- char *renamefrom();
-
- if (yyvsp[-3] && yyvsp[-1]) {
- fromname = renamefrom((char *) yyvsp[-1]);
- if (fromname == (char *) 0 && yyvsp[-1]) {
- free((char *) yyvsp[-1]);
+#line 510 "ftp.y"
+ {
+ if (yystack.l_mark[-3] && yystack.l_mark[-1]) {
+ fromname = renamefrom((char *) yystack.l_mark[-1]);
+ if (fromname == (char *) 0 && yystack.l_mark[-1]) {
+ free((char *) yystack.l_mark[-1]);
}
}
}
break;
case 49:
-#line 493 "ftp.y"
- {
- *(char **)&(yyval) = "";
+#line 524 "ftp.y"
+ {
+ *(const char **)(&(yyval)) = "";
}
break;
case 52:
-#line 504 "ftp.y"
- {
+#line 535 "ftp.y"
+ {
register char *a, *p;
a = (char *)&data_dest.sin_addr;
- a[0] = yyvsp[-10]; a[1] = yyvsp[-8]; a[2] = yyvsp[-6]; a[3] = yyvsp[-4];
+ a[0] = yystack.l_mark[-10]; a[1] = yystack.l_mark[-8]; a[2] = yystack.l_mark[-6]; a[3] = yystack.l_mark[-4];
p = (char *)&data_dest.sin_port;
- p[0] = yyvsp[-2]; p[1] = yyvsp[0];
+ p[0] = yystack.l_mark[-2]; p[1] = yystack.l_mark[0];
data_dest.sin_family = AF_INET;
}
break;
case 53:
-#line 516 "ftp.y"
- {
+#line 547 "ftp.y"
+ {
yyval = FORM_N;
}
break;
case 54:
-#line 520 "ftp.y"
- {
+#line 551 "ftp.y"
+ {
yyval = FORM_T;
}
break;
case 55:
-#line 524 "ftp.y"
- {
+#line 555 "ftp.y"
+ {
yyval = FORM_C;
}
break;
case 56:
-#line 530 "ftp.y"
- {
+#line 561 "ftp.y"
+ {
cmd_type = TYPE_A;
cmd_form = FORM_N;
}
break;
case 57:
-#line 535 "ftp.y"
- {
+#line 566 "ftp.y"
+ {
cmd_type = TYPE_A;
- cmd_form = yyvsp[0];
+ cmd_form = yystack.l_mark[0];
}
break;
case 58:
-#line 540 "ftp.y"
- {
+#line 571 "ftp.y"
+ {
cmd_type = TYPE_E;
cmd_form = FORM_N;
}
break;
case 59:
-#line 545 "ftp.y"
- {
+#line 576 "ftp.y"
+ {
cmd_type = TYPE_E;
- cmd_form = yyvsp[0];
+ cmd_form = yystack.l_mark[0];
}
break;
case 60:
-#line 550 "ftp.y"
- {
+#line 581 "ftp.y"
+ {
cmd_type = TYPE_I;
}
break;
case 61:
-#line 554 "ftp.y"
- {
+#line 585 "ftp.y"
+ {
cmd_type = TYPE_L;
cmd_bytesz = NBBY;
}
break;
case 62:
-#line 559 "ftp.y"
- {
+#line 590 "ftp.y"
+ {
cmd_type = TYPE_L;
- cmd_bytesz = yyvsp[0];
+ cmd_bytesz = yystack.l_mark[0];
}
break;
case 63:
-#line 565 "ftp.y"
- {
+#line 596 "ftp.y"
+ {
cmd_type = TYPE_L;
- cmd_bytesz = yyvsp[0];
+ cmd_bytesz = yystack.l_mark[0];
}
break;
case 64:
-#line 572 "ftp.y"
- {
+#line 603 "ftp.y"
+ {
yyval = STRU_F;
}
break;
case 65:
-#line 576 "ftp.y"
- {
+#line 607 "ftp.y"
+ {
yyval = STRU_R;
}
break;
case 66:
-#line 580 "ftp.y"
- {
+#line 611 "ftp.y"
+ {
yyval = STRU_P;
}
break;
case 67:
-#line 586 "ftp.y"
- {
+#line 617 "ftp.y"
+ {
yyval = MODE_S;
}
break;
case 68:
-#line 590 "ftp.y"
- {
+#line 621 "ftp.y"
+ {
yyval = MODE_B;
}
break;
case 69:
-#line 594 "ftp.y"
- {
+#line 625 "ftp.y"
+ {
yyval = MODE_C;
}
break;
case 70:
-#line 600 "ftp.y"
- {
+#line 631 "ftp.y"
+ {
/*
* Problem: this production is used for all pathname
* processing, but only gives a 550 error reply.
* This is a valid reply in some cases but not in others.
*/
- if (logged_in && yyvsp[0] && strncmp((char *) yyvsp[0], "~", 1) == 0) {
- *(char **)&(yyval) = *glob((char *) yyvsp[0]);
- if (globerr != NULL) {
+ if (logged_in && yystack.l_mark[0] && strncmp((char *) yystack.l_mark[0], "~", 1) == 0) {
+ *(char **)&(yyval) = *glob((char *) yystack.l_mark[0]);
+ if (globerr != 0) {
reply(550, globerr);
- yyval = NULL;
+ yyval = 0;
}
- free((char *) yyvsp[0]);
+ free((char *) yystack.l_mark[0]);
} else
- yyval = yyvsp[0];
+ yyval = yystack.l_mark[0];
}
break;
case 72:
-#line 622 "ftp.y"
- {
+#line 653 "ftp.y"
+ {
register int ret, dec, multby, digit;
/*
* Convert a number that was read as decimal number
* to what it would be if it had been read as octal.
*/
- dec = yyvsp[0];
+ dec = yystack.l_mark[0];
multby = 1;
ret = 0;
while (dec) {
}
break;
case 73:
-#line 647 "ftp.y"
- {
+#line 678 "ftp.y"
+ {
if (logged_in)
yyval = 1;
else {
}
}
break;
-#line 1688 "ftp.tab.c"
+#line 1922 "ftp.tab.c"
}
- yyssp -= yym;
- yystate = *yyssp;
- yyvsp -= yym;
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
- *++yyssp = YYFINAL;
- *++yyvsp = yyval;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
if (yychar < 0)
{
- if ((yychar = yylex()) < 0) yychar = 0;
+ if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
-to state %d\n", YYPREFIX, *yyssp, yystate);
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
- if (yyssp >= yyss + yystacksize - 1)
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
- *++yyssp = yystate;
- *++yyvsp = yyval;
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
goto yyloop;
+
yyoverflow:
yyerror("yacc stack overflow");
+
yyabort:
+ yyfreestack(&yystack);
return (1);
+
yyaccept:
+ yyfreestack(&yystack);
return (0);
}
-/* $NetBSD: ftp.tab.h,v 1.2 1998/01/09 08:08:56 perry Exp $ */
+/* $NetBSD: ftp.tab.h,v 1.3 2011/09/10 21:29:04 christos Exp $ */
#define A 257
#define B 258
-/* $NetBSD: ftp.y,v 1.6 2001/01/04 23:05:57 lukem Exp $ */
+/* $NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $ */
/*
* Copyright (c) 1985, 1988 Regents of the University of California.
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* from: @(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89
- * $NetBSD: ftp.y,v 1.6 2001/01/04 23:05:57 lukem Exp $
+ * $NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $
*/
/*
%{
#ifndef lint
-/*static char sccsid[] = "from: @(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89";*/
-static char rcsid[] = "$NetBSD: ftp.y,v 1.6 2001/01/04 23:05:57 lukem Exp $";
+static char sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89";
+static char rcsid[] = "$NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <arpa/ftp.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <setjmp.h>
#include <syslog.h>
#include <sys/stat.h>
+#include <string.h>
#include <time.h>
+#include <assert.h>
extern struct sockaddr_in data_dest;
extern int logged_in;
extern int usedefault;
extern int transflag;
extern char tmpline[];
-char **glob();
+
+extern char **glob(char *);
+extern char *renamefrom(char *);
+extern void cwd(const char *);
+
+extern void dologout(int);
+extern void fatal(const char *);
+extern void makedir(const char *);
+extern void nack(const char *);
+extern void pass(const char *);
+extern void passive(void);
+extern void pwd(void);
+extern void removedir(char *);
+extern void renamecmd(char *, char *);
+extern void retrieve(const char *, const char *);
+extern void send_file_list(const char *);
+extern void statcmd(void);
+extern void statfilecmd(const char *);
+extern void store(char *, const char *, int);
+extern void user(const char *);
+
+extern void perror_reply(int, const char *, ...);
+extern void reply(int, const char *, ...);
+extern void lreply(int, const char *, ...);
static int cmd_type;
static int cmd_form;
char cbuf[512];
char *fromname;
-char *index();
+
+
+static char * copy(const char *);
+
+static void
+yyerror(const char *msg)
+{
+ perror(msg);
+}
%}
%token
}
| RETR check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
retrieve((char *) 0, (char *) $4);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| STOR check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
store((char *) $4, "w", 0);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| APPE check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
store((char *) $4, "a", 0);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| NLST check_login CRLF
}
| NLST check_login SP STRING CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
send_file_list((char *) $4);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| LIST check_login CRLF
}
| LIST check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
retrieve("/bin/ls -lgA %s", (char *) $4);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| STAT check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
statfilecmd((char *) $4);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| STAT CRLF
}
| DELE check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
- delete((char *) $4);
- if ($4 != NULL)
+ if ($2 && $4 != 0)
+ remove((char *) $4);
+ if ($4 != 0)
free((char *) $4);
}
| RNTO SP pathname CRLF
}
| CWD check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
cwd((char *) $4);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| HELP CRLF
}
| MKD check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
makedir((char *) $4);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| RMD check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
removedir((char *) $4);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| PWD check_login CRLF
}
| SITE SP CHMOD check_login SP octal_number SP pathname CRLF
= {
- if ($4 && ($8 != NULL)) {
+ if ($4 && ($8 != 0)) {
if ($6 > 0777)
reply(501,
"CHMOD: Mode value must be between 0 and 0777");
else
reply(200, "CHMOD command successful.");
}
- if ($8 != NULL)
+ if ($8 != 0)
free((char *) $8);
}
| SITE SP IDLE CRLF
}
| STOU check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
store((char *) $4, "w", 1);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| SYST CRLF
*/
| SIZE check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL)
+ if ($2 && $4 != 0)
sizecmd((char *) $4);
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
*/
| MDTM check_login SP pathname CRLF
= {
- if ($2 && $4 != NULL) {
+ if ($2 && $4 != 0) {
struct stat stbuf;
if (stat((char *) $4, &stbuf) < 0)
perror_reply(550, "%s", (char *) $4);
(char *) $4);
} else {
register struct tm *t;
- struct tm *gmtime();
t = gmtime(&stbuf.st_mtime);
reply(213,
"%04d%02d%02d%02d%02d%02d",
t->tm_hour, t->tm_min, t->tm_sec);
}
}
- if ($4 != NULL)
+ if ($4 != 0)
free((char *) $4);
}
| QUIT CRLF
;
rcmd: RNFR check_login SP pathname CRLF
= {
- char *renamefrom();
-
if ($2 && $4) {
fromname = renamefrom((char *) $4);
if (fromname == (char *) 0 && $4) {
}
}
;
-
+
username: STRING
;
password: /* empty */
= {
- *(char **)&($$) = "";
+ *(const char **)(&($$)) = "";
}
| STRING
;
byte_size: NUMBER
;
-host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
+host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
NUMBER COMMA NUMBER
= {
register char *a, *p;
*/
if (logged_in && $1 && strncmp((char *) $1, "~", 1) == 0) {
*(char **)&($$) = *glob((char *) $1);
- if (globerr != NULL) {
+ if (globerr != 0) {
reply(550, globerr);
- $$ = NULL;
+ $$ = 0;
}
free((char *) $1);
} else
%%
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
extern jmp_buf errcatch;
+static void upper(char *);
+
#define CMD 0 /* beginning of command */
#define ARGS 1 /* expect miscellaneous arguments */
#define STR1 2 /* expect SP followed by STRING */
#define NSTR 8 /* Number followed by a string */
struct tab {
- char *name;
+ const char *name;
short token;
short state;
short implemented; /* 1 if command is implemented */
- char *help;
+ const char *help;
};
struct tab cmdtab[] = { /* In order defined in RFC 765 */
{ "STOU", STOU, STR1, 1, "<sp> file-name" },
{ "SIZE", SIZE, OSTR, 1, "<sp> path-name" },
{ "MDTM", MDTM, OSTR, 1, "<sp> path-name" },
- { NULL, 0, 0, 0, 0 }
+ { 0, 0, 0, 0, 0 }
};
struct tab sitetab[] = {
{ "IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]" },
{ "CHMOD", CHMOD, NSTR, 1, "<sp> mode <sp> file-name" },
{ "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
- { NULL, 0, 0, 0, 0 }
+ { 0, 0, 0, 0, 0 }
};
-struct tab *
-lookup(p, cmd)
- register struct tab *p;
- char *cmd;
+static struct tab *
+lookup(struct tab *p, char *cmd)
{
- for (; p->name != NULL; p++)
+ for (; p->name != 0; p++)
if (strcmp(cmd, p->name) == 0)
return (p);
return (0);
#include <arpa/telnet.h>
/*
- * getline - a hacked up version of fgets to ignore TELNET escape codes.
+ * get_line - a hacked up version of fgets to ignore TELNET escape codes.
*/
-char *
-getline(s, n, iop)
- char *s;
- register FILE *iop;
+static char *
+get_line(char *s, int n, FILE *iop)
{
- register c;
+ register int c;
register char *cs;
cs = s;
for (c = 0; tmpline[c] != '\0' && --n > 0; ++c) {
*cs++ = tmpline[c];
if (tmpline[c] == '\n') {
- *cs++ = '\0';
+ *cs = '\0';
if (debug)
syslog(LOG_DEBUG, "command: %s", s);
tmpline[0] = '\0';
break;
}
if (c == EOF && cs == s)
- return (NULL);
- *cs++ = '\0';
+ return (0);
+ *cs = '\0';
if (debug)
syslog(LOG_DEBUG, "command: %s", s);
return (s);
}
-static int
-toolong()
+static void
+toolong(int sig)
{
time_t now;
- extern char *ctime();
- extern time_t time();
+ (void) sig;
reply(421,
"Timeout (%d seconds): closing control connection.", timeout);
(void) time(&now);
dologout(1);
}
-yylex()
+int
+yylex(void)
{
static int cpos, state;
register char *cp, *cp2;
register struct tab *p;
int n;
- char c, *strpbrk();
- char *copy();
+ char c;
for (;;) {
switch (state) {
case CMD:
(void) signal(SIGALRM, toolong);
(void) alarm((unsigned) timeout);
- if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) {
+ if (get_line(cbuf, sizeof(cbuf)-1, stdin) == 0) {
reply(221, "You could at least say goodbye.");
dologout(0);
}
(void) alarm(0);
#ifdef SETPROCTITLE
- if (strncasecmp(cbuf, "PASS", 4) != NULL)
+ if (strncasecmp(cbuf, "PASS", 4) != 0)
setproctitle("%s: %s", proctitle, cbuf);
#endif /* SETPROCTITLE */
- if ((cp = index(cbuf, '\r'))) {
+ if ((cp = strchr(cbuf, '\r'))) {
*cp++ = '\n';
*cp = '\0';
}
/* NOTREACHED */
}
state = p->state;
- *(char **)&yylval = p->name;
+ *(const char **)(&yylval) = p->name;
return (p->token);
}
break;
/* NOTREACHED */
}
state = p->state;
- *(char **)&yylval = p->name;
+ *(const char **)(&yylval) = p->name;
return (p->token);
}
state = CMD;
dostr1:
if (cbuf[cpos] == ' ') {
cpos++;
- state = state == OSTR ? STR2 : ++state;
+ if (state == OSTR)
+ state = STR2;
+ else
+ ++state;
return (SP);
}
break;
}
}
-upper(s)
- register char *s;
+static void
+upper(char *s)
{
while (*s != '\0') {
if (islower(*s))
}
}
-char *
-copy(s)
- char *s;
+static char *
+copy(const char *s)
{
char *p;
- extern char *malloc(), *strcpy();
- p = malloc((unsigned) strlen(s) + 1);
- if (p == NULL)
+ p = (char * )malloc(strlen(s) + 1);
+ if (p == 0)
fatal("Ran out of memory.");
- (void) strcpy(p, s);
+ else
+ (void) strcpy(p, s);
return (p);
}
-help(ctab, s)
- struct tab *ctab;
- char *s;
+static void
+help(struct tab *ctab, char *s)
{
register struct tab *c;
register int width, NCMDS;
- char *type;
+ const char *help_type;
if (ctab == sitetab)
- type = "SITE ";
+ help_type = "SITE ";
else
- type = "";
+ help_type = "";
width = 0, NCMDS = 0;
- for (c = ctab; c->name != NULL; c++) {
+ for (c = ctab; c->name != 0; c++) {
int len = strlen(c->name);
if (len > width)
int columns, lines;
lreply(214, "The following %scommands are recognized %s.",
- type, "(* =>'s unimplemented)");
+ help_type, "(* =>'s unimplemented)");
columns = 76 / width;
if (columns == 0)
columns = 1;
printf(" ");
for (j = 0; j < columns; j++) {
c = ctab + j * lines + i;
+ assert(c->name != 0);
printf("%s%c", c->name,
c->implemented ? ' ' : '*');
if (c + lines >= &ctab[NCMDS])
return;
}
if (c->implemented)
- reply(214, "Syntax: %s%s %s", type, c->name, c->help);
+ reply(214, "Syntax: %s%s %s", help_type, c->name, c->help);
else
- reply(214, "%s%-*s\t%s; unimplemented.", type, width,
+ reply(214, "%s%-*s\t%s; unimplemented.", help_type, width,
c->name, c->help);
}
-sizecmd(filename)
-char *filename;
+static void
+sizecmd(char *filename)
{
switch (type) {
case TYPE_L:
(stbuf.st_mode&S_IFMT) != S_IFREG)
reply(550, "%s: not a plain file.", filename);
else
- reply(213, "%llu", (long long)stbuf.st_size);
+#ifdef HAVE_LONG_LONG
+ reply(213, "%llu", (long long) stbuf.st_size);
+#else
+ reply(213, "%lu", stbuf.st_size);
+#endif
break;}
case TYPE_A: {
FILE *fin;
register int c, count;
struct stat stbuf;
fin = fopen(filename, "r");
- if (fin == NULL) {
+ if (fin == 0) {
perror_reply(550, filename);
return;
}
--- /dev/null
+ 0 $accept : program $end
+
+ 1 program :
+ 2 | translation_unit
+
+ 3 translation_unit : external_declaration
+ 4 | translation_unit external_declaration
+
+ 5 external_declaration : declaration
+ 6 | function_definition
+ 7 | ';'
+ 8 | linkage_specification
+ 9 | T_ASM T_ASMARG ';'
+ 10 | error T_MATCHRBRACE
+ 11 | error ';'
+
+ 12 braces : T_LBRACE T_MATCHRBRACE
+
+ 13 linkage_specification : T_EXTERN T_STRING_LITERAL braces
+ 14 | T_EXTERN T_STRING_LITERAL declaration
+
+ 15 declaration : decl_specifiers ';'
+ 16 | decl_specifiers init_declarator_list ';'
+
+ 17 $$1 :
+
+ 18 declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'
+
+ 19 any_typedef : T_EXTENSION T_TYPEDEF
+ 20 | T_TYPEDEF
+
+ 21 opt_declarator_list :
+ 22 | declarator_list
+
+ 23 declarator_list : declarator
+ 24 | declarator_list ',' declarator
+
+ 25 $$2 :
+
+ 26 $$3 :
+
+ 27 function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE
+
+ 28 $$4 :
+
+ 29 function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE
+
+ 30 opt_declaration_list :
+ 31 | T_VA_DCL
+ 32 | declaration_list
+
+ 33 declaration_list : declaration
+ 34 | declaration_list declaration
+
+ 35 decl_specifiers : decl_specifier
+ 36 | decl_specifiers decl_specifier
+
+ 37 decl_specifier : storage_class
+ 38 | type_specifier
+ 39 | type_qualifier
+
+ 40 storage_class : T_AUTO
+ 41 | T_EXTERN
+ 42 | T_REGISTER
+ 43 | T_STATIC
+ 44 | T_INLINE
+ 45 | T_EXTENSION
+
+ 46 type_specifier : T_CHAR
+ 47 | T_DOUBLE
+ 48 | T_FLOAT
+ 49 | T_INT
+ 50 | T_LONG
+ 51 | T_SHORT
+ 52 | T_SIGNED
+ 53 | T_UNSIGNED
+ 54 | T_VOID
+ 55 | T_Bool
+ 56 | T_Complex
+ 57 | T_Imaginary
+ 58 | T_TYPEDEF_NAME
+ 59 | struct_or_union_specifier
+ 60 | enum_specifier
+
+ 61 type_qualifier : T_TYPE_QUALIFIER
+ 62 | T_DEFINE_NAME
+
+ 63 struct_or_union_specifier : struct_or_union any_id braces
+ 64 | struct_or_union braces
+ 65 | struct_or_union any_id
+
+ 66 struct_or_union : T_STRUCT
+ 67 | T_UNION
+
+ 68 init_declarator_list : init_declarator
+ 69 | init_declarator_list ',' init_declarator
+
+ 70 init_declarator : declarator
+
+ 71 $$5 :
+
+ 72 init_declarator : declarator '=' $$5 T_INITIALIZER
+
+ 73 enum_specifier : enumeration any_id braces
+ 74 | enumeration braces
+ 75 | enumeration any_id
+
+ 76 enumeration : T_ENUM
+
+ 77 any_id : T_IDENTIFIER
+ 78 | T_TYPEDEF_NAME
+
+ 79 declarator : pointer direct_declarator
+ 80 | direct_declarator
+
+ 81 direct_declarator : identifier_or_ref
+ 82 | '(' declarator ')'
+ 83 | direct_declarator T_BRACKETS
+ 84 | direct_declarator '(' parameter_type_list ')'
+ 85 | direct_declarator '(' opt_identifier_list ')'
+
+ 86 pointer : '*' opt_type_qualifiers
+ 87 | '*' opt_type_qualifiers pointer
+
+ 88 opt_type_qualifiers :
+ 89 | type_qualifier_list
+
+ 90 type_qualifier_list : type_qualifier
+ 91 | type_qualifier_list type_qualifier
+
+ 92 parameter_type_list : parameter_list
+ 93 | parameter_list ',' T_ELLIPSIS
+
+ 94 parameter_list : parameter_declaration
+ 95 | parameter_list ',' parameter_declaration
+
+ 96 parameter_declaration : decl_specifiers declarator
+ 97 | decl_specifiers abs_declarator
+ 98 | decl_specifiers
+
+ 99 opt_identifier_list :
+ 100 | identifier_list
+
+ 101 identifier_list : any_id
+ 102 | identifier_list ',' any_id
+
+ 103 identifier_or_ref : any_id
+ 104 | '&' any_id
+
+ 105 abs_declarator : pointer
+ 106 | pointer direct_abs_declarator
+ 107 | direct_abs_declarator
+
+ 108 direct_abs_declarator : '(' abs_declarator ')'
+ 109 | direct_abs_declarator T_BRACKETS
+ 110 | T_BRACKETS
+ 111 | direct_abs_declarator '(' parameter_type_list ')'
+ 112 | direct_abs_declarator '(' ')'
+ 113 | '(' parameter_type_list ')'
+ 114 | '(' ')'
+\f
+state 0
+ $accept : . program $end (0)
+ program : . (1)
+
+ error shift 1
+ '(' shift 2
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 6
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 9
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_TYPEDEF shift 12
+ T_INLINE shift 13
+ T_EXTENSION shift 14
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_ASM shift 31
+ ';' shift 32
+ $end reduce 1
+
+ program goto 33
+ decl_specifiers goto 34
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ declarator goto 41
+ direct_declarator goto 42
+ struct_or_union goto 43
+ pointer goto 44
+ any_id goto 45
+ identifier_or_ref goto 46
+ enumeration goto 47
+ translation_unit goto 48
+ external_declaration goto 49
+ declaration goto 50
+ function_definition goto 51
+ linkage_specification goto 52
+ any_typedef goto 53
+
+
+state 1
+ external_declaration : error . T_MATCHRBRACE (10)
+ external_declaration : error . ';' (11)
+
+ T_MATCHRBRACE shift 54
+ ';' shift 55
+ . error
+
+
+state 2
+ direct_declarator : '(' . declarator ')' (82)
+
+ '(' shift 2
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ . error
+
+ declarator goto 57
+ direct_declarator goto 42
+ pointer goto 44
+ any_id goto 45
+ identifier_or_ref goto 46
+
+
+state 3
+ pointer : '*' . opt_type_qualifiers (86)
+ pointer : '*' . opt_type_qualifiers pointer (87)
+ opt_type_qualifiers : . (88)
+
+ T_DEFINE_NAME shift 7
+ T_TYPE_QUALIFIER shift 30
+ '(' reduce 88
+ '*' reduce 88
+ '&' reduce 88
+ T_IDENTIFIER reduce 88
+ T_TYPEDEF_NAME reduce 88
+ T_BRACKETS reduce 88
+ ',' reduce 88
+ ')' reduce 88
+
+ type_qualifier goto 58
+ opt_type_qualifiers goto 59
+ type_qualifier_list goto 60
+
+
+state 4
+ identifier_or_ref : '&' . any_id (104)
+
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ . error
+
+ any_id goto 61
+
+
+state 5
+ any_id : T_IDENTIFIER . (77)
+
+ . reduce 77
+
+
+6: reduce/reduce conflict (reduce 58, reduce 78) on '('
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_TYPEDEF_NAME
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_DEFINE_NAME
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_AUTO
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_EXTERN
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_REGISTER
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_STATIC
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_INLINE
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_EXTENSION
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_CHAR
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_DOUBLE
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_FLOAT
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_INT
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_VOID
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_LONG
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_SHORT
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_SIGNED
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_UNSIGNED
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_ENUM
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_STRUCT
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_UNION
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_Bool
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_Complex
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_Imaginary
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_TYPE_QUALIFIER
+6: reduce/reduce conflict (reduce 58, reduce 78) on T_BRACKETS
+6: reduce/reduce conflict (reduce 58, reduce 78) on ';'
+6: reduce/reduce conflict (reduce 58, reduce 78) on ','
+6: reduce/reduce conflict (reduce 58, reduce 78) on ')'
+state 6
+ type_specifier : T_TYPEDEF_NAME . (58)
+ any_id : T_TYPEDEF_NAME . (78)
+
+ '(' reduce 58
+ '*' reduce 58
+ '&' reduce 58
+ T_IDENTIFIER reduce 58
+ T_TYPEDEF_NAME reduce 58
+ T_DEFINE_NAME reduce 58
+ T_AUTO reduce 58
+ T_EXTERN reduce 58
+ T_REGISTER reduce 58
+ T_STATIC reduce 58
+ T_TYPEDEF reduce 78
+ T_INLINE reduce 58
+ T_EXTENSION reduce 58
+ T_CHAR reduce 58
+ T_DOUBLE reduce 58
+ T_FLOAT reduce 58
+ T_INT reduce 58
+ T_VOID reduce 58
+ T_LONG reduce 58
+ T_SHORT reduce 58
+ T_SIGNED reduce 58
+ T_UNSIGNED reduce 58
+ T_ENUM reduce 58
+ T_STRUCT reduce 58
+ T_UNION reduce 58
+ T_Bool reduce 58
+ T_Complex reduce 58
+ T_Imaginary reduce 58
+ T_TYPE_QUALIFIER reduce 58
+ T_BRACKETS reduce 58
+ T_LBRACE reduce 78
+ T_VA_DCL reduce 78
+ ';' reduce 58
+ ',' reduce 58
+ '=' reduce 78
+ ')' reduce 58
+
+
+state 7
+ type_qualifier : T_DEFINE_NAME . (62)
+
+ . reduce 62
+
+
+state 8
+ storage_class : T_AUTO . (40)
+
+ . reduce 40
+
+
+state 9
+ linkage_specification : T_EXTERN . T_STRING_LITERAL braces (13)
+ linkage_specification : T_EXTERN . T_STRING_LITERAL declaration (14)
+ storage_class : T_EXTERN . (41)
+
+ T_STRING_LITERAL shift 62
+ '(' reduce 41
+ '*' reduce 41
+ '&' reduce 41
+ T_IDENTIFIER reduce 41
+ T_TYPEDEF_NAME reduce 41
+ T_DEFINE_NAME reduce 41
+ T_AUTO reduce 41
+ T_EXTERN reduce 41
+ T_REGISTER reduce 41
+ T_STATIC reduce 41
+ T_INLINE reduce 41
+ T_EXTENSION reduce 41
+ T_CHAR reduce 41
+ T_DOUBLE reduce 41
+ T_FLOAT reduce 41
+ T_INT reduce 41
+ T_VOID reduce 41
+ T_LONG reduce 41
+ T_SHORT reduce 41
+ T_SIGNED reduce 41
+ T_UNSIGNED reduce 41
+ T_ENUM reduce 41
+ T_STRUCT reduce 41
+ T_UNION reduce 41
+ T_Bool reduce 41
+ T_Complex reduce 41
+ T_Imaginary reduce 41
+ T_TYPE_QUALIFIER reduce 41
+ ';' reduce 41
+
+
+state 10
+ storage_class : T_REGISTER . (42)
+
+ . reduce 42
+
+
+state 11
+ storage_class : T_STATIC . (43)
+
+ . reduce 43
+
+
+state 12
+ any_typedef : T_TYPEDEF . (20)
+
+ . reduce 20
+
+
+state 13
+ storage_class : T_INLINE . (44)
+
+ . reduce 44
+
+
+state 14
+ any_typedef : T_EXTENSION . T_TYPEDEF (19)
+ storage_class : T_EXTENSION . (45)
+
+ T_TYPEDEF shift 63
+ '(' reduce 45
+ '*' reduce 45
+ '&' reduce 45
+ T_IDENTIFIER reduce 45
+ T_TYPEDEF_NAME reduce 45
+ T_DEFINE_NAME reduce 45
+ T_AUTO reduce 45
+ T_EXTERN reduce 45
+ T_REGISTER reduce 45
+ T_STATIC reduce 45
+ T_INLINE reduce 45
+ T_EXTENSION reduce 45
+ T_CHAR reduce 45
+ T_DOUBLE reduce 45
+ T_FLOAT reduce 45
+ T_INT reduce 45
+ T_VOID reduce 45
+ T_LONG reduce 45
+ T_SHORT reduce 45
+ T_SIGNED reduce 45
+ T_UNSIGNED reduce 45
+ T_ENUM reduce 45
+ T_STRUCT reduce 45
+ T_UNION reduce 45
+ T_Bool reduce 45
+ T_Complex reduce 45
+ T_Imaginary reduce 45
+ T_TYPE_QUALIFIER reduce 45
+ ';' reduce 45
+
+
+state 15
+ type_specifier : T_CHAR . (46)
+
+ . reduce 46
+
+
+state 16
+ type_specifier : T_DOUBLE . (47)
+
+ . reduce 47
+
+
+state 17
+ type_specifier : T_FLOAT . (48)
+
+ . reduce 48
+
+
+state 18
+ type_specifier : T_INT . (49)
+
+ . reduce 49
+
+
+state 19
+ type_specifier : T_VOID . (54)
+
+ . reduce 54
+
+
+state 20
+ type_specifier : T_LONG . (50)
+
+ . reduce 50
+
+
+state 21
+ type_specifier : T_SHORT . (51)
+
+ . reduce 51
+
+
+state 22
+ type_specifier : T_SIGNED . (52)
+
+ . reduce 52
+
+
+state 23
+ type_specifier : T_UNSIGNED . (53)
+
+ . reduce 53
+
+
+state 24
+ enumeration : T_ENUM . (76)
+
+ . reduce 76
+
+
+state 25
+ struct_or_union : T_STRUCT . (66)
+
+ . reduce 66
+
+
+state 26
+ struct_or_union : T_UNION . (67)
+
+ . reduce 67
+
+
+state 27
+ type_specifier : T_Bool . (55)
+
+ . reduce 55
+
+
+state 28
+ type_specifier : T_Complex . (56)
+
+ . reduce 56
+
+
+state 29
+ type_specifier : T_Imaginary . (57)
+
+ . reduce 57
+
+
+state 30
+ type_qualifier : T_TYPE_QUALIFIER . (61)
+
+ . reduce 61
+
+
+state 31
+ external_declaration : T_ASM . T_ASMARG ';' (9)
+
+ T_ASMARG shift 64
+ . error
+
+
+state 32
+ external_declaration : ';' . (7)
+
+ . reduce 7
+
+
+state 33
+ $accept : program . $end (0)
+
+ $end accept
+
+
+state 34
+ declaration : decl_specifiers . ';' (15)
+ declaration : decl_specifiers . init_declarator_list ';' (16)
+ function_definition : decl_specifiers . declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE (27)
+ decl_specifiers : decl_specifiers . decl_specifier (36)
+
+ '(' shift 2
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 6
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ ';' shift 67
+ . error
+
+ decl_specifier goto 68
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ init_declarator_list goto 69
+ init_declarator goto 70
+ declarator goto 71
+ direct_declarator goto 42
+ struct_or_union goto 43
+ pointer goto 44
+ any_id goto 45
+ identifier_or_ref goto 46
+ enumeration goto 47
+
+
+state 35
+ decl_specifiers : decl_specifier . (35)
+
+ . reduce 35
+
+
+state 36
+ decl_specifier : storage_class . (37)
+
+ . reduce 37
+
+
+state 37
+ decl_specifier : type_specifier . (38)
+
+ . reduce 38
+
+
+state 38
+ decl_specifier : type_qualifier . (39)
+
+ . reduce 39
+
+
+state 39
+ type_specifier : struct_or_union_specifier . (59)
+
+ . reduce 59
+
+
+state 40
+ type_specifier : enum_specifier . (60)
+
+ . reduce 60
+
+
+state 41
+ function_definition : declarator . $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE (29)
+ $$4 : . (28)
+
+ . reduce 28
+
+ $$4 goto 72
+
+
+state 42
+ declarator : direct_declarator . (80)
+ direct_declarator : direct_declarator . T_BRACKETS (83)
+ direct_declarator : direct_declarator . '(' parameter_type_list ')' (84)
+ direct_declarator : direct_declarator . '(' opt_identifier_list ')' (85)
+
+ '(' shift 73
+ T_BRACKETS shift 74
+ T_TYPEDEF_NAME reduce 80
+ T_DEFINE_NAME reduce 80
+ T_AUTO reduce 80
+ T_EXTERN reduce 80
+ T_REGISTER reduce 80
+ T_STATIC reduce 80
+ T_TYPEDEF reduce 80
+ T_INLINE reduce 80
+ T_EXTENSION reduce 80
+ T_CHAR reduce 80
+ T_DOUBLE reduce 80
+ T_FLOAT reduce 80
+ T_INT reduce 80
+ T_VOID reduce 80
+ T_LONG reduce 80
+ T_SHORT reduce 80
+ T_SIGNED reduce 80
+ T_UNSIGNED reduce 80
+ T_ENUM reduce 80
+ T_STRUCT reduce 80
+ T_UNION reduce 80
+ T_Bool reduce 80
+ T_Complex reduce 80
+ T_Imaginary reduce 80
+ T_TYPE_QUALIFIER reduce 80
+ T_LBRACE reduce 80
+ T_VA_DCL reduce 80
+ ';' reduce 80
+ ',' reduce 80
+ '=' reduce 80
+ ')' reduce 80
+
+
+state 43
+ struct_or_union_specifier : struct_or_union . any_id braces (63)
+ struct_or_union_specifier : struct_or_union . braces (64)
+ struct_or_union_specifier : struct_or_union . any_id (65)
+
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ T_LBRACE shift 75
+ . error
+
+ any_id goto 76
+ braces goto 77
+
+
+state 44
+ declarator : pointer . direct_declarator (79)
+
+ '(' shift 2
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ . error
+
+ direct_declarator goto 78
+ any_id goto 45
+ identifier_or_ref goto 46
+
+
+state 45
+ identifier_or_ref : any_id . (103)
+
+ . reduce 103
+
+
+state 46
+ direct_declarator : identifier_or_ref . (81)
+
+ . reduce 81
+
+
+state 47
+ enum_specifier : enumeration . any_id braces (73)
+ enum_specifier : enumeration . braces (74)
+ enum_specifier : enumeration . any_id (75)
+
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ T_LBRACE shift 75
+ . error
+
+ any_id goto 79
+ braces goto 80
+
+
+state 48
+ program : translation_unit . (2)
+ translation_unit : translation_unit . external_declaration (4)
+
+ error shift 1
+ '(' shift 2
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 6
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 9
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_TYPEDEF shift 12
+ T_INLINE shift 13
+ T_EXTENSION shift 14
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_ASM shift 31
+ ';' shift 32
+ $end reduce 2
+
+ decl_specifiers goto 34
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ declarator goto 41
+ direct_declarator goto 42
+ struct_or_union goto 43
+ pointer goto 44
+ any_id goto 45
+ identifier_or_ref goto 46
+ enumeration goto 47
+ external_declaration goto 81
+ declaration goto 50
+ function_definition goto 51
+ linkage_specification goto 52
+ any_typedef goto 53
+
+
+state 49
+ translation_unit : external_declaration . (3)
+
+ . reduce 3
+
+
+state 50
+ external_declaration : declaration . (5)
+
+ . reduce 5
+
+
+state 51
+ external_declaration : function_definition . (6)
+
+ . reduce 6
+
+
+state 52
+ external_declaration : linkage_specification . (8)
+
+ . reduce 8
+
+
+state 53
+ declaration : any_typedef . decl_specifiers $$1 opt_declarator_list ';' (18)
+
+ T_TYPEDEF_NAME shift 82
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ . error
+
+ decl_specifiers goto 83
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ struct_or_union goto 43
+ enumeration goto 47
+
+
+state 54
+ external_declaration : error T_MATCHRBRACE . (10)
+
+ . reduce 10
+
+
+state 55
+ external_declaration : error ';' . (11)
+
+ . reduce 11
+
+
+state 56
+ any_id : T_TYPEDEF_NAME . (78)
+
+ . reduce 78
+
+
+state 57
+ direct_declarator : '(' declarator . ')' (82)
+
+ ')' shift 84
+ . error
+
+
+state 58
+ type_qualifier_list : type_qualifier . (90)
+
+ . reduce 90
+
+
+state 59
+ pointer : '*' opt_type_qualifiers . (86)
+ pointer : '*' opt_type_qualifiers . pointer (87)
+
+ '*' shift 3
+ '(' reduce 86
+ '&' reduce 86
+ T_IDENTIFIER reduce 86
+ T_TYPEDEF_NAME reduce 86
+ T_BRACKETS reduce 86
+ ',' reduce 86
+ ')' reduce 86
+
+ pointer goto 85
+
+
+state 60
+ opt_type_qualifiers : type_qualifier_list . (89)
+ type_qualifier_list : type_qualifier_list . type_qualifier (91)
+
+ T_DEFINE_NAME shift 7
+ T_TYPE_QUALIFIER shift 30
+ '(' reduce 89
+ '*' reduce 89
+ '&' reduce 89
+ T_IDENTIFIER reduce 89
+ T_TYPEDEF_NAME reduce 89
+ T_BRACKETS reduce 89
+ ',' reduce 89
+ ')' reduce 89
+
+ type_qualifier goto 86
+
+
+state 61
+ identifier_or_ref : '&' any_id . (104)
+
+ . reduce 104
+
+
+state 62
+ linkage_specification : T_EXTERN T_STRING_LITERAL . braces (13)
+ linkage_specification : T_EXTERN T_STRING_LITERAL . declaration (14)
+
+ T_TYPEDEF_NAME shift 82
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_TYPEDEF shift 12
+ T_INLINE shift 13
+ T_EXTENSION shift 14
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_LBRACE shift 75
+ . error
+
+ decl_specifiers goto 87
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ struct_or_union goto 43
+ enumeration goto 47
+ declaration goto 88
+ braces goto 89
+ any_typedef goto 53
+
+
+state 63
+ any_typedef : T_EXTENSION T_TYPEDEF . (19)
+
+ . reduce 19
+
+
+state 64
+ external_declaration : T_ASM T_ASMARG . ';' (9)
+
+ ';' shift 90
+ . error
+
+
+state 65
+ storage_class : T_EXTERN . (41)
+
+ . reduce 41
+
+
+state 66
+ storage_class : T_EXTENSION . (45)
+
+ . reduce 45
+
+
+state 67
+ declaration : decl_specifiers ';' . (15)
+
+ . reduce 15
+
+
+state 68
+ decl_specifiers : decl_specifiers decl_specifier . (36)
+
+ . reduce 36
+
+
+state 69
+ declaration : decl_specifiers init_declarator_list . ';' (16)
+ init_declarator_list : init_declarator_list . ',' init_declarator (69)
+
+ ';' shift 91
+ ',' shift 92
+ . error
+
+
+state 70
+ init_declarator_list : init_declarator . (68)
+
+ . reduce 68
+
+
+state 71
+ function_definition : decl_specifiers declarator . $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE (27)
+ init_declarator : declarator . (70)
+ init_declarator : declarator . '=' $$5 T_INITIALIZER (72)
+ $$2 : . (25)
+
+ '=' shift 93
+ T_TYPEDEF_NAME reduce 25
+ T_DEFINE_NAME reduce 25
+ T_AUTO reduce 25
+ T_EXTERN reduce 25
+ T_REGISTER reduce 25
+ T_STATIC reduce 25
+ T_TYPEDEF reduce 25
+ T_INLINE reduce 25
+ T_EXTENSION reduce 25
+ T_CHAR reduce 25
+ T_DOUBLE reduce 25
+ T_FLOAT reduce 25
+ T_INT reduce 25
+ T_VOID reduce 25
+ T_LONG reduce 25
+ T_SHORT reduce 25
+ T_SIGNED reduce 25
+ T_UNSIGNED reduce 25
+ T_ENUM reduce 25
+ T_STRUCT reduce 25
+ T_UNION reduce 25
+ T_Bool reduce 25
+ T_Complex reduce 25
+ T_Imaginary reduce 25
+ T_TYPE_QUALIFIER reduce 25
+ T_LBRACE reduce 25
+ T_VA_DCL reduce 25
+ ';' reduce 70
+ ',' reduce 70
+
+ $$2 goto 94
+
+
+state 72
+ function_definition : declarator $$4 . opt_declaration_list T_LBRACE T_MATCHRBRACE (29)
+ opt_declaration_list : . (30)
+
+ T_TYPEDEF_NAME shift 82
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_TYPEDEF shift 12
+ T_INLINE shift 13
+ T_EXTENSION shift 14
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_VA_DCL shift 95
+ T_LBRACE reduce 30
+
+ decl_specifiers goto 87
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ struct_or_union goto 43
+ enumeration goto 47
+ declaration goto 96
+ any_typedef goto 53
+ opt_declaration_list goto 97
+ declaration_list goto 98
+
+
+state 73
+ direct_declarator : direct_declarator '(' . parameter_type_list ')' (84)
+ direct_declarator : direct_declarator '(' . opt_identifier_list ')' (85)
+ opt_identifier_list : . (99)
+
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 6
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ ')' reduce 99
+
+ decl_specifiers goto 99
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ parameter_type_list goto 100
+ parameter_list goto 101
+ parameter_declaration goto 102
+ opt_identifier_list goto 103
+ identifier_list goto 104
+ struct_or_union goto 43
+ any_id goto 105
+ enumeration goto 47
+
+
+state 74
+ direct_declarator : direct_declarator T_BRACKETS . (83)
+
+ . reduce 83
+
+
+state 75
+ braces : T_LBRACE . T_MATCHRBRACE (12)
+
+ T_MATCHRBRACE shift 106
+ . error
+
+
+state 76
+ struct_or_union_specifier : struct_or_union any_id . braces (63)
+ struct_or_union_specifier : struct_or_union any_id . (65)
+
+ T_LBRACE shift 75
+ '(' reduce 65
+ '*' reduce 65
+ '&' reduce 65
+ T_IDENTIFIER reduce 65
+ T_TYPEDEF_NAME reduce 65
+ T_DEFINE_NAME reduce 65
+ T_AUTO reduce 65
+ T_EXTERN reduce 65
+ T_REGISTER reduce 65
+ T_STATIC reduce 65
+ T_INLINE reduce 65
+ T_EXTENSION reduce 65
+ T_CHAR reduce 65
+ T_DOUBLE reduce 65
+ T_FLOAT reduce 65
+ T_INT reduce 65
+ T_VOID reduce 65
+ T_LONG reduce 65
+ T_SHORT reduce 65
+ T_SIGNED reduce 65
+ T_UNSIGNED reduce 65
+ T_ENUM reduce 65
+ T_STRUCT reduce 65
+ T_UNION reduce 65
+ T_Bool reduce 65
+ T_Complex reduce 65
+ T_Imaginary reduce 65
+ T_TYPE_QUALIFIER reduce 65
+ T_BRACKETS reduce 65
+ ';' reduce 65
+ ',' reduce 65
+ ')' reduce 65
+
+ braces goto 107
+
+
+state 77
+ struct_or_union_specifier : struct_or_union braces . (64)
+
+ . reduce 64
+
+
+state 78
+ declarator : pointer direct_declarator . (79)
+ direct_declarator : direct_declarator . T_BRACKETS (83)
+ direct_declarator : direct_declarator . '(' parameter_type_list ')' (84)
+ direct_declarator : direct_declarator . '(' opt_identifier_list ')' (85)
+
+ '(' shift 73
+ T_BRACKETS shift 74
+ T_TYPEDEF_NAME reduce 79
+ T_DEFINE_NAME reduce 79
+ T_AUTO reduce 79
+ T_EXTERN reduce 79
+ T_REGISTER reduce 79
+ T_STATIC reduce 79
+ T_TYPEDEF reduce 79
+ T_INLINE reduce 79
+ T_EXTENSION reduce 79
+ T_CHAR reduce 79
+ T_DOUBLE reduce 79
+ T_FLOAT reduce 79
+ T_INT reduce 79
+ T_VOID reduce 79
+ T_LONG reduce 79
+ T_SHORT reduce 79
+ T_SIGNED reduce 79
+ T_UNSIGNED reduce 79
+ T_ENUM reduce 79
+ T_STRUCT reduce 79
+ T_UNION reduce 79
+ T_Bool reduce 79
+ T_Complex reduce 79
+ T_Imaginary reduce 79
+ T_TYPE_QUALIFIER reduce 79
+ T_LBRACE reduce 79
+ T_VA_DCL reduce 79
+ ';' reduce 79
+ ',' reduce 79
+ '=' reduce 79
+ ')' reduce 79
+
+
+state 79
+ enum_specifier : enumeration any_id . braces (73)
+ enum_specifier : enumeration any_id . (75)
+
+ T_LBRACE shift 75
+ '(' reduce 75
+ '*' reduce 75
+ '&' reduce 75
+ T_IDENTIFIER reduce 75
+ T_TYPEDEF_NAME reduce 75
+ T_DEFINE_NAME reduce 75
+ T_AUTO reduce 75
+ T_EXTERN reduce 75
+ T_REGISTER reduce 75
+ T_STATIC reduce 75
+ T_INLINE reduce 75
+ T_EXTENSION reduce 75
+ T_CHAR reduce 75
+ T_DOUBLE reduce 75
+ T_FLOAT reduce 75
+ T_INT reduce 75
+ T_VOID reduce 75
+ T_LONG reduce 75
+ T_SHORT reduce 75
+ T_SIGNED reduce 75
+ T_UNSIGNED reduce 75
+ T_ENUM reduce 75
+ T_STRUCT reduce 75
+ T_UNION reduce 75
+ T_Bool reduce 75
+ T_Complex reduce 75
+ T_Imaginary reduce 75
+ T_TYPE_QUALIFIER reduce 75
+ T_BRACKETS reduce 75
+ ';' reduce 75
+ ',' reduce 75
+ ')' reduce 75
+
+ braces goto 108
+
+
+state 80
+ enum_specifier : enumeration braces . (74)
+
+ . reduce 74
+
+
+state 81
+ translation_unit : translation_unit external_declaration . (4)
+
+ . reduce 4
+
+
+state 82
+ type_specifier : T_TYPEDEF_NAME . (58)
+
+ . reduce 58
+
+
+83: shift/reduce conflict (shift 82, reduce 17) on T_TYPEDEF_NAME
+state 83
+ declaration : any_typedef decl_specifiers . $$1 opt_declarator_list ';' (18)
+ decl_specifiers : decl_specifiers . decl_specifier (36)
+ $$1 : . (17)
+
+ T_TYPEDEF_NAME shift 82
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ '(' reduce 17
+ '*' reduce 17
+ '&' reduce 17
+ T_IDENTIFIER reduce 17
+ ';' reduce 17
+
+ decl_specifier goto 68
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ struct_or_union goto 43
+ enumeration goto 47
+ $$1 goto 109
+
+
+state 84
+ direct_declarator : '(' declarator ')' . (82)
+
+ . reduce 82
+
+
+state 85
+ pointer : '*' opt_type_qualifiers pointer . (87)
+
+ . reduce 87
+
+
+state 86
+ type_qualifier_list : type_qualifier_list type_qualifier . (91)
+
+ . reduce 91
+
+
+state 87
+ declaration : decl_specifiers . ';' (15)
+ declaration : decl_specifiers . init_declarator_list ';' (16)
+ decl_specifiers : decl_specifiers . decl_specifier (36)
+
+ '(' shift 2
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 6
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ ';' shift 67
+ . error
+
+ decl_specifier goto 68
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ init_declarator_list goto 69
+ init_declarator goto 70
+ declarator goto 110
+ direct_declarator goto 42
+ struct_or_union goto 43
+ pointer goto 44
+ any_id goto 45
+ identifier_or_ref goto 46
+ enumeration goto 47
+
+
+state 88
+ linkage_specification : T_EXTERN T_STRING_LITERAL declaration . (14)
+
+ . reduce 14
+
+
+state 89
+ linkage_specification : T_EXTERN T_STRING_LITERAL braces . (13)
+
+ . reduce 13
+
+
+state 90
+ external_declaration : T_ASM T_ASMARG ';' . (9)
+
+ . reduce 9
+
+
+state 91
+ declaration : decl_specifiers init_declarator_list ';' . (16)
+
+ . reduce 16
+
+
+state 92
+ init_declarator_list : init_declarator_list ',' . init_declarator (69)
+
+ '(' shift 2
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ . error
+
+ init_declarator goto 111
+ declarator goto 110
+ direct_declarator goto 42
+ pointer goto 44
+ any_id goto 45
+ identifier_or_ref goto 46
+
+
+state 93
+ init_declarator : declarator '=' . $$5 T_INITIALIZER (72)
+ $$5 : . (71)
+
+ . reduce 71
+
+ $$5 goto 112
+
+
+state 94
+ function_definition : decl_specifiers declarator $$2 . opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE (27)
+ opt_declaration_list : . (30)
+
+ T_TYPEDEF_NAME shift 82
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_TYPEDEF shift 12
+ T_INLINE shift 13
+ T_EXTENSION shift 14
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_VA_DCL shift 95
+ T_LBRACE reduce 30
+
+ decl_specifiers goto 87
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ struct_or_union goto 43
+ enumeration goto 47
+ declaration goto 96
+ any_typedef goto 53
+ opt_declaration_list goto 113
+ declaration_list goto 98
+
+
+state 95
+ opt_declaration_list : T_VA_DCL . (31)
+
+ . reduce 31
+
+
+state 96
+ declaration_list : declaration . (33)
+
+ . reduce 33
+
+
+state 97
+ function_definition : declarator $$4 opt_declaration_list . T_LBRACE T_MATCHRBRACE (29)
+
+ T_LBRACE shift 114
+ . error
+
+
+state 98
+ opt_declaration_list : declaration_list . (32)
+ declaration_list : declaration_list . declaration (34)
+
+ T_TYPEDEF_NAME shift 82
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_TYPEDEF shift 12
+ T_INLINE shift 13
+ T_EXTENSION shift 14
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_LBRACE reduce 32
+
+ decl_specifiers goto 87
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ struct_or_union goto 43
+ enumeration goto 47
+ declaration goto 115
+ any_typedef goto 53
+
+
+state 99
+ decl_specifiers : decl_specifiers . decl_specifier (36)
+ parameter_declaration : decl_specifiers . declarator (96)
+ parameter_declaration : decl_specifiers . abs_declarator (97)
+ parameter_declaration : decl_specifiers . (98)
+
+ '(' shift 116
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 6
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_BRACKETS shift 117
+ ',' reduce 98
+ ')' reduce 98
+
+ decl_specifier goto 68
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ declarator goto 118
+ direct_declarator goto 42
+ abs_declarator goto 119
+ direct_abs_declarator goto 120
+ struct_or_union goto 43
+ pointer goto 121
+ any_id goto 45
+ identifier_or_ref goto 46
+ enumeration goto 47
+
+
+state 100
+ direct_declarator : direct_declarator '(' parameter_type_list . ')' (84)
+
+ ')' shift 122
+ . error
+
+
+state 101
+ parameter_type_list : parameter_list . (92)
+ parameter_type_list : parameter_list . ',' T_ELLIPSIS (93)
+ parameter_list : parameter_list . ',' parameter_declaration (95)
+
+ ',' shift 123
+ ')' reduce 92
+
+
+state 102
+ parameter_list : parameter_declaration . (94)
+
+ . reduce 94
+
+
+state 103
+ direct_declarator : direct_declarator '(' opt_identifier_list . ')' (85)
+
+ ')' shift 124
+ . error
+
+
+state 104
+ opt_identifier_list : identifier_list . (100)
+ identifier_list : identifier_list . ',' any_id (102)
+
+ ',' shift 125
+ ')' reduce 100
+
+
+state 105
+ identifier_list : any_id . (101)
+
+ . reduce 101
+
+
+state 106
+ braces : T_LBRACE T_MATCHRBRACE . (12)
+
+ . reduce 12
+
+
+state 107
+ struct_or_union_specifier : struct_or_union any_id braces . (63)
+
+ . reduce 63
+
+
+state 108
+ enum_specifier : enumeration any_id braces . (73)
+
+ . reduce 73
+
+
+state 109
+ declaration : any_typedef decl_specifiers $$1 . opt_declarator_list ';' (18)
+ opt_declarator_list : . (21)
+
+ '(' shift 2
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ ';' reduce 21
+
+ declarator goto 126
+ direct_declarator goto 42
+ pointer goto 44
+ any_id goto 45
+ identifier_or_ref goto 46
+ opt_declarator_list goto 127
+ declarator_list goto 128
+
+
+state 110
+ init_declarator : declarator . (70)
+ init_declarator : declarator . '=' $$5 T_INITIALIZER (72)
+
+ '=' shift 93
+ ';' reduce 70
+ ',' reduce 70
+
+
+state 111
+ init_declarator_list : init_declarator_list ',' init_declarator . (69)
+
+ . reduce 69
+
+
+state 112
+ init_declarator : declarator '=' $$5 . T_INITIALIZER (72)
+
+ T_INITIALIZER shift 129
+ . error
+
+
+state 113
+ function_definition : decl_specifiers declarator $$2 opt_declaration_list . T_LBRACE $$3 T_MATCHRBRACE (27)
+
+ T_LBRACE shift 130
+ . error
+
+
+state 114
+ function_definition : declarator $$4 opt_declaration_list T_LBRACE . T_MATCHRBRACE (29)
+
+ T_MATCHRBRACE shift 131
+ . error
+
+
+state 115
+ declaration_list : declaration_list declaration . (34)
+
+ . reduce 34
+
+
+state 116
+ direct_declarator : '(' . declarator ')' (82)
+ direct_abs_declarator : '(' . abs_declarator ')' (108)
+ direct_abs_declarator : '(' . parameter_type_list ')' (113)
+ direct_abs_declarator : '(' . ')' (114)
+
+ '(' shift 116
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 6
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_BRACKETS shift 117
+ ')' shift 132
+ . error
+
+ decl_specifiers goto 99
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ declarator goto 57
+ direct_declarator goto 42
+ abs_declarator goto 133
+ direct_abs_declarator goto 120
+ parameter_type_list goto 134
+ parameter_list goto 101
+ parameter_declaration goto 102
+ struct_or_union goto 43
+ pointer goto 121
+ any_id goto 45
+ identifier_or_ref goto 46
+ enumeration goto 47
+
+
+state 117
+ direct_abs_declarator : T_BRACKETS . (110)
+
+ . reduce 110
+
+
+state 118
+ parameter_declaration : decl_specifiers declarator . (96)
+
+ . reduce 96
+
+
+state 119
+ parameter_declaration : decl_specifiers abs_declarator . (97)
+
+ . reduce 97
+
+
+state 120
+ abs_declarator : direct_abs_declarator . (107)
+ direct_abs_declarator : direct_abs_declarator . T_BRACKETS (109)
+ direct_abs_declarator : direct_abs_declarator . '(' parameter_type_list ')' (111)
+ direct_abs_declarator : direct_abs_declarator . '(' ')' (112)
+
+ '(' shift 135
+ T_BRACKETS shift 136
+ ',' reduce 107
+ ')' reduce 107
+
+
+state 121
+ declarator : pointer . direct_declarator (79)
+ abs_declarator : pointer . (105)
+ abs_declarator : pointer . direct_abs_declarator (106)
+
+ '(' shift 116
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ T_BRACKETS shift 117
+ ',' reduce 105
+ ')' reduce 105
+
+ direct_declarator goto 78
+ direct_abs_declarator goto 137
+ any_id goto 45
+ identifier_or_ref goto 46
+
+
+state 122
+ direct_declarator : direct_declarator '(' parameter_type_list ')' . (84)
+
+ . reduce 84
+
+
+state 123
+ parameter_type_list : parameter_list ',' . T_ELLIPSIS (93)
+ parameter_list : parameter_list ',' . parameter_declaration (95)
+
+ T_TYPEDEF_NAME shift 82
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ T_ELLIPSIS shift 138
+ . error
+
+ decl_specifiers goto 99
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ parameter_declaration goto 139
+ struct_or_union goto 43
+ enumeration goto 47
+
+
+state 124
+ direct_declarator : direct_declarator '(' opt_identifier_list ')' . (85)
+
+ . reduce 85
+
+
+state 125
+ identifier_list : identifier_list ',' . any_id (102)
+
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ . error
+
+ any_id goto 140
+
+
+state 126
+ declarator_list : declarator . (23)
+
+ . reduce 23
+
+
+state 127
+ declaration : any_typedef decl_specifiers $$1 opt_declarator_list . ';' (18)
+
+ ';' shift 141
+ . error
+
+
+state 128
+ opt_declarator_list : declarator_list . (22)
+ declarator_list : declarator_list . ',' declarator (24)
+
+ ',' shift 142
+ ';' reduce 22
+
+
+state 129
+ init_declarator : declarator '=' $$5 T_INITIALIZER . (72)
+
+ . reduce 72
+
+
+state 130
+ function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE . $$3 T_MATCHRBRACE (27)
+ $$3 : . (26)
+
+ . reduce 26
+
+ $$3 goto 143
+
+
+state 131
+ function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE . (29)
+
+ . reduce 29
+
+
+state 132
+ direct_abs_declarator : '(' ')' . (114)
+
+ . reduce 114
+
+
+state 133
+ direct_abs_declarator : '(' abs_declarator . ')' (108)
+
+ ')' shift 144
+ . error
+
+
+state 134
+ direct_abs_declarator : '(' parameter_type_list . ')' (113)
+
+ ')' shift 145
+ . error
+
+
+state 135
+ direct_abs_declarator : direct_abs_declarator '(' . parameter_type_list ')' (111)
+ direct_abs_declarator : direct_abs_declarator '(' . ')' (112)
+
+ T_TYPEDEF_NAME shift 82
+ T_DEFINE_NAME shift 7
+ T_AUTO shift 8
+ T_EXTERN shift 65
+ T_REGISTER shift 10
+ T_STATIC shift 11
+ T_INLINE shift 13
+ T_EXTENSION shift 66
+ T_CHAR shift 15
+ T_DOUBLE shift 16
+ T_FLOAT shift 17
+ T_INT shift 18
+ T_VOID shift 19
+ T_LONG shift 20
+ T_SHORT shift 21
+ T_SIGNED shift 22
+ T_UNSIGNED shift 23
+ T_ENUM shift 24
+ T_STRUCT shift 25
+ T_UNION shift 26
+ T_Bool shift 27
+ T_Complex shift 28
+ T_Imaginary shift 29
+ T_TYPE_QUALIFIER shift 30
+ ')' shift 146
+ . error
+
+ decl_specifiers goto 99
+ decl_specifier goto 35
+ storage_class goto 36
+ type_specifier goto 37
+ type_qualifier goto 38
+ struct_or_union_specifier goto 39
+ enum_specifier goto 40
+ parameter_type_list goto 147
+ parameter_list goto 101
+ parameter_declaration goto 102
+ struct_or_union goto 43
+ enumeration goto 47
+
+
+state 136
+ direct_abs_declarator : direct_abs_declarator T_BRACKETS . (109)
+
+ . reduce 109
+
+
+state 137
+ abs_declarator : pointer direct_abs_declarator . (106)
+ direct_abs_declarator : direct_abs_declarator . T_BRACKETS (109)
+ direct_abs_declarator : direct_abs_declarator . '(' parameter_type_list ')' (111)
+ direct_abs_declarator : direct_abs_declarator . '(' ')' (112)
+
+ '(' shift 135
+ T_BRACKETS shift 136
+ ',' reduce 106
+ ')' reduce 106
+
+
+state 138
+ parameter_type_list : parameter_list ',' T_ELLIPSIS . (93)
+
+ . reduce 93
+
+
+state 139
+ parameter_list : parameter_list ',' parameter_declaration . (95)
+
+ . reduce 95
+
+
+state 140
+ identifier_list : identifier_list ',' any_id . (102)
+
+ . reduce 102
+
+
+state 141
+ declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';' . (18)
+
+ . reduce 18
+
+
+state 142
+ declarator_list : declarator_list ',' . declarator (24)
+
+ '(' shift 2
+ '*' shift 3
+ '&' shift 4
+ T_IDENTIFIER shift 5
+ T_TYPEDEF_NAME shift 56
+ . error
+
+ declarator goto 148
+ direct_declarator goto 42
+ pointer goto 44
+ any_id goto 45
+ identifier_or_ref goto 46
+
+
+state 143
+ function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 . T_MATCHRBRACE (27)
+
+ T_MATCHRBRACE shift 149
+ . error
+
+
+state 144
+ direct_abs_declarator : '(' abs_declarator ')' . (108)
+
+ . reduce 108
+
+
+state 145
+ direct_abs_declarator : '(' parameter_type_list ')' . (113)
+
+ . reduce 113
+
+
+state 146
+ direct_abs_declarator : direct_abs_declarator '(' ')' . (112)
+
+ . reduce 112
+
+
+state 147
+ direct_abs_declarator : direct_abs_declarator '(' parameter_type_list . ')' (111)
+
+ ')' shift 150
+ . error
+
+
+state 148
+ declarator_list : declarator_list ',' declarator . (24)
+
+ . reduce 24
+
+
+state 149
+ function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE . (27)
+
+ . reduce 27
+
+
+state 150
+ direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')' . (111)
+
+ . reduce 111
+
+
+State 6 contains 29 reduce/reduce conflicts.
+State 83 contains 1 shift/reduce conflict.
+
+
+44 terminals, 43 nonterminals
+115 grammar rules, 151 states
--- /dev/null
+/* $NetBSD: grammar.tab.c,v 1.1.1.4 2011/09/10 21:22:10 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse grammar_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex grammar_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror grammar_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar grammar_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval grammar_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval grammar_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug grammar_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs grammar_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag grammar_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs grammar_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen grammar_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred grammar_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto grammar_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex grammar_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex grammar_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex grammar_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable grammar_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck grammar_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname grammar_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule grammar_rule
+#endif /* yyrule */
+#define YYPREFIX "grammar_"
+
+#define YYPURE 0
+
+#line 69 "grammar.y"
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#define OPT_LINTLIBRARY 1
+
+#ifndef TRUE
+#define TRUE (1)
+#endif
+
+#ifndef FALSE
+#define FALSE (0)
+#endif
+
+/* #include "cproto.h" */
+#define MAX_TEXT_SIZE 1024
+
+/* Prototype styles */
+#if OPT_LINTLIBRARY
+#define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */
+#define PROTO_LINTLIBRARY -1 /* form lint-library source */
+#endif
+#define PROTO_NONE 0 /* do not output any prototypes */
+#define PROTO_TRADITIONAL 1 /* comment out parameters */
+#define PROTO_ABSTRACT 2 /* comment out parameter names */
+#define PROTO_ANSI 3 /* ANSI C prototype */
+
+typedef int PrototypeStyle;
+
+typedef char boolean;
+
+extern boolean types_out;
+extern PrototypeStyle proto_style;
+
+#define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB)
+#define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY)
+#define lintLibrary() (knrLintLibrary() || ansiLintLibrary())
+
+#if OPT_LINTLIBRARY
+#define FUNC_UNKNOWN -1 /* unspecified */
+#else
+#define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */
+#endif
+#define FUNC_NONE 0 /* not a function definition */
+#define FUNC_TRADITIONAL 1 /* traditional style */
+#define FUNC_ANSI 2 /* ANSI style */
+#define FUNC_BOTH 3 /* both styles */
+
+typedef int FuncDefStyle;
+
+/* Source file text */
+typedef struct text {
+ char text[MAX_TEXT_SIZE]; /* source text */
+ long begin; /* offset in temporary file */
+} Text;
+
+/* Declaration specifier flags */
+#define DS_NONE 0 /* default */
+#define DS_EXTERN 1 /* contains "extern" specifier */
+#define DS_STATIC 2 /* contains "static" specifier */
+#define DS_CHAR 4 /* contains "char" type specifier */
+#define DS_SHORT 8 /* contains "short" type specifier */
+#define DS_FLOAT 16 /* contains "float" type specifier */
+#define DS_INLINE 32 /* contains "inline" specifier */
+#define DS_JUNK 64 /* we're not interested in this declaration */
+
+/* This structure stores information about a declaration specifier. */
+typedef struct decl_spec {
+ unsigned short flags; /* flags defined above */
+ char *text; /* source text */
+ long begin; /* offset in temporary file */
+} DeclSpec;
+
+/* This is a list of function parameters. */
+typedef struct _ParameterList {
+ struct parameter *first; /* pointer to first parameter in list */
+ struct parameter *last; /* pointer to last parameter in list */
+ long begin_comment; /* begin offset of comment */
+ long end_comment; /* end offset of comment */
+ char *comment; /* comment at start of parameter list */
+} ParameterList;
+
+/* This structure stores information about a declarator. */
+typedef struct _Declarator {
+ char *name; /* name of variable or function */
+ char *text; /* source text */
+ long begin; /* offset in temporary file */
+ long begin_comment; /* begin offset of comment */
+ long end_comment; /* end offset of comment */
+ FuncDefStyle func_def; /* style of function definition */
+ ParameterList params; /* function parameters */
+ boolean pointer; /* TRUE if it declares a pointer */
+ struct _Declarator *head; /* head function declarator */
+ struct _Declarator *func_stack; /* stack of function declarators */
+ struct _Declarator *next; /* next declarator in list */
+} Declarator;
+
+/* This structure stores information about a function parameter. */
+typedef struct parameter {
+ struct parameter *next; /* next parameter in list */
+ DeclSpec decl_spec;
+ Declarator *declarator;
+ char *comment; /* comment following the parameter */
+} Parameter;
+
+/* This is a list of declarators. */
+typedef struct declarator_list {
+ Declarator *first; /* pointer to first declarator in list */
+ Declarator *last; /* pointer to last declarator in list */
+} DeclaratorList;
+
+/* #include "symbol.h" */
+typedef struct symbol {
+ struct symbol *next; /* next symbol in list */
+ char *name; /* name of symbol */
+ char *value; /* value of symbol (for defines) */
+ short flags; /* symbol attributes */
+} Symbol;
+
+/* parser stack entry type */
+typedef union {
+ Text text;
+ DeclSpec decl_spec;
+ Parameter *parameter;
+ ParameterList param_list;
+ Declarator *declarator;
+ DeclaratorList decl_list;
+} YYSTYPE;
+
+/* The hash table length should be a prime number. */
+#define SYM_MAX_HASH 251
+
+typedef struct symbol_table {
+ Symbol *bucket[SYM_MAX_HASH]; /* hash buckets */
+} SymbolTable;
+
+extern SymbolTable *new_symbol_table /* Create symbol table */
+ (void);
+extern void free_symbol_table /* Destroy symbol table */
+ (SymbolTable *s);
+extern Symbol *find_symbol /* Lookup symbol name */
+ (SymbolTable *s, const char *n);
+extern Symbol *new_symbol /* Define new symbol */
+ (SymbolTable *s, const char *n, const char *v, int f);
+
+/* #include "semantic.h" */
+extern void new_decl_spec (DeclSpec *, const char *, long, int);
+extern void free_decl_spec (DeclSpec *);
+extern void join_decl_specs (DeclSpec *, DeclSpec *, DeclSpec *);
+extern void check_untagged (DeclSpec *);
+extern Declarator *new_declarator (const char *, const char *, long);
+extern void free_declarator (Declarator *);
+extern void new_decl_list (DeclaratorList *, Declarator *);
+extern void free_decl_list (DeclaratorList *);
+extern void add_decl_list (DeclaratorList *, DeclaratorList *, Declarator *);
+extern Parameter *new_parameter (DeclSpec *, Declarator *);
+extern void free_parameter (Parameter *);
+extern void new_param_list (ParameterList *, Parameter *);
+extern void free_param_list (ParameterList *);
+extern void add_param_list (ParameterList *, ParameterList *, Parameter *);
+extern void new_ident_list (ParameterList *);
+extern void add_ident_list (ParameterList *, ParameterList *, const char *);
+extern void set_param_types (ParameterList *, DeclSpec *, DeclaratorList *);
+extern void gen_declarations (DeclSpec *, DeclaratorList *);
+extern void gen_prototype (DeclSpec *, Declarator *);
+extern void gen_func_declarator (Declarator *);
+extern void gen_func_definition (DeclSpec *, Declarator *);
+
+extern void init_parser (void);
+extern void process_file (FILE *infile, char *name);
+extern char *cur_text (void);
+extern char *cur_file_name (void);
+extern char *implied_typedef (void);
+extern void include_file (char *name, int convert);
+extern char *supply_parm (int count);
+extern char *xstrdup (const char *);
+extern int already_declared (char *name);
+extern int is_actual_func (Declarator *d);
+extern int lint_ellipsis (Parameter *p);
+extern int want_typedef (void);
+extern void begin_tracking (void);
+extern void begin_typedef (void);
+extern void copy_typedef (char *s);
+extern void ellipsis_varargs (Declarator *d);
+extern void end_typedef (void);
+extern void flush_varargs (void);
+extern void fmt_library (int code);
+extern void imply_typedef (const char *s);
+extern void indent (FILE *outf);
+extern void put_blankline (FILE *outf);
+extern void put_body (FILE *outf, DeclSpec *decl_spec, Declarator *declarator);
+extern void put_char (FILE *outf, int c);
+extern void put_error (void);
+extern void put_newline (FILE *outf);
+extern void put_padded (FILE *outf, const char *s);
+extern void put_string (FILE *outf, const char *s);
+extern void track_in (void);
+
+extern boolean file_comments;
+extern FuncDefStyle func_style;
+extern char base_file[];
+
+#define YYMAXDEPTH 150
+
+extern int yylex (void);
+
+/* declaration specifier attributes for the typedef statement currently being
+ * scanned
+ */
+static int cur_decl_spec_flags;
+
+/* pointer to parameter list for the current function definition */
+static ParameterList *func_params;
+
+/* A parser semantic action sets this pointer to the current declarator in
+ * a function parameter declaration in order to catch any comments following
+ * the parameter declaration on the same line. If the lexer scans a comment
+ * and <cur_declarator> is not NULL, then the comment is attached to the
+ * declarator. To ignore subsequent comments, the lexer sets this to NULL
+ * after scanning a comment or end of line.
+ */
+static Declarator *cur_declarator;
+
+/* temporary string buffer */
+static char buf[MAX_TEXT_SIZE];
+
+/* table of typedef names */
+static SymbolTable *typedef_names;
+
+/* table of define names */
+static SymbolTable *define_names;
+
+/* table of type qualifiers */
+static SymbolTable *type_qualifiers;
+
+/* information about the current input file */
+typedef struct {
+ char *base_name; /* base input file name */
+ char *file_name; /* current file name */
+ FILE *file; /* input file */
+ unsigned line_num; /* current line number in input file */
+ FILE *tmp_file; /* temporary file */
+ long begin_comment; /* tmp file offset after last written ) or ; */
+ long end_comment; /* tmp file offset after last comment */
+ boolean convert; /* if TRUE, convert function definitions */
+ boolean changed; /* TRUE if conversion done in this file */
+} IncludeStack;
+
+static IncludeStack *cur_file; /* current input file */
+
+/* #include "yyerror.c" */
+
+static int haveAnsiParam (void);
+
+
+/* Flags to enable us to find if a procedure returns a value.
+ */
+static int return_val; /* nonzero on BRACES iff return-expression found */
+
+static const char *
+dft_decl_spec (void)
+{
+ return (lintLibrary() && !return_val) ? "void" : "int";
+}
+
+static int
+haveAnsiParam (void)
+{
+ Parameter *p;
+ if (func_params != 0) {
+ for (p = func_params->first; p != 0; p = p->next) {
+ if (p->declarator->func_def == FUNC_ANSI) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+#line 378 "grammar.tab.c"
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
+#define T_IDENTIFIER 257
+#define T_TYPEDEF_NAME 258
+#define T_DEFINE_NAME 259
+#define T_AUTO 260
+#define T_EXTERN 261
+#define T_REGISTER 262
+#define T_STATIC 263
+#define T_TYPEDEF 264
+#define T_INLINE 265
+#define T_EXTENSION 266
+#define T_CHAR 267
+#define T_DOUBLE 268
+#define T_FLOAT 269
+#define T_INT 270
+#define T_VOID 271
+#define T_LONG 272
+#define T_SHORT 273
+#define T_SIGNED 274
+#define T_UNSIGNED 275
+#define T_ENUM 276
+#define T_STRUCT 277
+#define T_UNION 278
+#define T_Bool 279
+#define T_Complex 280
+#define T_Imaginary 281
+#define T_TYPE_QUALIFIER 282
+#define T_BRACKETS 283
+#define T_LBRACE 284
+#define T_MATCHRBRACE 285
+#define T_ELLIPSIS 286
+#define T_INITIALIZER 287
+#define T_STRING_LITERAL 288
+#define T_ASM 289
+#define T_ASMARG 290
+#define T_VA_DCL 291
+#define YYERRCODE 256
+static const short grammar_lhs[] = { -1,
+ 0, 0, 26, 26, 27, 27, 27, 27, 27, 27,
+ 27, 31, 30, 30, 28, 28, 34, 28, 32, 32,
+ 33, 33, 35, 35, 37, 38, 29, 39, 29, 36,
+ 36, 36, 40, 40, 1, 1, 2, 2, 2, 3,
+ 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 5, 5, 6, 6, 6, 19, 19, 8, 8, 9,
+ 41, 9, 7, 7, 7, 25, 23, 23, 10, 10,
+ 11, 11, 11, 11, 11, 20, 20, 21, 21, 22,
+ 22, 14, 14, 15, 15, 16, 16, 16, 17, 17,
+ 18, 18, 24, 24, 12, 12, 12, 13, 13, 13,
+ 13, 13, 13, 13,
+};
+static const short grammar_len[] = { 2,
+ 0, 1, 1, 2, 1, 1, 1, 1, 3, 2,
+ 2, 2, 3, 3, 2, 3, 0, 5, 2, 1,
+ 0, 1, 1, 3, 0, 0, 7, 0, 5, 0,
+ 1, 1, 1, 2, 1, 2, 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, 2, 2, 1, 1, 1, 3, 1,
+ 0, 4, 3, 2, 2, 1, 1, 1, 2, 1,
+ 1, 3, 2, 4, 4, 2, 3, 0, 1, 1,
+ 2, 1, 3, 1, 3, 2, 2, 1, 0, 1,
+ 1, 3, 1, 2, 1, 2, 1, 3, 2, 1,
+ 4, 3, 3, 2,
+};
+static const short grammar_defred[] = { 0,
+ 0, 0, 0, 0, 77, 0, 62, 40, 0, 42,
+ 43, 20, 44, 0, 46, 47, 48, 49, 54, 50,
+ 51, 52, 53, 76, 66, 67, 55, 56, 57, 61,
+ 0, 7, 0, 0, 35, 37, 38, 39, 59, 60,
+ 28, 0, 0, 0, 103, 81, 0, 0, 3, 5,
+ 6, 8, 0, 10, 11, 78, 0, 90, 0, 0,
+ 104, 0, 19, 0, 41, 45, 15, 36, 0, 68,
+ 0, 0, 0, 83, 0, 0, 64, 0, 0, 74,
+ 4, 58, 0, 82, 87, 91, 0, 14, 13, 9,
+ 16, 0, 71, 0, 31, 33, 0, 0, 0, 0,
+ 0, 94, 0, 0, 101, 12, 63, 73, 0, 0,
+ 69, 0, 0, 0, 34, 0, 110, 96, 97, 0,
+ 0, 84, 0, 85, 0, 23, 0, 0, 72, 26,
+ 29, 114, 0, 0, 0, 109, 0, 93, 95, 102,
+ 18, 0, 0, 108, 113, 112, 0, 24, 27, 111,
+};
+static const short grammar_dgoto[] = { 33,
+ 87, 35, 36, 37, 38, 39, 40, 69, 70, 41,
+ 42, 119, 120, 100, 101, 102, 103, 104, 43, 44,
+ 59, 60, 45, 46, 47, 48, 49, 50, 51, 52,
+ 77, 53, 127, 109, 128, 97, 94, 143, 72, 98,
+ 112,
+};
+static const short grammar_sindex[] = { -2,
+ -3, 27, -239, -177, 0, 0, 0, 0, -274, 0,
+ 0, 0, 0, -246, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ -266, 0, 0, 455, 0, 0, 0, 0, 0, 0,
+ 0, -35, -245, 128, 0, 0, -245, -2, 0, 0,
+ 0, 0, 642, 0, 0, 0, -15, 0, -12, -239,
+ 0, 590, 0, -27, 0, 0, 0, 0, -10, 0,
+ -11, 534, -72, 0, -237, -232, 0, -35, -232, 0,
+ 0, 0, 642, 0, 0, 0, 455, 0, 0, 0,
+ 0, 27, 0, 534, 0, 0, -222, 617, 209, 34,
+ 39, 0, 44, 42, 0, 0, 0, 0, 27, -11,
+ 0, -200, -196, -195, 0, 174, 0, 0, 0, -33,
+ 243, 0, 561, 0, -177, 0, 33, 49, 0, 0,
+ 0, 0, 53, 55, 417, 0, -33, 0, 0, 0,
+ 0, 27, -188, 0, 0, 0, 57, 0, 0, 0,
+};
+static const short grammar_rindex[] = { 99,
+ 0, 0, 275, 0, 0, -38, 0, 0, 481, 0,
+ 0, 0, 0, 509, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 30, 0, 0, 0, 0, 0, 101, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 343, 309,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 98, -182, 62, 0, 0, 133, 0, 64, 379, 0,
+ 0, 0, -5, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, -182, 0, 0, 0, -180, -19, 0,
+ 65, 0, 0, 68, 0, 0, 0, 0, 51, 9,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, -13,
+ 19, 0, 0, 0, 0, 0, 0, 52, 0, 0,
+ 0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const short grammar_gindex[] = { 0,
+ 11, -17, 0, 0, 13, 0, 0, 0, 20, 8,
+ -43, -1, -8, -89, 0, -9, 0, 0, 0, -44,
+ 0, 0, 4, 0, 0, 0, 70, -53, 0, 0,
+ -18, 0, 0, 0, 0, 22, 0, 0, 0, 0,
+ 0,
+};
+#define YYTABLESIZE 924
+static const short grammar_table[] = { 58,
+ 78, 58, 58, 58, 73, 58, 135, 61, 88, 57,
+ 34, 5, 56, 62, 85, 58, 68, 63, 96, 7,
+ 58, 98, 78, 64, 98, 84, 134, 107, 80, 3,
+ 107, 90, 17, 92, 17, 4, 17, 2, 75, 3,
+ 96, 71, 30, 89, 115, 147, 76, 106, 91, 93,
+ 79, 75, 70, 17, 121, 55, 32, 107, 34, 105,
+ 108, 114, 105, 83, 4, 68, 2, 70, 3, 68,
+ 80, 121, 86, 80, 122, 106, 105, 78, 106, 5,
+ 56, 68, 123, 99, 124, 125, 129, 130, 80, 131,
+ 80, 141, 142, 144, 110, 145, 149, 150, 1, 110,
+ 2, 30, 99, 32, 79, 92, 118, 79, 100, 21,
+ 22, 111, 137, 139, 133, 113, 126, 81, 0, 0,
+ 0, 0, 79, 57, 79, 0, 99, 0, 140, 0,
+ 0, 0, 0, 99, 0, 0, 0, 0, 0, 0,
+ 0, 70, 0, 0, 0, 99, 0, 0, 0, 148,
+ 0, 0, 0, 0, 0, 0, 70, 0, 0, 0,
+ 0, 0, 0, 0, 0, 4, 0, 2, 0, 0,
+ 65, 0, 65, 65, 65, 0, 65, 0, 0, 0,
+ 0, 0, 0, 0, 5, 6, 7, 8, 65, 10,
+ 11, 65, 13, 66, 15, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
+ 0, 4, 0, 116, 132, 3, 0, 0, 58, 58,
+ 58, 58, 58, 58, 58, 78, 58, 58, 58, 58,
+ 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
+ 58, 58, 58, 58, 58, 78, 4, 74, 116, 136,
+ 3, 17, 78, 1, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
+ 4, 54, 116, 5, 56, 0, 31, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 88, 80, 88, 88, 88, 0, 88, 0,
+ 80, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 79, 79, 79, 79, 79, 79, 89, 79, 89, 89,
+ 89, 0, 89, 0, 79, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 86, 25, 86, 86, 5, 56, 86, 0, 25, 65,
+ 65, 65, 65, 65, 65, 65, 0, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65, 65, 65, 65, 65, 75, 0, 75, 75,
+ 75, 0, 75, 0, 0, 0, 0, 0, 0, 0,
+ 5, 6, 7, 8, 65, 10, 11, 75, 13, 66,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 117, 146, 0, 0,
+ 0, 0, 0, 0, 0, 5, 6, 7, 8, 65,
+ 10, 11, 0, 13, 66, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 117, 4, 0, 2, 0, 3, 0, 0, 5,
+ 56, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 67, 0, 0, 0, 0, 41, 0,
+ 41, 0, 41, 0, 0, 117, 0, 0, 0, 0,
+ 0, 88, 88, 0, 0, 0, 0, 0, 0, 41,
+ 0, 0, 0, 0, 0, 0, 45, 0, 45, 0,
+ 45, 0, 0, 0, 0, 0, 0, 88, 0, 0,
+ 0, 0, 0, 0, 0, 89, 89, 45, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 89, 0, 0, 0, 0, 0, 0, 0, 86,
+ 86, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 86, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 75, 75, 75, 75, 75,
+ 75, 75, 0, 75, 75, 75, 75, 75, 75, 75,
+ 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
+ 75, 75, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 82, 7, 8, 65, 10, 11,
+ 0, 13, 66, 15, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, 26, 27, 28, 29, 30, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 5, 6, 7, 8, 65, 10, 11, 0, 13,
+ 66, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 41, 41, 41,
+ 41, 41, 41, 41, 0, 41, 41, 41, 41, 41,
+ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
+ 41, 41, 41, 0, 0, 45, 45, 45, 45, 45,
+ 45, 45, 0, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 45, 82, 7, 8, 65, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 0, 0, 82, 7,
+ 8, 65, 10, 11, 95, 13, 66, 15, 16, 17,
+ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 0, 0, 0, 138, 82, 7, 8,
+ 65, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
+ 29, 30, 0, 75, 82, 7, 8, 65, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, 26, 27, 28, 29, 30, 82,
+ 7, 8, 65, 10, 11, 0, 13, 66, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+ 27, 28, 29, 30,
+};
+static const short grammar_check[] = { 38,
+ 44, 40, 41, 42, 40, 44, 40, 4, 62, 2,
+ 0, 257, 258, 288, 59, 3, 34, 264, 72, 259,
+ 59, 41, 61, 290, 44, 41, 116, 41, 47, 42,
+ 44, 59, 38, 44, 40, 38, 42, 40, 284, 42,
+ 94, 34, 282, 62, 98, 135, 43, 285, 59, 61,
+ 47, 284, 44, 59, 99, 59, 59, 76, 48, 41,
+ 79, 284, 44, 53, 38, 83, 40, 59, 42, 87,
+ 41, 116, 60, 44, 41, 41, 73, 121, 44, 257,
+ 258, 99, 44, 73, 41, 44, 287, 284, 59, 285,
+ 61, 59, 44, 41, 87, 41, 285, 41, 0, 92,
+ 0, 284, 41, 284, 41, 41, 99, 44, 41, 59,
+ 59, 92, 121, 123, 116, 94, 109, 48, -1, -1,
+ -1, -1, 59, 116, 61, -1, 116, -1, 125, -1,
+ -1, -1, -1, 123, -1, -1, -1, -1, -1, -1,
+ -1, 44, -1, -1, -1, 135, -1, -1, -1, 142,
+ -1, -1, -1, -1, -1, -1, 59, -1, -1, -1,
+ -1, -1, -1, -1, -1, 38, -1, 40, -1, -1,
+ 38, -1, 40, 41, 42, -1, 44, -1, -1, -1,
+ -1, -1, -1, -1, 257, 258, 259, 260, 261, 262,
+ 263, 59, 265, 266, 267, 268, 269, 270, 271, 272,
+ 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
+ -1, 38, -1, 40, 41, 42, -1, -1, 257, 258,
+ 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
+ 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
+ 279, 280, 281, 282, 283, 284, 38, 283, 40, 283,
+ 42, 257, 291, 256, 257, 258, 259, 260, 261, 262,
+ 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
+ 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
+ 38, 285, 40, 257, 258, -1, 289, 258, 259, 260,
+ 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
+ 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
+ 281, 282, 38, 284, 40, 41, 42, -1, 44, -1,
+ 291, 258, 259, 260, 261, 262, 263, 264, 265, 266,
+ 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
+ 277, 278, 279, 280, 281, 282, 38, 284, 40, 41,
+ 42, -1, 44, -1, 291, 258, 259, 260, 261, 262,
+ 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
+ 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
+ 38, 284, 40, 41, 257, 258, 44, -1, 291, 257,
+ 258, 259, 260, 261, 262, 263, -1, 265, 266, 267,
+ 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
+ 278, 279, 280, 281, 282, 283, 38, -1, 40, 41,
+ 42, -1, 44, -1, -1, -1, -1, -1, -1, -1,
+ 257, 258, 259, 260, 261, 262, 263, 59, 265, 266,
+ 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
+ 277, 278, 279, 280, 281, 282, 283, 41, -1, -1,
+ -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
+ 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
+ 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
+ 282, 283, 38, -1, 40, -1, 42, -1, -1, 257,
+ 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 59, -1, -1, -1, -1, 38, -1,
+ 40, -1, 42, -1, -1, 283, -1, -1, -1, -1,
+ -1, 257, 258, -1, -1, -1, -1, -1, -1, 59,
+ -1, -1, -1, -1, -1, -1, 38, -1, 40, -1,
+ 42, -1, -1, -1, -1, -1, -1, 283, -1, -1,
+ -1, -1, -1, -1, -1, 257, 258, 59, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 283, -1, -1, -1, -1, -1, -1, -1, 257,
+ 258, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 283, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 257, 258, 259, 260, 261,
+ 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
+ 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
+ 282, 283, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 258, 259, 260, 261, 262, 263,
+ -1, 265, 266, 267, 268, 269, 270, 271, 272, 273,
+ 274, 275, 276, 277, 278, 279, 280, 281, 282, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 257, 258, 259, 260, 261, 262, 263, -1, 265,
+ 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
+ 276, 277, 278, 279, 280, 281, 282, 257, 258, 259,
+ 260, 261, 262, 263, -1, 265, 266, 267, 268, 269,
+ 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
+ 280, 281, 282, -1, -1, 257, 258, 259, 260, 261,
+ 262, 263, -1, 265, 266, 267, 268, 269, 270, 271,
+ 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
+ 282, 258, 259, 260, 261, 262, 263, 264, 265, 266,
+ 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
+ 277, 278, 279, 280, 281, 282, -1, -1, 258, 259,
+ 260, 261, 262, 263, 291, 265, 266, 267, 268, 269,
+ 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
+ 280, 281, 282, -1, -1, -1, 286, 258, 259, 260,
+ 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
+ 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
+ 281, 282, -1, 284, 258, 259, 260, 261, 262, 263,
+ 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
+ 274, 275, 276, 277, 278, 279, 280, 281, 282, 258,
+ 259, 260, 261, 262, 263, -1, 265, 266, 267, 268,
+ 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
+ 279, 280, 281, 282,
+};
+#define YYFINAL 33
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 291
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,
+"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+"T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN",
+"T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_EXTENSION","T_CHAR",
+"T_DOUBLE","T_FLOAT","T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED",
+"T_UNSIGNED","T_ENUM","T_STRUCT","T_UNION","T_Bool","T_Complex","T_Imaginary",
+"T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE","T_ELLIPSIS",
+"T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",
+};
+static const char *yyrule[] = {
+"$accept : program",
+"program :",
+"program : translation_unit",
+"translation_unit : external_declaration",
+"translation_unit : translation_unit external_declaration",
+"external_declaration : declaration",
+"external_declaration : function_definition",
+"external_declaration : ';'",
+"external_declaration : linkage_specification",
+"external_declaration : T_ASM T_ASMARG ';'",
+"external_declaration : error T_MATCHRBRACE",
+"external_declaration : error ';'",
+"braces : T_LBRACE T_MATCHRBRACE",
+"linkage_specification : T_EXTERN T_STRING_LITERAL braces",
+"linkage_specification : T_EXTERN T_STRING_LITERAL declaration",
+"declaration : decl_specifiers ';'",
+"declaration : decl_specifiers init_declarator_list ';'",
+"$$1 :",
+"declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'",
+"any_typedef : T_EXTENSION T_TYPEDEF",
+"any_typedef : T_TYPEDEF",
+"opt_declarator_list :",
+"opt_declarator_list : declarator_list",
+"declarator_list : declarator",
+"declarator_list : declarator_list ',' declarator",
+"$$2 :",
+"$$3 :",
+"function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE",
+"$$4 :",
+"function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE",
+"opt_declaration_list :",
+"opt_declaration_list : T_VA_DCL",
+"opt_declaration_list : declaration_list",
+"declaration_list : declaration",
+"declaration_list : declaration_list declaration",
+"decl_specifiers : decl_specifier",
+"decl_specifiers : decl_specifiers decl_specifier",
+"decl_specifier : storage_class",
+"decl_specifier : type_specifier",
+"decl_specifier : type_qualifier",
+"storage_class : T_AUTO",
+"storage_class : T_EXTERN",
+"storage_class : T_REGISTER",
+"storage_class : T_STATIC",
+"storage_class : T_INLINE",
+"storage_class : T_EXTENSION",
+"type_specifier : T_CHAR",
+"type_specifier : T_DOUBLE",
+"type_specifier : T_FLOAT",
+"type_specifier : T_INT",
+"type_specifier : T_LONG",
+"type_specifier : T_SHORT",
+"type_specifier : T_SIGNED",
+"type_specifier : T_UNSIGNED",
+"type_specifier : T_VOID",
+"type_specifier : T_Bool",
+"type_specifier : T_Complex",
+"type_specifier : T_Imaginary",
+"type_specifier : T_TYPEDEF_NAME",
+"type_specifier : struct_or_union_specifier",
+"type_specifier : enum_specifier",
+"type_qualifier : T_TYPE_QUALIFIER",
+"type_qualifier : T_DEFINE_NAME",
+"struct_or_union_specifier : struct_or_union any_id braces",
+"struct_or_union_specifier : struct_or_union braces",
+"struct_or_union_specifier : struct_or_union any_id",
+"struct_or_union : T_STRUCT",
+"struct_or_union : T_UNION",
+"init_declarator_list : init_declarator",
+"init_declarator_list : init_declarator_list ',' init_declarator",
+"init_declarator : declarator",
+"$$5 :",
+"init_declarator : declarator '=' $$5 T_INITIALIZER",
+"enum_specifier : enumeration any_id braces",
+"enum_specifier : enumeration braces",
+"enum_specifier : enumeration any_id",
+"enumeration : T_ENUM",
+"any_id : T_IDENTIFIER",
+"any_id : T_TYPEDEF_NAME",
+"declarator : pointer direct_declarator",
+"declarator : direct_declarator",
+"direct_declarator : identifier_or_ref",
+"direct_declarator : '(' declarator ')'",
+"direct_declarator : direct_declarator T_BRACKETS",
+"direct_declarator : direct_declarator '(' parameter_type_list ')'",
+"direct_declarator : direct_declarator '(' opt_identifier_list ')'",
+"pointer : '*' opt_type_qualifiers",
+"pointer : '*' opt_type_qualifiers pointer",
+"opt_type_qualifiers :",
+"opt_type_qualifiers : type_qualifier_list",
+"type_qualifier_list : type_qualifier",
+"type_qualifier_list : type_qualifier_list type_qualifier",
+"parameter_type_list : parameter_list",
+"parameter_type_list : parameter_list ',' T_ELLIPSIS",
+"parameter_list : parameter_declaration",
+"parameter_list : parameter_list ',' parameter_declaration",
+"parameter_declaration : decl_specifiers declarator",
+"parameter_declaration : decl_specifiers abs_declarator",
+"parameter_declaration : decl_specifiers",
+"opt_identifier_list :",
+"opt_identifier_list : identifier_list",
+"identifier_list : any_id",
+"identifier_list : identifier_list ',' any_id",
+"identifier_or_ref : any_id",
+"identifier_or_ref : '&' any_id",
+"abs_declarator : pointer",
+"abs_declarator : pointer direct_abs_declarator",
+"abs_declarator : direct_abs_declarator",
+"direct_abs_declarator : '(' abs_declarator ')'",
+"direct_abs_declarator : direct_abs_declarator T_BRACKETS",
+"direct_abs_declarator : T_BRACKETS",
+"direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'",
+"direct_abs_declarator : direct_abs_declarator '(' ')'",
+"direct_abs_declarator : '(' parameter_type_list ')'",
+"direct_abs_declarator : '(' ')'",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 1004 "grammar.y"
+
+/* lex.yy.c */
+#define BEGIN yy_start = 1 + 2 *
+
+#define CPP1 1
+#define INIT1 2
+#define INIT2 3
+#define CURLY 4
+#define LEXYACC 5
+#define ASM 6
+#define CPP_INLINE 7
+
+extern char *yytext;
+extern FILE *yyin, *yyout;
+
+static int curly; /* number of curly brace nesting levels */
+static int ly_count; /* number of occurances of %% */
+static int inc_depth; /* include nesting level */
+static SymbolTable *included_files; /* files already included */
+static int yy_start = 0; /* start state number */
+
+#define grammar_error(s) yaccError(s)
+
+static void
+yaccError (const char *msg)
+{
+ func_params = NULL;
+ put_error(); /* tell what line we're on, and what file */
+ fprintf(stderr, "%s at token '%s'\n", msg, yytext);
+}
+
+/* Initialize the table of type qualifier keywords recognized by the lexical
+ * analyzer.
+ */
+void
+init_parser (void)
+{
+ static const char *keywords[] = {
+ "const",
+ "restrict",
+ "volatile",
+ "interrupt",
+#ifdef vms
+ "noshare",
+ "readonly",
+#endif
+#if defined(MSDOS) || defined(OS2)
+ "__cdecl",
+ "__export",
+ "__far",
+ "__fastcall",
+ "__fortran",
+ "__huge",
+ "__inline",
+ "__interrupt",
+ "__loadds",
+ "__near",
+ "__pascal",
+ "__saveregs",
+ "__segment",
+ "__stdcall",
+ "__syscall",
+ "_cdecl",
+ "_cs",
+ "_ds",
+ "_es",
+ "_export",
+ "_far",
+ "_fastcall",
+ "_fortran",
+ "_huge",
+ "_interrupt",
+ "_loadds",
+ "_near",
+ "_pascal",
+ "_saveregs",
+ "_seg",
+ "_segment",
+ "_ss",
+ "cdecl",
+ "far",
+ "huge",
+ "near",
+ "pascal",
+#ifdef OS2
+ "__far16",
+#endif
+#endif
+#ifdef __GNUC__
+ /* gcc aliases */
+ "__builtin_va_arg",
+ "__builtin_va_list",
+ "__const",
+ "__const__",
+ "__inline",
+ "__inline__",
+ "__restrict",
+ "__restrict__",
+ "__volatile",
+ "__volatile__",
+#endif
+ };
+ unsigned i;
+
+ /* Initialize type qualifier table. */
+ type_qualifiers = new_symbol_table();
+ for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
+ new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
+ }
+}
+
+/* Process the C source file. Write function prototypes to the standard
+ * output. Convert function definitions and write the converted source
+ * code to a temporary file.
+ */
+void
+process_file (FILE *infile, char *name)
+{
+ char *s;
+
+ if (strlen(name) > 2) {
+ s = name + strlen(name) - 2;
+ if (*s == '.') {
+ ++s;
+ if (*s == 'l' || *s == 'y')
+ BEGIN LEXYACC;
+#if defined(MSDOS) || defined(OS2)
+ if (*s == 'L' || *s == 'Y')
+ BEGIN LEXYACC;
+#endif
+ }
+ }
+
+ included_files = new_symbol_table();
+ typedef_names = new_symbol_table();
+ define_names = new_symbol_table();
+ inc_depth = -1;
+ curly = 0;
+ ly_count = 0;
+ func_params = NULL;
+ yyin = infile;
+ include_file(strcpy(base_file, name), func_style != FUNC_NONE);
+ if (file_comments) {
+#if OPT_LINTLIBRARY
+ if (lintLibrary()) {
+ put_blankline(stdout);
+ begin_tracking();
+ }
+#endif
+ put_string(stdout, "/* ");
+ put_string(stdout, cur_file_name());
+ put_string(stdout, " */\n");
+ }
+ yyparse();
+ free_symbol_table(define_names);
+ free_symbol_table(typedef_names);
+ free_symbol_table(included_files);
+}
+
+#ifdef NO_LEAKS
+void
+free_parser(void)
+{
+ free_symbol_table (type_qualifiers);
+#ifdef FLEX_SCANNER
+ if (yy_current_buffer != 0)
+ yy_delete_buffer(yy_current_buffer);
+#endif
+}
+#endif
+#line 1073 "grammar.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 10:
+#line 367 "grammar.y"
+ {
+ yyerrok;
+ }
+break;
+case 11:
+#line 371 "grammar.y"
+ {
+ yyerrok;
+ }
+break;
+case 13:
+#line 382 "grammar.y"
+ {
+ /* Provide an empty action here so bison will not complain about
+ * incompatible types in the default action it normally would
+ * have generated.
+ */
+ }
+break;
+case 14:
+#line 389 "grammar.y"
+ {
+ /* empty */
+ }
+break;
+case 15:
+#line 396 "grammar.y"
+ {
+#if OPT_LINTLIBRARY
+ if (types_out && want_typedef()) {
+ gen_declarations(&yystack.l_mark[-1].decl_spec, (DeclaratorList *)0);
+ flush_varargs();
+ }
+#endif
+ free_decl_spec(&yystack.l_mark[-1].decl_spec);
+ end_typedef();
+ }
+break;
+case 16:
+#line 407 "grammar.y"
+ {
+ if (func_params != NULL) {
+ set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
+ } else {
+ gen_declarations(&yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
+#if OPT_LINTLIBRARY
+ flush_varargs();
+#endif
+ free_decl_list(&yystack.l_mark[-1].decl_list);
+ }
+ free_decl_spec(&yystack.l_mark[-2].decl_spec);
+ end_typedef();
+ }
+break;
+case 17:
+#line 421 "grammar.y"
+ {
+ cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
+ free_decl_spec(&yystack.l_mark[0].decl_spec);
+ }
+break;
+case 18:
+#line 426 "grammar.y"
+ {
+ end_typedef();
+ }
+break;
+case 19:
+#line 433 "grammar.y"
+ {
+ begin_typedef();
+ }
+break;
+case 20:
+#line 437 "grammar.y"
+ {
+ begin_typedef();
+ }
+break;
+case 23:
+#line 449 "grammar.y"
+ {
+ int flags = cur_decl_spec_flags;
+
+ /* If the typedef is a pointer type, then reset the short type
+ * flags so it does not get promoted.
+ */
+ if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
+ flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
+ new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
+ free_declarator(yystack.l_mark[0].declarator);
+ }
+break;
+case 24:
+#line 461 "grammar.y"
+ {
+ int flags = cur_decl_spec_flags;
+
+ if (strcmp(yystack.l_mark[0].declarator->text, yystack.l_mark[0].declarator->name) != 0)
+ flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
+ new_symbol(typedef_names, yystack.l_mark[0].declarator->name, NULL, flags);
+ free_declarator(yystack.l_mark[0].declarator);
+ }
+break;
+case 25:
+#line 473 "grammar.y"
+ {
+ check_untagged(&yystack.l_mark[-1].decl_spec);
+ if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
+ yyerror("syntax error");
+ YYERROR;
+ }
+ func_params = &(yystack.l_mark[0].declarator->head->params);
+ func_params->begin_comment = cur_file->begin_comment;
+ func_params->end_comment = cur_file->end_comment;
+ }
+break;
+case 26:
+#line 484 "grammar.y"
+ {
+ /* If we're converting to K&R and we've got a nominally K&R
+ * function which has a parameter which is ANSI (i.e., a prototyped
+ * function pointer), then we must override the deciphered value of
+ * 'func_def' so that the parameter will be converted.
+ */
+ if (func_style == FUNC_TRADITIONAL
+ && haveAnsiParam()
+ && yystack.l_mark[-3].declarator->head->func_def == func_style) {
+ yystack.l_mark[-3].declarator->head->func_def = FUNC_BOTH;
+ }
+
+ func_params = NULL;
+
+ if (cur_file->convert)
+ gen_func_definition(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
+ gen_prototype(&yystack.l_mark[-4].decl_spec, yystack.l_mark[-3].declarator);
+#if OPT_LINTLIBRARY
+ flush_varargs();
+#endif
+ free_decl_spec(&yystack.l_mark[-4].decl_spec);
+ free_declarator(yystack.l_mark[-3].declarator);
+ }
+break;
+case 28:
+#line 509 "grammar.y"
+ {
+ if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
+ yyerror("syntax error");
+ YYERROR;
+ }
+ func_params = &(yystack.l_mark[0].declarator->head->params);
+ func_params->begin_comment = cur_file->begin_comment;
+ func_params->end_comment = cur_file->end_comment;
+ }
+break;
+case 29:
+#line 519 "grammar.y"
+ {
+ DeclSpec decl_spec;
+
+ func_params = NULL;
+
+ new_decl_spec(&decl_spec, dft_decl_spec(), yystack.l_mark[-4].declarator->begin, DS_NONE);
+ if (cur_file->convert)
+ gen_func_definition(&decl_spec, yystack.l_mark[-4].declarator);
+ gen_prototype(&decl_spec, yystack.l_mark[-4].declarator);
+#if OPT_LINTLIBRARY
+ flush_varargs();
+#endif
+ free_decl_spec(&decl_spec);
+ free_declarator(yystack.l_mark[-4].declarator);
+ }
+break;
+case 36:
+#line 550 "grammar.y"
+ {
+ join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
+ free(yystack.l_mark[-1].decl_spec.text);
+ free(yystack.l_mark[0].decl_spec.text);
+ }
+break;
+case 40:
+#line 565 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 41:
+#line 569 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
+ }
+break;
+case 42:
+#line 573 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 43:
+#line 577 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
+ }
+break;
+case 44:
+#line 581 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
+ }
+break;
+case 45:
+#line 585 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
+ }
+break;
+case 46:
+#line 592 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
+ }
+break;
+case 47:
+#line 596 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 48:
+#line 600 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
+ }
+break;
+case 49:
+#line 604 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 50:
+#line 608 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 51:
+#line 612 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
+ }
+break;
+case 52:
+#line 616 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 53:
+#line 620 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 54:
+#line 624 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 55:
+#line 628 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
+ }
+break;
+case 56:
+#line 632 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 57:
+#line 636 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 58:
+#line 640 "grammar.y"
+ {
+ Symbol *s;
+ s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
+ if (s != NULL)
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
+ }
+break;
+case 61:
+#line 652 "grammar.y"
+ {
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
+ }
+break;
+case 62:
+#line 656 "grammar.y"
+ {
+ /* This rule allows the <pointer> nonterminal to scan #define
+ * names as if they were type modifiers.
+ */
+ Symbol *s;
+ s = find_symbol(define_names, yystack.l_mark[0].text.text);
+ if (s != NULL)
+ new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, s->flags);
+ }
+break;
+case 63:
+#line 669 "grammar.y"
+ {
+ char *s;
+ if ((s = implied_typedef()) == 0)
+ (void)sprintf(s = buf, "%s %s", yystack.l_mark[-2].text.text, yystack.l_mark[-1].text.text);
+ new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
+ }
+break;
+case 64:
+#line 676 "grammar.y"
+ {
+ char *s;
+ if ((s = implied_typedef()) == 0)
+ (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
+ new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
+ }
+break;
+case 65:
+#line 683 "grammar.y"
+ {
+ (void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
+ new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
+ }
+break;
+case 66:
+#line 691 "grammar.y"
+ {
+ imply_typedef(yyval.text.text);
+ }
+break;
+case 67:
+#line 695 "grammar.y"
+ {
+ imply_typedef(yyval.text.text);
+ }
+break;
+case 68:
+#line 702 "grammar.y"
+ {
+ new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
+ }
+break;
+case 69:
+#line 706 "grammar.y"
+ {
+ add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
+ }
+break;
+case 70:
+#line 713 "grammar.y"
+ {
+ if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
+ func_style == FUNC_TRADITIONAL && cur_file->convert) {
+ gen_func_declarator(yystack.l_mark[0].declarator);
+ fputs(cur_text(), cur_file->tmp_file);
+ }
+ cur_declarator = yyval.declarator;
+ }
+break;
+case 71:
+#line 722 "grammar.y"
+ {
+ if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
+ func_style == FUNC_TRADITIONAL && cur_file->convert) {
+ gen_func_declarator(yystack.l_mark[-1].declarator);
+ fputs(" =", cur_file->tmp_file);
+ }
+ }
+break;
+case 73:
+#line 734 "grammar.y"
+ {
+ char *s;
+ if ((s = implied_typedef()) == 0)
+ (void)sprintf(s = buf, "enum %s", yystack.l_mark[-1].text.text);
+ new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-2].text.begin, DS_NONE);
+ }
+break;
+case 74:
+#line 741 "grammar.y"
+ {
+ char *s;
+ if ((s = implied_typedef()) == 0)
+ (void)sprintf(s = buf, "%s {}", yystack.l_mark[-1].text.text);
+ new_decl_spec(&yyval.decl_spec, s, yystack.l_mark[-1].text.begin, DS_NONE);
+ }
+break;
+case 75:
+#line 748 "grammar.y"
+ {
+ (void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
+ new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
+ }
+break;
+case 76:
+#line 756 "grammar.y"
+ {
+ imply_typedef("enum");
+ yyval.text = yystack.l_mark[0].text;
+ }
+break;
+case 79:
+#line 769 "grammar.y"
+ {
+ yyval.declarator = yystack.l_mark[0].declarator;
+ (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
+ free(yyval.declarator->text);
+ yyval.declarator->text = xstrdup(buf);
+ yyval.declarator->begin = yystack.l_mark[-1].text.begin;
+ yyval.declarator->pointer = TRUE;
+ }
+break;
+case 81:
+#line 782 "grammar.y"
+ {
+ yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
+ }
+break;
+case 82:
+#line 786 "grammar.y"
+ {
+ yyval.declarator = yystack.l_mark[-1].declarator;
+ (void)sprintf(buf, "(%s)", yyval.declarator->text);
+ free(yyval.declarator->text);
+ yyval.declarator->text = xstrdup(buf);
+ yyval.declarator->begin = yystack.l_mark[-2].text.begin;
+ }
+break;
+case 83:
+#line 794 "grammar.y"
+ {
+ yyval.declarator = yystack.l_mark[-1].declarator;
+ (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
+ free(yyval.declarator->text);
+ yyval.declarator->text = xstrdup(buf);
+ }
+break;
+case 84:
+#line 801 "grammar.y"
+ {
+ yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
+ yyval.declarator->params = yystack.l_mark[-1].param_list;
+ yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
+ yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
+ yyval.declarator->func_def = FUNC_ANSI;
+ }
+break;
+case 85:
+#line 809 "grammar.y"
+ {
+ yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
+ yyval.declarator->params = yystack.l_mark[-1].param_list;
+ yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
+ yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
+ yyval.declarator->func_def = FUNC_TRADITIONAL;
+ }
+break;
+case 86:
+#line 820 "grammar.y"
+ {
+ (void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
+ yyval.text.begin = yystack.l_mark[-1].text.begin;
+ }
+break;
+case 87:
+#line 825 "grammar.y"
+ {
+ (void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
+ yyval.text.begin = yystack.l_mark[-2].text.begin;
+ }
+break;
+case 88:
+#line 833 "grammar.y"
+ {
+ strcpy(yyval.text.text, "");
+ yyval.text.begin = 0L;
+ }
+break;
+case 90:
+#line 842 "grammar.y"
+ {
+ (void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
+ yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
+ free(yystack.l_mark[0].decl_spec.text);
+ }
+break;
+case 91:
+#line 848 "grammar.y"
+ {
+ (void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
+ yyval.text.begin = yystack.l_mark[-1].text.begin;
+ free(yystack.l_mark[0].decl_spec.text);
+ }
+break;
+case 93:
+#line 858 "grammar.y"
+ {
+ add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
+ }
+break;
+case 94:
+#line 865 "grammar.y"
+ {
+ new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
+ }
+break;
+case 95:
+#line 869 "grammar.y"
+ {
+ add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
+ }
+break;
+case 96:
+#line 876 "grammar.y"
+ {
+ check_untagged(&yystack.l_mark[-1].decl_spec);
+ yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
+ }
+break;
+case 97:
+#line 881 "grammar.y"
+ {
+ check_untagged(&yystack.l_mark[-1].decl_spec);
+ yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
+ }
+break;
+case 98:
+#line 886 "grammar.y"
+ {
+ check_untagged(&yystack.l_mark[0].decl_spec);
+ yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
+ }
+break;
+case 99:
+#line 894 "grammar.y"
+ {
+ new_ident_list(&yyval.param_list);
+ }
+break;
+case 101:
+#line 902 "grammar.y"
+ {
+ new_ident_list(&yyval.param_list);
+ add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
+ }
+break;
+case 102:
+#line 907 "grammar.y"
+ {
+ add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
+ }
+break;
+case 103:
+#line 914 "grammar.y"
+ {
+ yyval.text = yystack.l_mark[0].text;
+ }
+break;
+case 104:
+#line 918 "grammar.y"
+ {
+#if OPT_LINTLIBRARY
+ if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
+ yyval.text = yystack.l_mark[0].text;
+ } else
+#endif
+ (void)sprintf(yyval.text.text, "&%s", yystack.l_mark[0].text.text);
+ yyval.text.begin = yystack.l_mark[-1].text.begin;
+ }
+break;
+case 105:
+#line 931 "grammar.y"
+ {
+ yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
+ }
+break;
+case 106:
+#line 935 "grammar.y"
+ {
+ yyval.declarator = yystack.l_mark[0].declarator;
+ (void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
+ free(yyval.declarator->text);
+ yyval.declarator->text = xstrdup(buf);
+ yyval.declarator->begin = yystack.l_mark[-1].text.begin;
+ }
+break;
+case 108:
+#line 947 "grammar.y"
+ {
+ yyval.declarator = yystack.l_mark[-1].declarator;
+ (void)sprintf(buf, "(%s)", yyval.declarator->text);
+ free(yyval.declarator->text);
+ yyval.declarator->text = xstrdup(buf);
+ yyval.declarator->begin = yystack.l_mark[-2].text.begin;
+ }
+break;
+case 109:
+#line 955 "grammar.y"
+ {
+ yyval.declarator = yystack.l_mark[-1].declarator;
+ (void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
+ free(yyval.declarator->text);
+ yyval.declarator->text = xstrdup(buf);
+ }
+break;
+case 110:
+#line 962 "grammar.y"
+ {
+ yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
+ }
+break;
+case 111:
+#line 966 "grammar.y"
+ {
+ yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
+ yyval.declarator->params = yystack.l_mark[-1].param_list;
+ yyval.declarator->func_stack = yystack.l_mark[-3].declarator;
+ yyval.declarator->head = (yystack.l_mark[-3].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-3].declarator->head;
+ yyval.declarator->func_def = FUNC_ANSI;
+ }
+break;
+case 112:
+#line 974 "grammar.y"
+ {
+ yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
+ yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
+ yyval.declarator->head = (yystack.l_mark[-2].declarator->func_stack == NULL) ? yyval.declarator : yystack.l_mark[-2].declarator->head;
+ yyval.declarator->func_def = FUNC_ANSI;
+ }
+break;
+case 113:
+#line 981 "grammar.y"
+ {
+ Declarator *d;
+
+ d = new_declarator("", "", yystack.l_mark[-2].text.begin);
+ yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].text.begin);
+ yyval.declarator->params = yystack.l_mark[-1].param_list;
+ yyval.declarator->func_stack = d;
+ yyval.declarator->head = yyval.declarator;
+ yyval.declarator->func_def = FUNC_ANSI;
+ }
+break;
+case 114:
+#line 992 "grammar.y"
+ {
+ Declarator *d;
+
+ d = new_declarator("", "", yystack.l_mark[-1].text.begin);
+ yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-1].text.begin);
+ yyval.declarator->func_stack = d;
+ yyval.declarator->head = yyval.declarator;
+ yyval.declarator->func_def = FUNC_ANSI;
+ }
+break;
+#line 1953 "grammar.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: grammar.tab.h,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
+
+#define T_IDENTIFIER 257
+#define T_TYPEDEF_NAME 258
+#define T_DEFINE_NAME 259
+#define T_AUTO 260
+#define T_EXTERN 261
+#define T_REGISTER 262
+#define T_STATIC 263
+#define T_TYPEDEF 264
+#define T_INLINE 265
+#define T_EXTENSION 266
+#define T_CHAR 267
+#define T_DOUBLE 268
+#define T_FLOAT 269
+#define T_INT 270
+#define T_VOID 271
+#define T_LONG 272
+#define T_SHORT 273
+#define T_SIGNED 274
+#define T_UNSIGNED 275
+#define T_ENUM 276
+#define T_STRUCT 277
+#define T_UNION 278
+#define T_Bool 279
+#define T_Complex 280
+#define T_Imaginary 281
+#define T_TYPE_QUALIFIER 282
+#define T_BRACKETS 283
+#define T_LBRACE 284
+#define T_MATCHRBRACE 285
+#define T_ELLIPSIS 286
+#define T_INITIALIZER 287
+#define T_STRING_LITERAL 288
+#define T_ASM 289
+#define T_ASMARG 290
+#define T_VA_DCL 291
--- /dev/null
+/* $NetBSD: grammar.y,v 1.1.1.4 2011/09/10 21:22:07 christos Exp $ */
+
+/* Id: grammar.y,v 1.3 2010/11/23 01:28:47 tom Exp
+ *
+ * yacc grammar for C function prototype generator
+ * This was derived from the grammar in Appendix A of
+ * "The C Programming Language" by Kernighan and Ritchie.
+ */
+%expect 1
+%token <text> '(' '*' '&'
+ /* identifiers that are not reserved words */
+ T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME
+
+ /* storage class */
+ T_AUTO T_EXTERN T_REGISTER T_STATIC T_TYPEDEF
+ /* This keyword included for compatibility with C++. */
+ T_INLINE
+ /* This keyword included for compatibility with GCC */
+ T_EXTENSION
+
+ /* type specifiers */
+ T_CHAR T_DOUBLE T_FLOAT T_INT T_VOID
+ T_LONG T_SHORT T_SIGNED T_UNSIGNED
+ T_ENUM T_STRUCT T_UNION
+ /* C9X new types */
+ T_Bool T_Complex T_Imaginary
+
+ /* type qualifiers */
+ T_TYPE_QUALIFIER
+
+ /* paired square brackets and everything between them: [ ... ] */
+ T_BRACKETS
+
+%token
+ /* left brace */
+ T_LBRACE
+ /* all input to the matching right brace */
+ T_MATCHRBRACE
+
+ /* three periods */
+ T_ELLIPSIS
+
+ /* constant expression or paired braces following an equal sign */
+ T_INITIALIZER
+
+ /* string literal */
+ T_STRING_LITERAL
+
+ /* asm */
+ T_ASM
+ /* ( "string literal" ) following asm keyword */
+ T_ASMARG
+
+ /* va_dcl from <varargs.h> */
+ T_VA_DCL
+
+%type <decl_spec> decl_specifiers decl_specifier
+%type <decl_spec> storage_class type_specifier type_qualifier
+%type <decl_spec> struct_or_union_specifier enum_specifier
+%type <decl_list> init_declarator_list
+%type <declarator> init_declarator declarator direct_declarator
+%type <declarator> abs_declarator direct_abs_declarator
+%type <param_list> parameter_type_list parameter_list
+%type <parameter> parameter_declaration
+%type <param_list> opt_identifier_list identifier_list
+%type <text> struct_or_union pointer opt_type_qualifiers type_qualifier_list
+ any_id identifier_or_ref
+%type <text> enumeration
+
+%{
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#define OPT_LINTLIBRARY 1
+
+#ifndef TRUE
+#define TRUE (1)
+#endif
+
+#ifndef FALSE
+#define FALSE (0)
+#endif
+
+/* #include "cproto.h" */
+#define MAX_TEXT_SIZE 1024
+
+/* Prototype styles */
+#if OPT_LINTLIBRARY
+#define PROTO_ANSI_LLIB -2 /* form ANSI lint-library source */
+#define PROTO_LINTLIBRARY -1 /* form lint-library source */
+#endif
+#define PROTO_NONE 0 /* do not output any prototypes */
+#define PROTO_TRADITIONAL 1 /* comment out parameters */
+#define PROTO_ABSTRACT 2 /* comment out parameter names */
+#define PROTO_ANSI 3 /* ANSI C prototype */
+
+typedef int PrototypeStyle;
+
+typedef char boolean;
+
+extern boolean types_out;
+extern PrototypeStyle proto_style;
+
+#define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB)
+#define knrLintLibrary() (proto_style == PROTO_LINTLIBRARY)
+#define lintLibrary() (knrLintLibrary() || ansiLintLibrary())
+
+#if OPT_LINTLIBRARY
+#define FUNC_UNKNOWN -1 /* unspecified */
+#else
+#define FUNC_UNKNOWN 0 /* unspecified (same as FUNC_NONE) */
+#endif
+#define FUNC_NONE 0 /* not a function definition */
+#define FUNC_TRADITIONAL 1 /* traditional style */
+#define FUNC_ANSI 2 /* ANSI style */
+#define FUNC_BOTH 3 /* both styles */
+
+typedef int FuncDefStyle;
+
+/* Source file text */
+typedef struct text {
+ char text[MAX_TEXT_SIZE]; /* source text */
+ long begin; /* offset in temporary file */
+} Text;
+
+/* Declaration specifier flags */
+#define DS_NONE 0 /* default */
+#define DS_EXTERN 1 /* contains "extern" specifier */
+#define DS_STATIC 2 /* contains "static" specifier */
+#define DS_CHAR 4 /* contains "char" type specifier */
+#define DS_SHORT 8 /* contains "short" type specifier */
+#define DS_FLOAT 16 /* contains "float" type specifier */
+#define DS_INLINE 32 /* contains "inline" specifier */
+#define DS_JUNK 64 /* we're not interested in this declaration */
+
+/* This structure stores information about a declaration specifier. */
+typedef struct decl_spec {
+ unsigned short flags; /* flags defined above */
+ char *text; /* source text */
+ long begin; /* offset in temporary file */
+} DeclSpec;
+
+/* This is a list of function parameters. */
+typedef struct _ParameterList {
+ struct parameter *first; /* pointer to first parameter in list */
+ struct parameter *last; /* pointer to last parameter in list */
+ long begin_comment; /* begin offset of comment */
+ long end_comment; /* end offset of comment */
+ char *comment; /* comment at start of parameter list */
+} ParameterList;
+
+/* This structure stores information about a declarator. */
+typedef struct _Declarator {
+ char *name; /* name of variable or function */
+ char *text; /* source text */
+ long begin; /* offset in temporary file */
+ long begin_comment; /* begin offset of comment */
+ long end_comment; /* end offset of comment */
+ FuncDefStyle func_def; /* style of function definition */
+ ParameterList params; /* function parameters */
+ boolean pointer; /* TRUE if it declares a pointer */
+ struct _Declarator *head; /* head function declarator */
+ struct _Declarator *func_stack; /* stack of function declarators */
+ struct _Declarator *next; /* next declarator in list */
+} Declarator;
+
+/* This structure stores information about a function parameter. */
+typedef struct parameter {
+ struct parameter *next; /* next parameter in list */
+ DeclSpec decl_spec;
+ Declarator *declarator;
+ char *comment; /* comment following the parameter */
+} Parameter;
+
+/* This is a list of declarators. */
+typedef struct declarator_list {
+ Declarator *first; /* pointer to first declarator in list */
+ Declarator *last; /* pointer to last declarator in list */
+} DeclaratorList;
+
+/* #include "symbol.h" */
+typedef struct symbol {
+ struct symbol *next; /* next symbol in list */
+ char *name; /* name of symbol */
+ char *value; /* value of symbol (for defines) */
+ short flags; /* symbol attributes */
+} Symbol;
+
+/* parser stack entry type */
+typedef union {
+ Text text;
+ DeclSpec decl_spec;
+ Parameter *parameter;
+ ParameterList param_list;
+ Declarator *declarator;
+ DeclaratorList decl_list;
+} YYSTYPE;
+
+/* The hash table length should be a prime number. */
+#define SYM_MAX_HASH 251
+
+typedef struct symbol_table {
+ Symbol *bucket[SYM_MAX_HASH]; /* hash buckets */
+} SymbolTable;
+
+extern SymbolTable *new_symbol_table /* Create symbol table */
+ (void);
+extern void free_symbol_table /* Destroy symbol table */
+ (SymbolTable *s);
+extern Symbol *find_symbol /* Lookup symbol name */
+ (SymbolTable *s, const char *n);
+extern Symbol *new_symbol /* Define new symbol */
+ (SymbolTable *s, const char *n, const char *v, int f);
+
+/* #include "semantic.h" */
+extern void new_decl_spec (DeclSpec *, const char *, long, int);
+extern void free_decl_spec (DeclSpec *);
+extern void join_decl_specs (DeclSpec *, DeclSpec *, DeclSpec *);
+extern void check_untagged (DeclSpec *);
+extern Declarator *new_declarator (const char *, const char *, long);
+extern void free_declarator (Declarator *);
+extern void new_decl_list (DeclaratorList *, Declarator *);
+extern void free_decl_list (DeclaratorList *);
+extern void add_decl_list (DeclaratorList *, DeclaratorList *, Declarator *);
+extern Parameter *new_parameter (DeclSpec *, Declarator *);
+extern void free_parameter (Parameter *);
+extern void new_param_list (ParameterList *, Parameter *);
+extern void free_param_list (ParameterList *);
+extern void add_param_list (ParameterList *, ParameterList *, Parameter *);
+extern void new_ident_list (ParameterList *);
+extern void add_ident_list (ParameterList *, ParameterList *, const char *);
+extern void set_param_types (ParameterList *, DeclSpec *, DeclaratorList *);
+extern void gen_declarations (DeclSpec *, DeclaratorList *);
+extern void gen_prototype (DeclSpec *, Declarator *);
+extern void gen_func_declarator (Declarator *);
+extern void gen_func_definition (DeclSpec *, Declarator *);
+
+extern void init_parser (void);
+extern void process_file (FILE *infile, char *name);
+extern char *cur_text (void);
+extern char *cur_file_name (void);
+extern char *implied_typedef (void);
+extern void include_file (char *name, int convert);
+extern char *supply_parm (int count);
+extern char *xstrdup (const char *);
+extern int already_declared (char *name);
+extern int is_actual_func (Declarator *d);
+extern int lint_ellipsis (Parameter *p);
+extern int want_typedef (void);
+extern void begin_tracking (void);
+extern void begin_typedef (void);
+extern void copy_typedef (char *s);
+extern void ellipsis_varargs (Declarator *d);
+extern void end_typedef (void);
+extern void flush_varargs (void);
+extern void fmt_library (int code);
+extern void imply_typedef (const char *s);
+extern void indent (FILE *outf);
+extern void put_blankline (FILE *outf);
+extern void put_body (FILE *outf, DeclSpec *decl_spec, Declarator *declarator);
+extern void put_char (FILE *outf, int c);
+extern void put_error (void);
+extern void put_newline (FILE *outf);
+extern void put_padded (FILE *outf, const char *s);
+extern void put_string (FILE *outf, const char *s);
+extern void track_in (void);
+
+extern boolean file_comments;
+extern FuncDefStyle func_style;
+extern char base_file[];
+
+#define YYMAXDEPTH 150
+
+extern int yylex (void);
+
+/* declaration specifier attributes for the typedef statement currently being
+ * scanned
+ */
+static int cur_decl_spec_flags;
+
+/* pointer to parameter list for the current function definition */
+static ParameterList *func_params;
+
+/* A parser semantic action sets this pointer to the current declarator in
+ * a function parameter declaration in order to catch any comments following
+ * the parameter declaration on the same line. If the lexer scans a comment
+ * and <cur_declarator> is not NULL, then the comment is attached to the
+ * declarator. To ignore subsequent comments, the lexer sets this to NULL
+ * after scanning a comment or end of line.
+ */
+static Declarator *cur_declarator;
+
+/* temporary string buffer */
+static char buf[MAX_TEXT_SIZE];
+
+/* table of typedef names */
+static SymbolTable *typedef_names;
+
+/* table of define names */
+static SymbolTable *define_names;
+
+/* table of type qualifiers */
+static SymbolTable *type_qualifiers;
+
+/* information about the current input file */
+typedef struct {
+ char *base_name; /* base input file name */
+ char *file_name; /* current file name */
+ FILE *file; /* input file */
+ unsigned line_num; /* current line number in input file */
+ FILE *tmp_file; /* temporary file */
+ long begin_comment; /* tmp file offset after last written ) or ; */
+ long end_comment; /* tmp file offset after last comment */
+ boolean convert; /* if TRUE, convert function definitions */
+ boolean changed; /* TRUE if conversion done in this file */
+} IncludeStack;
+
+static IncludeStack *cur_file; /* current input file */
+
+/* #include "yyerror.c" */
+
+static int haveAnsiParam (void);
+
+
+/* Flags to enable us to find if a procedure returns a value.
+ */
+static int return_val; /* nonzero on BRACES iff return-expression found */
+
+static const char *
+dft_decl_spec (void)
+{
+ return (lintLibrary() && !return_val) ? "void" : "int";
+}
+
+static int
+haveAnsiParam (void)
+{
+ Parameter *p;
+ if (func_params != 0) {
+ for (p = func_params->first; p != 0; p = p->next) {
+ if (p->declarator->func_def == FUNC_ANSI) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+%}
+%%
+
+program
+ : /* empty */
+ | translation_unit
+ ;
+
+translation_unit
+ : external_declaration
+ | translation_unit external_declaration
+ ;
+
+external_declaration
+ : declaration
+ | function_definition
+ | ';'
+ | linkage_specification
+ | T_ASM T_ASMARG ';'
+ | error T_MATCHRBRACE
+ {
+ yyerrok;
+ }
+ | error ';'
+ {
+ yyerrok;
+ }
+ ;
+
+braces
+ : T_LBRACE T_MATCHRBRACE
+ ;
+
+linkage_specification
+ : T_EXTERN T_STRING_LITERAL braces
+ {
+ /* Provide an empty action here so bison will not complain about
+ * incompatible types in the default action it normally would
+ * have generated.
+ */
+ }
+ | T_EXTERN T_STRING_LITERAL declaration
+ {
+ /* empty */
+ }
+ ;
+
+declaration
+ : decl_specifiers ';'
+ {
+#if OPT_LINTLIBRARY
+ if (types_out && want_typedef()) {
+ gen_declarations(&$1, (DeclaratorList *)0);
+ flush_varargs();
+ }
+#endif
+ free_decl_spec(&$1);
+ end_typedef();
+ }
+ | decl_specifiers init_declarator_list ';'
+ {
+ if (func_params != NULL) {
+ set_param_types(func_params, &$1, &$2);
+ } else {
+ gen_declarations(&$1, &$2);
+#if OPT_LINTLIBRARY
+ flush_varargs();
+#endif
+ free_decl_list(&$2);
+ }
+ free_decl_spec(&$1);
+ end_typedef();
+ }
+ | any_typedef decl_specifiers
+ {
+ cur_decl_spec_flags = $2.flags;
+ free_decl_spec(&$2);
+ }
+ opt_declarator_list ';'
+ {
+ end_typedef();
+ }
+ ;
+
+any_typedef
+ : T_EXTENSION T_TYPEDEF
+ {
+ begin_typedef();
+ }
+ | T_TYPEDEF
+ {
+ begin_typedef();
+ }
+ ;
+
+opt_declarator_list
+ : /* empty */
+ | declarator_list
+ ;
+
+declarator_list
+ : declarator
+ {
+ int flags = cur_decl_spec_flags;
+
+ /* If the typedef is a pointer type, then reset the short type
+ * flags so it does not get promoted.
+ */
+ if (strcmp($1->text, $1->name) != 0)
+ flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
+ new_symbol(typedef_names, $1->name, NULL, flags);
+ free_declarator($1);
+ }
+ | declarator_list ',' declarator
+ {
+ int flags = cur_decl_spec_flags;
+
+ if (strcmp($3->text, $3->name) != 0)
+ flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
+ new_symbol(typedef_names, $3->name, NULL, flags);
+ free_declarator($3);
+ }
+ ;
+
+function_definition
+ : decl_specifiers declarator
+ {
+ check_untagged(&$1);
+ if ($2->func_def == FUNC_NONE) {
+ yyerror("syntax error");
+ YYERROR;
+ }
+ func_params = &($2->head->params);
+ func_params->begin_comment = cur_file->begin_comment;
+ func_params->end_comment = cur_file->end_comment;
+ }
+ opt_declaration_list T_LBRACE
+ {
+ /* If we're converting to K&R and we've got a nominally K&R
+ * function which has a parameter which is ANSI (i.e., a prototyped
+ * function pointer), then we must override the deciphered value of
+ * 'func_def' so that the parameter will be converted.
+ */
+ if (func_style == FUNC_TRADITIONAL
+ && haveAnsiParam()
+ && $2->head->func_def == func_style) {
+ $2->head->func_def = FUNC_BOTH;
+ }
+
+ func_params = NULL;
+
+ if (cur_file->convert)
+ gen_func_definition(&$1, $2);
+ gen_prototype(&$1, $2);
+#if OPT_LINTLIBRARY
+ flush_varargs();
+#endif
+ free_decl_spec(&$1);
+ free_declarator($2);
+ }
+ T_MATCHRBRACE
+ | declarator
+ {
+ if ($1->func_def == FUNC_NONE) {
+ yyerror("syntax error");
+ YYERROR;
+ }
+ func_params = &($1->head->params);
+ func_params->begin_comment = cur_file->begin_comment;
+ func_params->end_comment = cur_file->end_comment;
+ }
+ opt_declaration_list T_LBRACE T_MATCHRBRACE
+ {
+ DeclSpec decl_spec;
+
+ func_params = NULL;
+
+ new_decl_spec(&decl_spec, dft_decl_spec(), $1->begin, DS_NONE);
+ if (cur_file->convert)
+ gen_func_definition(&decl_spec, $1);
+ gen_prototype(&decl_spec, $1);
+#if OPT_LINTLIBRARY
+ flush_varargs();
+#endif
+ free_decl_spec(&decl_spec);
+ free_declarator($1);
+ }
+ ;
+
+opt_declaration_list
+ : /* empty */
+ | T_VA_DCL
+ | declaration_list
+ ;
+
+declaration_list
+ : declaration
+ | declaration_list declaration
+ ;
+
+decl_specifiers
+ : decl_specifier
+ | decl_specifiers decl_specifier
+ {
+ join_decl_specs(&$$, &$1, &$2);
+ free($1.text);
+ free($2.text);
+ }
+ ;
+
+decl_specifier
+ : storage_class
+ | type_specifier
+ | type_qualifier
+ ;
+
+storage_class
+ : T_AUTO
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_EXTERN
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_EXTERN);
+ }
+ | T_REGISTER
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_STATIC
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_STATIC);
+ }
+ | T_INLINE
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_INLINE);
+ }
+ | T_EXTENSION
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_JUNK);
+ }
+ ;
+
+type_specifier
+ : T_CHAR
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_CHAR);
+ }
+ | T_DOUBLE
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_FLOAT
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_FLOAT);
+ }
+ | T_INT
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_LONG
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_SHORT
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_SHORT);
+ }
+ | T_SIGNED
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_UNSIGNED
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_VOID
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_Bool
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_CHAR);
+ }
+ | T_Complex
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_Imaginary
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_TYPEDEF_NAME
+ {
+ Symbol *s;
+ s = find_symbol(typedef_names, $1.text);
+ if (s != NULL)
+ new_decl_spec(&$$, $1.text, $1.begin, s->flags);
+ }
+ | struct_or_union_specifier
+ | enum_specifier
+ ;
+
+type_qualifier
+ : T_TYPE_QUALIFIER
+ {
+ new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+ }
+ | T_DEFINE_NAME
+ {
+ /* This rule allows the <pointer> nonterminal to scan #define
+ * names as if they were type modifiers.
+ */
+ Symbol *s;
+ s = find_symbol(define_names, $1.text);
+ if (s != NULL)
+ new_decl_spec(&$$, $1.text, $1.begin, s->flags);
+ }
+ ;
+
+struct_or_union_specifier
+ : struct_or_union any_id braces
+ {
+ char *s;
+ if ((s = implied_typedef()) == 0)
+ (void)sprintf(s = buf, "%s %s", $1.text, $2.text);
+ new_decl_spec(&$$, s, $1.begin, DS_NONE);
+ }
+ | struct_or_union braces
+ {
+ char *s;
+ if ((s = implied_typedef()) == 0)
+ (void)sprintf(s = buf, "%s {}", $1.text);
+ new_decl_spec(&$$, s, $1.begin, DS_NONE);
+ }
+ | struct_or_union any_id
+ {
+ (void)sprintf(buf, "%s %s", $1.text, $2.text);
+ new_decl_spec(&$$, buf, $1.begin, DS_NONE);
+ }
+ ;
+
+struct_or_union
+ : T_STRUCT
+ {
+ imply_typedef($$.text);
+ }
+ | T_UNION
+ {
+ imply_typedef($$.text);
+ }
+ ;
+
+init_declarator_list
+ : init_declarator
+ {
+ new_decl_list(&$$, $1);
+ }
+ | init_declarator_list ',' init_declarator
+ {
+ add_decl_list(&$$, &$1, $3);
+ }
+ ;
+
+init_declarator
+ : declarator
+ {
+ if ($1->func_def != FUNC_NONE && func_params == NULL &&
+ func_style == FUNC_TRADITIONAL && cur_file->convert) {
+ gen_func_declarator($1);
+ fputs(cur_text(), cur_file->tmp_file);
+ }
+ cur_declarator = $$;
+ }
+ | declarator '='
+ {
+ if ($1->func_def != FUNC_NONE && func_params == NULL &&
+ func_style == FUNC_TRADITIONAL && cur_file->convert) {
+ gen_func_declarator($1);
+ fputs(" =", cur_file->tmp_file);
+ }
+ }
+ T_INITIALIZER
+ ;
+
+enum_specifier
+ : enumeration any_id braces
+ {
+ char *s;
+ if ((s = implied_typedef()) == 0)
+ (void)sprintf(s = buf, "enum %s", $2.text);
+ new_decl_spec(&$$, s, $1.begin, DS_NONE);
+ }
+ | enumeration braces
+ {
+ char *s;
+ if ((s = implied_typedef()) == 0)
+ (void)sprintf(s = buf, "%s {}", $1.text);
+ new_decl_spec(&$$, s, $1.begin, DS_NONE);
+ }
+ | enumeration any_id
+ {
+ (void)sprintf(buf, "enum %s", $2.text);
+ new_decl_spec(&$$, buf, $1.begin, DS_NONE);
+ }
+ ;
+
+enumeration
+ : T_ENUM
+ {
+ imply_typedef("enum");
+ $$ = $1;
+ }
+ ;
+
+any_id
+ : T_IDENTIFIER
+ | T_TYPEDEF_NAME
+ ;
+
+declarator
+ : pointer direct_declarator
+ {
+ $$ = $2;
+ (void)sprintf(buf, "%s%s", $1.text, $$->text);
+ free($$->text);
+ $$->text = xstrdup(buf);
+ $$->begin = $1.begin;
+ $$->pointer = TRUE;
+ }
+ | direct_declarator
+ ;
+
+direct_declarator
+ : identifier_or_ref
+ {
+ $$ = new_declarator($1.text, $1.text, $1.begin);
+ }
+ | '(' declarator ')'
+ {
+ $$ = $2;
+ (void)sprintf(buf, "(%s)", $$->text);
+ free($$->text);
+ $$->text = xstrdup(buf);
+ $$->begin = $1.begin;
+ }
+ | direct_declarator T_BRACKETS
+ {
+ $$ = $1;
+ (void)sprintf(buf, "%s%s", $$->text, $2.text);
+ free($$->text);
+ $$->text = xstrdup(buf);
+ }
+ | direct_declarator '(' parameter_type_list ')'
+ {
+ $$ = new_declarator("%s()", $1->name, $1->begin);
+ $$->params = $3;
+ $$->func_stack = $1;
+ $$->head = ($1->func_stack == NULL) ? $$ : $1->head;
+ $$->func_def = FUNC_ANSI;
+ }
+ | direct_declarator '(' opt_identifier_list ')'
+ {
+ $$ = new_declarator("%s()", $1->name, $1->begin);
+ $$->params = $3;
+ $$->func_stack = $1;
+ $$->head = ($1->func_stack == NULL) ? $$ : $1->head;
+ $$->func_def = FUNC_TRADITIONAL;
+ }
+ ;
+
+pointer
+ : '*' opt_type_qualifiers
+ {
+ (void)sprintf($$.text, "*%s", $2.text);
+ $$.begin = $1.begin;
+ }
+ | '*' opt_type_qualifiers pointer
+ {
+ (void)sprintf($$.text, "*%s%s", $2.text, $3.text);
+ $$.begin = $1.begin;
+ }
+ ;
+
+opt_type_qualifiers
+ : /* empty */
+ {
+ strcpy($$.text, "");
+ $$.begin = 0L;
+ }
+ | type_qualifier_list
+ ;
+
+type_qualifier_list
+ : type_qualifier
+ {
+ (void)sprintf($$.text, "%s ", $1.text);
+ $$.begin = $1.begin;
+ free($1.text);
+ }
+ | type_qualifier_list type_qualifier
+ {
+ (void)sprintf($$.text, "%s%s ", $1.text, $2.text);
+ $$.begin = $1.begin;
+ free($2.text);
+ }
+ ;
+
+parameter_type_list
+ : parameter_list
+ | parameter_list ',' T_ELLIPSIS
+ {
+ add_ident_list(&$$, &$1, "...");
+ }
+ ;
+
+parameter_list
+ : parameter_declaration
+ {
+ new_param_list(&$$, $1);
+ }
+ | parameter_list ',' parameter_declaration
+ {
+ add_param_list(&$$, &$1, $3);
+ }
+ ;
+
+parameter_declaration
+ : decl_specifiers declarator
+ {
+ check_untagged(&$1);
+ $$ = new_parameter(&$1, $2);
+ }
+ | decl_specifiers abs_declarator
+ {
+ check_untagged(&$1);
+ $$ = new_parameter(&$1, $2);
+ }
+ | decl_specifiers
+ {
+ check_untagged(&$1);
+ $$ = new_parameter(&$1, (Declarator *)0);
+ }
+ ;
+
+opt_identifier_list
+ : /* empty */
+ {
+ new_ident_list(&$$);
+ }
+ | identifier_list
+ ;
+
+identifier_list
+ : any_id
+ {
+ new_ident_list(&$$);
+ add_ident_list(&$$, &$$, $1.text);
+ }
+ | identifier_list ',' any_id
+ {
+ add_ident_list(&$$, &$1, $3.text);
+ }
+ ;
+
+identifier_or_ref
+ : any_id
+ {
+ $$ = $1;
+ }
+ | '&' any_id
+ {
+#if OPT_LINTLIBRARY
+ if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
+ $$ = $2;
+ } else
+#endif
+ (void)sprintf($$.text, "&%s", $2.text);
+ $$.begin = $1.begin;
+ }
+ ;
+
+abs_declarator
+ : pointer
+ {
+ $$ = new_declarator($1.text, "", $1.begin);
+ }
+ | pointer direct_abs_declarator
+ {
+ $$ = $2;
+ (void)sprintf(buf, "%s%s", $1.text, $$->text);
+ free($$->text);
+ $$->text = xstrdup(buf);
+ $$->begin = $1.begin;
+ }
+ | direct_abs_declarator
+ ;
+
+direct_abs_declarator
+ : '(' abs_declarator ')'
+ {
+ $$ = $2;
+ (void)sprintf(buf, "(%s)", $$->text);
+ free($$->text);
+ $$->text = xstrdup(buf);
+ $$->begin = $1.begin;
+ }
+ | direct_abs_declarator T_BRACKETS
+ {
+ $$ = $1;
+ (void)sprintf(buf, "%s%s", $$->text, $2.text);
+ free($$->text);
+ $$->text = xstrdup(buf);
+ }
+ | T_BRACKETS
+ {
+ $$ = new_declarator($1.text, "", $1.begin);
+ }
+ | direct_abs_declarator '(' parameter_type_list ')'
+ {
+ $$ = new_declarator("%s()", "", $1->begin);
+ $$->params = $3;
+ $$->func_stack = $1;
+ $$->head = ($1->func_stack == NULL) ? $$ : $1->head;
+ $$->func_def = FUNC_ANSI;
+ }
+ | direct_abs_declarator '(' ')'
+ {
+ $$ = new_declarator("%s()", "", $1->begin);
+ $$->func_stack = $1;
+ $$->head = ($1->func_stack == NULL) ? $$ : $1->head;
+ $$->func_def = FUNC_ANSI;
+ }
+ | '(' parameter_type_list ')'
+ {
+ Declarator *d;
+
+ d = new_declarator("", "", $1.begin);
+ $$ = new_declarator("%s()", "", $1.begin);
+ $$->params = $2;
+ $$->func_stack = d;
+ $$->head = $$;
+ $$->func_def = FUNC_ANSI;
+ }
+ | '(' ')'
+ {
+ Declarator *d;
+
+ d = new_declarator("", "", $1.begin);
+ $$ = new_declarator("%s()", "", $1.begin);
+ $$->func_stack = d;
+ $$->head = $$;
+ $$->func_def = FUNC_ANSI;
+ }
+ ;
+
+%%
+
+/* lex.yy.c */
+#define BEGIN yy_start = 1 + 2 *
+
+#define CPP1 1
+#define INIT1 2
+#define INIT2 3
+#define CURLY 4
+#define LEXYACC 5
+#define ASM 6
+#define CPP_INLINE 7
+
+extern char *yytext;
+extern FILE *yyin, *yyout;
+
+static int curly; /* number of curly brace nesting levels */
+static int ly_count; /* number of occurances of %% */
+static int inc_depth; /* include nesting level */
+static SymbolTable *included_files; /* files already included */
+static int yy_start = 0; /* start state number */
+
+#define grammar_error(s) yaccError(s)
+
+static void
+yaccError (const char *msg)
+{
+ func_params = NULL;
+ put_error(); /* tell what line we're on, and what file */
+ fprintf(stderr, "%s at token '%s'\n", msg, yytext);
+}
+
+/* Initialize the table of type qualifier keywords recognized by the lexical
+ * analyzer.
+ */
+void
+init_parser (void)
+{
+ static const char *keywords[] = {
+ "const",
+ "restrict",
+ "volatile",
+ "interrupt",
+#ifdef vms
+ "noshare",
+ "readonly",
+#endif
+#if defined(MSDOS) || defined(OS2)
+ "__cdecl",
+ "__export",
+ "__far",
+ "__fastcall",
+ "__fortran",
+ "__huge",
+ "__inline",
+ "__interrupt",
+ "__loadds",
+ "__near",
+ "__pascal",
+ "__saveregs",
+ "__segment",
+ "__stdcall",
+ "__syscall",
+ "_cdecl",
+ "_cs",
+ "_ds",
+ "_es",
+ "_export",
+ "_far",
+ "_fastcall",
+ "_fortran",
+ "_huge",
+ "_interrupt",
+ "_loadds",
+ "_near",
+ "_pascal",
+ "_saveregs",
+ "_seg",
+ "_segment",
+ "_ss",
+ "cdecl",
+ "far",
+ "huge",
+ "near",
+ "pascal",
+#ifdef OS2
+ "__far16",
+#endif
+#endif
+#ifdef __GNUC__
+ /* gcc aliases */
+ "__builtin_va_arg",
+ "__builtin_va_list",
+ "__const",
+ "__const__",
+ "__inline",
+ "__inline__",
+ "__restrict",
+ "__restrict__",
+ "__volatile",
+ "__volatile__",
+#endif
+ };
+ unsigned i;
+
+ /* Initialize type qualifier table. */
+ type_qualifiers = new_symbol_table();
+ for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
+ new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
+ }
+}
+
+/* Process the C source file. Write function prototypes to the standard
+ * output. Convert function definitions and write the converted source
+ * code to a temporary file.
+ */
+void
+process_file (FILE *infile, char *name)
+{
+ char *s;
+
+ if (strlen(name) > 2) {
+ s = name + strlen(name) - 2;
+ if (*s == '.') {
+ ++s;
+ if (*s == 'l' || *s == 'y')
+ BEGIN LEXYACC;
+#if defined(MSDOS) || defined(OS2)
+ if (*s == 'L' || *s == 'Y')
+ BEGIN LEXYACC;
+#endif
+ }
+ }
+
+ included_files = new_symbol_table();
+ typedef_names = new_symbol_table();
+ define_names = new_symbol_table();
+ inc_depth = -1;
+ curly = 0;
+ ly_count = 0;
+ func_params = NULL;
+ yyin = infile;
+ include_file(strcpy(base_file, name), func_style != FUNC_NONE);
+ if (file_comments) {
+#if OPT_LINTLIBRARY
+ if (lintLibrary()) {
+ put_blankline(stdout);
+ begin_tracking();
+ }
+#endif
+ put_string(stdout, "/* ");
+ put_string(stdout, cur_file_name());
+ put_string(stdout, " */\n");
+ }
+ yyparse();
+ free_symbol_table(define_names);
+ free_symbol_table(typedef_names);
+ free_symbol_table(included_files);
+}
+
+#ifdef NO_LEAKS
+void
+free_parser(void)
+{
+ free_symbol_table (type_qualifiers);
+#ifdef FLEX_SCANNER
+ if (yy_current_buffer != 0)
+ yy_delete_buffer(yy_current_buffer);
+#endif
+}
+#endif
--- /dev/null
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr '+' expr
+ 8 | expr '-' expr
+ 9 | expr '*' expr
+ 10 | expr '/' expr
+ 11 | expr '%' expr
+ 12 | expr '&' expr
+ 13 | expr '|' expr
+ 14 | '-' expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+\f
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ DIGIT shift 3
+ LETTER shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 4
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 11
+ '|' reduce 15
+ '&' reduce 15
+ '+' reduce 15
+ '-' reduce 15
+ '*' reduce 15
+ '/' reduce 15
+ '%' reduce 15
+ '\n' reduce 15
+
+
+state 5
+ expr : '-' . expr (14)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 13
+ number goto 9
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ '|' reduce 16
+ '&' reduce 16
+ '+' reduce 16
+ '-' reduce 16
+ '*' reduce 16
+ '/' reduce 16
+ '%' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ stat : LETTER '=' . expr (5)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 12
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+state 13
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : '-' expr . (14)
+
+ . reduce 14
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr '|' . expr (13)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr '&' . expr (12)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr '+' . expr (7)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr '-' . expr (8)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr '*' . expr (9)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr '/' . expr (10)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '%' . expr (11)
+
+ DIGIT shift 3
+ LETTER shift 12
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '|' shift 16
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+state 26
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ '&' shift 17
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+state 27
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr '&' expr . (12)
+ expr : expr . '|' expr (13)
+
+ '+' shift 18
+ '-' shift 19
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 12
+ '&' reduce 12
+ '\n' reduce 12
+ ')' reduce 12
+
+
+state 28
+ expr : expr . '+' expr (7)
+ expr : expr '+' expr . (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 7
+ '&' reduce 7
+ '+' reduce 7
+ '-' reduce 7
+ '\n' reduce 7
+ ')' reduce 7
+
+
+state 29
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr '-' expr . (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ '*' shift 20
+ '/' shift 21
+ '%' shift 22
+ '|' reduce 8
+ '&' reduce 8
+ '+' reduce 8
+ '-' reduce 8
+ '\n' reduce 8
+ ')' reduce 8
+
+
+state 30
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr '*' expr . (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 9
+
+
+state 31
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr '/' expr . (10)
+ expr : expr . '%' expr (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 10
+
+
+state 32
+ expr : expr . '+' expr (7)
+ expr : expr . '-' expr (8)
+ expr : expr . '*' expr (9)
+ expr : expr . '/' expr (10)
+ expr : expr . '%' expr (11)
+ expr : expr '%' expr . (11)
+ expr : expr . '&' expr (12)
+ expr : expr . '|' expr (13)
+
+ . reduce 11
+
+
+16 terminals, 5 nonterminals
+19 grammar rules, 33 states
--- /dev/null
+/* $NetBSD: pure_calc.tab.c,v 1.1.1.3 2011/09/10 21:22:03 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse calc_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc_rule
+#endif /* yyrule */
+#define YYPREFIX "calc_"
+
+#define YYPURE 1
+
+#line 2 "pure_calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+#line 106 "pure_calc.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
+# define YYLEX yylex(&yylval, YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(YYSTYPE *yylval)
+# define YYLEX yylex(&yylval)
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
+#define YYERRCODE 256
+static const short calc_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short calc_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short calc_defred[] = { 1,
+ 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
+ 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
+ 10, 11,
+};
+static const short calc_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short calc_sindex[] = { 0,
+ -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
+ -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
+ -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
+ 0, 0,
+};
+static const short calc_rindex[] = { 0,
+ 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
+ 0, 0,
+};
+static const short calc_gindex[] = { 0,
+ 0, 65, 0,
+};
+#define YYTABLESIZE 220
+static const short calc_table[] = { 6,
+ 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
+ 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
+ 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
+ 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
+ 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
+ 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
+ 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
+ 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
+ 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
+ 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
+ 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
+ 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
+ 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
+};
+static const short calc_check[] = { 40,
+ 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
+ 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
+ -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
+ -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
+ -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
+ 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
+ -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
+ 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
+ -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
+ -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
+ -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
+ -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
+ -1, -1, -1, -1, -1, 124, -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, 256, 257, 258, 257, 258,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 259
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr '+' expr",
+"expr : expr '-' expr",
+"expr : expr '*' expr",
+"expr : expr '/' expr",
+"expr : expr '%' expr",
+"expr : expr '&' expr",
+"expr : expr '|' expr",
+"expr : '-' expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+#line 63 "pure_calc.y"
+ /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(YYSTYPE *value)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ *value = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ *value = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 338 "pure_calc.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yyerrflag;
+ int yychar;
+ YYSTYPE yyval;
+ YYSTYPE yylval;
+
+ /* variables for the parser stack */
+ YYSTACKDATA yystack;
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 25 "pure_calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 29 "pure_calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 31 "pure_calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 35 "pure_calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 37 "pure_calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 39 "pure_calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 41 "pure_calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 43 "pure_calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 45 "pure_calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 47 "pure_calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 49 "pure_calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 51 "pure_calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 53 "pure_calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 58 "pure_calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 60 "pure_calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 611 "pure_calc.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: pure_calc.tab.h,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
+
+#define DIGIT 257
+#define LETTER 258
+#define UMINUS 259
--- /dev/null
+/* $NetBSD: pure_calc.y,v 1.1.1.3 2011/09/10 21:22:10 christos Exp $ */
+
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+%}
+
+%start list
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr '+' expr
+ { $$ = $1 + $3; }
+ | expr '-' expr
+ { $$ = $1 - $3; }
+ | expr '*' expr
+ { $$ = $1 * $3; }
+ | expr '/' expr
+ { $$ = $1 / $3; }
+ | expr '%' expr
+ { $$ = $1 % $3; }
+ | expr '&' expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | '-' expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(YYSTYPE *value)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ *value = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ *value = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
--- /dev/null
+ 0 $accept : S $end
+
+ 1 S : error
+\f
+state 0
+ $accept : . S $end (0)
+
+ error shift 1
+ . error
+
+ S goto 2
+
+
+state 1
+ S : error . (1)
+
+ . reduce 1
+
+
+state 2
+ $accept : S . $end (0)
+
+ $end accept
+
+
+2 terminals, 2 nonterminals
+2 grammar rules, 3 states
--- /dev/null
+/* $NetBSD: pure_error.tab.c,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
+
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse error_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex error_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror error_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar error_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval error_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval error_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug error_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs error_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag error_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs error_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen error_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred error_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto error_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex error_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex error_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex error_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable error_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck error_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname error_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule error_rule
+#endif /* yyrule */
+#define YYPREFIX "error_"
+
+#define YYPURE 1
+
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
+# define YYLEX yylex(&yylval, YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(YYSTYPE *yylval)
+# define YYLEX yylex(&yylval)
+#endif
+
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
+extern int YYPARSE_DECL();
+
+#define YYERRCODE 256
+static const short error_lhs[] = { -1,
+ 0,
+};
+static const short error_len[] = { 2,
+ 1,
+};
+static const short error_defred[] = { 0,
+ 1, 0,
+};
+static const short error_dgoto[] = { 2,
+};
+static const short error_sindex[] = { -256,
+ 0, 0,
+};
+static const short error_rindex[] = { 0,
+ 0, 0,
+};
+static const short error_gindex[] = { 0,
+};
+#define YYTABLESIZE 0
+static const short error_table[] = { 1,
+};
+static const short error_check[] = { 256,
+};
+#define YYFINAL 2
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 0
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",
+};
+static const char *yyrule[] = {
+"$accept : S",
+"S : error",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+#line 4 "pure_error.y"
+
+#include <stdio.h>
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main(void)
+{
+ printf("yyparse() = %d\n", yyparse());
+ return 0;
+}
+
+int
+yylex(YYSTYPE *value)
+{
+ return value ? 0 : -1;
+}
+
+static void
+yyerror(const char* s)
+{
+ printf("%s\n", s);
+}
+#line 226 "pure_error.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yyerrflag;
+ int yychar;
+ YYSTYPE yyval;
+ YYSTYPE yylval;
+
+ /* variables for the parser stack */
+ YYSTACKDATA yystack;
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
--- /dev/null
+/* $NetBSD: pure_error.tab.h,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
+
--- /dev/null
+/* $NetBSD: pure_error.y,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
+
+%%
+S: error
+%%
+
+#include <stdio.h>
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+int
+main(void)
+{
+ printf("yyparse() = %d\n", yyparse());
+ return 0;
+}
+
+int
+yylex(YYSTYPE *value)
+{
+ return value ? 0 : -1;
+}
+
+static void
+yyerror(const char* s)
+{
+ printf("%s\n", s);
+}
--- /dev/null
+#!/bin/sh
+# Id: run_lint.sh,v 1.1 2010/06/08 09:00:58 tom Exp
+# vi:ts=4 sw=4:
+
+# run lint on each of the ".c" files in the test directory
+
+if test $# = 1
+then
+ PROG_DIR=`pwd`
+ TEST_DIR=$1
+else
+ PROG_DIR=..
+ TEST_DIR=.
+fi
+
+echo '** '`date`
+for i in ${TEST_DIR}/*.c
+do
+ make -f $PROG_DIR/makefile lint C_FILES=$i srcdir=$PROG_DIR
+done
--- /dev/null
+#!/bin/sh
+# Id: run_make.sh,v 1.1 2010/06/08 09:00:39 tom Exp
+# vi:ts=4 sw=4:
+
+# do a test-compile on each of the ".c" files in the test-directory
+
+if test $# = 1
+then
+ PROG_DIR=`pwd`
+ TEST_DIR=$1
+else
+ PROG_DIR=..
+ TEST_DIR=.
+fi
+
+echo '** '`date`
+for i in ${TEST_DIR}/*.c
+do
+ obj=`echo "$i" |sed -e 's/\.c$/.o/'`
+ make -f $PROG_DIR/makefile $obj C_FILES=$i srcdir=$PROG_DIR
+ test -f $obj && rm $obj
+done
--- /dev/null
+#!/bin/sh
+# Id: run_test.sh,v 1.6 2010/06/08 08:53:38 tom Exp
+# vi:ts=4 sw=4:
+
+if test $# = 1
+then
+ PROG_DIR=`pwd`
+ TEST_DIR=$1
+else
+ PROG_DIR=..
+ TEST_DIR=.
+fi
+
+YACC=$PROG_DIR/yacc
+
+tmpfile=temp$$
+
+echo '** '`date`
+for i in ${TEST_DIR}/*.y
+do
+ case $i in
+ test*)
+ echo "?? ignored $i"
+ ;;
+ *)
+ root=`basename $i .y`
+ ROOT="test-$root"
+ prefix=${root}_
+
+ OPTS=
+ TYPE=".output .tab.c .tab.h"
+ case $i in
+ ${TEST_DIR}/code_*)
+ OPTS="$OPTS -r"
+ TYPE="$TYPE .code.c"
+ prefix=`echo "$prefix" | sed -e 's/^code_//'`
+ ;;
+ ${TEST_DIR}/pure_*)
+ OPTS="$OPTS -P"
+ prefix=`echo "$prefix" | sed -e 's/^pure_//'`
+ ;;
+ esac
+
+ $YACC $OPTS -v -d -p $prefix -b $ROOT $i
+ for type in $TYPE
+ do
+ REF=${TEST_DIR}/${root}${type}
+ CMP=${ROOT}${type}
+ if test ! -f $CMP ; then
+ echo "...not found $CMP"
+ continue
+ fi
+ sed -e s,$CMP,$REF, \
+ -e /YYPATCH/d \
+ -e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \
+ < $CMP >$tmpfile \
+ && mv $tmpfile $CMP
+ if test ! -f $REF
+ then
+ mv $CMP $REF
+ echo "...saved $REF"
+ elif ( cmp -s $REF $CMP )
+ then
+ echo "...ok $REF"
+ rm -f $CMP
+ else
+ echo "...diff $REF"
+ diff -u $REF $CMP
+ fi
+ done
+ ;;
+ esac
+done
-/* $NetBSD: verbose.c,v 1.10 2009/04/14 09:41:31 lukem Exp $ */
-
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(__RCSID) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)verbose.c 5.3 (Berkeley) 1/20/91";
-#else
-__RCSID("$NetBSD: verbose.c,v 1.10 2009/04/14 09:41:31 lukem Exp $");
-#endif
-#endif /* not lint */
+/* $NetBSD: verbose.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
+/* Id: verbose.c,v 1.9 2010/06/09 08:58:29 tom Exp */
#include "defs.h"
-static short *null_rules;
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: verbose.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
-static void log_unused(void);
static void log_conflicts(void);
-static void print_state(int);
-static void print_conflicts(int);
-static void print_core(int);
-static void print_nulls(int);
-static void print_actions(int);
-static void print_shifts(action *);
-static void print_reductions(action *, int);
-static void print_gotos(int);
+static void log_unused(void);
+static void print_actions(int stateno);
+static void print_conflicts(int state);
+static void print_core(int state);
+static void print_gotos(int stateno);
+static void print_nulls(int state);
+static void print_shifts(action *p);
+static void print_state(int state);
+static void print_reductions(action *p, int defred2);
+
+static short *null_rules;
void
verbose(void)
{
int i;
- if (!vflag) return;
+ if (!vflag)
+ return;
+
+ null_rules = (short *)MALLOC((unsigned)nrules * sizeof(short));
+ NO_SPACE(null_rules);
- null_rules = (short *) MALLOC(nrules*sizeof(short));
- if (null_rules == 0) no_space();
fprintf(verbose_file, "\f\n");
for (i = 0; i < nstates; i++)
print_state(i);
fprintf(verbose_file, "%d grammar rules, %d states\n", nrules - 2, nstates);
}
-
static void
log_unused(void)
{
}
}
-
static void
log_conflicts(void)
{
if (SRconflicts[i] || RRconflicts[i])
{
fprintf(verbose_file, "State %d contains ", i);
- if (SRconflicts[i] == 1)
- fprintf(verbose_file, "1 shift/reduce conflict");
- else if (SRconflicts[i] > 1)
- fprintf(verbose_file, "%d shift/reduce conflicts",
- SRconflicts[i]);
+ if (SRconflicts[i] > 0)
+ fprintf(verbose_file, "%d shift/reduce conflict%s",
+ SRconflicts[i],
+ PLURAL(SRconflicts[i]));
if (SRconflicts[i] && RRconflicts[i])
fprintf(verbose_file, ", ");
- if (RRconflicts[i] == 1)
- fprintf(verbose_file, "1 reduce/reduce conflict");
- else if (RRconflicts[i] > 1)
- fprintf(verbose_file, "%d reduce/reduce conflicts",
- RRconflicts[i]);
+ if (RRconflicts[i] > 0)
+ fprintf(verbose_file, "%d reduce/reduce conflict%s",
+ RRconflicts[i],
+ PLURAL(RRconflicts[i]));
fprintf(verbose_file, ".\n");
}
}
}
-
static void
print_state(int state)
{
print_actions(state);
}
-
static void
print_conflicts(int state)
{
int symbol, act, number;
action *p;
- /* keep gcc -Wall happy. */
- act = number = 0;
-
+ act = 0; /* not shift/reduce... */
+ number = -1;
symbol = -1;
for (p = parser[state]; p; p = p->next)
{
}
}
-
static void
print_core(int state)
{
{
sp1 = sp = ritem + statep->items[i];
- while (*sp >= 0) ++sp;
+ while (*sp >= 0)
+ ++sp;
rule = -(*sp);
fprintf(verbose_file, "\t%s : ", symbol_name[rlhs[rule]]);
- for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
+ for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
fprintf(verbose_file, "%s ", symbol_name[*sp]);
putc('.', verbose_file);
}
}
-
static void
print_nulls(int state)
{
action *p;
- int i, j, k, nnulls;
+ Value_t i, j, k, nnulls;
nnulls = 0;
for (p = parser[state]; p; p = p->next)
{
if (p->action_code == REDUCE &&
- (p->suppressed == 0 || p->suppressed == 1))
+ (p->suppressed == 0 || p->suppressed == 1))
{
i = p->number;
- if (rrhs[i] + 1 == rrhs[i+1])
+ if (rrhs[i] + 1 == rrhs[i + 1])
{
for (j = 0; j < nnulls && i > null_rules[j]; ++j)
continue;
else if (i != null_rules[j])
{
++nnulls;
- for (k = nnulls - 1; k > j; --k)
- null_rules[k] = null_rules[k-1];
+ for (k = (Value_t) (nnulls - 1); k > j; --k)
+ null_rules[k] = null_rules[k - 1];
null_rules[j] = i;
}
}
fprintf(verbose_file, "\n");
}
-
static void
print_actions(int stateno)
{
}
}
-
static void
print_shifts(action *p)
{
{
if (p->action_code == SHIFT && p->suppressed == 0)
fprintf(verbose_file, "\t%s shift %d\n",
- symbol_name[p->symbol], p->number);
+ symbol_name[p->symbol], p->number);
}
}
}
-
static void
-print_reductions(action *p, int prdefred)
+print_reductions(action *p, int defred2)
{
int k, anyreds;
action *q;
anyreds = 0;
- for (q = p; q ; q = q->next)
+ for (q = p; q; q = q->next)
{
if (q->action_code == REDUCE && q->suppressed < 2)
{
{
for (; p; p = p->next)
{
- if (p->action_code == REDUCE && p->number != prdefred)
+ if (p->action_code == REDUCE && p->number != defred2)
{
k = p->number - 2;
if (p->suppressed == 0)
}
}
- if (prdefred > 0)
- fprintf(verbose_file, "\t. reduce %d\n", prdefred - 2);
+ if (defred2 > 0)
+ fprintf(verbose_file, "\t. reduce %d\n", defred2 - 2);
}
}
-
static void
print_gotos(int stateno)
{
int i, k;
int as;
- short *state;
+ short *to_state2;
shifts *sp;
putc('\n', verbose_file);
sp = shift_table[stateno];
- state = sp->shift;
+ to_state2 = sp->shift;
for (i = 0; i < sp->nshifts; ++i)
{
- k = state[i];
+ k = to_state2[i];
as = accessing_symbol[k];
if (ISVAR(as))
fprintf(verbose_file, "\t%s goto %d\n", symbol_name[as], k);
--- /dev/null
+$! Id: vmsbuild.com,v 1.1 2000/11/21 00:38:46 tom Exp
+$! VMS build-script for BYACC. Requires installed C compiler
+$!
+$! Screen Configurations
+$! ---------------------
+$! To build BYACC, type:
+$! $ @vmsbuild [BYACC [<compiler> [bld_target]]]
+$!
+$! where:
+$! <compiler> :== { decc | vaxc }
+$!
+$! The default compiler on VAX hosts is vaxc, else decc (Alpha hosts).
+$!
+$! -----------------------------------------------------------
+$ hlp = f$edit("''p1'", "UPCASE")
+$ if "''hlp'" .eqs. "HELP" .or. -
+ "''hlp'" .eqs. "-H" .or. -
+ "''hlp'" .eqs. "-?" .or. -
+ "''hlp'" .eqs. "?" then gosub usage
+$ goto start
+$!
+$ vaxc_config:
+$ comp = "__vaxc__=1"
+$ CFLAGS = "/VAXC"
+$ DEFS = ",HAVE_STRERROR"
+$ using_vaxc = 1
+$ return
+$!
+$ decc_config:
+$ comp = "__decc__=1"
+$ CFLAGS = "/DECC/prefix=all"
+$ DEFS = ",HAVE_ALARM,HAVE_STRERROR"
+$ return
+$!
+$ usage:
+$ write sys$output "usage: "
+$ write sys$output " $ @vmsbuild [BYACC [{decc | vaxc} [<bldtarget>]]]"
+$ exit 2
+$!
+$ start:
+$! -----------------------------------------------------------
+$! pickup user's compiler choice, if any
+$! -----------------------------------------------------------
+$!
+$ comp = ""
+$ using_vaxc = 0
+$ if "''p2'" .nes. ""
+$ then
+$ comp = f$edit(p2, "UPCASE")
+$ if "''comp'" .eqs. "VAXC"
+$ then
+$ gosub vaxc_config
+$ else
+$ if "''comp'" .eqs. "DECC"
+$ then
+$ gosub decc_config
+$ else
+$ gosub usage
+$ endif
+$ endif
+$ endif
+$! -----------------------------------------------------------
+$! Build the option-file
+$!
+$ open/write optf vms_link.opt
+$ write optf "closure.obj"
+$ write optf "error.obj"
+$ write optf "lalr.obj"
+$ write optf "lr0.obj"
+$ write optf "mkpar.obj"
+$ write optf "output.obj"
+$ write optf "reader.obj"
+$ write optf "skeleton.obj"
+$ write optf "symtab.obj"
+$ write optf "verbose.obj"
+$ write optf "warshall.obj"
+$! ----------------------------------
+$! Look for the compiler used and specify architecture.
+$!
+$ CC = "CC"
+$ if f$getsyi("HW_MODEL").ge.1024
+$ then
+$ arch = "__alpha__=1"
+$ if "''comp'" .eqs. "" then gosub decc_config
+$ else
+$ arch = "__vax__=1"
+$ if "''comp'" .nes. "" then goto screen_config
+$ if f$search("SYS$SYSTEM:VAXC.EXE").nes.""
+$ then
+$ gosub vaxc_config
+$ else
+$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").nes.""
+$ then
+$ gosub decc_config
+$ else
+$ DEFS = ",HAVE_STRERROR"
+$ if f$trnlnm("GNU_CC").eqs.""
+$ then
+$ write sys$output "C compiler required to rebuild BYACC"
+$ close optf
+$ exit
+$ else
+$ write optf "gnu_cc:[000000]gcclib.olb/lib"
+$ comp = "__gcc__=1"
+$ CC = "GCC"
+$ endif
+$ endif
+$ endif
+$ endif
+$!
+$ screen_config:
+$!
+$ if using_vaxc .eq. 1 then write optf "sys$library:vaxcrtl.exe/share"
+$ close optf
+$! -------------- vms_link.opt is created -------------
+$ if f$edit("''p1'", "UPCASE") .eqs. "VMS_LINK.OPT"
+$ then
+$! mms called this script to build vms_link.opt. all done
+$ exit
+$ endif
+$!
+$ if f$search("SYS$SYSTEM:MMS.EXE").eqs.""
+$ then
+$! can also use /Debug /Listing, /Show=All
+$
+$ CFLAGS := 'CFLAGS/Diagnostics /Define=("''DEFS'") /Include=([])
+$
+$ if "''p3'" .nes. "" then goto 'p3
+$!
+$!
+$ all :
+$!
+$ call make closure
+$ call make error
+$ call make lalr
+$ call make lr0
+$ call make main
+$ call make mkpar
+$ call make output
+$ call make reader
+$ call make skeleton
+$ call make symtab
+$ call make verbose
+$ call make warshall
+$!
+$ link /exec='target/map/cross main.obj, vms_link/opt
+$ goto build_last
+$!
+$ install :
+$ WRITE SYS$ERROR "** no rule for install"
+$ goto build_last
+$!
+$ clobber :
+$ if f$search("BYACC.com") .nes. "" then delete BYACC.com;*
+$ if f$search("*.exe") .nes. "" then delete *.exe;*
+$! fallthru
+$!
+$ clean :
+$ if f$search("*.obj") .nes. "" then delete *.obj;*
+$ if f$search("*.bak") .nes. "" then delete *.bak;*
+$ if f$search("*.lis") .nes. "" then delete *.lis;*
+$ if f$search("*.log") .nes. "" then delete *.log;*
+$ if f$search("*.map") .nes. "" then delete *.map;*
+$ if f$search("*.opt") .nes. "" then delete *.opt;*
+$! fallthru
+$!
+$ build_last :
+$ if f$search("*.dia") .nes. "" then delete *.dia;*
+$ if f$search("*.lis") .nes. "" then purge *.lis
+$ if f$search("*.obj") .nes. "" then purge *.obj
+$ if f$search("*.map") .nes. "" then purge *.map
+$ if f$search("*.opt") .nes. "" then purge *.opt
+$ if f$search("*.exe") .nes. "" then purge *.exe
+$ if f$search("*.log") .nes. "" then purge *.log
+$! fallthru
+$!
+$ vms_link_opt :
+$ exit 1
+$!
+$! Runs BYACC from the current directory (used for testing)
+$ byacc_com :
+$ if "''f$search("BYACC.com")'" .nes. "" then delete BYACC.com;*
+$ copy nl: BYACC.com
+$ open/append test_script BYACC.com
+$ write test_script "$ temp = f$environment(""procedure"")"
+$ write test_script "$ temp = temp -"
+$ write test_script " - f$parse(temp,,,""version"",""syntax_only"") -"
+$ write test_script " - f$parse(temp,,,""type"",""syntax_only"")"
+$ write test_script "$ BYACC :== $ 'temp'.exe"
+$ write test_script "$ define/user_mode sys$input sys$command"
+$ write test_script "$ define/user_mode sys$output sys$command"
+$ write test_script "$ BYACC 'p1 'p2 'p3 'p4 'p5 'p6 'p7 'p8"
+$ close test_script
+$ write sys$output "** made BYACC.com"
+$ exit
+$!
+$ else
+$ mms/ignore=warning/macro=('comp','mmstar','arch') 'p3
+$ endif
+$ exit
+$ make: subroutine
+$ if f$search("''p1'.obj") .eqs. ""
+$ then
+$ write sys$output "compiling ''p1'"
+$ 'CC 'CFLAGS 'p1.c
+$ if f$search("''p1'.dia") .nes. "" then delete 'p1.dia;*
+$ endif
+$exit
+$ return
+$ endsubroutine
--- /dev/null
+/* $NetBSD: warshall.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
+/* Id: warshall.c,v 1.7 2010/06/06 22:48:51 tom Exp */
+
+#include "defs.h"
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: warshall.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
+
+static void
+transitive_closure(unsigned *R, int n)
+{
+ int rowsize;
+ unsigned i;
+ unsigned *rowj;
+ unsigned *rp;
+ unsigned *rend;
+ unsigned *ccol;
+ unsigned *relend;
+ unsigned *cword;
+ unsigned *rowi;
+
+ rowsize = WORDSIZE(n);
+ relend = R + n * rowsize;
+
+ cword = R;
+ i = 0;
+ rowi = R;
+ while (rowi < relend)
+ {
+ ccol = cword;
+ rowj = R;
+
+ while (rowj < relend)
+ {
+ if (*ccol & (unsigned)(1 << i))
+ {
+ rp = rowi;
+ rend = rowj + rowsize;
+ while (rowj < rend)
+ *rowj++ |= *rp++;
+ }
+ else
+ {
+ rowj += rowsize;
+ }
+
+ ccol += rowsize;
+ }
+
+ if (++i >= BITS_PER_WORD)
+ {
+ i = 0;
+ cword++;
+ }
+
+ rowi += rowsize;
+ }
+}
+
+void
+reflexive_transitive_closure(unsigned *R, int n)
+{
+ int rowsize;
+ unsigned i;
+ unsigned *rp;
+ unsigned *relend;
+
+ transitive_closure(R, n);
+
+ rowsize = WORDSIZE(n);
+ relend = R + n * rowsize;
+
+ i = 0;
+ rp = R;
+ while (rp < relend)
+ {
+ *rp |= (unsigned)(1 << i);
+ if (++i >= BITS_PER_WORD)
+ {
+ i = 0;
+ rp++;
+ }
+
+ rp += rowsize;
+ }
+}
--- /dev/null
+.\" $NetBSD: yacc.1,v 1.4 2011/09/10 21:29:04 christos Exp $
+.\"
+.\" Id: yacc.1,v 1.12 2011/09/08 00:40:44 tom Exp
+.\"
+.\" .TH YACC 1 "July\ 15,\ 1990"
+.\" .UC 6
+.TH YACC 1 "September 7, 2011" "Berkeley Yacc" "User Commands"
+.SH NAME
+Yacc \- an LALR(1) parser generator
+.SH SYNOPSIS
+.B yacc [ -dgilrtv ] [ \-b
+.I file_prefix
+.B ] [ \-p
+.I symbol_prefix
+.B ]
+.I filename
+.SH DESCRIPTION
+.B Yacc
+reads the grammar specification in the file
+.I filename
+and generates an LALR(1) parser for it.
+The parsers consist of a set of LALR(1) parsing tables and a driver routine
+written in the C programming language.
+.B Yacc
+normally writes the parse tables and the driver routine to the file
+.IR y.tab.c.
+.PP
+The following options are available:
+.TP
+\fB\-b \fP\fIfile_prefix\fR
+The
+.B \-b
+option changes the prefix prepended to the output file names to
+the string denoted by
+.IR file_prefix.
+The default prefix is the character
+.IR y.
+.TP
+.B \-d
+The \fB-d\fR option causes the header file
+.BR y.tab.h
+to be written.
+It contains #define's for the token identifiers.
+.TP
+.B \-g
+The
+.B \-g
+option causes a graphical description of the generated LALR(1) parser to
+be written to the file
+.BR y.dot
+in graphviz format, ready to be processed by dot(1).
+.TP
+.B \-i
+The \fB-i\fR option causes a supplementary header file
+.BR y.tab.i
+to be written.
+It contains extern declarations
+and supplementary #define's as needed to map the conventional \fIyacc\fP
+\fByy\fP-prefixed names to whatever the \fB-p\fP option may specify.
+The code file, e.g., \fBy.tab.c\fP is modified to #include this file
+as well as the \fBy.tab.h\fP file, enforcing consistent usage of the
+symbols defined in those files.
+.IP
+The supplementary header file makes it simpler to separate compilation
+of lex- and yacc-files.
+.TP
+.B \-l
+If the
+.B \-l
+option is not specified,
+.B yacc
+will insert \fI#line\fP directives in the generated code.
+The \fI#line\fP directives let the C compiler relate errors in the
+generated code to the user's original code.
+If the \fB-l\fR option is specified,
+.B yacc
+will not insert the \fI#line\fP directives.
+\&\fI#line\fP directives specified by the user will be retained.
+.TP
+\fB\-o \fP\fIoutput_file\fR
+specify the filename for the parser file.
+If this option is not given, the output filename is
+the file prefix concatenated with the file suffix, e.g., \fBy.tab.c\fP.
+This overrides the \fB-p\fP option.
+.TP
+\fB\-p \fP\fIsymbol_prefix\fR
+The
+.B \-p
+option changes the prefix prepended to yacc-generated symbols to
+the string denoted by
+.IR symbol_prefix.
+The default prefix is the string
+.BR yy.
+.TP
+.B \-P
+create a reentrant parser, e.g., "%pure-parser".
+.TP
+.B \-r
+The
+.B \-r
+option causes
+.B yacc
+to produce separate files for code and tables. The code file
+is named
+.IR y.code.c,
+and the tables file is named
+.IR y.tab.c.
+The prefix "\fIy.\fP" can be overridden using the \fB\-b\fP option.
+.TP
+.B \-t
+The
+.B \-t
+option changes the preprocessor directives generated by
+.B yacc
+so that debugging statements will be incorporated in the compiled code.
+.TP
+.B \-v
+The
+.B \-v
+option causes a human-readable description of the generated parser to
+be written to the file
+.IR y.output.
+.TP
+.B \-V
+print the version number to the standard output.
+.SH EXTENSIONS
+.B yacc
+provides some extensions for compatibility with bison and other implementations
+of yacc:
+.TP
+\fB %expect\fP \fInumber\fP
+tell \fByacc\fP the expected number of shift/reduce conflicts.
+That makes it only report the number if it differs.
+.TP
+\fB %expect-rr\fP \fInumber\fP
+tell \fByacc\fP the expected number of reduce/reduce conflicts.
+That makes it only report the number if it differs.
+This is (unlike bison) allowable in LALR parsers.
+.TP
+\fB %lex-param\fP { \fIargument-declaration\fP }
+By default, the lexer accepts no parameters, e.g., \fByylex()\fP.
+Use this directive to add parameter declarations for your customized lexer.
+.TP
+\fB %parse-param\fP { \fIargument-declaration\fP }
+By default, the parser accepts no parameters, e.g., \fByyparse()\fP.
+Use this directive to add parameter declarations for your customized parser.
+.TP
+\fB %pure-parser\fP
+Most variables (other than \fByydebug\fP and \fByynerrs\fP) are
+allocated on the stack within \fByyparse\fP, making the parser reasonably
+reentrant.
+.
+.SH DIAGNOSTICS
+If there are rules that are never reduced, the number of such rules is
+reported on standard error.
+If there are any LALR(1) conflicts, the number of conflicts is reported
+on standard error.
--- /dev/null
+/* config.h. Generated automatically by configure. */
+/* @configure_input@ */
+/* $Id: config.h,v 1.2 2011/09/10 21:32:25 christos Exp $ */
+
+#define SYSTEM_NAME "netbsd"
+#define MIXEDCASE_FILENAMES 1
+#define CC_HAS_PROTOS 1
+#define HAVE_FCNTL_H 1
+#define HAVE_ATEXIT 1
+#define HAVE_MKSTEMP 1