[llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/COPYING LR0.c Makefile allocate.c bison.1 bison.cld bison.hairy bison.simple closure.c conflicts.c derives.c files.c files.h getargs.c getopt.c gram.c gram.h lalr.c lex.c lex.h machine.h main.c new.h nullable.c output.c parse.y.in print.c reader.c state.h symtab.c symtab.h types.h warshall.c

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 5 11:32:02 PDT 2004



Changes in directory llvm-test/MultiSource/Benchmarks/Prolangs-C/bison:

COPYING added (r1.1)
LR0.c added (r1.1)
Makefile added (r1.1)
allocate.c added (r1.1)
bison.1 added (r1.1)
bison.cld added (r1.1)
bison.hairy added (r1.1)
bison.simple added (r1.1)
closure.c added (r1.1)
conflicts.c added (r1.1)
derives.c added (r1.1)
files.c added (r1.1)
files.h added (r1.1)
getargs.c added (r1.1)
getopt.c added (r1.1)
gram.c added (r1.1)
gram.h added (r1.1)
lalr.c added (r1.1)
lex.c added (r1.1)
lex.h added (r1.1)
machine.h added (r1.1)
main.c added (r1.1)
new.h added (r1.1)
nullable.c added (r1.1)
output.c added (r1.1)
parse.y.in added (r1.1)
print.c added (r1.1)
reader.c added (r1.1)
state.h added (r1.1)
symtab.c added (r1.1)
symtab.h added (r1.1)
types.h added (r1.1)
warshall.c added (r1.1)
---
Log message:

Initial checkin


---
Diffs of the changes:  (+11024 -0)

Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/COPYING
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/COPYING:1.1
*** /dev/null	Tue Oct  5 13:32:00 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/COPYING	Tue Oct  5 13:31:49 2004
***************
*** 0 ****
--- 1,141 ----
+ 
+ 		    BISON GENERAL PUBLIC LICENSE
+ 		      (Clarified 11 Feb 1988)
+ 
+  Copyright (C) 1988 Richard M. Stallman
+  Everyone is permitted to copy and distribute verbatim copies
+  of this license, but changing it is not allowed.  You can also
+  use this wording to make the terms for other programs.
+ 
+   The license agreements of most software companies keep you at the
+ mercy of those companies.  By contrast, our general public license is
+ intended to give everyone the right to share BISON.  To make sure that
+ you get the rights we want you to have, we need to make restrictions
+ that forbid anyone to deny you these rights or to ask you to surrender
+ the rights.  Hence this license agreement.
+ 
+   Specifically, we want to make sure that you have the right to give
+ away copies of BISON, that you receive source code or else can get it
+ if you want it, that you can change BISON or use pieces of it in new
+ free programs, and that you know you can do these things.
+ 
+   To make sure that everyone has such rights, we have to forbid you to
+ deprive anyone else of these rights.  For example, if you distribute
+ copies of BISON, you must give the recipients all the rights that you
+ have.  You must make sure that they, too, receive or can get the
+ source code.  And you must tell them their rights.
+ 
+   Also, for our own protection, we must make certain that everyone
+ finds out that there is no warranty for BISON.  If BISON is modified by
+ someone else and passed on, we want its recipients to know that what
+ they have is not what we distributed, so that any problems introduced
+ by others will not reflect on our reputation.
+ 
+   Therefore we (Richard Stallman and the Free Software Fundation,
+ Inc.) make the following terms which say what you must do to be
+ allowed to distribute or change BISON.
+ 
+ 
+ 			COPYING POLICIES
+ 
+   1. You may copy and distribute verbatim copies of BISON source code as
+ you receive it, in any medium, provided that you conspicuously and
+ appropriately publish on each copy a valid copyright notice "Copyright
+ (C) 1986 Free Software Foundation, Inc." (or with whatever year is
+ appropriate); keep intact the notices on all files that refer
+ to this License Agreement and to the absence of any warranty; and give
+ any other recipients of the BISON program a copy of this License
+ Agreement along with the program.
+ 
+   2. You may modify your copy or copies of BISON or any portion of it,
+ and copy and distribute such modifications under the terms of
+ Paragraph 1 above, provided that you also do the following:
+ 
+     a) cause the modified files to carry prominent notices stating
+     that you changed the files and the date of any change; and
+ 
+     b) cause the whole of any work that you distribute or publish,
+     that in whole or in part contains or is a derivative of BISON or
+     any part thereof, to be licensed at no charge to all third
+     parties on terms identical to those contained in this License
+     Agreement (except that you may choose to grant more extensive
+     warranty protection to some or all third parties, at your
+     option)
+ 
+     c) You may charge a distribution fee for the physical act of
+     transferring a copy, and you may at your option offer warranty
+     protection in exchange for a fee.
+ 
+ Mere aggregation of another unrelated program with this program (or its
+ derivative) on a volume of a storage or distribution medium does not bring
+ the other program under the scope of these terms.
+ 
+   3. You may copy and distribute BISON (or a portion or derivative of it,
+ under Paragraph 2) in object code or executable form under the terms of
+ Paragraphs 1 and 2 above provided that you also do one of the following:
+ 
+     a) accompany it with the complete corresponding machine-readable
+     source code, which must be distributed under the terms of
+     Paragraphs 1 and 2 above; or,
+ 
+     b) accompany it with a written offer, valid for at least three
+     years, to give any third party free (except for a nominal
+     shipping charge) a complete machine-readable copy of the
+     corresponding source code, to be distributed under the terms of
+     Paragraphs 1 and 2 above; or,
+ 
+     c) accompany it with the information you received as to where the
+     corresponding source code may be obtained.  (This alternative is
+     allowed only for noncommercial distribution and only if you
+     received the program in object code or executable form alone.)
+ 
+ For an executable file, complete source code means all the source code for
+ all modules it contains; but, as a special exception, it need not include
+ source code for modules which are standard libraries that accompany the
+ operating system on which the executable file runs.
+ 
+   4. You may not copy, sublicense, distribute or transfer BISON
+ except as expressly provided under this License Agreement.  Any attempt
+ otherwise to copy, sublicense, distribute or transfer BISON is void and
+ your rights to use the program under this License agreement shall be
+ automatically terminated.  However, parties who have received computer
+ software programs from you with this License Agreement will not have
+ their licenses terminated so long as such parties remain in full compliance.
+ 
+   5. If you wish to incorporate parts of GNU CC into other free programs
+ whose distribution conditions are different, write to the Free Software
+ Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet worked
+ out a simple rule that can be stated here, but we will often permit this.
+ We will be guided by the two goals of preserving the free status of all
+ derivatives of our free software and of promoting the sharing and reuse of
+ software.
+ 
+ Your comments and suggestions about our licensing policies and our
+ software are welcome!  Please contact the Free Software Foundation, Inc.,
+ 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296.
+ 
+ In other words, go ahead and share BISON, but don't try to stop
+ anyone else from sharing it farther.  Help stamp out software hoarding!
+ 
+ 		       NO WARRANTY
+ 
+   BECAUSE BISON IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO
+ WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
+ WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
+ RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE BISON "AS IS" WITHOUT
+ WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF BISON IS WITH YOU.  SHOULD BISON PROVE DEFECTIVE, YOU
+ ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+ 
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
+ STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
+ WHO MAY MODIFY AND REDISTRIBUTE BISON AS PERMITTED ABOVE, BE LIABLE TO
+ YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
+ SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
+ INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
+ BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
+ FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) BISON, EVEN
+ IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR
+ ANY CLAIM BY ANY OTHER PARTY.


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/LR0.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/LR0.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/LR0.c	Tue Oct  5 13:31:49 2004
***************
*** 0 ****
--- 1,661 ----
+ /* Generate the nondeterministic finite state machine for bison,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* See comments in state.h for the data structures that represent it.
+    The entry point is generate_states.  */
+ 
+ #include <stdio.h>
+ #include "machine.h"
+ #include "new.h"
+ #include "gram.h"
+ #include "state.h"
+ 
+ 
+ extern char *nullable;
+ extern short *itemset;
+ extern short *itemsetend;
+ 
+ 
+ int nstates;
+ int final_state;
+ core *first_state;
+ shifts *first_shift;
+ reductions *first_reduction;
+ 
+ int get_state();
+ core *new_state();
+ 
+ static core *this_state;
+ static core *last_state;
+ static shifts *last_shift;
+ static reductions *last_reduction;
+ 
+ static int nshifts;
+ static short *shift_symbol;
+ 
+ static short *redset;
+ static short *shiftset;
+ 
+ static short **kernel_base;
+ static short **kernel_end;
+ static short *kernel_items;
+ 
+ /* hash table for states, to recognize equivalent ones.  */
+ 
+ #define	STATE_TABLE_SIZE	1009
+ static core **state_table;
+ 
+ extern void initialize_closure(int n);
+ extern void closure(short *core,int n);
+ extern void finalize_closure(void);
+ extern void toomany(char *s);
+ 
+ void initialize_states(void);
+ void save_reductions(void);
+ void new_itemsets(void);
+ void append_states(void);
+ void save_shifts(void);
+ void augment_automaton(void);
+ void insert_start_shift(void);
+ 
+ void allocate_itemsets(void)
+ {
+   register short *itemp;
+   register int symbol;
+   register int i;
+   register count;
+   register int max;
+   register short *symbol_count;
+ 
+   count = 0;
+   symbol_count = NEW2(nsyms, short);
+ 
+   itemp = ritem;
+   symbol = *itemp++;
+   while (symbol)
+     {
+       if (symbol > 0)
+ 	{
+ 	  count++;
+ 	  symbol_count[symbol]++;
+ 	}
+       symbol = *itemp++;
+     }
+ 
+   /* see comments before new-itemset.  All the vectors of items
+      live inside kernel_items.  The number of active items after
+      some symbol cannot be more than the number of times that symbol
+      appears as an item, which is symbol_count[symbol].
+      We allocate that much space for each symbol.  */
+ 
+   kernel_base = NEW2(nsyms, short *);
+   kernel_items = NEW2(count, short);
+ 
+   count = 0;
+   max = 0;
+   for (i = 0; i < nsyms; i++)
+     {
+       kernel_base[i] = kernel_items + count;
+       count += symbol_count[i];
+       if (max < symbol_count[i])
+ 	max = symbol_count[i];
+     }
+ 
+   shift_symbol = symbol_count;
+   kernel_end = NEW2(nsyms, short *);
+ }
+ 
+ 
+ 
+ void allocate_storage(void)
+ {
+   allocate_itemsets();
+ 
+   shiftset = NEW2(nsyms, short);
+   redset = NEW2(nrules + 1, short);
+   state_table = NEW2(STATE_TABLE_SIZE, core *);
+ }
+ 
+ 
+ 
+ void free_storage(void)
+ {
+   FREE(shift_symbol);
+   FREE(redset);
+   FREE(shiftset);
+   FREE(kernel_base);
+   FREE(kernel_end);
+   FREE(kernel_items);
+   FREE(state_table);
+ }
+ 
+ 
+ 
+ /* compute the nondeterministic finite state machine (see state.h for details)
+ from the grammar.  */
+ 
+ void generate_states(void)
+ {
+   allocate_storage();
+   initialize_closure(nitems);
+   initialize_states();
+ 
+   while (this_state)
+     {
+       /* Set up ruleset and itemset for the transitions out of this state.
+          ruleset gets a 1 bit for each rule that could reduce now.
+ 	 itemset gets a vector of all the items that could be accepted next.  */
+       closure(this_state->items, this_state->nitems);
+       /* record the reductions allowed out of this state */
+       save_reductions();
+       /* find the itemsets of the states that shifts can reach */
+       new_itemsets();
+       /* find or create the core structures for those states */
+       append_states();
+ 
+       /* create the shifts structures for the shifts to those states,
+          now that the state numbers transitioning to are known */
+       if (nshifts > 0)
+         save_shifts();
+ 
+       /* states are queued when they are created; process them all */
+       this_state = this_state->next;
+     }
+ 
+   /* discard various storage */
+   finalize_closure();
+   free_storage();
+ 
+   /* set up initial and final states as parser wants them */
+   augment_automaton();
+ }
+ 
+ 
+ 
+ /* Find which symbols can be shifted in the current state,
+    and for each one record which items would be active after that shift.
+    Uses the contents of itemset.
+    shift_symbol is set to a vector of the symbols that can be shifted.
+    For each symbol in the grammer, kernel_base[symbol] points to
+    a vector of item numbers activated if that symbol is shifted,
+    and kernel_end[symbol] points after the end of that vector.  */
+ 
+ void new_itemsets(void)
+ {
+   register int i;
+   register int shiftcount;
+   register short *isp;
+   register short *ksp;
+   register int symbol;
+ 
+ #ifdef	TRACE
+   fprintf(stderr, "Entering new_itemsets\n");
+ #endif
+ 
+   for (i = 0; i < nsyms; i++)
+     kernel_end[i] = NULL;
+ 
+   shiftcount = 0;
+ 
+   isp = itemset;
+ 
+   while (isp < itemsetend)
+     {
+       i = *isp++;
+       symbol = ritem[i];
+       if (symbol > 0)
+ 	{
+           ksp = kernel_end[symbol];
+ 
+           if (!ksp)
+ 	    {
+ 	      shift_symbol[shiftcount++] = symbol;
+ 	      ksp = kernel_base[symbol];
+ 	    }
+ 
+           *ksp++ = i + 1;
+           kernel_end[symbol] = ksp;
+ 	}
+     }
+ 
+   nshifts = shiftcount;
+ }
+ 
+ 
+ 
+ /* Use the information computed by new_itemset to find the state numbers
+    reached by each shift transition from the current state.
+ 
+    shiftset is set up as a vector of state numbers of those states.  */
+ 
+ void append_states(void)
+ {
+   register int i;
+   register int j;
+   register int symbol;
+ 
+ #ifdef	TRACE
+   fprintf(stderr, "Entering append_states\n");
+ #endif
+ 
+   /* first sort shift_symbol into increasing order */
+ 
+   for (i = 1; i < nshifts; i++)
+     {
+       symbol = shift_symbol[i];
+       j = i;
+       while (j > 0 && shift_symbol[j - 1] > symbol)
+ 	{
+ 	  shift_symbol[j] = shift_symbol[j - 1];
+ 	  j--;
+ 	}
+       shift_symbol[j] = symbol;
+     }
+ 
+   for (i = 0; i < nshifts; i++)
+     {
+       symbol = shift_symbol[i];
+       shiftset[i] = get_state(symbol);
+     }
+ }
+ 
+ 
+ 
+ /* find the state number for the state we would get to
+ (from the current state) by shifting symbol.
+ Create a new state if no equivalent one exists already.
+ Used by append_states  */
+ 
+ int get_state(int symbol)
+ {
+   register int key;
+   register short *isp1;
+   register short *isp2;
+   register short *iend;
+   register core *sp;
+   register int found;
+ 
+   int n;
+ 
+ #ifdef	TRACE
+   fprintf(stderr, "Entering get_state, symbol = %d\n", symbol);
+ #endif
+ 
+   isp1 = kernel_base[symbol];
+   iend = kernel_end[symbol];
+   n = iend - isp1;
+ 
+   /* add up the target state's active item numbers to get a hash key */
+   key = 0;
+   while (isp1 < iend)
+     key += *isp1++;
+ 
+   key = key % STATE_TABLE_SIZE;
+ 
+   sp = state_table[key];
+ 
+   if (sp)
+     {
+       found = 0;
+       while (!found)
+ 	{
+ 	  if (sp->nitems == n)
+ 	    {
+ 	      found = 1;
+ 	      isp1 = kernel_base[symbol];
+ 	      isp2 = sp->items;
+ 
+ 	      while (found && isp1 < iend)
+ 		{
+ 		  if (*isp1++ != *isp2++)
+ 		    found = 0;
+ 		}
+ 	    }
+ 
+ 	  if (!found)
+ 	    {
+ 	      if (sp->link)
+ 		{
+ 		  sp = sp->link;
+ 		}
+ 	      else   /* bucket exhausted and no match */
+ 		{
+ 		  sp = sp->link = new_state(symbol);
+ 		  found = 1;
+ 		}
+ 	    }
+ 	}
+     }
+   else      /* bucket is empty */
+     {
+       state_table[key] = sp = new_state(symbol);
+     }
+ 
+   return (sp->number);
+ }
+ 
+ 
+ 
+ /* subroutine of get_state.  create a new state for those items, if necessary.  */
+ 
+ core *new_state(int symbol)
+ {
+   register int n;
+   register core *p;
+   register short *isp1;
+   register short *isp2;
+   register short *iend;
+ 
+ #ifdef	TRACE
+   fprintf(stderr, "Entering new_state, symbol = %d\n", symbol);
+ #endif
+ 
+   if (nstates >= MAXSHORT)
+     toomany("states");
+ 
+   isp1 = kernel_base[symbol];
+   iend = kernel_end[symbol];
+   n = iend - isp1;
+ 
+   p = (core *) mallocate((unsigned) (sizeof(core) + (n - 1) * sizeof(short)));
+   p->accessing_symbol = symbol;
+   p->number = nstates;
+   p->nitems = n;
+ 
+   isp2 = p->items;
+   while (isp1 < iend)
+     *isp2++ = *isp1++;
+ 
+   last_state->next = p;
+   last_state = p;
+ 
+   nstates++;
+ 
+   return (p);
+ }
+ 
+ 
+ 
+ void initialize_states(void)
+ {
+   register core *p;
+ /*  register unsigned *rp1; JF unused */
+ /*  register unsigned *rp2; JF unused */
+ /*  register unsigned *rend; JF unused */
+ 
+   p = (core *) mallocate((unsigned) (sizeof(core) - sizeof(short)));
+   first_state = last_state = this_state = p;
+   nstates = 1;
+ }
+ 
+ 
+ 
+ void save_shifts(void)
+ {
+   register shifts *p;
+   register short *sp1;
+   register short *sp2;
+   register short *send;
+ 
+   p = (shifts *) mallocate((unsigned) (sizeof(shifts) +
+ 				       (nshifts - 1) * sizeof(short)));
+ 
+   p->number = this_state->number;
+   p->nshifts = nshifts;
+ 
+   sp1 = shiftset;
+   sp2 = p->shifts;
+   send = shiftset + nshifts;
+ 
+   while (sp1 < send)
+     *sp2++ = *sp1++;
+ 
+   if (last_shift)
+     {
+       last_shift->next = p;
+       last_shift = p;
+     }
+   else
+     {
+       first_shift = p;
+       last_shift = p;
+     }
+ }
+ 
+ 
+ 
+ /* find which rules can be used for reduction transitions from the current state
+    and make a reductions structure for the state to record their rule numbers.  */
+ 
+ void save_reductions(void)
+ {
+   register short *isp;
+   register short *rp1;
+   register short *rp2;
+   register int item;
+   register int count;
+   register reductions *p;
+ 
+   short *rend;
+ 
+   /* find and count the active items that represent ends of rules */
+ 
+   count = 0;
+   for (isp = itemset; isp < itemsetend; isp++)
+     {
+       item = ritem[*isp];
+       if (item < 0)
+ 	{
+ 	  redset[count++] = -item;
+ 	}
+     }
+ 
+   /* make a reductions structure and copy the data into it.  */
+ 
+   if (count)
+     {
+       p = (reductions *) mallocate((unsigned) (sizeof(reductions) +
+ 					       (count - 1) * sizeof(short)));
+ 
+       p->number = this_state->number;
+       p->nreds = count;
+ 
+       rp1 = redset;
+       rp2 = p->rules;
+       rend = rp1 + count;
+ 
+       while (rp1 < rend)
+ 	*rp2++ = *rp1++;
+ 
+       if (last_reduction)
+ 	{
+ 	  last_reduction->next = p;
+ 	  last_reduction = p;
+ 	}
+       else
+ 	{
+ 	  first_reduction = p;
+ 	  last_reduction = p;
+ 	}
+     }
+ }
+ 
+ 
+ 
+ /* Make sure that the initial state has a shift that accepts the
+ grammar's start symbol and goes to the next-to-final state,
+ which has a shift going to the final state, which has a shift
+ to the termination state.
+ Create such states and shifts if they don't happen to exist already.  */
+ 
+ void augment_automaton(void)
+ {
+   register int i;
+   register int k;
+ /*  register int found; JF unused */
+   register core *statep;
+   register shifts *sp;
+   register shifts *sp2;
+   register shifts *sp1;
+ 
+   sp = first_shift;
+ 
+   if (sp)
+     {
+       if (sp->number == 0)
+ 	{
+ 	  k = sp->nshifts;
+ 	  statep = first_state->next;
+ 
+ 	  while (statep->accessing_symbol < start_symbol
+ 		  && statep->number < k)
+ 	    statep = statep->next;
+ 
+ 	  if (statep->accessing_symbol == start_symbol)
+ 	    {
+ 	      k = statep->number;
+ 
+ 	      while (sp->number < k)
+ 		{
+ 		  sp1 = sp;
+ 		  sp = sp->next;
+ 		}
+ 
+ 	      if (sp->number == k)
+ 		{
+ 		  sp2 = (shifts *) mallocate((unsigned) (sizeof(shifts)
+ 							 + sp->nshifts * sizeof(short)));
+ 		  sp2->next = sp->next;
+ 		  sp2->number = k;
+ 		  sp2->nshifts = sp->nshifts + 1;
+ 		  sp2->shifts[0] = nstates;
+ 		  for (i = sp->nshifts; i > 0; i--)
+ 		    sp2->shifts[i] = sp->shifts[i - 1];
+ 
+ 		  sp1->next = sp2;
+ 		  FREE(sp);
+ 		}
+ 	      else
+ 		{
+ 		  sp2 = NEW(shifts);
+ 		  sp2->next = sp;
+ 		  sp2->number = k;
+ 		  sp2->nshifts = 1;
+ 		  sp2->shifts[0] = nstates;
+ 
+ 		  sp1->next = sp2;
+ 		  if (!sp)
+ 		    last_shift = sp2;
+ 		}
+ 	    }
+ 	  else
+ 	    {
+ 	      k = statep->number;
+ 	      sp = first_shift;
+ 
+ 	      sp2 = (shifts *) mallocate((unsigned) (sizeof(shifts)
+ 						     + sp->nshifts * sizeof(short)));
+ 	      sp2->next = sp->next;
+ 	      sp2->nshifts = sp->nshifts + 1;
+ 
+ 	      for (i = 0; i < k; i++)
+ 		sp2->shifts[i] = sp->shifts[i];
+ 
+ 	      sp2->shifts[k] = nstates;
+ 
+ 	      for (i = k; i < sp->nshifts; i++)
+ 		sp2->shifts[i + 1] = sp->shifts[i];
+ 
+ 	      first_shift = sp2;
+ 	      if (last_shift == sp)
+ 		last_shift = sp2;
+ 
+ 	      FREE(sp);
+ 
+ 	      insert_start_shift();
+ 	    }
+ 	}
+       else
+ 	{
+ 	  sp = NEW(shifts);
+ 	  sp->next = first_shift;
+ 	  sp->nshifts = 1;
+ 	  sp->shifts[0] = nstates;
+ 
+ 	  first_shift = sp;
+ 
+ 	  insert_start_shift();
+ 	}
+     }
+   else
+     {
+       sp = NEW(shifts);
+       sp->nshifts = 1;
+       sp->shifts[0] = nstates;
+ 
+       first_shift = sp;
+       last_shift = sp;
+ 
+       insert_start_shift();
+     }
+ 
+   statep = (core *) mallocate((unsigned) (sizeof(core) - sizeof(short)));
+   statep->number = nstates;
+   last_state->next = statep;
+   last_state = statep;
+ 
+   sp = NEW(shifts);
+   sp->number = nstates++;
+   sp->nshifts = 1;
+   sp->shifts[0] = nstates;
+   last_shift->next = sp;
+   last_shift = sp;
+ 
+   final_state = nstates;
+ 
+   statep = (core *) mallocate((unsigned) (sizeof(core) - sizeof(short)));
+   statep->number = nstates++;
+   last_state->next = statep;
+   last_state = statep;
+ }
+ 
+ 
+ /* subroutine of augment_automaton */
+ 
+ void insert_start_shift(void)
+ {
+   register core *statep;
+   register shifts *sp;
+ 
+   statep = (core *) mallocate((unsigned) (sizeof(core) - sizeof(short)));
+   statep->number = nstates;
+   statep->accessing_symbol = start_symbol;
+ 
+   last_state->next = statep;
+   last_state = statep;
+ 
+   sp = NEW(shifts);
+   sp->number = nstates++;
+   sp->nshifts = 1;
+   sp->shifts[0] = nstates;
+ 
+   last_shift->next = sp;
+   last_shift = sp;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/Makefile
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/Makefile:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/Makefile	Tue Oct  5 13:31:49 2004
***************
*** 0 ****
--- 1,5 ----
+ LEVEL = ../../../..
+ 
+ PROG = mybison
+ include $(LEVEL)/MultiSource/Makefile.multisrc
+ 


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/allocate.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/allocate.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/allocate.c	Tue Oct  5 13:31:49 2004
***************
*** 0 ****
--- 1,38 ----
+ /* Allocate and clear storage for bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+ extern void done(int k);
+ 
+ char *mallocate(register unsigned n)
+ {
+   register char *block;
+ 
+   block = calloc(n,1);
+   if (block == NULL)
+     {
+       fprintf(stderr, "bison: memory exhausted\n");
+       done(1);
+     }
+ 
+   return (block);
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.1
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.1:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.1	Tue Oct  5 13:31:49 2004
***************
*** 0 ****
--- 1,96 ----
+ .TH BISON 1 local
+ .SH NAME
+ bison \- GNU Project parser generator (yacc replacement)
+ .SH SYNOPSIS
+ .B bison
+ [
+ .B \-dlvty
+ ] file
+ .SH DESCRIPTION
+ .I Bison
+ is a parser generator in the style of
+ .IR yacc (1).
+ It should be upwardly compatible with input files designed
+ for
+ .IR yacc .
+ .PP
+ Input files should follow the
+ .I yacc
+ convention of ending in ``.y''.
+ Unlike
+ .IR yacc ,
+ the generated files do not have fixed names, but instead use the prefix
+ of the input file.
+ For instance, a grammar description file named
+ .B parse.y
+ would produce the generated parser in a file named
+ .BR parse.tab.c ,
+ instead of
+ .IR yacc 's
+ .BR y.tab.c .
+ .PP
+ .I Bison
+ takes five optional flags.
+ .TP
+ .B \-d
+ Produce a
+ .B .tab.h
+ file, similar to
+ .IR yacc 's
+ .B y.tab.h
+ file.
+ .TP
+ .B \-l
+ Omit
+ .B #line
+ lines in the parser output file. Error messages from the C compiler will
+ then be associated with lines in the parser output file, instead of lines
+ in the original grammar file.
+ .TP
+ .B \-t
+ Turn on debugging. This option causes the
+ .I bison
+ output to have debugging code made available via the C pre-processor.
+ The external variable
+ .B yydebug
+ should be made non-zero to have the debugging code actually
+ produce output.
+ .TP
+ .B \-v
+ Be verbose. Analogous to the same flag for
+ .IR yacc .
+ .TP
+ .B \-y
+ Use fixed output file names. I.e., force the output to be in files
+ .BR y.tab.c ,
+ .BR y.tab.h ,
+ and so on. This is for full
+ .I yacc
+ compatibility.
+ .PP
+ If
+ .I bison
+ is invoked with the name
+ .IR yacc ,
+ it will behave like
+ .I yacc
+ does. This is equivalent to simply supplying the
+ .B \-y
+ flag.
+ .SH FILES
+ /usr/local/lib/bison.simple	simple parser
+ .br
+ /usr/local/lib/bison.hairy	complicated parser
+ .SH SEE ALSO
+ .IR yacc (1)
+ .br
+ The
+ .IR "Bison Reference Manual" ,
+ included as the file
+ .B bison.texinfo
+ in the
+ .I bison
+ source distribution.
+ .SH DIAGNOSTICS
+ ``Self explanatory.''
+ ... ha!


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.cld
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.cld:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.cld	Tue Oct  5 13:31:49 2004
***************
*** 0 ****
--- 1,11 ----
+ !
+ !	VMS BISON command definition file
+ !
+ DEFINE	VERB	BISON
+ 	IMAGE	GNU_BISON:[000000]BISON
+ 
+ 	PARAMETER	P1,Label=BISON$INFILE,Prompt="File"
+ 				value(required,type=$infile)
+ 	QUALIFIER	VERBOSE,Label=BISON$VERBOSE
+ 	QUALIFIER	DEFINES,Label=BISON$DEFINES
+ 	QUALIFIER	FIXED_OUTFILES,Label=BISON$FIXED_OUTFILES


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.hairy
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.hairy:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.hairy	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,334 ----
+ 
+ extern int timeclock;
+ 
+ 
+ int yyerror;		/*  Yyerror and yycost are set by guards.	*/
+ int yycost;		/*  If yyerror is set to a nonzero value by a	*/
+ 			/*  guard, the reduction with which the guard	*/
+ 			/*  is associated is not performed, and the	*/
+ 			/*  error recovery mechanism is invoked.	*/
+ 			/*  Yycost indicates the cost of performing	*/
+ 			/*  the reduction given the attributes of the	*/
+ 			/*  symbols.					*/
+ 
+ 
+ /*  YYMAXDEPTH indicates the size of the parser's state and value	*/
+ /*  stacks.								*/
+ 
+ #ifndef	YYMAXDEPTH
+ #define	YYMAXDEPTH	500
+ #endif
+ 
+ /*  YYMAXRULES must be at least as large as the number of rules that	*/
+ /*  could be placed in the rule queue.  That number could be determined	*/
+ /*  from the grammar and the size of the stack, but, as yet, it is not.	*/
+ 
+ #ifndef	YYMAXRULES
+ #define	YYMAXRULES	100
+ #endif
+ 
+ #ifndef	YYMAXBACKUP
+ #define YYMAXBACKUP	100
+ #endif
+ 
+ 
+ short	yyss[YYMAXDEPTH];	/*  the state stack			*/
+ YYSTYPE	yyvs[YYMAXDEPTH];	/*  the semantic value stack		*/
+ YYLTYPE yyls[YYMAXDEPTH];	/*  the location stack			*/
+ short	yyrq[YYMAXRULES];	/*  the rule queue			*/
+ int	yychar;			/*  the lookahead symbol		*/
+ 
+ YYSTYPE	yylval;			/*  the semantic value of the		*/
+ 				/*  lookahead symbol			*/
+ 
+ YYSTYPE yytval;			/*  the semantic value for the state	*/
+ 				/*  at the top of the state stack.	*/
+ 
+ YYSTYPE yyval;			/*  the variable used to return		*/
+ 				/*  semantic values from the action	*/
+ 				/*  routines				*/
+ 
+ YYLTYPE yylloc;		/*  location data for the lookahead	*/
+ 				/*  symbol				*/
+ 
+ YYLTYPE yytloc;		/*  location data for the state at the	*/
+ 				/*  top of the state stack		*/
+ 
+ 
+ int	yynunlexed;
+ short	yyunchar[YYMAXBACKUP];
+ YYSTYPE	yyunval[YYMAXBACKUP];
+ YYLTYPE yyunloc[YYMAXBACKUP];
+ 
+ short *yygssp;			/*  a pointer to the top of the state	*/
+ 				/*  stack; only set during error	*/
+ 				/*  recovery.				*/
+ 
+ YYSTYPE *yygvsp;		/*  a pointer to the top of the value	*/
+ 				/*  stack; only set during error	*/
+ 				/*  recovery.				*/
+ 
+ YYLTYPE *yyglsp;		/*  a pointer to the top of the		*/
+ 				/*  location stack; only set during	*/
+ 				/*  error recovery.			*/
+ 
+ 
+ /*  Yyget is an interface between the parser and the lexical analyzer.	*/
+ /*  It is costly to provide such an interface, but it avoids requiring	*/
+ /*  the lexical analyzer to be able to back up the scan.		*/
+ 
+ yyget()
+ {
+   if (yynunlexed > 0)
+     {
+       yynunlexed--;
+       yychar = yyunchar[yynunlexed];
+       yylval = yyunval[yynunlexed];
+       yylloc = yyunloc[yynunlexed];
+     }
+   else if (yychar <= 0)
+     yychar = 0;
+   else
+     {
+       yychar = yylex();
+       if (yychar < 0)
+ 	yychar = 0;
+       else yychar = YYTRANSLATE(yychar);
+     }
+ }
+ 
+ 
+ 
+ yyunlex(chr, val, loc)
+ int chr;
+ YYSTYPE val;
+ YYLTYPE loc;
+ {
+   yyunchar[yynunlexed] = chr;
+   yyunval[yynunlexed] = val;
+   yyunloc[yynunlexed] = loc;
+   yynunlexed++;
+ }
+ 
+ 
+ 
+ yyrestore(first, last)
+ register short *first;
+ register short *last;
+ {
+   register short *ssp;
+   register short *rp;
+   register int symbol;
+   register int state;
+   register int tvalsaved;
+ 
+   ssp = yygssp;
+   yyunlex(yychar, yylval, yylloc);
+ 
+   tvalsaved = 0;
+   while (first != last)
+     {
+       symbol = yystos[*ssp];
+       if (symbol < YYNTBASE)
+ 	{
+ 	  yyunlex(symbol, yytval, yytloc);
+ 	  tvalsaved = 1;
+ 	  ssp--;
+ 	}
+ 
+       ssp--;
+ 
+       if (first == yyrq)
+ 	first = yyrq + YYMAXRULES;
+ 
+       first--;
+ 
+       for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)
+ 	{
+ 	  if (symbol < YYNTBASE)
+ 	    state = yytable[yypact[*ssp] + symbol];
+ 	  else
+ 	    {
+ 	      state = yypgoto[symbol - YYNTBASE] + *ssp;
+ 
+ 	      if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)
+ 		state = yytable[state];
+ 	      else
+ 		state = yydefgoto[symbol - YYNTBASE];
+ 	    }
+ 
+ 	  *++ssp = state;
+ 	}
+     }
+ 
+   if ( ! tvalsaved && ssp > yyss)
+     {
+       yyunlex(yystos[*ssp], yytval, yytloc);
+       ssp--;
+     }
+ 
+   yygssp = ssp;
+ }
+ 
+ 
+ 
+ int
+ yyparse()
+ {
+   register int yystate;
+   register int yyn;
+   register short *yyssp;
+   register short *yyrq0;
+   register short *yyptr;
+   register YYSTYPE *yyvsp;
+ 
+   int yylen;
+   YYLTYPE *yylsp;
+   short *yyrq1;
+   short *yyrq2;
+ 
+   yystate = 0;
+   yyssp = yyss - 1;
+   yyvsp = yyvs - 1;
+   yylsp = yyls - 1;
+   yyrq0 = yyrq;
+   yyrq1 = yyrq0;
+   yyrq2 = yyrq0;
+ 
+   yychar = yylex();
+   if (yychar < 0)
+     yychar = 0;
+   else yychar = YYTRANSLATE(yychar);
+ 
+ yynewstate:
+ 
+   if (yyssp >= yyss + YYMAXDEPTH - 1)
+     {
+       yyabort("Parser Stack Overflow");
+       YYABORT;
+     }
+ 
+   *++yyssp = yystate;
+ 
+ yyresume:
+ 
+   yyn = yypact[yystate];
+   if (yyn == YYFLAG)
+     goto yydefault;
+ 
+   yyn += yychar;
+   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)
+     goto yydefault;
+ 
+   yyn = yytable[yyn];
+   if (yyn < 0)
+     {
+       yyn = -yyn;
+       goto yyreduce;
+     }
+   else if (yyn == 0)
+     goto yyerrlab;
+ 
+   yystate = yyn;
+ 
+   yyptr = yyrq2;
+   while (yyptr != yyrq1)
+     {
+       yyn = *yyptr++;
+       yylen = yyr2[yyn];
+       yyvsp -= yylen;
+       yylsp -= yylen;
+ 
+       yyguard(yyn, yyvsp, yylsp);
+       if (yyerror)
+ 	goto yysemerr;
+ 
+       yyaction(yyn, yyvsp, yylsp);
+       *++yyvsp = yyval;
+ 
+       yylsp++;
+       if (yylen == 0)
+ 	{
+ 	  yylsp->timestamp = timeclock;
+ 	  yylsp->first_line = yytloc.first_line;
+ 	  yylsp->first_column = yytloc.first_column;
+ 	  yylsp->last_line = (yylsp-1)->last_line;
+ 	  yylsp->last_column = (yylsp-1)->last_column;
+ 	  yylsp->text = 0;
+ 	}
+       else
+ 	{
+ 	  yylsp->last_line = (yylsp+yylen-1)->last_line;
+ 	  yylsp->last_column = (yylsp+yylen-1)->last_column;
+ 	}
+ 	  
+       if (yyptr == yyrq + YYMAXRULES)
+         yyptr = yyrq;
+     }
+ 
+   if (yystate == YYFINAL)
+     YYACCEPT;
+ 
+   yyrq2 = yyptr;
+   yyrq1 = yyrq0;
+ 
+   *++yyvsp = yytval;
+   *++yylsp = yytloc;
+   yytval = yylval;
+   yytloc = yylloc;
+   yyget();
+ 
+   goto yynewstate;
+ 
+ yydefault:
+ 
+   yyn = yydefact[yystate];
+   if (yyn == 0)
+     goto yyerrlab;
+ 
+ yyreduce:
+ 
+   *yyrq0++ = yyn;
+ 
+   if (yyrq0 == yyrq + YYMAXRULES)
+     yyrq0 = yyrq;
+ 
+   if (yyrq0 == yyrq2)
+     {
+       yyabort("Parser Rule Queue Overflow");
+       YYABORT;
+     }
+ 
+   yyssp -= yyr2[yyn];
+   yyn = yyr1[yyn];
+ 
+   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
+   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+     yystate = yytable[yystate];
+   else
+     yystate = yydefgoto[yyn - YYNTBASE];
+ 
+   goto yynewstate;
+ 
+ yysemerr:
+   *--yyptr = yyn;
+   yyrq2 = yyptr;
+   yyvsp += yyr2[yyn];
+ 
+ yyerrlab:
+ 
+   yygssp = yyssp;
+   yygvsp = yyvsp;
+   yyglsp = yylsp;
+   yyrestore(yyrq0, yyrq2);
+   yyrecover();
+   yystate = *yygssp;
+   yyssp = yygssp;
+   yyvsp = yygvsp;
+   yyrq0 = yyrq;
+   yyrq1 = yyrq0;
+   yyrq2 = yyrq0;
+   goto yyresume;
+ }
+ 
+ $


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.simple
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.simple:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/bison.simple	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,1371 ----
+ #line 2 "bison.simple"
+ /* Skeleton output parser for bison,
+    copyright (C) 1984 Bob Corbett and Richard Stallman
+ 
+ 		       NO WARRANTY
+ 
+   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
+ NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
+ WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
+ RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
+ AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
+ DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
+ CORRECTION.
+ 
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
+ STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
+ WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
+ LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
+ OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+ USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
+ DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
+ A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
+ PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
+ 
+ 		GENERAL PUBLIC LICENSE TO COPY
+ 
+   1. You may copy and distribute verbatim copies of this source file
+ as you receive it, in any medium, provided that you conspicuously and
+ appropriately publish on each copy a valid copyright notice "Copyright
+ (C) 1985 Free Software Foundation, Inc."; and include following the
+ copyright notice a verbatim copy of the above disclaimer of warranty
+ and of this License.  You may charge a distribution fee for the
+ physical act of transferring a copy.
+ 
+   2. You may modify your copy or copies of this source file or
+ any portion of it, and copy and distribute such modifications under
+ the terms of Paragraph 1 above, provided that you also do the following:
+ 
+     a) cause the modified files to carry prominent notices stating
+     that you changed the files and the date of any change; and
+ 
+     b) cause the whole of any work that you distribute or publish,
+     that in whole or in part contains or is a derivative of this
+     program or any part thereof, to be licensed at no charge to all
+     third parties on terms identical to those contained in this
+     License Agreement (except that you may choose to grant more extensive
+     warranty protection to some or all third parties, at your option).
+ 
+     c) You may charge a distribution fee for the physical act of
+     transferring a copy, and you may at your option offer warranty
+     protection in exchange for a fee.
+ 
+ Mere aggregation of another unrelated program with this program (or its
+ derivative) on a volume of a storage or distribution medium does not bring
+ the other program under the scope of these terms.
+ 
+   3. You may copy and distribute this program (or a portion or derivative
+ of it, under Paragraph 2) in object code or executable form under the terms
+ of Paragraphs 1 and 2 above provided that you also do one of the following:
+ 
+     a) accompany it with the complete corresponding machine-readable
+     source code, which must be distributed under the terms of
+     Paragraphs 1 and 2 above; or,
+ 
+     b) accompany it with a written offer, valid for at least three
+     years, to give any third party free (except for a nominal
+     shipping charge) a complete machine-readable copy of the
+     corresponding source code, to be distributed under the terms of
+     Paragraphs 1 and 2 above; or,
+ 
+     c) accompany it with the information you received as to where the
+     corresponding source code may be obtained.  (This alternative is
+     allowed only for noncommercial distribution and only if you
+     received the program in object code or executable form alone.)
+ 
+ For an executable file, complete source code means all the source code for
+ all modules it contains; but, as a special exception, it need not include
+ source code for modules which are standard libraries that accompany the
+ operating system on which the executable file runs.
+ 
+   4. You may not copy, sublicense, distribute or transfer this program
+ except as expressly provided under this License Agreement.  Any attempt
+ otherwise to copy, sublicense, distribute or transfer this program is void and
+ your rights to use the program under this License agreement shall be
+ automatically terminated.  However, parties who have received computer
+ software programs from you with this License Agreement will not have
+ their licenses terminated so long as such parties remain in full compliance.
+ 
+   5. If you wish to incorporate parts of this program into other free
+ programs whose distribution conditions are different, write to the Free
+ Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
+ worked out a simple rule that can be stated here, but we will often permit
+ this.  We will be guided by the two goals of preserving the free status of
+ all derivatives of our free software and of promoting the sharing and reuse of
+ software.
+ 
+ 
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* This is the parser code that is written into each bison parser
+   when the %semantic_parser declaration is not specified in the grammar.
+   It was written by Richard Stallman by simplifying the hairy parser
+   used when %semantic_parser is specified.  */
+ 
+ /* Note: there must be only one dollar sign in this file.
+    It is replaced by the list of actions, each action
+    as one case of the switch.  */
+ 
+ #define yyerrok		(yyp->yyerrstatus = 0)
+ #define yyclearin	(yychar = YYEMPTY)
+ #define YYEMPTY		-2
+ #define YYEOF		0
+ #define YYFAIL		goto yyerrlab;
+ #define YYACCEPT	goto yyaccept
+ #define YYABORT		goto yyabort
+ 
+ #define YYTERROR	1
+ 
+ #ifndef YYIMPURE
+ #define YYLEX		yylex(currentfile)
+ #endif
+ 
+ static char *dummy = NULL;
+ char **_yytext = &dummy;
+ static YYSTYPE dummys;
+ YYSTYPE *_yylval = &dummys;
+ static YYLTYPE dummyl;
+ YYLTYPE *_yylloc = &dummyl;
+ static int dummyp;
+ int *_yyppval = &dummyp;
+ 
+ #ifdef YYDEBUG
+ int yydebug = 0;		/*  nonzero means print parse debug info */
+ int yytrace = 0;		/*  nonzero means print high-level parse
+ 				    trace */
+ #endif
+ 
+ #ifndef YYPURE
+ #define YYLEX		yylex(currentfile, &yylval, &yylloc)
+ #endif
+ 
+ /* If nonreentrant, generate the variables here */
+ 
+ #ifndef YYIMPURE
+ 
+ int	yyn;
+ 
+ #endif  /* YYIMPURE */
+ 
+ 
+ /*  YYMAXDEPTH indicates the initial size of the parser's stacks	*/
+ 
+ #ifndef	YYMAXDEPTH
+ #define YYMAXDEPTH 200
+ #endif
+ 
+ /*  YYMAXLIMIT is the maximum size the stacks can grow to
+     (effective only if the built-in stack extension method is used).  */
+ 
+ #ifndef YYMAXLIMIT
+ #define YYMAXLIMIT 10000
+ #endif
+ 
+ #define YYMAXFORKDEPTH 20
+ 
+ typedef struct parsestate {
+ 	struct parsestate *flink, *blink;
+ 	char *text;
+   	YYSTYPE lval;
+ 	YYLTYPE lloc;
+ 	int cur_token_number;
+ 	int yychar;
+ 	int blocked;
+ 	int lineno;		/* line number containing PP token */
+ 	int yystate;
+ 	int yyerrstatus;
+ 	int yynerr;		/* number of parse errors so far */
+ 	short *yyss, *yyssp;	/* state stack and state tos */
+ 	YYSTYPE *yyvs, *yyvsp, *last_reduction;	/* val stack and val tos */
+ 	YYSTYPE *tos_stack[YYMAXFORKDEPTH], **tos_tos;
+ #ifdef YYLSP_NEEDED
+ 	YYLTYPE *yyls, *yylsp;	/* line stack and line tos */
+ #endif
+ 	unsigned short flags_stack[YYMAXFORKDEPTH], *flags; /* control flags */
+ 	int  data_stack[YYMAXFORKDEPTH], *data; /* client specific data */
+ 	/* The following manage the correspondence between the
+ 	   two parses for an #ifdef. "pending_join" is the
+ 	   partner that will be next joined to. "pending_endif"
+ 	   is the partner that will be awoken on the next ifdef. */
+ 	struct parsestate *pending_join_stack[YYMAXFORKDEPTH], **pending_join;
+ 	struct parsestate *pending_endif_stack[YYMAXFORKDEPTH], **pending_endif;
+ 	short yymaxdepth;	/* max depth of current stack */
+ #ifdef YYDEBUG
+ 	char *branch_stack[YYMAXFORKDEPTH], **branch; 
+ #endif
+ } *parse;
+ 
+ #define SEEN_ENDIF_BIT 		0x01
+ #define SEEN_PP_TOKEN_BIT	0x02
+ #define JOIN_PENDING_BIT 	0x04
+ #define IFDEF_FORK_BIT 		0x08
+ #define JUST_SHIFTED_BIT	0x10
+ #define ACCEPTED_BIT		0x20
+ #define ABORTED_BIT		0x40
+ #define ACTIVE_BIT		0x80
+ #define DONE_SOMETHING_BIT	0x100
+ #define SEEN_ENDIF(p) 		(*(p)->flags & SEEN_ENDIF_BIT)
+ #define SEEN_PP_TOKEN(p)	(*(p)->flags & SEEN_PP_TOKEN_BIT)
+ #define JOIN_PENDING(p) 	(*(p)->flags & JOIN_PENDING_BIT)
+ #define IFDEF_FORK(p) 		(*(p)->flags & IFDEF_FORK_BIT)
+ #define JUST_SHIFTED(p)		(*(p)->flags & JUST_SHIFTED_BIT)
+ #define ACCEPTED(p) 		(*(p)->flags & ACCEPTED_BIT)
+ #define ABORTED(p) 		(*(p)->flags & ABORTED_BIT)
+ #define ACTIVE(p) 		(*(p)->flags & ACTIVE_BIT)
+ #define DONE_SOMETHING(p) 	(*(p)->flags & DONE_SOMETHING_BIT)
+ #define SET_SEEN_ENDIF(p) 	(*(p)->flags |= SEEN_ENDIF_BIT)
+ #define SET_SEEN_PP_TOKEN(p) 	(*(p)->flags |= SEEN_PP_TOKEN_BIT)
+ #define SET_JOIN_PENDING(p) 	(*(p)->flags |= JOIN_PENDING_BIT)
+ #define SET_IFDEF_FORK(p) 	(*(p)->flags |= IFDEF_FORK_BIT)
+ #define SET_JUST_SHIFTED(p) 	(*(p)->flags |= JUST_SHIFTED_BIT)
+ #define SET_ACCEPTED(p) 	(*(p)->flags |= ACCEPTED_BIT)
+ #define SET_ABORTED(p) 		(*(p)->flags |= ABORTED_BIT)
+ #define SET_ACTIVE(p) 		(*(p)->flags |= ACTIVE_BIT)
+ #define SET_DONE_SOMETHING(p) 	(*(p)->flags |= DONE_SOMETHING_BIT)
+ #define UNSET_SEEN_ENDIF(p) 	(*(p)->flags &= ~SEEN_ENDIF_BIT)
+ #define UNSET_SEEN_PP_TOKEN(p) 	(*(p)->flags &= ~SEEN_PP_TOKEN_BIT)
+ #define UNSET_JOIN_PENDING(p) 	(*(p)->flags &= ~JOIN_PENDING_BIT)
+ #define UNSET_IFDEF_FORK(p) 	(*(p)->flags &= ~IFDEF_FORK_BIT)
+ #define UNSET_JUST_SHIFTED(p) 	(*(p)->flags &= ~JUST_SHIFTED_BIT)
+ #define UNSET_ACCEPTED(p) 	(*(p)->flags &= ~ACCEPTED_BIT)
+ #define UNSET_ABORTED(p) 	(*(p)->flags &= ~ABORTED_BIT)
+ #define UNSET_ACTIVE(p) 	(*(p)->flags &= ~ACTIVE_BIT)
+ #define UNSET_DONE_SOMETHING(p) (*(p)->flags &= ~DONE_SOMETHING_BIT)
+ #define UNSET_ALL(p)		(*(p)->flags = 0)
+ 
+ #ifdef YYDEBUG
+ void
+ dumpparse(p)
+ parse p;
+ {
+     short *ss;
+ 
+     printf("parse %x, flink=%x, blink=%x, token=%d, yychar=%d\n",
+ 	   p, p->flink, p->blink, p->cur_token_number, p->yychar);
+     printf("\tblocked=%d, lineno=%d, yystate=%d, yyerrstatus=%d, yynerr=%d\n",
+ 	   p->blocked, p->lineno, p->yystate, p->yyerrstatus, p->yynerr);
+     printf("\tstate-stack: ");
+     for (ss = p->yyss; ss <= p->yyssp; ss++) {
+ 	printf(" %d", *ss);
+ 	if (ss - p->yyss == *p->tos_tos - p->yyvs)
+ 	    printf(" t");
+     }
+     printf("\n\n");
+ }
+ 
+ #endif
+ 
+ #if 0
+ extern int yylineno();		/* current line number per the scanner */
+ #endif
+ 
+ int id;
+ 
+ YYSTYPE (*yyfork)();
+ YYSTYPE (*yyjoin)();
+ void	(*yyelse)();
+ void	(*yyendif)();
+ void    (*yyfinish)();
+ void	(*yyswitch)();
+ int	(*yyskip)();
+ 
+ #include "preprocessor.h"
+ #include "alloc.h"
+ 
+ extern FILE *errfile;
+ 
+ parse
+ start_parse()
+ {
+     register parse p;
+ #ifdef YYDEBUG
+     if (yydebug)
+ 	fprintf(errfile, "Starting parse\n");
+ #endif
+     p = (parse)Malloc(sizeof *p);
+ 
+     p->yystate = 0;
+     p->yyerrstatus = 0;
+     p->yynerr = 0;
+     p->blocked = 0;
+     p->cur_token_number = -1;
+     p->yychar = YYEMPTY;
+     p->last_reduction = 0;
+ 
+     /* Initialize stack pointers.  Waste one element of value and
+      * location stack so that they stay on the same level as the state
+      * stack.
+      */
+     p->yyss = (short *)Malloc(sizeof(short) * YYMAXDEPTH);
+     p->yyssp = p->yyss - 1;
+     p->yyvsp = p->yyvs = (YYSTYPE *)Malloc(sizeof(YYSTYPE) * YYMAXDEPTH);
+     p->tos_tos = &p->tos_stack[0];
+     *p->tos_tos = p->yyvsp;
+     p->flags = &p->flags_stack[0];
+     *p->flags = 0;
+     p->data = &p->data_stack[0];
+     *p->data = 0;
+     p->pending_join = &p->pending_join_stack[0];
+     p->pending_endif = &p->pending_endif_stack[0];
+     *p->pending_join = *p->pending_endif = 0;
+ #ifdef YYLSP_NEEDED
+     p->yylsp = p->yyls = (YYLTYPE *)Malloc(sizeof(YYLTYPE) * YYMAXDEPTH);
+ #endif
+     p->yymaxdepth = YYMAXDEPTH;
+     /* make it a circular linked list */
+     p->flink = p->blink = p;
+ #ifdef YYDEBUG
+     p->branch = &p->branch_stack[0];
+     *p->branch = "TRUE branch";
+ #endif
+     return p;
+ }
+ 
+ kill_parse(p)
+ register parse p;
+ {
+     Free(p->yyss);
+     Free(p->yyvs);
+ #ifdef YYLSP_NEEDED
+     Free(p->yyls);
+ #endif
+     Free(p);
+ }
+ 
+ unify_parses(p1, p2)
+ parse p1, p2;
+ {
+     register short *s1 = p1->yyssp;
+     register short *s2 = p2->yyssp;
+ 
+     if (*p1->pending_join != p2 || *p2->pending_join != p1)
+ 	return 0;
+ 
+     if (JUST_SHIFTED(p1) || JUST_SHIFTED(p2)) 
+ 	return 0;
+ 
+     if (!ACTIVE(p1) || !ACTIVE(p2)) 
+ 	return 0;
+ 
+     if ((!DONE_SOMETHING(p1) && !DONE_SOMETHING(p2)) ||
+ 	(ACCEPTED(p1) && ACCEPTED(p2))) {
+ #ifdef YYDEBUG	       
+ 	if (yydebug)
+ 	    fprintf(errfile, "Joining parse %x to parse %x\n", p1, p2);
+ #endif
+ 	return 1;
+     }
+     
+     if ((p1->yyvsp > *p1->tos_tos+1) || (p2->yyvsp > *p2->tos_tos+1))
+ 	return 0;
+     
+     while (s1 != p1->yyss && s2 != p2->yyss) {
+ 	if (*s1 != *s2)
+ 	    break;
+ 	s1--; s2--;
+     }
+ 
+     if (s1 == p1->yyss && s2 == p2->yyss) {
+ #ifdef YYDEBUG	       
+ 	if (yydebug) {
+ 	    fprintf(errfile, "Joining parse %x to parse %x\n", p1, p2);
+ 	}
+ #endif
+ 	return 1;
+     }
+     return 0;
+ }
+ 
+ void realloc_stack(as, p)
+     ScanPtr as;
+     register parse p;
+ {
+     /* Give user a chance to reallocate the stack. */
+ 
+ 
+     /* Get the current used size of the three stacks, in elements.  */
+     int size = p->yyssp - p->yyss + 1;
+ 
+     if (p->yymaxdepth >= YYMAXLIMIT)
+ 	yyerror(as, "parser stack overflow");
+ 
+     p->yymaxdepth *= 2;
+     if (p->yymaxdepth > YYMAXLIMIT)
+ 	p->yymaxdepth = YYMAXLIMIT;
+ 
+     p->yyss = (short *) Realloc(p->yyss,
+ 				p->yymaxdepth * (sizeof (*p->yyssp)));
+     p->yyvs = (YYSTYPE *) Realloc(p->yyvs, 
+ 				  p->yymaxdepth * (sizeof (*p->yyvsp)));
+ #ifdef YYLSP_NEEDED
+     p->yyls = (YYLTYPE *) Realloc(p->yyls, 
+ 				  p->yymaxdepth * (sizeof (*p->yylsp)));
+ #endif
+ 
+     p->yyssp = p->yyss + size - 1;
+     p->yyvsp = p->yyvs + size - 1;
+ #ifdef YYLSP_NEEDED
+     p->yylsp = p->yyls + size - 1;
+ #endif
+ 
+ #ifdef YYDEBUG
+     if (yydebug)
+ 	fprintf(errfile, "Stack size increased to %d\n", p->yymaxdepth);
+ #endif
+ 
+ #if 0
+     if (p->yyssp >= p->yyss + p->yymaxdepth - 1)
+ 	return
+ #endif
+ }
+ 
+ #define REDUCTION 1
+ 
+ #if 0
+ static parse
+ next_applicable_parse(p, parselist)
+ register parse p, parselist;
+ {
+     register parse l = parselist->flink;
+ 
+     while (l != p) {
+ 	if (l->cur_token_number == p->cur_token_number)
+ 	    break;
+ 	l = l->flink;
+     }
+     return l == p ? NULL : l;
+ }
+ #endif
+ 
+ static void
+ notify_of_endif(p, limit, activelist, cur_token_number)
+     parse p;
+     parse limit;
+     parse *activelist;
+ {
+     parse *pending;
+ 
+     --p->pending_endif;
+     p->cur_token_number = cur_token_number;
+     p->yychar = YYEMPTY;
+     SET_SEEN_ENDIF(p);
+     SET_SEEN_PP_TOKEN(p);
+     /* if p isn't active, make it so and put it on the activelist */
+     if (!ACTIVE(p)) {
+ 	SET_ACTIVE(p);
+ 	if (*activelist == NULL) {
+ 	    *activelist = p;
+ 	    (*activelist)->flink = (*activelist)->blink = *activelist;
+ 	} else {
+ 	    (*activelist)->blink->flink = p;
+ 	    p->flink = *activelist;
+ 	    p->blink = (*activelist)->blink;
+ 	    (*activelist)->blink = p;
+ 	}
+     }
+ 
+     for (pending = p->pending_join; *pending != limit; pending--) {
+ 	notify_of_endif(*pending, p, activelist, cur_token_number);
+     }
+ 
+ }
+ 
+ static parse
+ find_next_parse(parselist, cur_token_number)
+ register parse parselist;
+ {
+     register parse l, best_parse;
+     int parse_val, best_parse_val;
+ 
+     if (parselist->flink == parselist)
+     	if (ACCEPTED(parselist) || ABORTED(parselist))
+ 	    return NULL;
+ 	else
+     	    return parselist;
+ 
+     l = parselist;
+     best_parse_val = -2;
+     best_parse = NULL;
+     do {
+ 	if (ACCEPTED(l) || ABORTED(l)) {
+ 	    l = l->flink;
+ 	    continue;
+ 	}
+ 	else if (l->cur_token_number < cur_token_number) 
+ 	    parse_val = 100000;
+ 	else 
+ 	    parse_val = 0;
+ 
+ 	parse_val += l->yyssp - l->yyss;
+ 	if (parse_val > best_parse_val) {
+ 	    best_parse_val = parse_val;
+ 	    best_parse = l;
+ 	} else if (parse_val == best_parse_val &&
+ 		   *l->yyssp > *best_parse->yyssp) {
+ 	    best_parse_val = parse_val;
+ 	    best_parse = l;
+ 	}
+ 	    
+ 	l = l->flink;
+     } while (l != parselist);
+     return best_parse;
+ }
+ 
+ #define FALSE 0
+ #define TRUE 1
+ 
+ all_blocked(parselist, cur_token_number)
+ parse parselist;
+ {
+     register parse l = parselist;
+     do {
+ 	if (l->cur_token_number != cur_token_number)
+ 	    return FALSE;
+ 	l = l->flink;
+     } while (l != parselist);
+     return TRUE;
+ }
+ 
+ static parse merge_parses(yyp, ap, activelist, currentfile)
+     parse yyp, ap;
+     parse *activelist;
+     FilePtr currentfile;
+ {
+     parse tmp;
+     
+     if (!IFDEF_FORK(yyp)) {
+ 	/* swap ap and yyp so that the result of the join
+ 	   (yyp) is the true branch of the fork */
+ 	tmp = ap;
+ 	ap = yyp;
+ 	yyp = tmp;
+     }
+ #ifdef YYDEBUG
+     if (yydebug)
+ 	fprintf(errfile, "Joining parse 0x%x and 0x%x.\n", 
+ 		yyp, ap);
+ #endif		
+     if (yyjoin) {
+ 	if (!yyp->last_reduction) 
+ 	    yyp->last_reduction = yyp->yyvsp;
+ 	if (!ap->last_reduction) 
+ 	    ap->last_reduction = ap->yyvsp;
+ 	*yyp->yyvsp = (*yyjoin)(yyp->last_reduction,
+ 				ap->last_reduction,
+ 				yyp->data, ap->data,
+ 				&currentfile->cpp_skipping);
+     }
+     --yyp->pending_join;
+     --yyp->data;
+     --yyp->flags;
+     --yyp->tos_tos;
+ #ifdef YYDEBUG
+     --yyp->branch;
+ #endif			
+     
+     /* get rid of the duplicate parse */
+     ap->blink->flink = ap->flink;
+     ap->flink->blink = ap->blink;
+     if (ap == *activelist)
+ 	*activelist = ap->flink;
+     kill_parse(ap);
+     return yyp;
+ }
+ 
+ static void merge_active(activelist, currentfile)
+     parse *activelist;
+     FilePtr currentfile;
+ {
+     parse yyp, ap;
+     int parses_merged;
+     
+     /*
+      * See if there are any parses that we can join.
+      */
+     parses_merged = 1;
+     while (parses_merged && (*activelist)->flink != *activelist) {
+ 	parses_merged = 0;
+ 	yyp = *activelist;
+ 	do {
+ 	    ap = *yyp->pending_join;
+ 	    if (unify_parses(yyp, ap)) {
+ 		yyp = merge_parses(yyp, ap, activelist, currentfile);
+ 		parses_merged = 1;
+ 	    }
+ 	    yyp = yyp->flink;
+ 	} while (yyp != *activelist);
+     }
+ }
+ 
+ #line 607 "bison.simple"
+ int yyparse(currentfile)
+     FilePtr currentfile;
+ {
+     int yychar1; /*  lookahead token as an internal (translated) token number */
+ 
+ #ifndef YYPURE
+     int yyn;
+ #endif
+ 
+ #ifdef YYDEBUG
+     extern int yydebug;
+ #endif
+ 
+     YYSTYPE yyval;    	/* the variable used to return */
+     			/* semantic values from the action */
+     			/* routines */
+     int yylen;
+     register parse yyp;
+     parse ap, activelist;
+     int curtoken, retval;
+     char *curtext, **oldtext;
+     YYSTYPE curlval, *oldlval;
+     YYLTYPE curlloc, *oldlloc;
+     int cur_token_number = 0;
+ 
+ 
+     oldtext = _yytext;
+     oldlval = _yylval;
+     oldlloc = _yylloc;
+     
+     activelist = start_parse();
+     SET_ACTIVE(activelist);
+      
+     /* Go through parses in round-robin fashion. Activelist is a circular */
+     /* doubly linked list. */ 
+     while (yyp = find_next_parse(activelist, cur_token_number)) {
+ 	_yytext = &(yyp->text);
+ 	_yylval = &(yyp->lval);
+ 	_yylloc = &(yyp->lloc);
+ #ifdef YYDEBUG
+ 	if (yydebug)
+ 	    fprintf(errfile, "Resuming parser %x %s\n", yyp, *yyp->branch);
+ #endif
+ 	if (yyswitch) 
+ 	    (*yyswitch)(yyp->data, &currentfile->cpp_skipping);
+ 
+ 	/*
+ 	 * Figure out where to resume.  If this parse has never
+ 	 * seen a token, we start below the test statements, otherwise
+ 	 * we start where we left off.
+ 	 */
+ #if 1
+ 	if (yyp->blocked == REDUCTION) {
+ #ifdef YYDEBUG
+ 	    if (yydebug) 
+ 		fprintf(errfile, "yyp->blocked == REDUCTION, yyp->token = %d, %d\n", yyp->cur_token_number, cur_token_number);
+ #endif
+ 	    goto yyresume;
+ 	}
+ 	else 
+ #endif
+ 	    if (SEEN_PP_TOKEN(yyp)) {
+ #ifdef YYDEBUG
+ 		if (yydebug) 
+ 		    fprintf(errfile, "SEEN_PP_TOKEN");
+ #endif
+ 		goto yyresume;
+ 	}
+ 	else if (yyp->cur_token_number < 0) {
+ 	    /*
+ 	     * This is the start-up case for the parser.  We have
+ 	     * to set the token counter so that we will read the first
+ 	     * token and then fall through to push the initial state.
+ 	     */
+ 	    yyp->cur_token_number = cur_token_number;
+ 	} else 
+ 	    goto yyresume;
+ 
+         /*
+ 	 * Push a new state, which is found in yystate .  In all
+ 	 * cases, when you get here, the value and location stacks
+ 	 * have just been pushed.  so pushing a state here evens the
+ 	 * stacks.
+   	 */
+     yynewstate:
+ #ifdef YYDEBUG
+ 	    if (yydebug) 
+ 		fprintf(errfile, "yynewstate: ");
+ #endif
+ 	*++yyp->yyssp = yyp->yystate;
+ 	SET_DONE_SOMETHING(yyp);
+ 
+ 	if (yyp->yyssp >= yyp->yyss + yyp->yymaxdepth - 1)
+ 	    realloc_stack(currentfile->as, yyp);
+ #ifdef YYDEBUG
+ 	if (yydebug) {
+ 	    short *ssp1 = yyp->yyss - 1;
+ 	    fprintf(errfile, "Entering state %d ", yyp->yystate);
+ 	    fprintf (errfile, "state stack now");
+ 	    while (ssp1 != yyp->yyssp)
+ 		fprintf (errfile, " %d", *++ssp1);
+ 	    fprintf (errfile, "\n");
+ 	}
+ #endif
+ 
+ 	/*
+ 	 * We've already done the reduction.  Now see if we can join this
+ 	 * parse with its partner.
+ 	 */
+ 	if (SEEN_ENDIF(yyp) && (ap = *yyp->pending_join)) {
+ 	    /* we should really make sure that both parses can be
+ 	       reduced here */
+ 	    if (unify_parses(yyp, ap))
+ 		yyp = merge_parses(yyp, ap, &activelist, currentfile);
+ 	}
+ 
+ #if 2	
+ 	/*
+ 	 * If we are here and blocked == REDUCTION, then we just
+ 	 * did a reduction so we should block to see if there is a better 
+ 	 * candidate parse for reduction.
+ 	 */
+ 	if (yyp->blocked == REDUCTION)
+ 	   continue; 
+ #endif
+ 
+ 	/* Do appropriate processing given the current state.  Read
+ 	 * a lookahead token if we need one and don't already have
+ 	 * one.
+ 	 */
+     yyresume:
+ #ifdef YYDEBUG
+ 	if (yydebug) 
+ 	    fprintf(errfile, "yyresume: ");
+ #endif
+ 
+ 	/* First try to decide what to do without reference to
+ 	 * lookahead token.
+ 	 */
+ 
+ 	yyn = yypact[yyp->yystate];
+ 	if (yyn == YYFLAG)
+ 	    goto yydefault;
+ 
+ 	/* Not known => get a lookahead token if don't already have
+ 	 * one.
+ 	 */
+ 
+ 	/* yychar is either YYEMPTY or YYEOF or a valid token in
+ 	 * external form.
+ 	 */
+ 
+ 	if (yyp->yychar == YYEMPTY) {
+ 	    register parse newp;
+ 	    int need_new_token;
+ 
+ 	    /*
+ 	     * Synchronize on input.  Suspend this parse if other
+ 	     * parses haven't read the current token.
+ 	     */
+ 	    if (!(need_new_token = all_blocked(activelist, cur_token_number)) &&
+ 		yyp->cur_token_number == cur_token_number)
+ 		continue;
+ 
+ 	    if (need_new_token) {
+ #ifdef YYDEBUG
+ 		if (yydebug)
+ 		    fprintf(errfile, "Reading a token: ");
+ #endif
+ 		yyp->yychar = curtoken = YYLEX;
+ 		curtext = yytext;
+ 		curlval = yylval;
+ 		curlloc = yylloc;
+ 		yyp->cur_token_number = ++cur_token_number;
+ 	    } else {
+ 		yyp->yychar = curtoken;
+ 		yyp->text = curtext;
+ 		yyp->lval = curlval;
+ 		yyp->lloc = curlloc;
+ 		yyp->cur_token_number = cur_token_number;
+ 	    }
+ 
+ 	    switch (yyp->yychar) {
+ 		parse tail;
+ 		int token_val;
+ 
+ 	    case PPELSE:
+ 	    case PPELIF:
+ #ifdef YYDEBUG
+ 		if (yydebug)
+ 		    fprintf(errfile, "Next token is ELSE\n");
+ #endif
+ 		token_val = yyp->yychar;
+ 
+ 		/*
+ 		 * Swap role of active and sleeping parses
+ 		 * by putting all currently active parses to sleep
+ 		 * and waking all their partners.
+ 		 */
+ 		ap = activelist;        /* save old activelist */
+ 		activelist = NULL;	/* nothing currently active */
+ 		tail = ap;
+ 		
+ 		/*
+ 		 * Now put the relevant sleeping parses back on
+ 		 * activelist.
+ 		 */
+ 	    	{
+ 		    parse nextap = 0, partner;
+ 		    
+ 		    for (; ap && nextap != tail; ap = nextap) {
+ 			nextap = ap->flink;
+ 			partner = *ap->pending_endif;
+ 			UNSET_ACTIVE(ap);
+ 			if (!ACTIVE(partner)) {
+ 			    if (activelist == NULL) {
+ 				activelist = partner;
+ 				activelist->flink = activelist->blink =
+ 				    activelist;
+ 			    } else {
+ 				/* Put parse on end. Is this necessary? */
+ 				activelist->blink->flink = partner;
+ 				partner->flink = activelist;
+ 				partner->blink = activelist->blink;
+ 				activelist->blink = partner;
+ 			    }
+ 			    /* force this parse to read new token */
+ 			    partner->cur_token_number = cur_token_number;
+ 			    /* mark this parse as having just seen a
+ 			       preprocessor token */
+ 			    UNSET_ALL(partner);
+ 			    SET_SEEN_PP_TOKEN(partner);
+ 			    SET_ACTIVE(partner);
+ 			}
+ 		    }		/* for loop */
+ 		}		/* compound stmt */
+ 
+ 		if (yyelse) 
+ 		    if (IFDEF_FORK(yyp))
+ 			(*yyelse)(yyp->data, (*yyp->pending_endif)->data);
+ 		    else
+ 			(*yyelse)((*yyp->pending_endif)->data, yyp->data);
+ 
+ 
+ 		yyp->yychar = YYEMPTY;
+ 		yyp = activelist->blink;
+ 		if (token_val == PPELSE) {
+ 		    continue;
+ 		} else {
+ 		    /* fall through to do IF part of PPELIF case */ ;
+ 		    yyp->yychar = PPELIF;
+ #ifdef YYDEBUG
+ 		    if (yydebug)
+ 			fprintf(errfile, "Next token was really ELSIF\n");
+ #endif
+ 		}
+ 	    case PPIFDEF:
+ 	    case PPIF:
+ 	    case PPIFNDEF:
+ 
+ #ifdef YYDEBUG
+ 		if (yydebug)	
+ 		    fprintf(errfile, "Next token is IFDEF, IFNDEF, or IF. ");
+ #endif
+ 		/* save current tos for yyvs */
+ 		*(++yyp->tos_tos) = yyp->yyvsp;
+ 		++yyp->flags;
+ 		SET_JOIN_PENDING(yyp);
+ 		UNSET_SEEN_ENDIF(yyp);
+ 		SET_SEEN_PP_TOKEN(yyp);
+ 		SET_IFDEF_FORK(yyp);
+ 		SET_ACTIVE(yyp);
+ 		UNSET_DONE_SOMETHING(yyp);
+ 		++yyp->pending_join;
+ 		++yyp->pending_endif;
+ 		++yyp->data;
+ 		
+ 		/*
+ 		 * fork an alternate parse for this active parse.
+ 		 */
+ 		newp = start_parse();
+ #ifdef YYDEBUG
+ 		if (yydebug)
+ 		    fprintf(errfile, 
+ 			    "Splitting parse 0x%x. New parse is 0x%x.\n", 
+ 			    yyp, newp);
+ #endif		
+ 
+ #ifdef YYDEBUG
+ 		++yyp->branch;
+ 		*yyp->branch = "TRUE branch";
+ 		bcopy(yyp->branch_stack, newp->branch_stack, sizeof
+ 		      newp->branch_stack);
+ 		newp->branch = newp->branch_stack + (yyp->branch -
+ 						     yyp->branch_stack);
+ 		*newp->branch = "FALSE branch";
+ #endif
+ 		bcopy(yyp->yyss, newp->yyss,
+ 		      (yyp->yyssp - yyp->yyss + 1) * (sizeof *yyp->yyss));
+ 		newp->yyssp = newp->yyss + (yyp->yyssp - yyp->yyss);
+ 		bcopy(yyp->yyvs, newp->yyvs,
+ 		      (yyp->yyvsp - yyp->yyvs + 1) * (sizeof *yyp->yyvs));
+ 		newp->yyvsp = newp->yyvs + (yyp->yyvsp - yyp->yyvs);
+ #ifdef YYLSP_NEEDED
+ 		bcopy(yyp->yyls, newp->yyls,
+ 		      (yyp->yylsp - yyp->yyls + 1) * (sizeof *yyp->yyls));
+ 		newp->yylsp = newp->yyls + (yyp->yylsp - yyp->yyls);
+ #endif
+ 
+ 		{
+ 		    int i;
+ 		    for (i = 0; &yyp->tos_stack[i] <= yyp->tos_tos; i++)
+ 			newp->tos_stack[i] = newp->yyvs
+ 			    + (yyp->tos_stack[i] - yyp->yyvs);
+ 		}
+ 		newp->tos_tos = newp->tos_stack
+ 		    + (yyp->tos_tos - yyp->tos_stack);
+ 
+ 		newp->lineno = yyp->lineno = yylineno(currentfile->as);
+ 		newp->yystate = yyp->yystate;
+ 		newp->yyerrstatus = yyp->yyerrstatus;
+ 		newp->yynerr = yyp->yynerr;
+ 		newp->yymaxdepth = yyp->yymaxdepth;
+ 		
+ 		bcopy(yyp->flags_stack, newp->flags_stack,  
+ 		      sizeof newp->flags_stack);
+ 		newp->flags =
+ 		    newp->flags_stack + (yyp->flags - yyp->flags_stack);
+ 		UNSET_ALL(newp);
+ 		SET_JOIN_PENDING(newp);
+ 
+ 		bcopy(yyp->pending_join_stack, newp->pending_join_stack, 
+ 		      sizeof newp->pending_join_stack);
+ 		newp->pending_join =
+ 		    newp->pending_join_stack + (yyp->pending_join - 
+ 						yyp->pending_join_stack);
+ 		*newp->pending_join = yyp;
+ 		*yyp->pending_join = newp;
+ 
+ 		bcopy(yyp->pending_endif_stack, newp->pending_endif_stack, 
+ 		      sizeof newp->pending_endif_stack);
+ 		newp->pending_endif =
+ 		    newp->pending_endif_stack + (yyp->pending_endif - 
+ 						 yyp->pending_endif_stack);
+ 		*newp->pending_endif = yyp;
+ 		*yyp->pending_endif = newp;
+ 
+ 		bcopy(yyp->data_stack, newp->data_stack, sizeof
+ 		      newp->data_stack);
+ 		newp->data = newp->data_stack + (yyp->data - yyp->data_stack);
+ 
+ 		if (yyfork)
+ 		    if (yyp->last_reduction)
+ 		    	*yyp->last_reduction =
+ 			   (*yyfork)(yyp->last_reduction,
+ 				     yyp->yychar, yytext, yyppval, 
+ 				     yyp->data, newp->data,
+ 				     currentfile->cpp_skipping);
+ 		    else
+ 			(void)(*yyfork)(yyp->last_reduction,
+ 					yyp->yychar, yytext, yyppval,
+ 					yyp->data, newp->data,
+ 					currentfile->cpp_skipping);
+ 
+ 		yyp->cur_token_number = cur_token_number;
+ 		yyp->yychar = YYEMPTY;
+ 
+ 		continue;	/* do the next parse */
+ 
+ 	    case PPENDIF:
+ #ifdef YYDEBUG
+ 		if (yydebug)
+ 		    fprintf(errfile, "Next token is ENDIF\n");
+ #endif
+ 		ap = *yyp->pending_endif;
+ 
+ 		if (yyendif) 
+ 		    if (IFDEF_FORK(yyp))
+ 			(*yyendif)(yyp->data, ap->data);
+ 		    else
+ 			(*yyendif)(ap->data, yyp->data);
+ 
+ 		notify_of_endif(yyp, ap, &activelist, cur_token_number);
+ 		notify_of_endif(ap, *ap->pending_endif,
+ 		                &activelist, cur_token_number);
+ 
+ 		/* all partners are now active and have been notified of
+ 		   the #endif. See if there's anything we can join. */
+ 		merge_active(&activelist, currentfile);
+ 
+ 		continue;
+ 		
+ 	    case PPDEFINE:
+ 	    case PPINCLUDE:
+ 	    case PPLINE:
+ 		yyp->yychar = YYEMPTY;
+ 		break;
+ 	    }
+ 	}
+ 	/* This is a real token. Mark this parse has having seen one. */
+ #ifdef YYDEBUG
+ 	if (yydebug && SEEN_PP_TOKEN(yyp))
+ 	    fprintf(errfile, "Unsetting SEEN_PP_TOKEN for %x, (%s).\n", yyp,
+ 		    *yyp->branch);
+ #endif
+ 	UNSET_SEEN_PP_TOKEN(yyp);
+ 
+ 	/* Convert token to internal form (in yychar1) for indexing
+ 	 * tables with
+ 	 */
+ 
+ 	if (yyp->yychar <= 0) { /* This means end of input. */
+ 	    yychar1 = 0;
+ 	    yyp->yychar = YYEOF;	/* Don't call YYLEX any more */
+ 
+ #ifdef YYDEBUG
+ 	    if (yydebug)
+ 		fprintf(errfile, "Now at end of input.\n");
+ #endif
+ 	} else {
+ 	    yychar1 = YYTRANSLATE(yyp->yychar);
+ 
+ #ifdef YYDEBUG
+ 	    if (yydebug)
+ 		fprintf(errfile, "Next token is %d (%s, %s)\n", yyp->yychar, yytname[yychar1], yytext);
+ #endif
+ 	}
+ 
+ 	yyn += yychar1;
+ 	if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
+ 	    goto yydefault;
+ 
+ 	yyn = yytable[yyn];
+ 
+ 	/* yyn is what to do for this token type in this state.
+ 	 * Negative => reduce, -yyn is rule number.  	 Positive =>
+ 	 * shift, yyn is new state.  	 New state is final state =>
+ 	 * don't bother to shift, 	 just return success.  	 0, or
+ 	 * most negative number => error.
+ 	 */
+ 
+ 	if (yyn < 0) {
+ 	    if (yyn == YYFLAG)
+ 		goto yyerrlab;
+ 	    yyn = -yyn;
+ 	    goto yyreduce;
+ 	} else if (yyn == 0)
+ 	    goto yyerrlab;
+ 
+ 	if (yyn == YYFINAL) {
+ 	    _yytext = oldtext;
+ 	    _yylval = oldlval;
+ 	    _yylloc = oldlloc;
+ 	    YYACCEPT;
+ 	}
+ 
+ 	/* Shift the lookahead token.  */
+ 
+ #ifdef YYDEBUG
+ 	if (yydebug)
+ 	    fprintf(errfile, "Shifting token %d (%s, %s), ", yyp->yychar, yytname[yychar1], yytext);
+ #endif
+ 
+ 	/* Discard the token being shifted unless it is eof.  */
+ 	if (yyp->yychar != YYEOF) {
+ 	    yyp->yychar = YYEMPTY;
+ 	    *++yyp->yyvsp = yylval;
+ #ifdef YYLSP_NEEDED
+ 	    ++yyp->yylsp;
+ 	    *yyp->yylsp = yylloc;
+ #endif
+ 	    SET_JUST_SHIFTED(yyp);
+ 	}
+ 
+ 	/* count tokens shifted since error; after three, turn off
+ 	 * error status.
+ 	 */
+  	if (yyp->yyerrstatus) yyp->yyerrstatus--;
+ 
+ 	yyp->yystate = yyn;
+ 	goto yynewstate;
+ 
+ 	/* Do the default action for the current state.  */
+     yydefault:
+ #ifdef YYDEBUG
+ 	if (yydebug) 
+ 	    fprintf(errfile, "yydefault: ");
+ #endif
+ 	yyn = yydefact[yyp->yystate];
+ 	if (yyn == 0)
+ 	    goto yyerrlab;
+ 
+ 	/* Do a reduction.  yyn is the number of a rule to reduce
+ 	 * with.
+ 	 */
+     yyreduce:
+ #ifdef YYDEBUG
+ 	if (yydebug) 
+ 	    fprintf(errfile, "yyreduce: ");
+ #endif
+  	yylen = yyr2[yyn];
+ 	yyval = (yyp->yyvsp)[1-yylen];
+ 	/* implement default value of the action */
+ 
+ #ifdef YYDEBUG
+ 	if (yydebug) {
+ 	    if (yylen == 1)
+ 		fprintf (errfile, "Reducing 1 value via line %d, ",
+ 			 yyrline[yyn]);
+ 	    else
+ 		fprintf (errfile, "Reducing %d values via line %d, ",
+ 			 yylen, yyrline[yyn]);
+ 	}
+ #endif
+ 
+ 
+ $	/* the action file gets copied in in place of this dollarsign */
+ #line 1120 "bison.simple"
+ 
+     	yyp->yyvsp -= yylen;
+ 	if (JOIN_PENDING(yyp) && yyp->yyvsp < *yyp->tos_tos)
+ 	    *yyp->tos_tos = yyp->yyvsp;
+ 	*++yyp->yyvsp = yyval;
+ 	if (yylen > 0) {
+ 	    yyp->last_reduction = yyp->yyvsp;
+ 	    UNSET_JUST_SHIFTED(yyp);
+ 	}
+ 
+ 	yyp->yyssp -= yylen;
+ #ifdef YYLSP_NEEDED
+ 	yyp->yylsp -= yylen;
+ #endif
+ 
+ #ifdef YYDEBUG
+ 	if (yydebug) {
+ 	    short *ssp1 = yyp->yyss - 1;
+ 	    fprintf (errfile, "state stack now");
+ 	    while (ssp1 != yyp->yyssp)
+ 		fprintf (errfile, " %d", *++ssp1);
+ 	    fprintf (errfile, "\n");
+ 
+ 	}
+ #endif
+ 
+ #ifdef YYLSP_NEEDED
+ 	yyp->yylsp++;
+ 	if (yylen == 0)	{
+ 	    yyp->yylsp->first_line = yylloc.first_line;
+ 	    yyp->yylsp->first_column = yylloc.first_column;
+ 	    yyp->yylsp->last_line = (yyp->yylsp-1)->last_line;
+ 	    yyp->yylsp->last_column = (yyp->yylsp-1)->last_column;
+ 	} else {
+ 	    yyp->yylsp->last_line = (yyp->yylsp+yylen-1)->last_line;
+ 	    yyp->yylsp->last_column = (yyp->yylsp+yylen-1)->last_column;
+ 	}
+ #endif
+ 
+ 
+ 	/* Now "shift" the result of the reduction. Determine
+ 	 * what state that goes to, based on the state we popped
+ 	 * back to and the rule number reduced by.
+ 	 */
+ 
+ 	yyn = yyr1[yyn];
+ 
+ 	yyp->yystate = yypgoto[yyn - YYNTBASE] + *yyp->yyssp;
+ 	if (yyp->yystate >= 0 && yyp->yystate <= YYLAST && yycheck[yyp->yystate] == *yyp->yyssp)
+ 	    yyp->yystate = yytable[yyp->yystate];
+ 	else
+ 	    yyp->yystate = yydefgoto[yyn - YYNTBASE];
+ 
+ 	yyp->blocked = REDUCTION;
+ 	goto yynewstate;
+ 
+     yyerrlab:			/* here on detecting error */
+ 
+ 	if (! yyp->yyerrstatus) {
+ 	    if (yyp->flink == yyp || !(*yyskip)(yyp->data)) {
+ 		/* If not already recovering from an error,  report this
+ 		   error. */ 
+ 		++yyp->yynerr;
+ 		yyerror(currentfile->as, "parse error");
+ 		if ((yyn = yypact[yyp->yystate]) > YYFLAG && yyn < YYLAST)
+ 		{
+ 		    int x, count;
+ 		    count = 0;
+ 		    for (x = 3; x < (sizeof(yytname) / sizeof(char *)); x++)
+ 		    {
+ 			if (yycheck[x + yyn] == x)
+ 			{
+ 			    fprintf (errfile, "%s %s", 
+ 				     count == 0 ? "expecting:" : " or", 
+ 				     yytname[x]);
+ 			    count++;
+ 			}
+ 		    }
+ 		    fprintf (errfile, "%s", count > 0 ? "\n" : "");
+ 		}
+ 	    }
+ 	    else {
+ 		YYABORT;
+ 	    }
+ 	}
+ 
+ 	if (yyp->yyerrstatus == 3) {
+ 
+ 	    /* if just tried and failed to reuse lookahead token after
+ 	     * an error, discard it.
+ 	     */
+ 
+ 	    /* return failure if at end of input */
+ 	    if (yyp->yychar == YYEOF) {
+ 		_yytext = oldtext;
+ 		_yylval = oldlval;
+ 		_yylloc = oldlloc;
+ 		YYABORT;
+ 	    }
+ 
+ #ifdef YYDEBUG
+ 	    if (yydebug)
+ 		fprintf(errfile, "Discarding token %d (%s).\n", yyp->yychar, yytname[yychar1]);
+ #endif
+ 
+ 	    yyp->yychar = YYEMPTY;
+ 	}
+ 
+ 	/* Else will try to reuse lookahead token
+ 	   after shifting the error token.  */
+ 
+ 	yyp->yyerrstatus = 3;   /* Each real token shifted decrements this */
+ 
+ 	goto yyerrhandle;
+ 
+     yyerrdefault: 	 
+ 
+ 	/* current state does not do anything special for the error
+ 	* token.
+ 	*/
+ 
+ #if 0
+ 	/* This is wrong; only states that explicitly want error
+ 	 * tokens should shift them.
+ 	 */
+ 	yyn = yydefact[yyp->yystate];
+ 
+ 	/* If its default is to accept any token, ok.  Otherwise pop
+ 	 * it.
+ 	 */
+ 	if (yyn) goto yydefault;
+ #endif
+ 
+     yyerrpop: 	 
+ 
+ 	/* pop the current state because it cannot handle the error token */
+ 
+ 	if (yyp->yyssp == yyp->yyss)  {
+ 	    _yytext = oldtext;
+ 	    _yylval = oldlval;
+ 	    _yylloc = oldlloc;
+ 	    YYABORT;
+ 	}
+ 	yyp->yyvsp--;
+ 	yyp->yystate = *--yyp->yyssp;
+ #ifdef YYLSP_NEEDED
+ 	yyp->yylsp--;
+ #endif
+ 
+ #ifdef YYDEBUG
+ 	if (yydebug) {
+ 	    short *ssp1 = yyp->yyss - 1;
+ 	    fprintf (errfile, "Error: state stack now");
+ 	    while (ssp1 != yyp->yyssp)
+ 		fprintf (errfile, " %d", *++ssp1);
+ 	    fprintf (errfile, "\n");
+ 	}
+ #endif
+ 
+     yyerrhandle:
+ 
+ 	yyn = yypact[yyp->yystate];
+ 	if (yyn == YYFLAG)
+ 	    goto yyerrdefault;
+ 
+ 	yyn += YYTERROR;
+ 	if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
+ 	    goto yyerrdefault;
+ 
+ 	yyn = yytable[yyn];
+ 	if (yyn < 0) {
+ 	    if (yyn == YYFLAG)
+ 		goto yyerrpop;
+ 	    yyn = -yyn;
+ 	    goto yyreduce;
+ 	} else if (yyn == 0)
+ 	    goto yyerrpop;
+ 
+ 	if (yyn == YYFINAL) {
+ 	    _yytext = oldtext;
+ 	    _yylval = oldlval;
+ 	    _yylloc = oldlloc;
+ 	    YYACCEPT;
+ 	}
+ 
+ #ifdef YYDEBUG
+ 	if (yydebug)
+ 	    fprintf(errfile, "Shifting error token, ");
+ #endif
+ 
+ 	*++yyp->yyvsp = yylval;
+ #ifdef YYLSP_NEEDED
+ 	*++yyp->yylsp = yylloc;
+ #endif
+ 
+ 	yyp->yystate = yyn;
+ 	goto yynewstate;
+     yyabort:
+ 	SET_ABORTED(yyp);
+ #ifdef YYDEBUG
+ 	if (yydebug)
+ 	    fprintf(errfile, "yyabort for parse %x\n", yyp);
+ #endif
+ 	continue;
+     yyaccept: {
+ 	unsigned short *flags;
+ 	
+ 	UNSET_JUST_SHIFTED(yyp); /* Don't care that we just shifted the EOF
+ 				    token. */
+ 	for (flags = yyp->flags; flags >= yyp->flags_stack; flags--) 
+ 	    *flags |= ACCEPTED_BIT;
+ 
+ #ifdef YYDEBUG
+ 	if (yydebug) {
+ 	    short *ssp1 = yyp->yyss - 1;
+ 	    fprintf(errfile, "yyaccept for parse %x\n", yyp);
+ 	    fprintf (errfile, " state stack now");
+ 	    while (ssp1 != yyp->yyssp)
+ 		fprintf (errfile, " %d", *++ssp1);
+ 	    fprintf (errfile, "\n");
+ 
+ 	}
+ #endif
+ 	continue;
+     }
+ 	
+     } /* end for loop */
+ 
+     merge_active(&activelist, currentfile);
+ 
+     _yytext = oldtext;
+     _yylval = oldlval;
+     _yylloc = oldlloc;
+     
+     if (yyfinish) 
+ 	yyfinish(activelist->yyvsp, &currentfile->tree_root);
+     yyp = activelist;
+     retval = ABORTED(activelist) || activelist != activelist->flink;
+     do {
+ 	ap = yyp->flink;
+ 	kill_parse(yyp);
+ 	yyp = ap;
+     } while (yyp != activelist);
+     
+     return retval;
+     
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/closure.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/closure.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/closure.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,360 ----
+ /* Subroutines for bison
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* subroutines of file LR0.c.
+ 
+ Entry points:
+ 
+   closure (items, n)
+ 
+ Given a vector of item numbers items, of length n,
+ set up ruleset and itemset to indicate what rules could be run
+ and which items could be accepted when those items are the active ones.
+ 
+ ruleset contains a bit for each rule.  closure sets the bits
+ for all rules which could potentially describe the next input to be read.
+ 
+ itemset is a vector of item numbers; itemsetend points to just beyond the end
+  of the part of it that is significant.
+ closure places there the indices of all items which represent units of
+ input that could arrive next.
+ 
+   initialize_closure (n)
+ 
+ Allocates the itemset and ruleset vectors,
+ and precomputes useful data so that closure can be called.
+ n is the number of elements to allocate for itemset.
+ 
+   finalize_closure ()
+ 
+ Frees itemset, ruleset and internal data.
+ 
+ */
+ 
+ #include <stdio.h>
+ #include "machine.h"
+ #include "new.h"
+ #include "gram.h"
+ 
+ extern short **derives;
+ 
+ short *itemset;
+ short *itemsetend;
+ static unsigned *ruleset;
+ 
+ /* internal data.  See comments before set_fderives and set_firsts.  */
+ static unsigned *fderives;
+ static unsigned *firsts;
+ 
+ /* number of words required to hold a bit for each rule */
+ static int rulesetsize;
+ 
+ /* number of words required to hold a bit for each variable */
+ static int varsetsize;
+ 
+ extern void RTC(unsigned *R,int n);
+ 
+ void set_fderives(void);
+ void set_firsts(void);
+ 
+ void initialize_closure(int n)
+ {
+   itemset = NEW2(n, short);
+ 
+   rulesetsize = WORDSIZE(nrules + 1);
+   ruleset = NEW2(rulesetsize, unsigned);
+ 
+   set_fderives();
+ }
+ 
+ /* set fderives to an nvars by nrules matrix of bits
+    indicating which rules can help derive the beginning of the data
+    for each nonterminal.  For example, if symbol 5 can be derived as
+    the sequence of symbols 8 3 20, and one of the rules for deriving
+    symbol 8 is rule 4, then the [5 - ntokens, 4] bit in fderives is set.  */
+ 
+ void set_fderives(void)
+ {
+   register unsigned *rrow;
+   register unsigned *vrow;
+   register int j;
+   register unsigned mask;
+   register unsigned cword;
+   register short *rp;
+ 
+   int ruleno;
+   int i;
+ 
+   fderives = NEW2(nvars * rulesetsize, unsigned) - ntokens * rulesetsize;
+ 
+   set_firsts();
+ 
+   rrow = fderives + ntokens * rulesetsize;
+ 
+   for (i = ntokens; i < nsyms; i++)
+     {
+       vrow = firsts + ((i - ntokens) * varsetsize);
+       cword = *vrow++;
+       mask = 1;
+       for (j = ntokens; j < nsyms; j++)
+ 	{
+ 	  if (cword & mask)
+ 	    {
+ 	      rp = derives[j];
+ 	      while ((ruleno = *rp++) > 0)
+ 		{
+ 		  SETBIT(rrow, ruleno);
+ 		}
+ 	    }
+ 
+ 	  mask <<= 1;
+ 	  if (mask == 0 && j + 1 < nsyms)
+ 	    {
+ 	      cword = *vrow++;
+ 	      mask = 1;
+ 	    }
+ 	}
+ 
+       vrow += varsetsize;
+       rrow += rulesetsize;
+     }
+ 
+ #ifdef	DEBUG
+   print_fderives();
+ #endif
+ 
+   FREE(firsts);
+ }
+ 
+ /* set firsts to be an nvars by nvars bit matrix indicating which items
+    can represent the beginning of the input corresponding to which other items.
+    For example, if some rule expands symbol 5 into the sequence of symbols 8 3 20,
+    the symbol 8 can be the beginning of the data for symbol 5,
+    so the bit [8 - ntokens, 5 - ntokens] in firsts is set. */
+ 
+ void set_firsts(void)
+ {
+   register unsigned *row;
+ /*   register int done; JF unused */
+   register int symbol;
+   register short *sp;
+   register int rowsize;
+ 
+   int i;
+ 
+   varsetsize = rowsize = WORDSIZE(nvars);
+ 
+   firsts = NEW2(nvars * rowsize, unsigned);
+ 
+   row = firsts;
+   for (i = ntokens; i < nsyms; i++)
+     {
+       sp = derives[i];
+       while (*sp >= 0)
+ 	{
+ 	  symbol = ritem[rrhs[*sp++]];
+ 	  if (ISVAR(symbol))
+ 	    {
+ 	      symbol -= ntokens;
+ 	      SETBIT(row, symbol);
+ 	    }
+ 	}
+ 
+       row += rowsize;
+     }
+ 
+   RTC(firsts, nvars);
+ 
+ #ifdef	DEBUG
+   print_firsts();
+ #endif
+ }
+ 
+ void closure(short *core,int n)
+ {
+   register int ruleno;
+   register unsigned word;
+   register unsigned mask;
+   register short *csp;
+   register unsigned *dsp;
+   register unsigned *rsp;
+ 
+   short *csend;
+   unsigned *rsend;
+   int symbol;
+   int itemno;
+ 
+   rsp = ruleset;
+   rsend = ruleset + rulesetsize;
+   csend = core + n;
+ 
+   if (n == 0)
+     {
+       dsp = fderives + start_symbol * rulesetsize;
+       while (rsp < rsend)
+ 	*rsp++ = *dsp++;
+     }
+   else
+     {
+       while (rsp < rsend)
+ 	*rsp++ = 0;
+ 
+       csp = core;
+       while (csp < csend)
+ 	{
+ 	  symbol = ritem[*csp++];
+ 	  if (ISVAR(symbol))
+ 	    {
+ 	      dsp = fderives + symbol * rulesetsize;
+ 	      rsp = ruleset;
+ 	      while (rsp < rsend)
+ 		*rsp++ |= *dsp++;
+ 	    }
+ 	}
+     }
+ 
+   ruleno = 0;
+   itemsetend = itemset;
+   csp = core;
+   rsp = ruleset;
+   while (rsp < rsend)
+     {
+       word = *rsp++;
+       if (word == 0)
+ 	{
+ 	  ruleno += BITS_PER_WORD;
+ 	}
+       else
+ 	{
+ 	  mask = 1;
+ 	  while (mask)
+ 	    {
+ 	      if (word & mask)
+ 		{
+ 		  itemno = rrhs[ruleno];
+ 		  while (csp < csend && *csp < itemno)
+ 		    *itemsetend++ = *csp++;
+ 		  *itemsetend++ = itemno;
+ 		}
+ 
+ 	      mask <<= 1;
+ 	      ruleno++;
+ 	    }
+ 	}
+     }
+ 
+   while (csp < csend)
+     *itemsetend++ = *csp++;
+ 
+ #ifdef	DEBUG
+   print_closure(n);
+ #endif
+ }
+ 
+ void finalize_closure(void)
+ {
+   FREE(itemset);
+   FREE(ruleset);
+   FREE(fderives + ntokens * rulesetsize);
+ }
+ 
+ #ifdef	DEBUG
+ 
+ void print_closure(int n)
+ {
+   register short *isp;
+ 
+   printf("\n\nn = %d\n\n", n);
+   for (isp = itemset; isp < itemsetend; isp++)
+     printf("   %d\n", *isp);
+ }
+ 
+ void print_firsts(void)
+ {
+   register int i;
+   register int j;
+   register unsigned *rowp;
+   register unsigned cword;
+   register unsigned mask;
+ 
+   extern char **tags;
+ 
+   printf("\n\n\nFIRSTS\n\n");
+ 
+   for (i = ntokens; i < nsyms; i++)
+     {
+       printf("\n\n%s firsts\n\n", tags[i]);
+ 
+       rowp = firsts + ((i - ntokens) * vrowsize);
+ 
+       cword = *rowp++;
+       mask = 1;
+       for (j = 0; j < nsyms; j++)
+ 	{
+ 	  if (cword & mask)
+ 	    printf("   %s\n", tags[j + ntokens]);
+ 
+ 	  mask <<= 1;
+ 
+ 	  if (mask == 0 && j + 1 < nsyms)
+ 	    {
+ 	      cword = *rowp++;
+ 	      mask = 1;
+ 	    }
+ 	}
+     }
+ }
+ 
+ void print_fderives(void)
+ {
+   register int i;
+   register int j;
+   register unsigned *rp;
+   register unsigned cword;
+   register unsigned mask;
+ 
+   extern char **tags;
+ 
+   printf("\n\n\nFDERIVES\n");
+ 
+   for (i = ntokens; i < nsyms; i++)
+     {
+       printf("\n\n%s derives\n\n", tags[i]);
+       rp = fderives + i * rrowsize;
+       cword = *rp++;
+       mask = 1;
+       for (j = 0; j <= nrules; j++)
+         {
+ 	  if (cword & mask)
+ 	    printf("   %d\n", j);
+ 
+ 	  mask <<= 1;
+ 	  if (mask == 0 && j + 1 < nrules)
+ 	    {
+ 	      cword = *rp++;
+ 	      mask = 1;
+ 	    }
+ 	}
+     }
+ 
+   fflush(stdout);
+ }
+ 
+ #endif


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/conflicts.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/conflicts.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/conflicts.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,728 ----
+ /* Find and resolve or report look-ahead conflicts for bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include "machine.h"
+ #include "new.h"
+ #include "files.h"
+ #include "gram.h"
+ #include "state.h"
+ 
+ 
+ #ifdef USG
+ #include <memory.h>
+ #define bcopy(src, dst, num) memcpy((dst), (src), (num))
+ #endif
+ 
+ #ifdef sparc
+ #include <alloca.h>
+ #endif
+ 
+ #define alloca1(x)  malloc(x)
+ 
+ extern char **tags;
+ extern int tokensetsize;
+ extern char *consistent;
+ extern short *accessing_symbol;
+ extern shifts **shift_table;
+ extern unsigned *LA;
+ extern short *LAruleno;
+ extern short *lookaheads;
+ extern int verboseflag;
+ 
+ /*
+ extern char *alloca ();
+ */
+ 
+ char any_conflicts;
+ char *conflicts;
+ errs **err_table;
+ int expected_conflicts;
+ 
+ 
+ static unsigned *shiftset;
+ static unsigned *lookaheadset;
+ static int src_total;
+ static int rrc_total;
+ static int src_count;
+ static int rrc_count;
+ 
+ void set_conflicts(int state);
+ void resolve_sr_conflict(int state,int lookaheadnum);
+ void flush_shift(int state,int token);
+ void log_resolution(int state,int LAno,int token,char *resolution);
+ void total_conflicts(void);
+ void count_sr_conflicts(int state);
+ void count_rr_conflicts(int state);
+ 
+ void initialize_conflicts(void)
+ {
+   register int i;
+ /*  register errs *sp; JF unused */
+ 
+   conflicts = NEW2(nstates, char);
+   shiftset = NEW2(tokensetsize, unsigned);
+   lookaheadset = NEW2(tokensetsize, unsigned);
+ 
+   err_table = NEW2(nstates, errs *);
+ 
+   any_conflicts = 0;
+ 
+   for (i = 0; i < nstates; i++)
+     set_conflicts(i);
+ }
+ 
+ 
+ 
+ void set_conflicts(int state)
+ {
+   register int i;
+   register int k;
+   register shifts *shiftp;
+   register unsigned *fp2;
+   register unsigned *fp3;
+   register unsigned *fp4;
+   register unsigned *fp1;
+   register int symbol;
+ 
+   if (consistent[state]) return;
+ 
+   for (i = 0; i < tokensetsize; i++)
+     lookaheadset[i] = 0;
+ 
+   shiftp = shift_table[state];
+   if (shiftp)
+     {
+       k = shiftp->nshifts;
+       for (i = 0; i < k; i++)
+ 	{
+ 	  symbol = accessing_symbol[shiftp->shifts[i]];
+ 	  if (ISVAR(symbol)) break;
+ 	  SETBIT(lookaheadset, symbol);
+ 	}
+     }
+ 
+   k = lookaheads[state + 1];
+   fp4 = lookaheadset + tokensetsize;
+ 
+   /* loop over all rules which require lookahead in this state */
+   /* first check for shift-reduce conflict, and try to resolve using precedence  */
+ 
+   for (i = lookaheads[state]; i < k; i++)
+     if (rprec[LAruleno[i]])
+       {
+ 	fp1 = LA + i * tokensetsize;
+ 	fp2 = fp1;
+ 	fp3 = lookaheadset;
+   
+ 	while (fp3 < fp4)
+ 	  {
+ 	    if (*fp2++ & *fp3++)
+ 	      {
+ 		resolve_sr_conflict(state, i);
+ 		break;
+ 	      }
+ 	  }
+       }
+ 
+   /* loop over all rules which require lookahead in this state */
+   /* Check for conflicts not resolved above.  */
+ 
+   for (i = lookaheads[state]; i < k; i++)
+     {
+       fp1 = LA + i * tokensetsize;
+       fp2 = fp1;
+       fp3 = lookaheadset;
+ 
+       while (fp3 < fp4)
+ 	{
+ 	  if (*fp2++ & *fp3++)
+ 	    {
+ 	      conflicts[state] = 1;
+ 	      any_conflicts = 1;
+ 	    }
+ 	}
+ 
+       fp2 = fp1;
+       fp3 = lookaheadset;
+ 
+       while (fp3 < fp4)
+ 	*fp3++ |= *fp2++;
+     }
+ }
+ 
+ /* Attempt to resolve shift-reduce conflict for one rule
+ by means of precedence declarations.
+ It has already been checked that the rule has a precedence.
+ A conflict is resolved by modifying the shift or reduce tables
+ so that there is no longer a conflict.  */
+ 
+ void resolve_sr_conflict(int state,int lookaheadnum)
+ {
+   register int i;
+   register int mask;
+   register unsigned *fp1;
+   register unsigned *fp2;
+   register int redprec;
+   errs *errp = (errs *) alloca1 (sizeof(errs) + ntokens * sizeof(short));
+   short *errtokens = errp->errs;
+ 
+   /* find the rule to reduce by to get precedence of reduction  */
+   redprec = rprec[LAruleno[lookaheadnum]];
+ 
+   mask = 1;
+   fp1 = LA + lookaheadnum * tokensetsize;
+   fp2 = lookaheadset;
+   for (i = 0; i < ntokens; i++)
+     {
+       if ((mask & *fp2 & *fp1) && sprec[i])
+ 	/* shift-reduce conflict occurs for token number i and it has a precision.
+ 	   The precedence of shifting is that of token i.  */
+ 	{
+ 	  if (sprec[i] < redprec)
+ 	    {
+ 	      if (verboseflag) log_resolution(state, lookaheadnum, i, "reduce");
+ 	      *fp2 &= ~mask;  /* flush the shift for this token */
+ 	      flush_shift(state, i);
+ 	    }
+ 	  else if (sprec[i] > redprec)
+ 	    {
+ 	      if (verboseflag) log_resolution(state, lookaheadnum, i, "shift");
+ 	      *fp1 &= ~mask;  /* flush the reduce for this token */
+ 	    }
+ 	  else
+ 	    {
+ 	      /* Matching precedence levels.
+ 		 For left association, keep only the reduction.
+ 		 For right association, keep only the shift.
+ 		 For nonassociation, keep neither.  */
+ 
+ 	      switch (sassoc[i])
+ 		{
+ 
+ 		case RIGHT_ASSOC:
+ 	          if (verboseflag) log_resolution(state, lookaheadnum, i, "shift");
+ 		  break;
+ 
+ 		case LEFT_ASSOC:
+ 	          if (verboseflag) log_resolution(state, lookaheadnum, i, "reduce");
+ 		  break;
+ 
+ 		case NON_ASSOC:
+ 	          if (verboseflag) log_resolution(state, lookaheadnum, i, "an error");
+ 		  break;
+ 		}
+ 
+ 	      if (sassoc[i] != RIGHT_ASSOC)
+ 		{
+ 		  *fp2 &= ~mask;  /* flush the shift for this token */
+ 		  flush_shift(state, i);
+ 		}
+ 	      if (sassoc[i] != LEFT_ASSOC)
+ 	        {
+ 		  *fp1 &= ~mask;  /* flush the reduce for this token */
+ 		}
+ 	      if (sassoc[i] == NON_ASSOC)
+ 		{
+ 		  /* Record an explicit error for this token.  */
+ 		  *errtokens++ = i;
+ 		}
+ 	    }
+ 	}
+ 
+       mask <<= 1;
+       if (mask == 0)
+ 	{
+ 	  mask = 1;
+ 	  fp2++;  fp1++;
+ 	}
+     }
+   errp->nerrs = errtokens - errp->errs;
+   if (errp->nerrs)
+     {
+       /* Some tokens have been explicitly made errors.  Allocate
+ 	 a permanent errs structure for this state, to record them.  */
+       i = (char *) errtokens - (char *) errp;
+       err_table[state] = (errs *) mallocate ((unsigned int)i);
+       bcopy (errp, err_table[state], i);
+     }
+   else
+     err_table[state] = 0;
+ }
+ 
+ 
+ 
+ /* turn off the shift recorded for the specified token in the specified state.
+ Used when we resolve a shift-reduce conflict in favor of the reduction.  */
+ 
+ void flush_shift(int state,int token)
+ {
+   register shifts *shiftp;
+   register int k, i;
+ /*  register unsigned symbol; JF unused */
+ 
+   shiftp = shift_table[state];
+ 
+   if (shiftp)
+     {
+       k = shiftp->nshifts;
+       for (i = 0; i < k; i++)
+ 	{
+ 	  if (shiftp->shifts[i] && token == accessing_symbol[shiftp->shifts[i]])
+ 	    (shiftp->shifts[i]) = 0;
+ 	}
+     }
+ }
+ 
+ 
+ 
+ void log_resolution(int state,int LAno,int token,char *resolution)
+ {
+   fprintf(foutput,
+ 	  "Conflict in state %d between rule %d and token %s resolved as %s.\n",
+ 	  state, LAruleno[LAno], tags[token], resolution);
+ }
+ 
+ 
+ 
+ void conflict_log(void)
+ {
+   register int i;
+ 
+   src_total = 0;
+   rrc_total = 0;
+ 
+   for (i = 0; i < nstates; i++)
+     {
+       if (conflicts[i])
+ 	{
+ 	  count_sr_conflicts(i);
+ 	  count_rr_conflicts(i);
+ 	  src_total += src_count;
+ 	  rrc_total += rrc_count;
+ 	}
+     }
+ 
+   total_conflicts();
+ }
+   
+ 
+ 
+ void verbose_conflict_log(void)
+ {
+   register int i;
+ 
+   src_total = 0;
+   rrc_total = 0;
+ 
+   for (i = 0; i < nstates; i++)
+     {
+       if (conflicts[i])
+ 	{
+ 	  count_sr_conflicts(i);
+ 	  count_rr_conflicts(i);
+ 	  src_total += src_count;
+ 	  rrc_total += rrc_count;
+ 
+ 	  fprintf(foutput, "State %d contains", i);
+ 
+ 	  if (src_count == 1)
+ 	    fprintf(foutput, " 1 shift/reduce conflict");
+ 	  else if (src_count > 1)
+ 	    fprintf(foutput, " %d shift/reduce conflicts", src_count);
+ 
+ 	  if (src_count > 0 && rrc_count > 0)
+ 	    fprintf(foutput, " and");
+ 
+ 	  if (rrc_count == 1)
+ 	    fprintf(foutput, " 1 reduce/reduce conflict");
+ 	  else if (rrc_count > 1)
+ 	    fprintf(foutput, " %d reduce/reduce conflicts", rrc_count);
+ 
+ 	  putc('.', foutput);
+ 	  putc('\n', foutput);
+ 	}
+     }
+ 
+   total_conflicts();
+ }
+ 
+ 
+ 
+ void total_conflicts(void)
+ {
+   if (src_total == expected_conflicts && rrc_total == 0)
+     return;
+ 
+   fprintf(stderr, "%s contains", infile);
+ 
+   if (src_total == 1)
+     fprintf(stderr, " 1 shift/reduce conflict");
+   else if (src_total > 1)
+     fprintf(stderr, " %d shift/reduce conflicts", src_total);
+ 
+   if (src_total > 0 && rrc_total > 0)
+     fprintf(stderr, " and");
+ 
+   if (rrc_total == 1)
+     fprintf(stderr, " 1 reduce/reduce conflict");
+   else if (rrc_total > 1)
+     fprintf(stderr, " %d reduce/reduce conflicts", rrc_total);
+ 
+   putc('.', stderr);
+   putc('\n', stderr);
+ }
+ 
+ 
+ 
+ void count_sr_conflicts(int state)
+ {
+   register int i;
+   register int k;
+   register int mask;
+   register shifts *shiftp;
+   register unsigned *fp1;
+   register unsigned *fp2;
+   register unsigned *fp3;
+   register int symbol;
+ 
+   src_count = 0;
+ 
+   shiftp = shift_table[state];
+   if (!shiftp) return;
+ 
+   for (i = 0; i < tokensetsize; i++)
+     {
+       shiftset[i] = 0;
+       lookaheadset[i] = 0;
+     }
+ 
+   k = shiftp->nshifts;
+   for (i = 0; i < k; i++)
+     {
+       if (! shiftp->shifts[i]) continue;
+       symbol = accessing_symbol[shiftp->shifts[i]];
+       if (ISVAR(symbol)) break;
+       SETBIT(shiftset, symbol);
+     }
+ 
+   k = lookaheads[state + 1];
+   fp3 = lookaheadset + tokensetsize;
+ 
+   for (i = lookaheads[state]; i < k; i++)
+     {
+       fp1 = LA + i * tokensetsize;
+       fp2 = lookaheadset;
+ 
+       while (fp2 < fp3)
+ 	*fp2++ |= *fp1++;
+     }
+ 
+   fp1 = shiftset;
+   fp2 = lookaheadset;
+ 
+   while (fp2 < fp3)
+     *fp2++ &= *fp1++;
+ 
+   mask = 1;
+   fp2 = lookaheadset;
+   for (i = 0; i < ntokens; i++)
+     {
+       if (mask & *fp2)
+ 	src_count++;
+ 
+       mask <<= 1;
+       if (mask == 0)
+ 	{
+ 	  mask = 1;
+ 	  fp2++;
+ 	}
+     }
+ }
+ 
+ void count_rr_conflicts(int state)
+ {
+   register int i;
+   register int j;
+   register int count;
+   register unsigned mask;
+   register unsigned *baseword;
+   register unsigned *wordp;
+   register int m;
+   register int n;
+ 
+   rrc_count = 0;
+ 
+   m = lookaheads[state];
+   n = lookaheads[state + 1];
+ 
+   if (n - m < 2) return;
+ 
+   mask = 1;
+   baseword = LA + m * tokensetsize;
+   for (i = 0; i < ntokens; i++)
+     {
+       wordp = baseword;
+ 
+       count = 0;
+       for (j = m; j < n; j++)
+ 	{
+ 	  if (mask & *wordp)
+ 	    count++;
+ 
+ 	  wordp += tokensetsize;
+ 	}
+ 
+       if (count >= 2) rrc_count++;
+ 
+       mask <<= 1;
+       if (mask == 0)
+ 	{
+ 	  mask = 1;
+ 	  baseword++;
+ 	}
+     }
+ }
+ 
+ 
+ 
+ void print_reductions(int state)
+ {
+   register int i;
+   register int j;
+   register int k;
+   register unsigned *fp1;
+   register unsigned *fp2;
+   register unsigned *fp3;
+   register unsigned *fp4;
+   register int rule;
+   register int symbol;
+   register unsigned mask;
+   register int m;
+   register int n;
+   register int default_LA;
+   register int default_rule;
+   register int cmax;
+   register int count;
+   register shifts *shiftp;
+   register errs *errp;
+   int nodefault = 0;
+ 
+   for (i = 0; i < tokensetsize; i++)
+     shiftset[i] = 0;
+ 
+   shiftp = shift_table[state];
+   if (shiftp)
+     {
+       k = shiftp->nshifts;
+       for (i = 0; i < k; i++)
+ 	{
+ 	  if (! shiftp->shifts[i]) continue;
+ 	  symbol = accessing_symbol[shiftp->shifts[i]];
+ 	  if (ISVAR(symbol)) break;
+ 	  /* if this state has a shift for the error token,
+ 	     don't use a default rule.  */
+ 	  if (symbol == error_token_number) nodefault = 1;
+ 	  SETBIT(shiftset, symbol);
+ 	}
+     }
+ 
+   errp = err_table[state];
+   if (errp)
+     {
+       k = errp->nerrs;
+       for (i = 0; i < k; i++)
+ 	{
+ 	  if (! errp->errs[i]) continue;
+ 	  symbol = errp->errs[i];
+ 	  SETBIT(shiftset, symbol);
+ 	}
+     }
+ 
+   m = lookaheads[state];
+   n = lookaheads[state + 1];
+ 
+   if (n - m == 1 && ! nodefault)
+     {
+       default_rule = LAruleno[m];
+ 
+       fp1 = LA + m * tokensetsize;
+       fp2 = shiftset;
+       fp3 = lookaheadset;
+       fp4 = lookaheadset + tokensetsize;
+ 
+       while (fp3 < fp4)
+ 	*fp3++ = *fp1++ & *fp2++;
+ 
+       mask = 1;
+       fp3 = lookaheadset;
+ 
+       for (i = 0; i < ntokens; i++)
+ 	{
+ 	  if (mask & *fp3)
+ 	    fprintf(foutput, "    %-4s\t[reduce  %d  (%s)]\n",
+ 		    tags[i], default_rule, tags[rlhs[default_rule]]);
+ 
+ 	  mask <<= 1;
+ 	  if (mask == 0)
+ 	    {
+ 	      mask = 1;
+ 	      fp3++;
+ 	    }
+ 	}
+ 
+       fprintf(foutput, "    $default\treduce  %d  (%s)\n\n",
+ 	      default_rule, tags[rlhs[default_rule]]);
+     }
+   else if (n - m >= 1)
+     {
+       cmax = 0;
+       default_LA = -1;
+       fp4 = lookaheadset + tokensetsize;
+ 
+       if (! nodefault)
+ 	for (i = m; i < n; i++)
+ 	  {
+ 	    fp1 = LA + i * tokensetsize;
+ 	    fp2 = shiftset;
+ 	    fp3 = lookaheadset;
+   
+ 	    while (fp3 < fp4)
+ 	      *fp3++ = *fp1++ & ( ~ (*fp2++));
+   
+ 	    count = 0;
+ 	    mask = 1;
+ 	    fp3 = lookaheadset;
+ 	    for (j = 0; j < ntokens; j++)
+ 	      {
+ 		if (mask & *fp3)
+ 		  count++;
+   
+ 		mask <<= 1;
+ 		if (mask == 0)
+ 		  {
+ 		    mask = 1;
+ 		    fp3++;
+ 		  }
+ 	      }
+   
+ 	    if (count > cmax)
+ 	      {
+ 		cmax = count;
+ 		default_LA = i;
+ 		default_rule = LAruleno[i];
+ 	      }
+   
+ 	    fp2 = shiftset;
+ 	    fp3 = lookaheadset;
+   
+ 	    while (fp3 < fp4)
+ 	      *fp2++ |= *fp3++;
+ 	  }
+ 
+       for (i = 0; i < tokensetsize; i++)
+         shiftset[i] = 0;
+ 
+       if (shiftp)
+         {
+           k = shiftp->nshifts;
+           for (i = 0; i < k; i++)
+ 	    {
+ 	      if (! shiftp->shifts[i]) continue;
+ 	      symbol = accessing_symbol[shiftp->shifts[i]];
+ 	      if (ISVAR(symbol)) break;
+ 	      SETBIT(shiftset, symbol);
+ 	    }
+         }
+ 
+       mask = 1;
+       fp1 = LA + m * tokensetsize;
+       fp2 = shiftset;
+       for (i = 0; i < ntokens; i++)
+ 	{
+ 	  int defaulted = 0;
+ 
+ 	  if (mask & *fp2)
+ 	    count = 1;
+ 	  else
+ 	    count = 0;
+ 
+ 	  fp3 = fp1;
+ 	  for (j = m; j < n; j++)
+ 	    {
+ 	      if (mask & *fp3)
+ 		{
+ 		  if (count == 0)
+ 		    {
+ 		      if (j != default_LA)
+ 			{
+ 			  rule = LAruleno[j];
+ 			  fprintf(foutput, "    %-4s\treduce  %d  (%s)\n",
+ 				  tags[i], rule, tags[rlhs[rule]]);
+ 			}
+ 		      else defaulted = 1;
+ 
+ 		      count++;
+ 		    }
+ 		  else
+ 		    {
+ 		      if (defaulted)
+ 			{
+ 			  rule = LAruleno[default_LA];
+ 			  fprintf(foutput, "    %-4s\treduce  %d  (%s)\n",
+ 				  tags[i], rule, tags[rlhs[rule]]);
+ 			  defaulted = 0;
+ 			}
+ 		      rule = LAruleno[j];
+ 		      fprintf(foutput, "    %-4s\t[reduce  %d  (%s)]\n",
+ 			      tags[i], rule, tags[rlhs[rule]]);
+ 		    }
+ 		}
+ 
+ 	      fp3 += tokensetsize;
+ 	    }
+ 
+ 	  mask <<= 1;
+ 	  if (mask == 0)
+ 	    {
+ 	      mask = 1;
+ 	      fp1++;
+ 	    }
+ 	}
+ 
+       if (default_LA >= 0)
+ 	{
+ 	  fprintf(foutput, "    $default\treduce  %d  (%s)\n",
+ 		  default_rule, tags[rlhs[default_rule]]);
+ 	}
+ 
+       putc('\n', foutput);
+     }
+ }
+ 
+ 
+ 
+ void finalize_conflicts(void)
+ {
+   FREE(conflicts);
+   FREE(shiftset);
+   FREE(lookaheadset);
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/derives.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/derives.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/derives.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,111 ----
+ /* Match rules with nonterminals for bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* set_derives finds, for each variable (nonterminal), which rules can derive it.
+    It sets up the value of derives so that
+    derives[i - ntokens] points to a vector of rule numbers, terminated with a zero.  */
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include "new.h"
+ #include "types.h"
+ #include "gram.h"
+ 
+ short **derives;
+ 
+ void set_derives(void)
+ {
+   register int i;
+   register int lhs;
+   register shorts *p;
+   register short *q;
+   register shorts **dset;
+   register shorts *delts;
+ 
+   dset = NEW2(nvars, shorts *) - ntokens;
+   delts = NEW2(nrules + 1, shorts);
+ 
+   p = delts;
+   for (i = nrules; i > 0; i--)
+     {
+       lhs = rlhs[i];
+       p->next = dset[lhs];
+       p->value = i;
+       dset[lhs] = p;
+       p++;
+     }
+ 
+   derives = NEW2(nvars, short *) - ntokens;
+   q = NEW2(nvars + nrules, short);
+ 
+   for (i = ntokens; i < nsyms; i++)
+     {
+       derives[i] = q;
+       p = dset[i];
+       while (p)
+ 	{
+ 	  *q++ = p->value;
+ 	  p = p->next;
+ 	}
+       *q++ = -1;
+     }
+ 
+ #ifdef	DEBUG
+   print_derives();
+ #endif
+ 
+   FREE(dset + ntokens);
+   FREE(delts);
+ }
+ 
+ 
+ void free_derives(void)
+ {
+   FREE(derives[ntokens]);
+   FREE(derives + ntokens);
+ }
+ 
+ 
+ 
+ #ifdef	DEBUG
+ 
+ void print_derives(void)
+ {
+   register int i;
+   register short *sp;
+ 
+   extern char **tags;
+ 
+   printf("\n\n\nDERIVES\n\n");
+ 
+   for (i = ntokens; i < nsyms; i++)
+     {
+       printf("%s derives", tags[i]);
+       for (sp = derives[i]; *sp > 0; sp++)
+ 	{
+ 	  printf("  %d", *sp);
+ 	}
+       putchar('\n');
+     }
+ 
+   putchar('\n');
+ }
+ 
+ #endif


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/files.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/files.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/files.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,287 ----
+ /* Open and close files for bison,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #ifdef VMS
+ #include <ssdef.h>
+ #define unlink delete
+ #define XPFILE "GNU_BISON:[000000]BISON.SIMPLE"
+ #define XPFILE1 "GNU_BISON:[000000]BISON.HAIRY"
+ #endif
+ /*
+ #define XPFILE "GNU_BISON:[000000]BISON.SIMPLE"
+ #define XPFILE1 "GNU_BISON:[000000]BISON.HAIRY"
+ */
+ 
+ #include <stdio.h>
+ #include <unistd.h>
+ #include "files.h"
+ #include "new.h"
+ #include "gram.h"
+ 
+ FILE *finput = NULL;
+ FILE *foutput = NULL;
+ FILE *fdefines = NULL;
+ FILE *ftable = NULL;
+ FILE *fattrs = NULL;
+ FILE *fguard = NULL;
+ FILE *faction = NULL;
+ FILE *fparser = NULL;
+ 
+ /* File name specified with -o for the output file, or 0 if no -o.  */
+ char *spec_outfile;
+ 
+ char *infile;
+ char *outfile;
+ char *defsfile;
+ char *tabfile;
+ char *attrsfile;
+ char *guardfile;
+ char *actfile;
+ char *tmpattrsfile;
+ char *tmptabfile;
+ 
+ char	*mktemp();	/* So the compiler won't complain */
+ FILE	*tryopen();	/* This might be a good idea */
+ 
+ extern int verboseflag;
+ extern int definesflag;
+ int fixed_outfiles = 0;
+ 
+ void done(int k);
+ 
+ char *stringappend(char *string1,int end1,char *string2)
+ {
+   register char *ostring;
+   register char *cp, *cp1;
+   register int i;
+ 
+   cp = string2;  i = 0;
+   while (*cp++) i++;
+ 
+   ostring = NEW2(i+end1+1, char);
+ 
+   cp = ostring;
+   cp1 = string1;
+   for (i = 0; i < end1; i++)
+     *cp++ = *cp1++;
+ 
+   cp1 = string2;
+   while (*cp++ = *cp1++) ;
+ 
+   return ostring;
+ }
+ 
+ 
+ /* JF this has been hacked to death.  Nowaday it sets up the file names for
+    the output files, and opens the tmp files and the parser */
+ void openfiles(void)
+ {
+   char *name_base;
+   register char *cp;
+   char *filename;
+   int base_length;
+   int short_base_length;
+ 
+ #ifdef VMS
+   char *tmp_base = "sys$scratch:b_";
+ #else
+   char *tmp_base = "/tmp/b.";
+ #endif
+   int tmp_len = strlen (tmp_base);
+ 
+   if (spec_outfile)
+     {
+       /* -o was specified.  The precise -o name will be used for ftable.
+ 	 For other output files, remove the ".c" or ".tab.c" suffix.  */
+       name_base = spec_outfile;
+       /* BASE_LENGTH includes ".tab" but not ".c".  */
+       base_length = strlen (name_base);
+       if (!strcmp (name_base + base_length - 2, ".c"))
+ 	base_length -= 2;
+       /* SHORT_BASE_LENGTH includes neither ".tab" nor ".c".  */
+       short_base_length = base_length;
+       if (!strcmp (name_base + short_base_length - 4, ".tab"))
+ 	short_base_length -= 4;
+       else if (!strcmp (name_base + short_base_length - 4, "_tab"))
+ 	short_base_length -= 4;
+     }
+   else
+     {
+       /* -o was not specified; compute output file name from input
+ 	 or use y.tab.c, etc., if -y was specified.  */
+ 
+       name_base = fixed_outfiles ? "y.y" : infile;
+ 
+       /* Discard any directory names from the input file name
+ 	 to make the base of the output.  */
+       cp = name_base;
+       while (*cp)
+ 	{
+ 	  if (*cp == '/')
+ 	    name_base = cp+1;
+ 	  cp++;
+ 	}
+ 
+       /* BASE_LENGTH gets length of NAME_BASE, sans ".y" suffix if any.  */
+ 
+       base_length = strlen (name_base);
+       if (!strcmp (name_base + base_length - 2, ".y"))
+ 	base_length -= 2;
+       short_base_length = base_length;
+ 
+ #ifdef VMS
+       name_base = stringappend(name_base, short_base_length, "_tab");
+ #else
+       name_base = stringappend(name_base, short_base_length, ".tab");
+ #endif
+       base_length = short_base_length + 4;
+     }
+ 
+   finput = tryopen(infile, "r");
+ 
+   filename = (char *) getenv ("BISON_SIMPLE");
+   fparser = tryopen(filename ? filename : PFILE, "r");
+ 
+   if (verboseflag)
+     {
+       outfile = stringappend(name_base, short_base_length, ".output");
+       foutput = tryopen(outfile, "w");
+     }
+ 
+   if (definesflag)
+     {
+       defsfile = stringappend(name_base, base_length, ".h");
+       fdefines = tryopen(defsfile, "w");
+     }
+ 
+   actfile = mktemp(stringappend(tmp_base, tmp_len, "act.XXXXXX"));
+   faction = tryopen(actfile, "w+");
+   unlink(actfile);
+ 
+   tmpattrsfile = mktemp(stringappend(tmp_base, tmp_len, "attrs.XXXXXX"));
+   fattrs = tryopen(tmpattrsfile,"w+");
+   unlink(tmpattrsfile);
+ 
+   tmptabfile = mktemp(stringappend(tmp_base, tmp_len, "tab.XXXXXX"));
+   ftable = tryopen(tmptabfile, "w+");
+   unlink(tmptabfile);
+ 
+ 	/* These are opened by `done' or `open_extra_files', if at all */
+   if (spec_outfile)
+     tabfile = spec_outfile;
+   else
+     tabfile = stringappend(name_base, base_length, ".c");
+ 
+ #ifdef VMS
+   attrsfile = stringappend(name_base, short_base_length, "_stype.h");
+   guardfile = stringappend(name_base, short_base_length, "_guard.c");
+ #else
+   attrsfile = stringappend(name_base, short_base_length, ".stype.h");
+   guardfile = stringappend(name_base, short_base_length, ".guard.c");
+ #endif
+ }
+ 
+ 
+ 
+ /* open the output files needed only for the semantic parser.
+ This is done when %semantic_parser is seen in the declarations section.  */
+ 
+ void open_extra_files(void)
+ {
+   FILE *ftmp;
+   int c;
+   char *filename;
+ 		/* JF change open parser file */
+   fclose(fparser);
+   filename = (char *) getenv ("BISON_HAIRY");
+   fparser= tryopen(filename ? filename : PFILE1, "r");
+ 
+ 		/* JF change from inline attrs file to separate one */
+   ftmp = tryopen(attrsfile, "w");
+   rewind(fattrs);
+   while((c=getc(fattrs))!=EOF)	/* Thank god for buffering */
+     putc(c,ftmp);
+   fclose(fattrs);
+   fattrs=ftmp;
+ 
+   fguard = tryopen(guardfile, "w");
+ 
+ }
+ 
+ 	/* JF to make file opening easier.  This func tries to open file
+ 	   NAME with mode MODE, and prints an error message if it fails. */
+ FILE *tryopen(char *name,char *mode)
+ {
+   FILE	*ptr;
+ 
+   ptr = fopen(name, mode);
+   if (ptr == NULL)
+     {
+       fprintf(stderr, "bison: ");
+       perror(name);
+       done(2);
+     }
+   return ptr;
+ }
+ 
+ void done(int k)
+ {
+   if (faction)
+     fclose(faction);
+ 
+   if (fattrs)
+     fclose(fattrs);
+ 
+   if (fguard)
+     fclose(fguard);
+ 
+   if (finput)
+     fclose(finput);
+ 
+   if (fparser)
+     fclose(fparser);
+ 
+   if (foutput)
+     fclose(foutput);
+ 
+ 	/* JF write out the output file */
+   if (k == 0 && ftable)
+     {
+       FILE *ftmp;
+       register int c;
+ 
+       ftmp=tryopen(tabfile, "w");
+       rewind(ftable);
+       while((c=getc(ftable)) != EOF)
+         putc(c,ftmp);
+       fclose(ftmp);
+       fclose(ftable);
+     }
+ 
+ #ifdef VMS
+   delete(actfile);
+   delete(tmpattrsfile);
+   delete(tmptabfile);
+   if (k==0) sys$exit(SS$_NORMAL);
+   sys$exit(SS$_ABORT);
+ #else
+   exit(k);
+ #endif
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/files.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/files.h:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/files.h	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,47 ----
+ /* File names and variables for bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* These two should be pathnames for opening the sample parser files.
+    When bison is installed, they should be absolute pathnames.
+    XPFILE1 and XPFILE2 normally come from the Makefile.  */
+ 
+ #define PFILE	"parse.y.in"		/* Simple parser */
+ #define PFILE1	"parse.y.in"		/* Semantic parser */
+ 
+ extern FILE *finput;   /* read grammar specifications */
+ extern FILE *foutput;  /* optionally output messages describing the actions taken */
+ extern FILE *fdefines; /* optionally output #define's for token numbers. */
+ extern FILE *ftable;   /* output the tables and the parser */
+ extern FILE *fattrs;   /* if semantic parser, output a .h file that defines YYSTYPE */
+ 		       /* and also contains all the %{ ... %} definitions.  */
+ extern FILE *fguard;   /* if semantic parser, output yyguard, containing all the guard code */
+ extern FILE *faction;  /* output all the action code; precise form depends on which parser */
+ extern FILE *fparser;  /* read the parser to copy into ftable */
+ 
+ /* File name specified with -o for the output file, or 0 if no -o.  */
+ extern char *spec_outfile;
+ 
+ extern char *infile;
+ extern char *outfile;
+ extern char *defsfile;
+ extern char *tabfile;
+ extern char *attrsfile;
+ extern char *guardfile;
+ extern char *actfile;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/getargs.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/getargs.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/getargs.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,94 ----
+ /* Parse command line arguments for bison,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #include <stdio.h>
+ #include "files.h"
+ 
+ int verboseflag;
+ int definesflag;
+ int debugflag;
+ int nolinesflag;
+ extern int fixed_outfiles;/* JF */
+ 
+ extern void fatal(char *s);
+ extern int getopt(int argc,char **argv,char *optstring);
+ 
+ void getargs(int argc,char *argv[])
+ {
+   register int c;
+   char *p = argv[0];
+   char *lastcomponent;
+ 
+   extern int optind;
+   extern char *optarg;
+ 
+   verboseflag = 0;
+   definesflag = 0;
+   debugflag = 0;
+   fixed_outfiles = 0;
+ 
+   /* See if the program was invoked as "yacc".  */
+ 
+   lastcomponent = p;
+   while (*p)
+     {
+       if (*p == '/')
+ 	lastcomponent = p + 1;
+       p++;
+     }
+   if (! strcmp (lastcomponent, "yacc"))
+     /* If so, pretend we have "-y" as argument.  */
+     fixed_outfiles = 1;
+ 
+   while ((c = getopt (argc, argv, "yvdlto:")) != EOF)
+     switch (c)
+       {
+       case 'y':
+ 	fixed_outfiles = 1;
+ 	break;
+ 
+       case 'v':
+ 	verboseflag = 1;
+ 	break;
+ 
+       case 'd':
+ 	definesflag = 1;
+ 	break;
+ 
+       case 'l':
+ 	nolinesflag = 1;
+ 	break;
+ 
+       case 't':
+ 	debugflag = 1;
+ 	break;
+ 
+       case 'o':
+ 	spec_outfile = optarg;
+       }
+ 
+   if (optind == argc)
+     fatal("grammar file not specified");
+   else
+     infile = argv[optind];
+ 
+   if (optind < argc - 1)
+     fprintf(stderr, "bison: warning: extra arguments ignored\n");
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/getopt.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/getopt.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/getopt.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,491 ----
+ /* Getopt for GNU.
+    Copyright (C) 1987 Free Software Foundation, Inc.
+ 
+ 		       NO WARRANTY
+ 
+   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
+ NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
+ WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
+ RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
+ AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
+ DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
+ CORRECTION.
+ 
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
+ STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
+ WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
+ LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
+ OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+ USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
+ DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
+ A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
+ PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
+ 
+ 		GENERAL PUBLIC LICENSE TO COPY
+ 
+   1. You may copy and distribute verbatim copies of this source file
+ as you receive it, in any medium, provided that you conspicuously and
+ appropriately publish on each copy a valid copyright notice "Copyright
+  (C) 1987 Free Software Foundation, Inc."; and include following the
+ copyright notice a verbatim copy of the above disclaimer of warranty
+ and of this License.  You may charge a distribution fee for the
+ physical act of transferring a copy.
+ 
+   2. You may modify your copy or copies of this source file or
+ any portion of it, and copy and distribute such modifications under
+ the terms of Paragraph 1 above, provided that you also do the following:
+ 
+     a) cause the modified files to carry prominent notices stating
+     that you changed the files and the date of any change; and
+ 
+     b) cause the whole of any work that you distribute or publish,
+     that in whole or in part contains or is a derivative of this
+     program or any part thereof, to be licensed at no charge to all
+     third parties on terms identical to those contained in this
+     License Agreement (except that you may choose to grant more
+     extensive warranty protection to third parties, at your option).
+ 
+     c) You may charge a distribution fee for the physical act of
+     transferring a copy, and you may at your option offer warranty
+     protection in exchange for a fee.
+ 
+   3. You may copy and distribute this program or any portion of it in
+ compiled, executable or object code form under the terms of Paragraphs
+ 1 and 2 above provided that you do the following:
+ 
+     a) cause each such copy to be accompanied by the
+     corresponding machine-readable source code, which must
+     be distributed under the terms of Paragraphs 1 and 2 above; or,
+ 
+     b) cause each such copy to be accompanied by a
+     written offer, with no time limit, to give any third party
+     free (except for a nominal shipping charge) a machine readable
+     copy of the corresponding source code, to be distributed
+     under the terms of Paragraphs 1 and 2 above; or,
+ 
+     c) in the case of a recipient of this program in compiled, executable
+     or object code form (without the corresponding source code) you
+     shall cause copies you distribute to be accompanied by a copy
+     of the written offer of source code which you received along
+     with the copy you received.
+ 
+   4. You may not copy, sublicense, distribute or transfer this program
+ except as expressly provided under this License Agreement.  Any attempt
+ otherwise to copy, sublicense, distribute or transfer this program is void and
+ your rights to use the program under this License agreement shall be
+ automatically terminated.  However, parties who have received computer
+ software programs from you with this License Agreement will not have
+ their licenses terminated so long as such parties remain in full compliance.
+ 
+   5. If you wish to incorporate parts of this program into other free
+ programs whose distribution conditions are different, write to the Free
+ Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
+ worked out a simple rule that can be stated here, but we will often permit
+ this.  We will be guided by the two goals of preserving the free status of
+ all derivatives of our free software and of promoting the sharing and reuse of
+ software.
+ 
+ 
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* This version of `getopt' appears to the caller like standard Unix `getopt'
+    but it behaves differently for the user, since it allows the user
+    to intersperse the options with the other arguments.
+ 
+    As `getopt' works, it permutes the elements of `argv' so that,
+    when it is done, all the options precede everything else.  Thus
+    all application programs are extended to handle flexible argument order.
+ 
+    Setting the environment variable _POSIX_OPTION_ORDER disables permutation.
+    Then the behavior is completely standard.
+ 
+    GNU application programs can use a third alternative mode in which
+    they can distinguish the relative order of options and other arguments.  */
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ #ifdef sparc
+ #include <alloca.h>
+ #endif
+ 
+ #define alloca1(x)  malloc(x)
+ #ifndef bcopy
+ #define bcopy(src, dst, num) memcpy((dst), (src), (num))
+ #endif
+ 
+ /* For communication from `getopt' to the caller.
+    When `getopt' finds an option that takes an argument,
+    the argument value is returned here.
+    Also, when `ordering' is RETURN_IN_ORDER,
+    each non-option ARGV-element is returned here.  */
+ 
+ char *optarg = 0;
+ 
+ /* Index in ARGV of the next element to be scanned.
+    This is used for communication to and from the caller
+    and for communication between successive calls to `getopt'.
+ 
+    On entry to `getopt', zero means this is the first call; initialize.
+ 
+    When `getopt' returns EOF, this is the index of the first of the
+    non-option elements that the caller should itself scan.
+ 
+    Otherwise, `optind' communicates from one call to the next
+    how much of ARGV has been scanned so far.  */
+ 
+ int optind = 0;
+ 
+ /* The next char to be scanned in the option-element
+    in which the last option character we returned was found.
+    This allows us to pick up the scan where we left off.
+ 
+    If this is zero, or a null string, it means resume the scan
+    by advancing to the next ARGV-element.  */
+ 
+ static char *nextchar;
+ 
+ /* Callers store zero here to inhibit the error message
+    for unrecognized options.  */
+ 
+ int opterr = 1;
+ 
+ /* Describe how to deal with options that follow non-option ARGV-elements.
+ 
+    UNSPECIFIED means the caller did not specify anything;
+    the default is then REQUIRE_ORDER if the environment variable
+    _OPTIONS_FIRST is defined, PERMUTE otherwise.
+ 
+    REQUIRE_ORDER means don't recognize them as options.
+    Stop option processing when the first non-option is seen.
+    This is what Unix does.
+ 
+    PERMUTE is the default.  We permute the contents of `argv' as we scan,
+    so that eventually all the options are at the end.  This allows options
+    to be given in any order, even with programs that were not written to
+    expect this.
+ 
+    RETURN_IN_ORDER is an option available to programs that were written
+    to expect options and other ARGV-elements in any order and that care about
+    the ordering of the two.  We describe each non-option ARGV-element
+    as if it were the argument of an option with character code zero.
+    Using `-' as the first character of the list of option characters
+    requests this mode of operation.
+ 
+    The special argument `--' forces an end of option-scanning regardless
+    of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
+    `--' can cause `getopt' to return EOF with `optind' != ARGC.  */
+ 
+ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
+ 
+ /* Handle permutation of arguments.  */
+ 
+ /* Describe the part of ARGV that contains non-options that have
+    been skipped.  `first_nonopt' is the index in ARGV of the first of them;
+    `last_nonopt' is the index after the last of them.  */
+ 
+ static int first_nonopt;
+ static int last_nonopt;
+ 
+ /* Exchange two adjacent subsequences of ARGV.
+    One subsequence is elements [first_nonopt,last_nonopt)
+     which contains all the non-options that have been skipped so far.
+    The other is elements [last_nonopt,optind), which contains all
+     the options processed since those non-options were skipped.
+ 
+    `first_nonopt' and `last_nonopt' are relocated so that they describe
+     the new indices of the non-options in ARGV after they are moved.  */
+ 
+ static void exchange(char **argv)
+ {
+   int nonopts_size
+     = (last_nonopt - first_nonopt) * sizeof (char *);
+   char **temp = (char **) alloca1 (nonopts_size);
+ 
+   /* Interchange the two blocks of data in argv.  */
+ 
+   bcopy (&argv[first_nonopt], temp, nonopts_size);
+   bcopy (&argv[last_nonopt], &argv[first_nonopt],
+ 	 (optind - last_nonopt) * sizeof (char *));
+   bcopy (temp, &argv[first_nonopt + optind - last_nonopt],
+ 	 nonopts_size);
+ 
+   /* Update records for the slots the non-options now occupy.  */
+ 
+   first_nonopt += (optind - last_nonopt);
+   last_nonopt = optind;
+ }
+ 
+ /* Scan elements of ARGV (whose length is ARGC) for option characters
+    given in OPTSTRING.
+ 
+    If an element of ARGV starts with '-', and is not exactly "-" or "--",
+    then it is an option element.  The characters of this element
+    (aside from the initial '-') are option characters.  If `getopt'
+    is called repeatedly, it returns successively each of theoption characters
+    from each of the option elements.
+ 
+    If `getopt' finds another option character, it returns that character,
+    updating `optind' and `nextchar' so that the next call to `getopt' can
+    resume the scan with the following option character or ARGV-element.
+ 
+    If there are no more option characters, `getopt' returns `EOF'.
+    Then `optind' is the index in ARGV of the first ARGV-element
+    that is not an option.  (The ARGV-elements have been permuted
+    so that those that are not options now come last.)
+ 
+    OPTSTRING is a string containing the legitimate option characters.
+    A colon in OPTSTRING means that the previous character is an option
+    that wants an argument.  The argument is taken from the rest of the
+    current ARGV-element, or from the following ARGV-element,
+    and returned in `optarg'.
+ 
+    If an option character is seen that is not listed in OPTSTRING,
+    return '?' after printing an error message.  If you set `opterr' to
+    zero, the error message is suppressed but we still return '?'.
+ 
+    If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+    so the following text in the same ARGV-element, or the text of the following
+    ARGV-element, is returned in `optarg.  Two colons mean an option that
+    wants an optional arg; if there is text in the current ARGV-element,
+    it is returned in `optarg'.
+ 
+    If OPTSTRING starts with `-', it requests a different method of handling the
+    non-option ARGV-elements.  See the comments about RETURN_IN_ORDER, above. 
+ */
+ 
+ int getopt(int argc,char **argv,char *optstring)
+ {
+   /* Initialize the internal data when the first call is made.
+      Start processing options with ARGV-element 1 (since ARGV-element 0
+      is the program name); the sequence of previously skipped
+      non-option ARGV-elements is empty.  */
+ 
+   if (optind == 0)
+     {
+       first_nonopt = last_nonopt = optind = 1;
+ 
+       nextchar = 0;
+ 
+       /* Determine how to handle the ordering of options and nonoptions.  */
+ 
+       if (optstring[0] == '-')
+ 	ordering = RETURN_IN_ORDER;
+       else if (getenv ("_POSIX_OPTION_ORDER") != 0)
+ 	ordering = REQUIRE_ORDER;
+       else
+ 	ordering = PERMUTE;
+     }
+ 
+   if (nextchar == 0 || *nextchar == 0)
+     {
+       if (ordering == PERMUTE)
+ 	{
+ 	  /* If we have just processed some options following some non-options,
+ 	     exchange them so that the options come first.  */
+ 
+ 	  if (first_nonopt != last_nonopt && last_nonopt != optind)
+ 	    exchange (argv);
+ 	  else if (last_nonopt != optind)
+ 	    first_nonopt = optind;
+ 
+ 	  /* Now skip any additional non-options
+ 	     and extend the range of non-options previously skipped.  */
+ 
+ 	  while (optind < argc
+ 		 && (argv[optind][0] != '-'
+ 		     || argv[optind][1] == 0))
+ 	    optind++;
+ 	  last_nonopt = optind;
+ 	}
+ 
+       /* Special ARGV-element `--' means premature end of options.
+ 	 Skip it like a null option,
+ 	 then exchange with previous non-options as if it were an option,
+ 	 then skip everything else like a non-option.  */
+ 
+       if (optind != argc && !strcmp (argv[optind], "--"))
+ 	{
+ 	  optind++;
+ 
+ 	  if (first_nonopt != last_nonopt && last_nonopt != optind)
+ 	    exchange (argv);
+ 	  else if (first_nonopt == last_nonopt)
+ 	    first_nonopt = optind;
+ 	  last_nonopt = argc;
+ 
+ 	  optind = argc;
+ 	}
+ 
+       /* If we have done all the ARGV-elements, stop the scan
+ 	 and back over any non-options that we skipped and permuted.  */
+ 
+       if (optind == argc)
+ 	{
+ 	  /* Set the next-arg-index to point at the non-options
+ 	     that we previously skipped, so the caller will digest them.  */
+ 	  if (first_nonopt != last_nonopt)
+ 	    optind = first_nonopt;
+ 	  return EOF;
+ 	}
+ 	 
+       /* If we have come to a non-option and did not permute it,
+ 	 either stop the scan or describe it to the caller and pass it by.  */
+ 
+       if (argv[optind][0] != '-' || argv[optind][1] == 0)
+ 	{
+ 	  if (ordering == REQUIRE_ORDER)
+ 	    return EOF;
+ 	  optarg = argv[optind++];
+ 	  return 0;
+ 	}
+ 
+       /* We have found another option-ARGV-element.
+ 	 Start decoding its characters.  */
+ 
+       nextchar = argv[optind] + 1;
+     }
+ 
+   /* Look at and handle the next option-character.  */
+ 
+   {
+     char c = *nextchar++;
+     
+     /*  This is only supported with 'cc'
+     char *temp = (char *) index (optstring, c);
+     */
+ 
+     char *temp = strchr(optstring, (int) c);
+     
+     /* Increment `optind' when we start to process its last character.  */
+     if (*nextchar == 0)
+       optind++;
+ 
+     if (temp == 0 || c == ':')
+       {
+ 	if (opterr != 0)
+ 	  {
+ 	    if (c < 040 || c >= 0177)
+ 	      fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
+ 		       argv[0], c);
+ 	    else
+ 	      fprintf (stderr, "%s: unrecognized option `-%c'\n",
+ 		       argv[0], c);
+ 	  }
+ 	return '?';
+       }
+     if (temp[1] == ':')
+       {
+ 	if (temp[2] == ':')
+ 	  {
+ 	    /* This is an option that accepts an argument optionally.  */
+ 	    if (*nextchar != 0)
+ 	      {
+ 	        optarg = nextchar;
+ 		optind++;
+ 	      }
+ 	    else
+ 	      optarg = 0;
+ 	    nextchar = 0;
+ 	  }
+ 	else
+ 	  {
+ 	    /* This is an option that requires an argument.  */
+ 	    if (*nextchar != 0)
+ 	      {
+ 		optarg = nextchar;
+ 		/* If we end this ARGV-element by taking the rest as an arg,
+ 		   we must advance to the next element now.  */
+ 		optind++;
+ 	      }
+ 	    else if (optind == argc)
+ 	      {
+ 		if (opterr != 0)
+ 		  fprintf (stderr, "%s: no argument for `-%c' option\n",
+ 			   argv[0], c);
+ 		optarg = 0;
+ 	      }
+ 	    else
+ 	      /* We already incremented `optind' once;
+ 		 increment it again when taking next ARGV-elt as argument.  */
+ 	      optarg = argv[optind++];
+ 	    nextchar = 0;
+ 	  }
+       }
+     return c;
+   }
+ }
+ 
+ #ifdef TEST
+ 
+ /* Compile with -DTEST to make an executable for use in testing
+    the above definition of `getopt'.  */
+ 
+ int main(int argc,char **argv)
+ {
+   char c;
+   int digit_optind = 0;
+ 
+   while (1)
+     {
+       int this_option_optind = optind;
+       if ((c = getopt (argc, argv, "abc:d:0123456789")) == EOF)
+ 	break;
+ 
+       switch (c)
+ 	{
+ 	case '0':
+ 	case '1':
+ 	case '2':
+ 	case '3':
+ 	case '4':
+ 	case '5':
+ 	case '6':
+ 	case '7':
+ 	case '8':
+ 	case '9':
+ 	  if (digit_optind != 0 && digit_optind != this_option_optind)
+ 	    printf ("digits occur in two different argv-elements.\n");
+ 	  digit_optind = this_option_optind;
+ 	  printf ("option %c\n", c);
+ 	  break;
+ 
+ 	case 'a':
+ 	  printf ("option a\n");
+ 	  break;
+ 
+ 	case 'b':
+ 	  printf ("option b\n");
+ 	  break;
+ 
+ 	case 'c':
+ 	  printf ("option c with value `%s'\n", optarg);
+ 	  break;
+ 
+ 	case '?':
+ 	  break;
+ 
+ 	default:
+ 	  printf ("?? getopt returned character code 0%o ??\n", c);
+ 	}
+     }
+ 
+   if (optind < argc)
+     {
+       printf ("non-option ARGV-elements: ");
+       while (optind < argc)
+ 	printf ("%s ", argv[optind++]);
+       printf ("\n");
+     }
+ 
+   return 0;
+ }
+ 
+ #endif /* TEST */


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/gram.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/gram.c:1.1
*** /dev/null	Tue Oct  5 13:32:01 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/gram.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,49 ----
+ /* Allocate input grammar variables for bison,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* comments for these variables are in gram.h  */
+ 
+ int nitems;
+ int nrules;
+ int nsyms;
+ int ntokens;
+ int nvars;
+ 
+ short *ritem;
+ short *rlhs;
+ short *rrhs;
+ short *rprec;
+ short *sprec;
+ short *rassoc;
+ short *sassoc;
+ short *token_translations;
+ short *rline;
+ 
+ int start_symbol;
+ 
+ int translations;
+ 
+ int max_user_token_number;
+ 
+ int semantic_parser;
+ 
+ int pure_parser;
+ 
+ int error_token_number;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/gram.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/gram.h:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/gram.h	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,111 ----
+ /* Data definitions for internal representation of bison's input,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* representation of the grammar rules:
+ 
+ ntokens is the number of tokens, and nvars is the number of variables (nonterminals).
+ nsyms is the total number, ntokens + nvars.
+ 
+ Each symbol (either token or variable) receives a symbol number.
+ Numbers 0 to ntokens-1 are for tokens, and ntokens to nsyms-1 are for variables.
+ Symbol number zero is the end-of-input token.  This token is counted in ntokens.
+ 
+ The rules receive rule numbers 1 to nrules in the order they are written.
+ Actions and guards are accessed via the rule number.
+ 
+ The rules themselves are described by three arrays: rrhs, rlhs and ritems.
+ rlhs[r] is the symbol number of the left hand side of rule r.
+ The right hand side is stored as symbol numbers in a portion of ritems.
+ rrhs[r] contains the index in ritems of the beginning of the portion for rule r.
+ The length of the portion is one greater
+  than the number of symbols in the rule's right hand side.
+ The last element in the portion contains minus r, which
+ identifies it as the end of a portion and says which rule it is for.
+ 
+ The portions of ritems come in order of increasing rule number and are
+ followed by an element which is zero to mark the end.  nitems is the
+ total length of ritems, not counting the final zero.  Each element of
+ ritems is called an "item" and its index in ritems is an item number.
+ 
+ Item numbers are used in the finite state machine to represent
+ places that parsing can get to.
+ 
+ Precedence levels are recorded in the vectors sprec and rprec.
+ sprec records the precedence level of each symbol,
+ rprec the precedence level of each rule.
+ 
+ Precedence levels are assigned in increasing order starting with 1
+ so that numerically higher precedence values mean tighter binding
+ as they ought to.  Zero as a symbol or rule's precedence means none is assigned.
+ 
+ Associativities are recorded similarly in rassoc and sassoc.  */
+ 
+ 
+ #define	ISTOKEN(s)	((s) < ntokens)
+ #define	ISVAR(s)	((s) >= ntokens)
+ 
+ 
+ extern int nitems;
+ extern int nrules;
+ extern int nsyms;
+ extern int ntokens;
+ extern int nvars;
+ 
+ extern short *ritem;
+ extern short *rlhs;
+ extern short *rrhs;
+ extern short *rprec;
+ extern short *sprec;
+ extern short *rassoc;
+ extern short *sassoc;
+ extern short *rline;		/* Source line number of each rule */
+ 
+ extern int start_symbol;
+ 
+ 
+ /* associativity values in elements of rassoc, sassoc.  */
+ 
+ #define RIGHT_ASSOC 1
+ #define LEFT_ASSOC 2
+ #define NON_ASSOC 3
+ 
+ /* token translation table:
+ indexed by a token number as returned by the user's yylex routine,
+ it yields the internal token number used by the parser and throughout bison.
+ If translations is zero, the translation table is not used because
+ the two kinds of token numbers are the same.  */
+ 
+ extern short *token_translations;
+ extern int translations;
+ extern int max_user_token_number;
+ 
+ /* semantic_parser is nonzero if the input file says to use the hairy parser
+ that provides for semantic error recovery.  If it is zero, the yacc-compatible
+ simplified parser is used.  */
+ 
+ extern int semantic_parser;
+ 
+ /* pure_parser is nonzero if should generate a parser that is all pure and reentrant. */
+ 
+ extern int pure_parser;
+ 
+ /* error_token_number is the token number of the error token.  */
+ 
+ extern int error_token_number;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lalr.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lalr.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lalr.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,745 ----
+ /* Compute look-ahead criteria for bison,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* Compute how to make the finite state machine deterministic;
+  find which rules need lookahead in each state, and which lookahead tokens they accept.
+ 
+ lalr(), the entry point, builds these data structures:
+ 
+ goto_map, from_state and to_state 
+  record each shift transition which accepts a variable (a nonterminal).
+ ngotos is the number of such transitions.
+ from_state[t] is the state number which a transition leads from
+ and to_state[t] is the state number it leads to.
+ All the transitions that accept a particular variable are grouped together and
+ goto_map[i - ntokens] is the index in from_state and to_state of the first of them.
+ 
+ consistent[s] is nonzero if no lookahead is needed to decide what to do in state s.
+ 
+ LAruleno is a vector which records the rules that need lookahead in various states.
+ The elements of LAruleno that apply to state s are those from
+  lookaheads[s] through lookaheads[s+1]-1.
+ Each element of LAruleno is a rule number.
+ 
+ If lr is the length of LAruleno, then a number from 0 to lr-1 
+ can specify both a rule and a state where the rule might be applied.
+ 
+ LA is a lr by ntokens matrix of bits.
+ LA[l, i] is 1 if the rule LAruleno[l] is applicable in the appropriate state
+  when the next token is symbol i.
+ If LA[l, i] and LA[l, j] are both 1 for i != j, it is a conflict.
+ */
+ 
+ #include <stdio.h>
+ #include "machine.h"
+ #include "types.h"
+ #include "state.h"
+ #include "new.h"
+ #include "gram.h"
+ 
+ 
+ extern short **derives;
+ extern char *nullable;
+ 
+ 
+ int tokensetsize;
+ short *lookaheads;
+ short *LAruleno;
+ unsigned *LA;
+ short *accessing_symbol;
+ char *consistent;
+ core **state_table;
+ shifts **shift_table;
+ reductions **reduction_table;
+ short *goto_map;
+ short *from_state;
+ short *to_state;
+ 
+ short **transpose();
+ 
+ 
+ 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;
+ 
+ extern void toomany(char *s);
+ extern void berror(char *s);
+ 
+ void set_state_table(void);
+ void set_accessing_symbol(void);
+ void set_shift_table(void);
+ void set_reduction_table(void);
+ void set_maxrhs(void);
+ void initialize_LA(void);
+ void set_goto_map(void);
+ void initialize_F(void);
+ void build_relations(void);
+ void compute_FOLLOWS(void);
+ void compute_lookaheads(void);
+ void digraph(short **relation);
+ void add_lookback_edge(int stateno,int ruleno,int gotono);
+ void traverse(register int i);
+ 
+ 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();
+ }
+ 
+ 
+ 
+ void set_state_table(void)
+ {
+   register core *sp;
+ 
+   state_table = NEW2(nstates, core *);
+ 
+   for (sp = first_state; sp; sp = sp->next)
+     state_table[sp->number] = sp;
+ }
+ 
+ 
+ 
+ void set_accessing_symbol(void)
+ {
+   register core *sp;
+ 
+   accessing_symbol = NEW2(nstates, short);
+ 
+   for (sp = first_state; sp; sp = sp->next)
+     accessing_symbol[sp->number] = sp->accessing_symbol;
+ }
+ 
+ 
+ 
+ void set_shift_table(void)
+ {
+   register shifts *sp;
+ 
+   shift_table = NEW2(nstates, shifts *);
+ 
+   for (sp = first_shift; sp; sp = sp->next)
+     shift_table[sp->number] = sp;
+ }
+ 
+ 
+ 
+ void set_reduction_table(void)
+ {
+   register reductions *rp;
+ 
+   reduction_table = NEW2(nstates, reductions *);
+ 
+   for (rp = first_reduction; rp; rp = rp->next)
+     reduction_table[rp->number] = rp;
+ }
+ 
+ 
+ 
+ void set_maxrhs(void)
+ {
+   register short *itemp;
+   register int length;
+   register int max;
+ 
+   length = 0;
+   max = 0;
+   for (itemp = ritem; *itemp; itemp++)
+     {
+       if (*itemp > 0)
+ 	{
+ 	  length++;
+ 	}
+       else
+ 	{
+ 	  if (length > max) max = length;
+ 	  length = 0;
+ 	}
+     }
+ 
+   maxrhs = max;
+ }
+ 
+ 
+ 
+ void initialize_LA(void)
+ {
+   register int i;
+   register int j;
+   register int count;
+   register reductions *rp;
+   register shifts *sp;
+   register short *np;
+ 
+   consistent = NEW2(nstates, char);
+   lookaheads = NEW2(nstates + 1, short);
+ 
+   count = 0;
+   for (i = 0; i < nstates; i++)
+     {
+       register int j;
+ 
+       lookaheads[i] = count;
+ 
+       rp = reduction_table[i];
+       sp = shift_table[i];
+       if (rp && (rp->nreds > 1
+           || (sp && ! ISVAR(accessing_symbol[sp->shifts[0]]))))
+ 	count += rp->nreds;
+       else
+ 	consistent[i] = 1;
+ 
+       if (sp)
+ 	for (j = 0; j < sp->nshifts; j++)
+ 	  {
+ 	    if (accessing_symbol[sp->shifts[j]] == error_token_number)
+ 	      {
+ 		consistent[i] = 0;
+ 		break;
+ 	      }
+ 	  }
+     }
+ 
+   lookaheads[nstates] = count;
+ 
+   LA = NEW2(count * tokensetsize, unsigned);
+   LAruleno = NEW2(count, short);
+   lookback = NEW2(count, shorts *);
+ 
+   np = LAruleno;
+   for (i = 0; i < nstates; i++)
+     {
+       if (!consistent[i])
+ 	{
+ 	  if (rp = reduction_table[i])
+ 	    for (j = 0; j < rp->nreds; j++)
+ 	      *np++ = rp->rules[j];
+ 	}
+     }
+ }
+ 
+ 
+ 
+ void set_goto_map(void)
+ {
+   register shifts *sp;
+   register int i;
+   register int symbol;
+   register int k;
+   register short *temp_map;
+   register int state2;
+   register 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->shifts[i]];
+ 
+ 	  if (ISTOKEN(symbol)) break;
+ 
+ 	  if (ngotos == MAXSHORT)
+ 	    toomany("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->shifts[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.	*/
+ 
+ int map_goto(int state,int symbol)
+ {
+   register int high;
+   register int low;
+   register int middle;
+   register int s;
+ 
+   low = goto_map[symbol];
+   high = goto_map[symbol + 1];
+ 
+   while (low <= high)
+     {
+       middle = (low + high) / 2;
+       s = from_state[middle];
+       if (s == state)
+ 	return (middle);
+       else if (s < state)
+ 	low = middle + 1;
+       else
+ 	high = middle - 1;
+     }
+ 
+   berror("map_goto");
+ 
+ /* NOTREACHED */
+ }
+ 
+ 
+ 
+ void initialize_F(void)
+ {
+   register int i;
+   register int j;
+   register int k;
+   register shifts *sp;
+   register short *edge;
+   register unsigned *rowp;
+   register short *rp;
+   register short **reads;
+   register int nedges;
+   register int stateno;
+   register int symbol;
+   register 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->shifts[j]];
+ 	      if (ISVAR(symbol))
+ 		break;
+ 	      SETBIT(rowp, symbol);
+ 	    }
+ 
+ 	  for (; j < k; j++)
+ 	    {
+ 	      symbol = accessing_symbol[sp->shifts[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;
+     }
+ 
+   digraph(reads);
+ 
+   for (i = 0; i < ngotos; i++)
+     {
+       if (reads[i])
+ 	FREE(reads[i]);
+     }
+ 
+   FREE(reads);
+   FREE(edge);
+ }
+ 
+ void build_relations(void)
+ {
+   register int i;
+   register int j;
+   register int k;
+   register short *rulep;
+   register short *rp;
+   register shifts *sp;
+   register int length;
+   register int nedges;
+   register int done;
+   register int state1;
+   register int stateno;
+   register int symbol1;
+   register int symbol2;
+   register short *shortp;
+   register short *edge;
+   register short *states;
+   register 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->shifts[j];
+ 		  if (accessing_symbol[stateno] == symbol2) break;
+ 		}
+ 
+ 	      states[length++] = stateno;
+ 	    }
+ 
+ 	  if (!consistent[stateno])
+ 	    add_lookback_edge(stateno, *rulep, i);
+ 
+ 	  length--;
+ 	  done = 0;
+ 	  while (!done)
+ 	    {
+ 	      done = 1;
+ 	      rp--;
+ 			/* JF added rp>=ritem &&   I hope to god its right! */
+ 	      if (rp>=ritem && ISVAR(*rp))
+ 		{
+ 		  stateno = states[--length];
+ 		  edge[nedges++] = map_goto(stateno, *rp);
+ 		  if (nullable[*rp]) done = 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);
+ }
+ 
+ 
+ 
+ void add_lookback_edge(int stateno,int ruleno,int gotono)
+ {
+   register int i;
+   register int k;
+   register int found;
+   register shorts *sp;
+ 
+   i = lookaheads[stateno];
+   k = lookaheads[stateno + 1];
+   found = 0;
+   while (!found && i < k)
+     {
+       if (LAruleno[i] == ruleno)
+ 	found = 1;
+       else
+ 	i++;
+     }
+ 
+   if (found == 0)
+     berror("add_lookback_edge");
+ 
+   sp = NEW(shorts);
+   sp->next = lookback[i];
+   sp->value = gotono;
+   lookback[i] = sp;
+ }
+ 
+ 
+ 
+ short **transpose(short **R,int n)
+ {
+   register short **new_R;
+   register short **temp_R;
+   register short *nedges;
+   register short *sp;
+   register int i;
+   register int k;
+ 
+   nedges = NEW2(n, short);
+ 
+   for (i = 0; i < n; i++)
+     {
+       sp = R[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 = R[i];
+       if (sp)
+ 	{
+ 	  while (*sp >= 0)
+ 	    *temp_R[*sp++]++ = i;
+ 	}
+     }
+ 
+   FREE(temp_R);
+ 
+   return (new_R);
+ }
+ 
+ 
+ 
+ void compute_FOLLOWS(void)
+ {
+   register int i;
+ 
+   digraph(includes);
+ 
+   for (i = 0; i < ngotos; i++)
+     {
+       if (includes[i]) FREE(includes[i]);
+     }
+ 
+   FREE(includes);
+ }
+ 
+ 
+ 
+ void compute_lookaheads(void)
+ {
+   register int i;
+   register int n;
+   register unsigned *fp1;
+   register unsigned *fp2;
+   register unsigned *fp3;
+   register shorts *sp;
+   register unsigned *rowp;
+ /*   register short *rulep; JF unused */
+ /*  register int count; JF unused */
+   register shorts *sptmp;/* JF */
+ 
+   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++)
+     {/* JF removed ref to freed storage */
+       for (sp = lookback[i]; sp; sp = sptmp) {
+ 	sptmp=sp->next;
+ 	FREE(sp);
+       }
+     }
+ 
+   FREE(lookback);
+   FREE(F);
+ }
+ 
+ 
+ 
+ void digraph(short **relation)
+ {
+   register 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);
+ }
+ 
+ void traverse(register int i)
+ {
+   register unsigned *fp1;
+   register unsigned *fp2;
+   register unsigned *fp3;
+   register int j;
+   register 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++;
+ 	}
+     }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lex.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lex.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lex.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,440 ----
+ /* Token-reader for Bison's input parser,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* 
+    lex() is the entry point.  It is called from reader.c.
+    It returns one of the token-type codes defined in lex.h.
+    When an identifier is seen, the code IDENTIFIER is returned
+    and the name is looked up in the symbol table using symtab.c;
+    symval is set to a pointer to the entry found.  */
+ 
+ #include <stdio.h>
+ #include <ctype.h>
+ #include "files.h"
+ #include "symtab.h"
+ #include "lex.h"
+ 
+ 
+ extern int lineno;
+ extern int translations;
+ 
+ 
+ char token_buffer[MAXTOKEN + 1];
+ bucket *symval;
+ int numval;
+ 
+ static int unlexed;		/* these two describe a token to be reread */
+ static bucket *unlexed_symval;	/* by the next call to lex */
+ 
+ extern void fatals(char *fmt,int x1,int x2,int x3,int x4,int x5,int x6,
+                    int x7,int x8);
+ extern void fatal(char *s);
+ 
+ int parse_percent_token(void);
+ 
+ void init_lex(void)
+ {
+   unlexed = -1;
+ }
+ 
+ 
+ 
+ int skip_white_space(void)
+ {
+   register int c;
+   register int inside;
+ 
+   c = getc(finput);
+ 
+   for (;;)
+     {
+       switch (c)
+ 	{
+ 	case '/':
+ 	  c = getc(finput);
+ 	  if (c != '*')
+ 	    fatals("unexpected '/%c' found",c,0,0,0,0,0,0,0);
+ 
+ 	  c = getc(finput);
+ 
+ 	  inside = 1;
+ 	  while (inside)
+ 	    {
+ 	      if (c == '*')
+ 		{
+ 		  while (c == '*')
+ 		    c = getc(finput);
+ 
+ 		  if (c == '/')
+ 		    {
+ 		      inside = 0;
+ 		      c = getc(finput);
+ 		    }
+ 		}
+ 	      else if (c == '\n')
+ 		{
+ 		  lineno++;
+ 		  c = getc(finput);
+ 		}
+ 	      else if (c == EOF)
+ 		fatal("unterminated comment");
+ 	      else
+ 		c = getc(finput);
+ 	    }
+ 
+ 	  break;
+ 
+ 	case '\n':
+ 	  lineno++;
+ 
+ 	case ' ':
+ 	case '\t':
+ 	case '\f':
+ 	  c = getc(finput);
+ 	  break;
+ 
+ 	default:
+ 	  return (c);
+ 	}
+     }
+ }
+ 
+ void unlex(int token)
+ {
+   unlexed = token;
+   unlexed_symval = symval;
+ }
+ 
+ int lex(void)
+ {
+   register int c;
+   register char *p;
+ 
+   if (unlexed >= 0)
+     {
+       symval = unlexed_symval;
+       c = unlexed;
+       unlexed = -1;
+       return (c);
+     }
+ 
+   c = skip_white_space();
+ 
+   switch (c)
+     {
+     case EOF:
+       return (ENDFILE);
+ 
+     case 'A':  case 'B':  case 'C':  case 'D':  case 'E':
+     case 'F':  case 'G':  case 'H':  case 'I':  case 'J':
+     case 'K':  case 'L':  case 'M':  case 'N':  case 'O':
+     case 'P':  case 'Q':  case 'R':  case 'S':  case 'T':
+     case 'U':  case 'V':  case 'W':  case 'X':  case 'Y':
+     case 'Z':
+     case 'a':  case 'b':  case 'c':  case 'd':  case 'e':
+     case 'f':  case 'g':  case 'h':  case 'i':  case 'j':
+     case 'k':  case 'l':  case 'm':  case 'n':  case 'o':
+     case 'p':  case 'q':  case 'r':  case 's':  case 't':
+     case 'u':  case 'v':  case 'w':  case 'x':  case 'y':
+     case 'z':
+     case '.':  case '_':
+       p = token_buffer;
+       while (isalnum(c) || c == '_' || c == '.')
+ 	{
+ 	  if (p < token_buffer + MAXTOKEN)
+ 	    *p++ = c;
+ 	  c = getc(finput);
+ 	}
+ 
+       *p = 0;
+       ungetc(c, finput);
+       symval = getsym(token_buffer);
+       return (IDENTIFIER);
+ 
+     case '0':  case '1':  case '2':  case '3':  case '4':
+     case '5':  case '6':  case '7':  case '8':  case '9':
+       {
+ 	numval = 0;
+ 
+ 	while (isdigit(c))
+ 	  {
+ 	    numval = numval*10 + c - '0';
+ 	    c = getc(finput);
+ 	  }
+ 	ungetc(c, finput);
+ 	return (NUMBER);
+       }
+ 
+     case '\'':
+       translations = -1;
+ 
+       /* parse the literal token and compute character code in  code  */
+ 
+       c = getc(finput);
+       {
+ 	register int code = 0;
+ 
+ 	if (c == '\\')
+ 	  {
+ 	    c = getc(finput);
+ 
+ 	    if (c <= '7' && c >= '0')
+ 	      {
+ 		while (c <= '7' && c >= '0')
+ 		  {
+ 		    code = (code * 8) + (c - '0');
+ 		    c = getc(finput);
+ 		  }
+ 		if (code >= 128 || code<0)/* JF this said if(c>=128) */
+ 		  fatals("malformatted literal token '\\%03o'",code,0,0,0,0,0,
+                          0,0);
+ 	      }
+ 	    else
+ 	      {
+ 		if (c == 't')
+ 		  code = '\t';
+ 		else if (c == 'n')
+ 		  code = '\n';
+ 		else if (c == 'r')
+ 		  code = '\r';
+ 		else if (c == 'f')
+ 		  code = '\f';
+ 		else if (c == 'b')
+ 		  code = '\b';
+ 		else if (c == '\\')
+ 		  code = '\\';
+ 		else if (c == '\'')
+ 		  code = '\'';
+ 		else if (c == '\"')	/* JF this is a good idea */
+ 		  code = '\"';
+ 		else fatals("invalid literal token '\\%c'",c,0,0,0,0,0,0,0);
+ 		c = getc(finput);
+ 	      }
+ 	  }
+ 	else
+ 	  {
+ 	    code = c;
+ 	    c = getc(finput);
+ 	  }
+ 	if (c != '\'')
+ 	  fatal("multicharacter literal tokens NOT supported");
+ 
+ 	/* now fill token_buffer with the canonical name for this character
+ 	   as a literal token.  Do not use what the user typed,
+ 	   so that '\012' and '\n' can be interchangeable.  */
+ 
+ 	p = token_buffer;
+ 	*p++ = '\'';
+ 	if (code == '\\')
+ 	  {
+ 	    p = token_buffer + 1;
+ 	    *p++ = '\\';
+ 	    *p++ = '\\';
+ 	  }
+ 	else if (code == '\'')
+ 	  {
+ 	    p = token_buffer + 1;
+ 	    *p++ = '\\';
+ 	    *p++ = '\'';
+ 	  }
+ 	else if (code >= 040 && code != 0177)
+ 	  *p++ = code;
+ 	else if (code == '\t')
+ 	  {
+ 	    p = token_buffer + 1;
+ 	    *p++ = '\\';
+ 	    *p++ = 't';
+ 	  }
+ 	else if (code == '\n')
+ 	  {
+ 	    p = token_buffer + 1;
+ 	    *p++ = '\\';
+ 	    *p++ = 'n';
+ 	  }
+ 	else if (code == '\r')
+ 	  {
+ 	    p = token_buffer + 1;
+ 	    *p++ = '\\';
+ 	    *p++ = 'r';
+ 	  }
+ 	else if (code == '\b')
+ 	  {
+ 	    p = token_buffer + 1;
+ 	    *p++ = '\\';
+ 	    *p++ = 'b';
+ 	  }
+ 	else if (code == '\f')
+ 	  {
+ 	    p = token_buffer + 1;
+ 	    *p++ = '\\';
+ 	    *p++ = 'f';
+ 	  }
+         else
+ 	  {
+ 	    *p++ = code / 0100 + '0';
+ 	    *p++ = ((code / 010) & 07) + '0';
+ 	    *p++ = (code & 07) + '0';
+ 	  }
+ 	*p++ = '\'';
+ 	*p = 0;
+ 	symval = getsym(token_buffer);
+ 	symval->class = STOKEN;
+ 	if (! symval->user_token_number)
+ 	  symval->user_token_number = code;
+ 	return (IDENTIFIER);
+       }
+ 
+     case ',':
+       return (COMMA);
+ 
+     case ':':
+       return (COLON);
+ 
+     case ';':
+       return (SEMICOLON);
+ 
+     case '|':
+       return (BAR);
+ 
+     case '{':
+       return (LEFT_CURLY);
+ 
+     case '=':
+       do
+ 	{
+ 	  c = getc(finput);
+ 	  if (c == '\n') lineno++;
+ 	}
+       while(c==' ' || c=='\n' || c=='\t');
+ 
+       if (c == '{')
+       	return(LEFT_CURLY);
+       else
+ 	{
+ 	  ungetc(c, finput);
+ 	  return(ILLEGAL);
+ 	}
+ 
+     case '<':
+       p = token_buffer;
+       c = getc(finput);
+       while (c != '>')
+ 	{
+ 	  if (c == '\n' || c == EOF)
+ 	    fatal("unterminated type name");
+ 
+ 	  if (p >= token_buffer + MAXTOKEN - 1)
+ 	    fatals("type name too long (%d max)",MAXTOKEN-1,0,0,0,0,0,0,0);
+ 
+ 	  *p++ = c;
+ 	  c = getc(finput);
+ 	}
+       *p = 0;
+       return (TYPENAME);
+ 	    
+ 
+     case '%':
+       return (parse_percent_token());
+ 
+     default:
+       return (ILLEGAL);
+     }
+ }
+ 
+ 
+ /* parse a token which starts with %.  Assumes the % has already been read and discarded.  */
+ 
+ int parse_percent_token(void)
+ {
+   register int c;
+   register char *p;
+ 
+   p = token_buffer;
+   c = getc(finput);
+ 
+   switch (c)
+     {
+     case '%':
+       return (TWO_PERCENTS);
+ 
+     case '{':
+       return (PERCENT_LEFT_CURLY);
+ 
+     case '<':
+       return (LEFT);
+ 
+     case '>':
+       return (RIGHT);
+ 
+     case '2':
+       return (NONASSOC);
+ 
+     case '0':
+       return (TOKEN);
+ 
+     case '=':
+       return (PREC);
+     }
+   if (!isalpha(c))
+     return (ILLEGAL);
+ 
+   while (isalpha(c) || c == '_')
+     {
+       if (p < token_buffer + MAXTOKEN)
+ 	*p++ = c;
+       c = getc(finput);
+     }
+ 
+   ungetc(c, finput);
+ 
+   *p = 0;
+ 
+   if (strcmp(token_buffer, "token") == 0
+       ||
+       strcmp(token_buffer, "term") == 0)
+     return (TOKEN);
+   else if (strcmp(token_buffer, "nterm") == 0)
+     return (NTERM);
+   else if (strcmp(token_buffer, "type") == 0)
+     return (TYPE);
+   else if (strcmp(token_buffer, "guard") == 0)
+     return (GUARD);
+   else if (strcmp(token_buffer, "union") == 0)
+     return (UNION);
+   else if (strcmp(token_buffer, "expect") == 0)
+     return (EXPECT);
+   else if (strcmp(token_buffer, "start") == 0)
+     return (START);
+   else if (strcmp(token_buffer, "left") == 0)
+     return (LEFT);
+   else if (strcmp(token_buffer, "right") == 0)
+     return (RIGHT);
+   else if (strcmp(token_buffer, "nonassoc") == 0
+ 	   ||
+ 	   strcmp(token_buffer, "binary") == 0)
+     return (NONASSOC);
+   else if (strcmp(token_buffer, "semantic_parser") == 0)
+     return (SEMANTIC_PARSER);
+   else if (strcmp(token_buffer, "pure_parser") == 0)
+     return (PURE_PARSER);
+   else if (strcmp(token_buffer, "prec") == 0)
+     return (PREC);
+   else return (ILLEGAL);
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lex.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lex.h:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/lex.h	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,47 ----
+ /* Token type definitions for bison's input reader,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #define	ENDFILE		0
+ #define	IDENTIFIER	1
+ #define	COMMA		2
+ #define COLON		3
+ #define	SEMICOLON	4
+ #define	BAR		5
+ #define LEFT_CURLY	6
+ #define TWO_PERCENTS	7
+ #define PERCENT_LEFT_CURLY	8
+ #define	TOKEN		9
+ #define	NTERM		10
+ #define GUARD	       11
+ #define	TYPE	       12
+ #define	UNION	       13
+ #define START	       14
+ #define LEFT	       15
+ #define RIGHT	       16
+ #define NONASSOC       17
+ #define PREC	       18
+ #define SEMANTIC_PARSER 19
+ #define PURE_PARSER    20
+ #define TYPENAME       21
+ #define NUMBER	       22
+ #define EXPECT	       23
+ #define	ILLEGAL	       24
+ 
+ #define	MAXTOKEN	1024


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/machine.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/machine.h:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/machine.h	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,26 ----
+ /* Define machine-dependencies for bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #define	MAXSHORT	32767
+ #define	MINSHORT	-32768
+ 
+ #define	BITS_PER_WORD	32
+ #define	WORDSIZE(n)	(((n) + 31) / 32)
+ #define	SETBIT(x, i)	((x)[(i)>>5] |= (1<<((i) & 31)))


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/main.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/main.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/main.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,124 ----
+ /* Top level entry point of bison,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #include <stdio.h>
+ #include "machine.h"	/* JF for MAXSHORT */
+ 
+ extern	int lineno;
+ extern	int verboseflag;
+ 
+ /* Nonzero means failure has been detected; don't write a parser file.  */
+ int failure;
+ 
+ extern void getargs(int argc,char *argv[]);
+ extern void openfiles(void);
+ extern void reader(void);
+ extern void set_derives(void);
+ extern void set_nullable(void);
+ extern void generate_states(void);
+ extern void lalr(void);
+ extern void initialize_conflicts(void);
+ extern void verbose(void);
+ extern void terse(void);
+ extern void output(void);
+ extern void done(int k);
+ 
+ void main(int argc,char *argv[])
+ {
+   failure = 0;
+   lineno = 0;
+   getargs(argc, argv);
+   openfiles();
+ 
+   /* read the input.  Copy some parts of it to fguard, faction, ftable and fattrs.
+      In file reader.
+      The other parts are recorded in the grammar; see gram.h.  */
+   reader();
+ 
+   /* record other info about the grammar.  In files derives and nullable.  */
+   set_derives();
+   set_nullable();
+ 
+   /* convert to nondeterministic finite state machine.  In file LR0.
+      See state.h for more info.  */
+   generate_states();
+ 
+   /* make it deterministic.  In file lalr.  */
+   lalr();
+ 
+   /* Find and record any conflicts: places where one token of lookahead is not
+      enough to disambiguate the parsing.  In file conflicts.
+      Currently this does not do anything to resolve them;
+      the trivial form of conflict resolution that exists is done in output.  */
+   initialize_conflicts();
+ 
+   /* print information about results, if requested.  In file print. */
+   if (verboseflag)
+     verbose();
+   else
+     terse();
+ 
+   /* output the tables and the parser to ftable.  In file output. */
+   output();
+   done(failure);
+ }
+ 
+ /* functions to report errors which prevent a parser from being generated */
+ 
+ void fatal(char *s)
+ {
+   extern char *infile;
+ 
+   if (infile == 0)
+     fprintf(stderr, "fatal error: %s\n", s);
+   else
+     fprintf(stderr, "\"%s\", line %d: %s\n", infile, lineno, s);
+   done(1);
+ }
+ 
+ 
+ /* JF changed to accept/deal with variable args.  Is a real kludge since
+    we don't support _doprnt calls */
+ /*VARARGS1*/
+ 
+ void fatals(char *fmt,int x1,int x2,int x3,int x4,int x5,int x6,int x7,int x8)
+ {
+   char buffer[200];
+ 
+   sprintf(buffer, fmt, x1,x2,x3,x4,x5,x6,x7,x8);
+   fatal(buffer);
+ }
+ 
+ 
+ 
+ void toomany(char *s)
+ {
+   char buffer[200];
+ 
+ 	/* JF new msg */
+   sprintf(buffer, "limit of %d exceeded, too many %s", MAXSHORT, s);
+   fatal(buffer);
+ }
+ 
+ void berror(char *s)
+ {
+   fprintf(stderr, "internal error, %s\n", s);
+   abort();
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/new.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/new.h:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/new.h	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,42 ----
+ /* Storage allocation interface for bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #include <stdlib.h>
+ 
+ #define	NEW(t)		((t *) mallocate((unsigned) sizeof(t)))
+ #define	NEW2(n, t)	((t *) mallocate((unsigned) ((n) * sizeof(t))))
+ 
+ /* #define	FREE(x)		(x && free((char *) (x)))
+ */
+ 
+ #define FREE(x)        {if (x) free(x);}
+ 
+ /*
+ void FREE(void *temp)
+ {
+   if (temp)
+     free(temp);
+ }
+ */
+ 
+ extern	char *mallocate();
+ 
+ 
+ 


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/nullable.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/nullable.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/nullable.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,128 ----
+ /* Part of the bison parser generator,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* set up nullable, a vector saying which nonterminals can expand into the null string.
+    nullable[i - ntokens] is nonzero if symbol i can do so.  */
+ 
+ #include <stdio.h>
+ #include "types.h"
+ #include "gram.h"
+ #include "new.h"
+ 
+ 
+ char *nullable;
+ 
+ void set_nullable(void)
+ {
+   register short *r;
+   register short *s1;
+   register short *s2;
+   register int ruleno;
+   register int symbol;
+   register shorts *p;
+ 
+   short *squeue;
+   short *rcount;
+   shorts **rsets;
+   shorts *relts;
+   char any_tokens;
+   short *r1;
+ 
+ #ifdef	TRACE
+   fprintf(stderr, "Entering set_nullable");
+ #endif
+ 
+   nullable = NEW2(nvars, char) - ntokens;
+ 
+   squeue = NEW2(nvars, short);
+   s1 = s2 = squeue;
+ 
+   rcount = NEW2(nrules + 1, short);
+   rsets = NEW2(nvars, shorts *) - ntokens;
+   relts = NEW2(nitems + nvars + 1, shorts);
+   p = relts;
+ 
+   r = ritem;
+   while (*r)
+     {
+       if (*r < 0)
+ 	{
+ 	  symbol = rlhs[-(*r++)];
+ 	  if (!nullable[symbol])
+ 	    {
+ 	      nullable[symbol] = 1;
+ 	      *s2++ = symbol;
+ 	    }
+ 	}
+       else
+ 	{
+ 	  r1 = r;
+ 	  any_tokens = 0;
+ 	  for (symbol = *r++; symbol > 0; symbol = *r++)
+ 	    {
+ 	      if (ISTOKEN(symbol))
+ 		any_tokens = 1;
+ 	    }
+ 
+ 	  if (!any_tokens)
+ 	    {
+ 	      ruleno = -symbol;
+ 	      r = r1;
+ 	      for (symbol = *r++; symbol > 0; symbol = *r++)
+ 		{
+ 		  rcount[ruleno]++;
+ 		  p->next = rsets[symbol];
+ 		  p->value = ruleno;
+ 		  rsets[symbol] = p;
+ 		  p++;
+ 		}
+ 	    }
+ 	}
+     }
+ 
+   while (s1 < s2)
+     {
+       p = rsets[*s1++];
+       while (p)
+ 	{
+ 	  ruleno = p->value;
+ 	  p = p->next;
+ 	  if (--rcount[ruleno] == 0)
+ 	    {
+ 	      symbol = rlhs[ruleno];
+ 	      if (!nullable[symbol])
+ 		{
+ 		  nullable[symbol] = 1;
+ 		  *s2++ = symbol;
+ 		}
+ 	    }
+ 	}
+     }
+ 
+   FREE(squeue);
+   FREE(rcount);
+   FREE(rsets + ntokens);
+   FREE(relts);
+ }
+ 
+ void free_nullable(void)
+ {
+   FREE(nullable + ntokens);
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/output.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/output.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/output.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,1345 ----
+ /* Output the generated parsing program for bison,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* functions to output parsing data to various files.  Entries are:
+ 
+   output_headers ()
+ 
+ Output constant strings to the beginning of certain files.
+ 
+   output_trailers()
+ 
+ Output constant strings to the ends of certain files.
+ 
+   output ()
+ 
+ Output the parsing tables and the parser code to ftable.
+ 
+ The parser tables consist of:  (starred ones needed only for the semantic parser)
+ 
+ yytranslate = vector mapping yylex's token numbers into bison's token numbers.
+ 
+ yytname = vector of string-names indexed by bison token number
+ 
+ yyrline = vector of line-numbers of all rules.  For yydebug printouts.
+ 
+ * yyrhs = vector of items of all rules.
+         This is exactly what ritems contains.
+ 
+ * yyprhs[r] = index in yyrhs of first item for rule r.
+ 
+ yyr1[r] = symbol number of symbol that rule r derives.
+ 
+ yyr2[r] = number of symbols composing right hand side of rule r.
+ 
+ * yystos[s] = the symbol number of the symbol that leads to state s.
+ 
+ yydefact[s] = default rule to reduce with in state s,
+ 	      when yytable doesn't specify something else to do.
+ 	      Zero means the default is an error.
+ 
+ yydefgoto[i] = default state to go to after a reduction of a rule that
+ 	       generates variable ntokens + i, except when yytable
+ 	       specifies something else to do.
+ 
+ yypact[s] = index in yytable of the portion describing state s.
+             The lookahed token's type is used to index that portion
+             to find out what to do.
+ 
+ 	    If the value in yytable is positive,
+ 	    we shift the token and go to that state.
+ 
+ 	    If the value is negative, it is minus a rule number to reduce by.
+ 
+ 	    If the value is zero, the default action from yydefact[s] is used.
+ 
+ yypgoto[i] = the index in yytable of the portion describing 
+              what to do after reducing a rule that derives variable i + ntokens.
+              This portion is indexed by the parser state number
+ 	     as of before the text for this nonterminal was read.
+ 	     The value from yytable is the state to go to.
+ 
+ yytable = a vector filled with portions for different uses,
+           found via yypact and yypgoto.
+ 
+ yycheck = a vector indexed in parallel with yytable.
+ 	  It indicates, in a roundabout way, the bounds of the
+ 	  portion you are trying to examine.
+ 
+ 	  Suppose that the portion of yytable starts at index p
+ 	  and the index to be examined within the portion is i.
+ 	  Then if yycheck[p+i] != i, i is outside the bounds
+ 	  of what is actually allocated, and the default
+ 	  (from yydefact or yydefgoto) should be used.
+ 	  Otherwise, yytable[p+i] should be used.
+ 
+ YYFINAL = the state number of the termination state.
+ YYFLAG = most negative short int.  Used to flag ??
+ YYNTBASE = ntokens.
+ 
+ */
+ 
+ #include <stdio.h>
+ #include "machine.h"
+ #include "new.h"
+ #include "files.h"
+ #include "gram.h"
+ #include "state.h"
+ 
+ #define	MAXTABLE 32767
+ 
+ 
+ extern int debugflag;
+ extern int nolinesflag;
+ 
+ extern char **tags;
+ extern int tokensetsize;
+ extern int final_state;
+ extern core **state_table;
+ extern shifts **shift_table;
+ extern errs **err_table;
+ extern reductions **reduction_table;
+ extern short *accessing_symbol;
+ extern unsigned *LA;
+ extern short *LAruleno;
+ extern short *lookaheads;
+ extern char *consistent;
+ extern short *goto_map;
+ extern short *from_state;
+ extern short *to_state;
+ 
+ 
+ static int nvectors;
+ static int nentries;
+ static short **froms;
+ static short **tos;
+ static short *tally;
+ static short *width;
+ static short *actrow;
+ static short *state_count;
+ static short *order;
+ static short *base;
+ static short *pos;
+ static short *table;
+ static short *check;
+ static int lowzero;
+ static int high;
+ 
+ 
+ 
+ #define	GUARDSTR	"\n#include \"%s\"\nextern int yyerror;\n\
+ extern int yycost;\nextern char * yymsg;\nextern YYSTYPE yyval;\n\n\
+ yyguard(n, yyvsp, yylsp)\nregister int n;\nregister YYSTYPE *yyvsp;\n\
+ register YYLTYPE *yylsp;\n\
+ {\n  yyerror = 0;\nyycost = 0;\n  yymsg = 0;\nswitch (n)\n    {"
+ 
+ #define	ACTSTR		"\n#include \"%s\"\nextern YYSTYPE yyval;\
+ \nextern int yychar;\
+ yyaction(n, yyvsp, yylsp)\nregister int n;\nregister YYSTYPE *yyvsp;\n\
+ register YYLTYPE *yylsp;\n{\n  switch (n)\n{"
+ 
+ #define	ACTSTR_SIMPLE	"\n  switch (yyn) {\n"
+ 
+ extern void berror(char *s);
+ extern void fatals(char *fmt,int x1,int x2,int x3,int x4,int x5,int x6,
+                    int x7,int x8);
+ 
+ void free_itemsets(void);
+ void output_defines(void);
+ void output_token_translations(void);
+ void output_gram(void);
+ void output_stos(void);
+ void output_rule_data(void);
+ void output_actions(void);
+ void output_parser(void);
+ void output_program(void);
+ void token_actions(void);
+ void free_shifts(void);
+ void free_reductions(void);
+ void goto_actions(void);
+ void sort_actions(void);
+ void pack_table(void);
+ void output_base(void);
+ void output_table(void);
+ void output_check(void);
+ int action_row(int state);
+ void save_row(int state);
+ int default_goto(int symbol);
+ void save_column(int symbol,int default_state);
+ int matching_state(int vector);
+ int pack_vector(int vector);
+ 
+ 
+ void output_headers(void)
+ {
+   if (semantic_parser)
+     fprintf(fguard, GUARDSTR, attrsfile);
+   fprintf(faction, (semantic_parser ? ACTSTR : ACTSTR_SIMPLE), attrsfile);
+ /*  if (semantic_parser)	JF moved this below
+     fprintf(ftable, "#include \"%s\"\n", attrsfile);
+   fprintf(ftable, "#include <stdio.h>\n\n"); */
+ }
+ 
+ void output_trailers(void)
+ {
+   if (semantic_parser)
+     {
+       fprintf(fguard, "\n    }\n}\n");
+       fprintf(faction, "\n    }\n}\n");
+     }
+   else
+     fprintf(faction, "\n}\n");
+ }
+ 
+ 
+ void output(void)
+ {
+   int c;
+ 
+   /* output_token_defines(ftable);	JF put out token defines FIRST */
+   if (!semantic_parser)		/* JF Put out other stuff */
+     {
+       rewind(fattrs);
+       while ((c=getc(fattrs))!=EOF)
+         putc(c,ftable);
+     }
+ 
+   if (debugflag)
+     fprintf(ftable, "#define YYDEBUG\n");
+ 
+   if (semantic_parser)
+     fprintf(ftable, "#include \"%s\"\n", attrsfile);
+   fprintf(ftable, "#include <stdio.h>\n\n");
+ 
+   /* Make "const" do nothing if not in ANSI C.  */
+   fprintf (ftable, "#ifndef __STDC__\n#define const\n#endif\n\n");
+ 
+   free_itemsets();
+   output_defines();
+   output_token_translations();
+   if (semantic_parser)
+     output_gram();
+   FREE(ritem);
+   if (semantic_parser)
+     output_stos();
+   output_rule_data();
+   output_actions();
+   output_parser();
+   output_program();
+ }
+ 
+ void output_token_translations(void)
+ {
+   register int i, j;
+ /*   register short *sp; JF unused */
+ 
+   if (translations)
+     {
+       fprintf(ftable,
+ 	      "\n#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\n",
+ 	      max_user_token_number, nsyms);
+     
+       if (ntokens < 127)  /* play it very safe; check maximum element value.  */
+         fprintf(ftable, "\nstatic const char yytranslate[] = {     0");
+       else
+ 	fprintf(ftable, "\nstatic const short yytranslate[] = {     0");
+     
+       j = 10;
+       for (i = 1; i <= max_user_token_number; i++)
+ 	{
+ 	  putc(',', ftable);
+     
+ 	  if (j >= 10)
+ 	    {
+ 	      putc('\n', ftable);
+ 	      j = 1;
+ 	    }
+ 	  else
+ 	    {
+ 	      j++;
+ 	    }
+     
+ 	  fprintf(ftable, "%6d", token_translations[i]);
+ 	}
+     
+       fprintf(ftable, "\n};\n");
+     }
+   else
+     {
+       fprintf(ftable, "\n#define YYTRANSLATE(x) (x)\n");
+     } 
+ }
+ 
+ 
+ 
+ void output_gram(void)
+ {
+   register int i;
+   register int j;
+   register short *sp;
+ 
+   fprintf(ftable, "\nstatic const short yyprhs[] = {     0");
+ 
+   j = 10;
+   for (i = 1; i <= nrules; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", rrhs[i]);
+     }
+ 
+   fprintf(ftable, "\n};\n\nstatic const short yyrhs[] = {%6d", ritem[0]);
+ 
+   j = 10;
+   for (sp = ritem + 1; *sp; sp++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       if (*sp > 0)
+ 	fprintf(ftable, "%6d", *sp);
+       else
+ 	fprintf(ftable, "     0");
+     }
+ 
+   fprintf(ftable, "\n};\n");
+ }
+ 
+ 
+ 
+ void output_stos(void)
+ {
+   register int i;
+   register int j;
+ 
+   fprintf(ftable, "\nstatic const short yystos[] = {     0");
+ 
+   j = 10;
+   for (i = 1; i < nstates; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", accessing_symbol[i]);
+     }
+ 
+   fprintf(ftable, "\n};\n");
+ }
+ 
+ 
+ 
+ void output_rule_data(void)
+ {
+   register int i;
+   register int j;
+ 
+   fprintf(ftable, "\nstatic const short yyrline[] = {     0");
+ 
+   j = 10;
+   for (i = 1; i <= nrules; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", rline[i]);
+     }
+ 
+   /* Output the table of token names.  */
+ 
+   fprintf(ftable, "\n};\n\nstatic const char * const yytname[] = {     0");
+ 
+   j = 10;
+   for (i = 1; i <= ntokens; i++)
+     {
+       register char *p;
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       putc ('\"', ftable);
+ 
+       for (p = tags[i]; *p; p++)
+ 	if (*p == '"' || *p == '\\')
+ 	  fprintf(ftable, "\\%c", *p);
+ 	else if (*p == '\n')
+ 	  fprintf(ftable, "\\n");
+ 	else if (*p == '\t')
+ 	  fprintf(ftable, "\\t");
+ 	else if (*p == '\b')
+ 	  fprintf(ftable, "\\b");
+ 	else if (*p < 040 || *p >= 0177)
+ 	  fprintf(ftable, "\\%03o", *p);
+ 	else
+ 	  putc(*p, ftable);
+ 
+       putc ('\"', ftable);
+     }
+ 
+   fprintf(ftable, "\n};\n\nstatic const short yyr1[] = {     0");
+ 
+   j = 10;
+   for (i = 1; i <= nrules; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", rlhs[i]);
+     }
+ 
+   FREE(rlhs + 1);
+ 
+   fprintf(ftable, "\n};\n\nstatic const short yyr2[] = {     0");
+ 
+   j = 10;
+   for (i = 1; i < nrules; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", rrhs[i + 1] - rrhs[i] - 1);
+     }
+ 
+   putc(',', ftable);
+   if (j >= 10)
+     putc('\n', ftable);
+ 
+   fprintf(ftable, "%6d\n};\n", nitems - rrhs[nrules] - 1);
+   FREE(rrhs + 1);
+ }
+ 
+ 
+ 
+ void output_defines(void)
+ {
+   fprintf(ftable, "\n\n#define\tYYFINAL\t\t%d\n", final_state);
+   fprintf(ftable, "#define\tYYFLAG\t\t%d\n", MINSHORT);
+   fprintf(ftable, "#define\tYYNTBASE\t%d\n", ntokens);
+ }
+ 
+ 
+ 
+ /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable and yycheck.  */
+ 
+ void output_actions(void)
+ {
+   nvectors = nstates + nvars;
+ 
+   froms = NEW2(nvectors, short *);
+   tos = NEW2(nvectors, short *);
+   tally = NEW2(nvectors, short);
+   width = NEW2(nvectors, short);
+ 
+   token_actions();
+   free_shifts();
+   free_reductions();
+   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();
+ }
+ 
+ 
+ 
+ /* figure out the actions for the specified state, indexed by lookahead token type.
+ 
+    The yydefact table is output now.  The detailed info
+    is saved for putting into yytable later.  */
+ 
+ void token_actions(void)
+ {
+   register int i;
+   register int j;
+   register int k;
+ 
+   actrow = NEW2(ntokens, short);
+ 
+   k = action_row(0);
+   fprintf(ftable, "\nstatic const short yydefact[] = {%6d", k);
+   save_row(0);
+ 
+   j = 10;
+   for (i = 1; i < nstates; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       k = action_row(i);
+       fprintf(ftable, "%6d", k);
+       save_row(i);
+     }
+ 
+   fprintf(ftable, "\n};\n");
+   FREE(actrow);
+ }
+ 
+ 
+ 
+ /* Decide what to do for each type of token if seen as the lookahead token in specified state.
+    The value returned is used as the default action (yydefact) for the state.
+    In addition, actrow is filled with what to do for each kind of token,
+    index by symbol number, with zero meaning do the default action.
+    The value MINSHORT, a very negative number, means this situation
+    is an error.  The parser recognizes this value specially.
+ 
+    This is where conflicts are resolved.  The loop over lookahead rules
+    considered lower-numbered rules last, and the last rule considered that likes
+    a token gets to handle it.  */
+ 
+ int action_row(int state)
+ {
+   register int i;
+   register int j;
+   register int k;
+   register int m;
+   register int n;
+   register int count;
+   register int default_rule;
+   register int nreds;
+   register int max;
+   register int rule;
+   register int shift_state;
+   register int symbol;
+   register unsigned mask;
+   register unsigned *wordp;
+   register reductions *redp;
+   register shifts *shiftp;
+   register errs *errp;
+   int nodefault = 0;  /* set nonzero to inhibit having any default reduction */
+ 
+   for (i = 0; i < ntokens; i++)
+     actrow[i] = 0;
+ 
+   default_rule = 0;
+   nreds = 0;
+   redp = reduction_table[state];
+ 
+   if (redp)
+     {
+       nreds = redp->nreds;
+ 
+       if (nreds >= 1)
+ 	{
+ 	  /* loop over all the rules available here which require lookahead */
+ 	  m = lookaheads[state];
+ 	  n = lookaheads[state + 1];
+ 
+ 	  for (i = n - 1; i >= m; i--)
+ 	    {
+ 	      rule = - LAruleno[i];
+ 	      wordp = LA + i * tokensetsize;
+ 	      mask = 1;
+ 
+ 	      /* and find each token which the rule finds acceptable to come next */
+ 	      for (j = 0; j < ntokens; j++)
+ 		{
+ 		  /* and record this rule as the rule to use if that token follows.  */
+ 		  if (mask & *wordp)
+ 		    actrow[j] = rule;
+ 
+ 		  mask <<= 1;
+ 		  if (mask == 0)
+ 		    {
+ 		      mask = 1;
+ 		      wordp++;
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
+ 
+   shiftp = shift_table[state];
+ 
+   /* now see which tokens are allowed for shifts in this state.
+      For them, record the shift as the thing to do.  So shift is preferred to reduce.  */
+ 
+   if (shiftp)
+     {
+       k = shiftp->nshifts;
+ 
+       for (i = 0; i < k; i++)
+ 	{
+ 	  shift_state = shiftp->shifts[i];
+ 	  if (! shift_state) continue;
+ 
+ 	  symbol = accessing_symbol[shift_state];
+ 
+ 	  if (ISVAR(symbol))
+ 	    break;
+ 
+ 	  actrow[symbol] = shift_state;
+ 
+ 	  /* do not use any default reduction if there is a shift for error */
+ 
+ 	  if (symbol == error_token_number) nodefault = 1;
+ 	}
+     }
+ 
+   errp = err_table[state];
+ 
+   /* See which tokens are an explicit error in this state
+      (due to %nonassoc).  For them, record MINSHORT as the action.  */
+ 
+   if (errp)
+     {
+       k = errp->nerrs;
+ 
+       for (i = 0; i < k; i++)
+ 	{
+ 	  symbol = errp->errs[i];
+ 	  actrow[symbol] = MINSHORT;
+ 	}
+     }
+ 
+   /* now find the most common reduction and make it the default action for this state.  */
+ 
+   if (nreds >= 1 && ! nodefault)
+     {
+       if (consistent[state])
+ 	default_rule = redp->rules[0];
+       else
+ 	{
+ 	  max = 0;
+ 	  for (i = m; i < n; i++)
+ 	    {
+ 	      count = 0;
+ 	      rule = - LAruleno[i];
+     
+ 	      for (j = 0; j < ntokens; j++)
+ 		{
+ 		  if (actrow[j] == rule)
+ 		    count++;
+ 		}
+     
+ 	      if (count > max)
+ 		{
+ 		  max = count;
+ 		  default_rule = rule;
+ 		}
+ 	    }
+     
+ 	  /* actions which match the default are replaced with zero,
+ 	     which means "use the default" */
+     
+ 	  if (max > 0)
+ 	    {
+ 	      for (j = 0; j < ntokens; j++)
+ 		{
+ 		  if (actrow[j] == default_rule)
+ 		    actrow[j] = 0;
+ 		}
+     
+ 	      default_rule = - default_rule;
+ 	    }
+ 	}
+     }
+ 
+   /* If have no default rule, the default is an error.
+      So replace any action which says "error" with "use default".  */
+ 
+   if (default_rule == 0)
+     for (j = 0; j < ntokens; j++)
+       {
+ 	if (actrow[j] == MINSHORT)
+ 	  actrow[j] = 0;
+       }
+ 
+   return (default_rule);
+ }
+ 
+ void save_row(int state)
+ {
+   register int i;
+   register int count;
+   register short *sp;
+   register short *sp1;
+   register short *sp2;
+ 
+   count = 0;
+   for (i = 0; i < ntokens; i++)
+     {
+       if (actrow[i] != 0)
+ 	count++;
+     }
+ 
+   if (count == 0)
+     return;
+ 
+   froms[state] = sp1 = sp = NEW2(count, short);
+   tos[state] = sp2 = NEW2(count, short);
+ 
+   for (i = 0; i < ntokens; i++)
+     {
+       if (actrow[i] != 0)
+ 	{
+ 	  *sp1++ = i;
+ 	  *sp2++ = actrow[i];
+ 	}
+     }
+ 
+   tally[state] = count;
+   width[state] = sp1[-1] - sp[0] + 1;
+ }
+ 
+ /* figure out what to do after reducing with each rule,
+    depending on the saved state from before the beginning
+    of parsing the data that matched this rule.
+ 
+    The yydefgoto table is output now.  The detailed info
+    is saved for putting into yytable later.  */
+ 
+ void goto_actions(void)
+ {
+   register int i;
+   register int j;
+   register int k;
+ 
+   state_count = NEW2(nstates, short);
+ 
+   k = default_goto(ntokens);
+   fprintf(ftable, "\nstatic const short yydefgoto[] = {%6d", k);
+   save_column(ntokens, k);
+ 
+   j = 10;
+   for (i = ntokens + 1; i < nsyms; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       k = default_goto(i);
+       fprintf(ftable, "%6d", k);
+       save_column(i, k);
+     }
+ 
+   fprintf(ftable, "\n};\n");
+   FREE(state_count);
+ }
+ 
+ int default_goto(int symbol)
+ {
+   register int i;
+   register int m;
+   register int n;
+   register int default_state;
+   register int max;
+ 
+   m = goto_map[symbol];
+   n = goto_map[symbol + 1];
+ 
+   if (m == n)
+     return (-1);
+ 
+   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 = -1;
+ 
+   for (i = 0; i < nstates; i++)
+     {
+       if (state_count[i] > max)
+ 	{
+ 	  max = state_count[i];
+ 	  default_state = i;
+ 	}
+     }
+ 
+   return (default_state);
+ }
+ 
+ void save_column(int symbol,int default_state)
+ {
+   register int i;
+   register int m;
+   register int n;
+   register short *sp;
+   register short *sp1;
+   register short *sp2;
+   register int count;
+   register 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 - ntokens + 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;
+ }
+ 
+ 
+ 
+ /* the next few functions decide how to pack 
+    the actions and gotos information into yytable. */
+ 
+ void sort_actions(void)
+ {
+   register int i;
+   register int j;
+   register int k;
+   register int t;
+   register 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++;
+ 	}
+     }
+ }
+ 
+ 
+ 
+ void pack_table(void)
+ {
+   register int i;
+   register int place;
+   register int state;
+ 
+   base = NEW2(nvectors, short);
+   pos = NEW2(nentries, short);
+   table = NEW2(MAXTABLE, short);
+   check = NEW2(MAXTABLE, short);
+ 
+   lowzero = 0;
+   high = 0;
+ 
+   for (i = 0; i < nvectors; i++)
+     base[i] = MINSHORT;
+ 
+   for (i = 0; i < MAXTABLE; i++)
+     check[i] = -1;
+ 
+   for (i = 0; i < nentries; i++)
+     {
+       state = matching_state(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++)
+     {
+       FREE(froms[i]);
+       FREE(tos[i]);
+     }
+ 
+   FREE(froms);
+   FREE(tos);
+   FREE(pos);
+ }
+ 
+ 
+ 
+ int matching_state(int vector)
+ {
+   register int i;
+   register int j;
+   register int k;
+   register int t;
+   register int w;
+   register int match;
+   register int prev;
+ 
+   i = order[vector];
+   if (i >= 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);
+ }
+ 
+ 
+ 
+ int pack_vector(int vector)
+ {
+   register int i;
+   register int j;
+   register int k;
+   register int t;
+   register int loc;
+   register int ok;
+   register short *from;
+   register short *to;
+ 
+   i = order[vector];
+   t = tally[i];
+ 
+   if (t == 0)
+     berror("pack_vector");
+ 
+   from = froms[i];
+   to = tos[i];
+ 
+   for (j = lowzero - from[0]; j < MAXTABLE; j++)
+     {
+       ok = 1;
+ 
+       for (k = 0; ok && k < t; k++)
+ 	{
+ 	  loc = j + from[k];
+ 	  if (loc > MAXTABLE)
+ 	    fatals("maximum table size (%d) exceeded",MAXTABLE,0,0,0,0,0,0,0);
+ 
+ 	  if (table[loc] != 0)
+ 	    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];
+ 	    }
+ 
+ 	  while (table[lowzero] != 0)
+ 	    lowzero++;
+ 
+ 	  if (loc > high)
+ 	    high = loc;
+ 
+ 	  return (j);
+ 	}
+     }
+ 
+   berror("pack_vector");
+   return 0;	/* JF keep lint happy */
+ }
+ 
+ 
+ 
+ /* the following functions output yytable, yycheck
+    and the vectors whose elements index the portion starts */
+ 
+ void output_base(void)
+ {
+   register int i;
+   register int j;
+ 
+   fprintf(ftable, "\nstatic const short yypact[] = {%6d", base[0]);
+ 
+   j = 10;
+   for (i = 1; i < nstates; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", base[i]);
+     }
+ 
+   fprintf(ftable, "\n};\n\nstatic const short yypgoto[] = {%6d", base[nstates]);
+ 
+   j = 10;
+   for (i = nstates + 1; i < nvectors; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", base[i]);
+     }
+ 
+   fprintf(ftable, "\n};\n");
+   FREE(base);
+ }
+ 
+ void output_table(void)
+ {
+   register int i;
+   register int j;
+ 
+   fprintf(ftable, "\n\n#define\tYYLAST\t\t%d\n\n", high);
+   fprintf(ftable, "\nstatic const short yytable[] = {%6d", table[0]);
+ 
+   j = 10;
+   for (i = 1; i <= high; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", table[i]);
+     }
+ 
+   fprintf(ftable, "\n};\n");
+   FREE(table);
+ }
+ 
+ void output_check(void)
+ {
+   register int i;
+   register int j;
+ 
+   fprintf(ftable, "\nstatic const short yycheck[] = {%6d", check[0]);
+ 
+   j = 10;
+   for (i = 1; i <= high; i++)
+     {
+       putc(',', ftable);
+ 
+       if (j >= 10)
+ 	{
+ 	  putc('\n', ftable);
+ 	  j = 1;
+ 	}
+       else
+ 	{
+ 	  j++;
+ 	}
+ 
+       fprintf(ftable, "%6d", check[i]);
+     }
+ 
+   fprintf(ftable, "\n};\n");
+   FREE(check);
+ }
+ 
+ 
+ 
+ /* copy the parser code into the ftable file at the end.  */
+ 
+ void output_parser(void)
+ {
+   register int c;
+ #ifdef DONTDEF
+   FILE *fpars;
+ #else
+ #define fpars fparser
+ #endif
+ 
+   if (pure_parser)
+     fprintf(ftable, "#define YYIMPURE 1\n\n");
+   else
+     fprintf(ftable, "#define YYPURE 1\n\n");
+ 
+ #ifdef DONTDEF	/* JF no longer needed 'cuz open_extra_files changes the
+ 		   currently open parser from bison.simple to bison.hairy */
+   if (semantic_parser)
+     fpars = fparser;
+   else fpars = fparser1;
+ #endif
+ 
+   c = getc(fpars);
+   while (c != EOF)
+     {
+       /* This is a kludgy but easy-to-write way to delete lines
+ 	 that start with `#line'.  */
+       if (nolinesflag)
+ 	if (c == '\n')
+ 	  {
+ 	    putc (c, ftable);
+ 	    c = getc (fpars);
+ 	    if (c == '#')
+ 	      {
+ 		c = getc (fpars);
+ 		if (c == 'l')
+ 		  {
+ 		    c = getc (fpars);
+ 		    if (c == 'i')
+ 		      {
+ 			c = getc (fpars);
+ 			if (c == 'n')
+ 			  {
+ 			    c = getc (fpars);
+ 			    if (c == 'e')
+ 			      {
+ 				while (1)
+ 				  {
+ 				    c = getc (fpars);
+ 				    if (c == '\n' || c < 0)
+ 				      break;
+ 				  }
+ 				c = getc (fpars);
+ 			      }
+ 			    else
+ 			      fprintf (ftable, "#lin");
+ 			  }
+ 			else
+ 			  fprintf (ftable, "#li");
+ 		      }
+ 		    else
+ 		      fprintf (ftable, "#l");
+ 		  }
+ 		else
+ 		  fprintf (ftable, "#");
+ 	      }
+ 	  }
+ 
+       if (c == '$') {
+ #ifdef DONTDEF
+         fprintf(ftable, "#include \"%s\"\n", actfile);
+ #else
+       	/* JF don't #include the action file.  Stuff it right in. */
+ 	rewind(faction);
+ 	for(c=getc(faction);c!=EOF;c=getc(faction))
+ 		putc(c,ftable);
+ #endif
+       } else
+ 	putc(c, ftable);
+       c = getc(fpars);
+     }
+ }
+ 
+ 
+ 
+ void output_program(void)
+ {
+   register int c;
+   extern int lineno;
+ 
+   fprintf(ftable, "#line %d \"%s\"\n", lineno, infile);
+ 
+   c = getc(finput);
+   while (c != EOF)
+     {
+       putc(c, ftable);
+       c = getc(finput);
+     }
+ }
+ 
+ 
+ 
+ void free_itemsets(void)
+ {
+   register core *cp,*cptmp;
+ 
+   FREE(state_table);
+ 
+   for (cp = first_state; cp; cp = cptmp) {
+     cptmp=cp->next;
+     FREE(cp);
+   }
+ }
+ 
+ void free_shifts(void)
+ {
+   register shifts *sp,*sptmp;/* JF derefrenced freed ptr */
+ 
+   FREE(shift_table);
+ 
+   for (sp = first_shift; sp; sp = sptmp) {
+     sptmp=sp->next;
+     FREE(sp);
+   }
+ }
+ 
+ void free_reductions(void)
+ {
+   register reductions *rp,*rptmp;/* JF fixed freed ptr */
+ 
+   FREE(reduction_table);
+ 
+   for (rp = first_reduction; rp; rp = rptmp) {
+     rptmp=rp->next;
+     FREE(rp);
+   }
+ }
+ 


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/parse.y.in
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/parse.y.in:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/parse.y.in	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,763 ----
+ %{
+ #include <malloc.h>
+ #include <string.h>
+ #include "attr.h"
+ int yylex();
+ void yyerror(char* s);
+ #include "symtab.h"
+ /* Global variables */
+ scopeEntry current = NULL;  /* Points to current scope */
+ scopeEntry temp = NULL;     /* Used temporarily for adding and/or
+ 			       removing scopes */
+ %}
+ 
+ %union { int number;
+ 	 tokentype token;
+ 	 BaseType basetype;
+ 	 typeinfo totaltype;
+ 	 namelist names;
+ 	 expnode exps;
+ 	 explist elist;}
+ 
+ %token PROG PERIOD PROC FUNC VAR ARRAY RANGE OF
+ %token INT CHAR BOOL WRITELN THEN ELSE IF DO WHILE
+ %token BEG END ASG NOT TRUE_TOK FALSE_TOK
+ %token <token> ID CCONST ICONST
+ 
+ %type <basetype> stype
+ %type <totaltype> type exp constant lhs var
+ %type <names> idlist vardcl vardcls parmlist parms parm variables
+ %type <elist> explist optexplist
+ 
+ %start program
+ %nonassoc '=' NEQ LT LEQ GEQ GT
+ %left '+' '-' OR
+ %left '*' AND DIV
+ %right NOT
+ 
+ %%
+ program : PROG ID
+         { enterblock(); }
+         ';' block PERIOD 
+         {leaveblock();};
+ 
+ block : variables
+       {
+       /* Seen all the variables so declare them in the current scope */
+ 	 symTabEntry s;
+          namenode tmpnode;
+ 
+ 	 tmpnode = $1.firstname;
+ 	 while ( tmpnode != NULL )
+ 	 {
+             if ( lookup( tmpnode -> name , current ) == NULL )
+ 	    {
+  	       s = declare(tmpnode -> name,tmpnode -> idtype.basetype,
+ 		       tmpnode -> idtype.gentype,tmpnode -> ptype,
+                        tmpnode -> idtype.number, tmpnode -> idtype.endnum);
+ 	    }
+             else
+ 	       printf("\n***Error: duplicate declaration of %s\n", tmpnode ->
+ 		      name);
+ 	    tmpnode = tmpnode -> next;
+ 	 }
+       }
+       procdcls cmpdstmt;
+ 
+ procdcls : procdcls procdcl | /* empty */ ;
+ 
+ procdcl : PROC ID 
+         {  
+ 	   symTabEntry find;
+ 
+ 	   if (lookup($2.str,current) == NULL)
+ 	      find = declare($2.str,VOIDTYPE,PROCTYPE,NOTPARM,-1,-1);
+ 	   /* Just make a spot in the outerscope to hold the name of the */
+ 	   /* procedure */
+ 	   else
+ 	      printf("\n***Error: duplicate declaration of %s\n",$2.str);
+ 	   enterblock();
+            procentry($2.str,PROCTYPE);
+ 	} 
+         parmlist
+         {           /* After we have seen the parmlist, install it and */
+            int n;   /* update the number field */
+ 	   
+ 	   n = installparms($4);
+ 	   current -> procedure -> number = n;
+         }
+         ';' block ';'
+         {
+ 	   symTabEntry find;
+ 	   
+ 	   find = lookup($2.str, current -> outerscope);  /* Before we leave the block */
+ 	   if ( find != NULL )                            /* We must transfer the link */
+ 	   {                                              /* to the outer scope        */
+ 	      find -> number = current -> procedure -> number;
+ 	      find -> formals = current -> procedure -> formals;
+ 	   }
+            leaveblock();
+ 	}
+ 	| FUNC ID
+         {   /* Same as above up until where 'stype' is */
+ 	   symTabEntry find;
+ 	   if (lookup($2.str,current) == NULL)
+ 	      find = declare($2.str,VOIDTYPE,FUNCTYPE,NOTPARM,-1,-1);
+ 	   else
+ 	      printf("\n***Error: duplicate declaration of %s\n",$2.str);
+ 	   enterblock();
+            procentry($2.str,FUNCTYPE);
+         } 
+         parmlist
+         {
+ 	   int n;
+ 	   
+ 	   n = installparms($4);
+ 	   current -> procedure -> number = n;
+ 	}
+         ':' stype ';'
+          { finishfunc($7);
+ 	   /* We NOW know what type it returns so record it */}  
+ 	block ';'
+         {
+ 	   symTabEntry find;
+ 	  
+ 	   find = lookup($2.str, current -> outerscope );
+ 	   if ( find != NULL )
+ 	   {   /* Before we leave the block, we must make the link in the outer scope */
+ 	      find -> number = current -> procedure -> number;
+ 	      find -> basetype = current -> procedure -> basetype;
+ 	      find -> formals = current -> procedure -> formals;
+ 	   }
+            leaveblock(); 
+ 	}
+ 	;
+ parmlist : '(' parms ')'
+          { $$ = $2; }    /* Pass up the list of params */
+ 	 | /* empty */
+          { $$.firstname = NULL;   /* There are no params so the list is NULL */
+ 	   $$.lastname = NULL; };
+ 
+ parms : parms ';' parm
+         {  /* Link the current list to the new parmlist and send it up */
+ 	   $1.lastname -> next = $3.firstname;
+ 	   $$.firstname = $1.firstname;
+ 	   $$.lastname = $3.lastname;
+ 	}
+ 	| parm   
+         { $$ = $1; }; /* Send up the base case */
+ 
+ parm :  VAR vardcl	                  
+         {  /* We know that these are pass by reference so record
+ 	      it in all the nodes */
+ 	   namenode tmpnode;
+ 	   
+ 	   tmpnode = $2.firstname;
+ 	   while ( tmpnode != NULL )
+ 	   {
+ 	      tmpnode -> ptype = REFPARM;
+ 	      tmpnode = tmpnode -> next;
+ 	   }
+ 	   $$ = $2; /* Send up the new list */
+ 	}
+ 	| vardcl                          
+         {  /* We know that these are pass by value so record
+ 	      it in all the nodes */
+ 	   namenode tmpnode;
+ 	   
+ 	   tmpnode = $1.firstname;
+ 	   while ( tmpnode != NULL )
+ 	   {
+ 	      tmpnode -> ptype = VALPARM;
+ 	      tmpnode = tmpnode -> next;
+ 	   }
+ 	   $$ = $1; /* Send up the new list */
+ 	};
+ 
+ variables: /* empty */ 
+         { $$.firstname = NULL;  /* No variables = no list */
+ 	  $$.lastname = NULL; }
+ 	| VAR vardcls           /* Pass up the list of variables */
+         { $$ = $2; };
+ 
+ vardcls	: vardcls vardcl ';'
+         {  /* Concatenates the 2 namelists */
+            $1.lastname -> next = $2.firstname;
+ 	   $$.firstname = $1.firstname;
+ 	   $$.lastname = $2.lastname;
+         }
+ 	| vardcl ';'
+         { $$ = $1; };
+ vardcl	: idlist ':' type
+         {  /* We have a list of IDs and we have their type so
+ 	      we can now record them to be all of the same type */
+ 	   namenode tmpnode;
+ 
+ 	   tmpnode = $1.firstname;
+ 	   while ( tmpnode != NULL )
+ 	   {
+ 	      tmpnode->idtype.basetype = $3.basetype;
+ 	      tmpnode->idtype.gentype = $3.gentype;
+ 	      tmpnode->idtype.number = $3.number;
+ 	      tmpnode->idtype.endnum = $3.endnum;
+ 	      tmpnode->ptype = NOTPARM;
+               tmpnode = tmpnode -> next;
+ 	   }
+            $$ = $1; /* Send up the new list */
+         };
+ idlist	: idlist ',' ID
+         {  /* Hook the new ID to the current list of IDs */
+ 	   namenode tmpname1 = NULL;
+ 
+ 	   tmpname1 = (namenode) malloc(sizeof(struct _namenode));
+ 	   tmpname1 -> name = $3.str;
+ 	   tmpname1 -> next = NULL;
+            $1.lastname -> next = tmpname1;
+            $$.firstname = $1.firstname;
+ 	   $$.lastname = tmpname1;
+         }
+         | ID
+         {  /* Start the linked list with the first ID */
+ 	   namenode tmpname1 = NULL;
+ 	
+ 	   tmpname1 = (namenode) malloc(sizeof(struct _namenode));
+ 	   tmpname1 -> name = $1.str;
+ 	   tmpname1 -> next = NULL;
+ 	   $$.firstname = tmpname1;
+ 	   $$.lastname = tmpname1;
+         }
+ 	;
+ type	: ARRAY '[' ICONST RANGE ICONST ']' OF stype
+         { if ($3.num > $5.num)
+ 	  {
+ 	     printf("\n***Error: lower bound exceeds upper bound\n");
+ 	     $$.basetype = $8;   /* Basetype is whatever 'stype' was */
+ 	     $$.gentype = ARRAYTYPE;
+ 	     $$.number = $5.num;
+ 	     $$.endnum = $3.num;
+ 	  }
+           else
+ 	  {
+              $$.basetype = $8;   /* Basetype is whatever 'stype' was */
+              $$.gentype = ARRAYTYPE;
+ 	     $$.number = $3.num;
+ 	     $$.endnum = $5.num;
+           }
+ 	}
+ 	| stype
+         {   
+            $$.basetype = $1;
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1;
+         };
+ 
+ stype	: INT	                    { $$ = INTTYPE; /* Send up the basetypes */ }
+ 	| CHAR	                    { $$ = CHARTYPE;                            }
+ 	| BOOL	                    { $$ = BOOLTYPE;                            };
+ 
+ stmtlist : stmtlist ';' stmt      {   }
+ 	| stmt                    {   };
+ 
+ stmt	: ifstmt                  {   }
+ 	| wstmt                   {   }
+ 	| astmt                   {   }
+ 	| procstmt                {   }
+ 	| cmpdstmt                {   }
+ 	| writestmt               {   };
+ 
+ writestmt: WRITELN '(' exp ')'
+         { if (( $3.basetype == INTTYPE ) || ( $3.basetype == STRINGTYPE ))
+ 	  {  /* Must be a string or int */
+ 	     if ( $3.gentype != NOTYPE )
+ 	        printf("\n***Error: illegal type for writeln\n"); /* No arrays or such */
+ 	  }
+ 	  else
+ 	     printf("\n***Error: illegal type for writeln\n"); /* Only ints and strings */
+ 	};
+ 
+ procstmt: ID optexplist
+         {
+            symTabEntry s;
+ 	   
+ 	   s = lookupALL($1.str);
+ 	   if ( s == NULL )       /* ID not found */
+ 	      printf("\n***Error: undeclared identifier %s\n",$1.str);
+ 	   else
+ 	   {
+ 	      if ( s -> gentype != PROCTYPE ) /* Found, but not a procedure */
+ 	         printf("\n***Error: id %s is not a procedure\n",$1.str);
+ 	      else
+ 	      {  /* Found and it is a procedure so check the parameters */
+ 		 int check;
+ 		 check = checkparams( s -> formals , $2 );
+ 	      }
+ 	   }
+         }
+ 	;
+ ifstmt	: ifhead THEN stmt ELSE stmt
+ 	| ifhead THEN stmt
+ 	;
+ ifhead	: IF exp
+         {  /* only booleans */
+ 	   if ($2.basetype != BOOLTYPE)
+ 	      printf("\n***Error: exp in if stmt must be boolean\n");
+ 	}
+ 	;
+ wstmt	: whead DO stmt
+ 	;
+ whead	: WHILE exp
+         {  /* only booleans */
+ 	   if ($2.basetype != BOOLTYPE)
+ 	      printf("\n***Error: exp in while stmt must be boolean\n");
+ 	};
+ 
+ cmpdstmt: BEG stmtlist END;
+ 
+ astmt : lhs exp
+         {  /* Make sure the assignment types match */
+            if (!(match($1,$2)))
+ 	      printf("\n***Error: assignment types do not match\n");
+         };
+ 
+ lhs	: var ASG
+         { $$ = $1; };
+ 
+ optexplist: /* empty */
+         { $$.firstexp = NULL;   /* No optexplist = NULL list */
+ 	  $$.lastexp = NULL; }
+ 	| '(' explist ')'
+         { $$ = $2; };
+ 
+ explist : explist ',' exp
+         {  /* Hook the new expression type to the current list */
+ 	   expnode tmpnode;
+ 	   
+ 	   tmpnode = makeexp($3);
+ 	   $1.lastexp -> next = tmpnode;
+ 	   $$.firstexp = $1.firstexp;
+ 	   $$.lastexp = tmpnode;
+         }
+ 	| exp
+         {  /* Start the list with the first expression */
+ 	   expnode tmpnode;
+ 	   
+ 	   tmpnode = makeexp($1);
+ 	   $$.firstexp = tmpnode;
+ 	   $$.lastexp = tmpnode;
+         };
+ 
+ exp	: exp '+' exp
+         {  /* '+' requires integers */
+ 
+ 	   if (( $1.basetype != INTTYPE ) || ( $3.basetype != INTTYPE ) ||
+                ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+               printf("\n***Error: operands of '+' must be integers\n");
+            $$.basetype = INTTYPE;
+            $$.gentype = NOTYPE;
+            $$.number = -1;
+            $$.endnum = -1;
+         }
+ 	| exp '-' exp
+ 	{  /* '-' requires integers */
+ 
+ 	   if (( $1.basetype != INTTYPE ) || ( $3.basetype != INTTYPE ) ||
+                ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+               printf("\n***Error: operands of '-' must be integers\n");
+            $$.basetype = INTTYPE;
+            $$.gentype = NOTYPE;
+            $$.number = -1;
+            $$.endnum = -1;
+ 	}
+ 	| '-' exp %prec NOT
+         {  /* unary '-' requires an integer */
+ 
+            if (( $2.basetype != INTTYPE ) || ( $2.gentype != NOTYPE ))
+ 	      printf("\n***Error: right operand of '-' must be an integer\n");
+ 	   $$.basetype = INTTYPE;
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1;
+ 	}
+ 	| exp '*' exp
+         {  /* '*' requires integers */
+ 
+            if (( $1.basetype != INTTYPE ) || ( $3.basetype != INTTYPE ) ||
+                ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+               printf("\n***Error: operands of '*' must be integers\n");
+            $$.basetype = INTTYPE;
+            $$.gentype = NOTYPE;
+            $$.number = -1;
+            $$.endnum = -1;
+         }
+ 	| exp DIV exp
+         {  /* DIV requires integers */
+ 
+ 	   if (( $1.basetype != INTTYPE ) || ( $3.basetype != INTTYPE ) ||
+ 	       ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+ 	      printf("\n***Error: operands of div must be integers\n");
+ 	   $$.basetype = INTTYPE;
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1;
+         }
+ 	| exp NEQ exp
+         {  /* '<>' requires the same types AND only base types */
+ 
+ 	   if ( $1.basetype != $3.basetype )
+               printf("\n***Error: operands of '<>' have different types\n");
+            if (( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+ 	      printf("\n***Error: operands of '<>' must be base types\n");
+            $$.basetype = BOOLTYPE;
+            $$.gentype = NOTYPE;
+            $$.number = -1;
+            $$.endnum = -1;
+         }
+ 	| exp '=' exp                    
+         {  /* '=' requires the same types AND only base types */
+ 
+            if (($1.basetype != $3.basetype ) || ( $1.gentype != NOTYPE ) ||
+                ( $3.gentype != NOTYPE ))
+ 	      printf("\n***Error: operands of '=' have different types\n");
+ 	   $$.basetype = BOOLTYPE;
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1;
+         }
+ 	| exp GEQ exp                    
+         {  /* '>=' requires integers */
+ 
+ 	   if (( $1.basetype != INTTYPE ) || ( $3.basetype != INTTYPE ) ||
+                ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+               printf("\n***Error: operands of '>=' must be integers\n");
+            $$.basetype = BOOLTYPE;
+            $$.gentype = NOTYPE;
+            $$.number = -1;
+            $$.endnum = -1;
+         }
+ 	| exp GT exp	                 
+         {  /* '>' requires integers */
+ 
+ 	   if (( $1.basetype != INTTYPE ) || ( $3.basetype != INTTYPE ) ||
+                ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+               printf("\n***Error: operands of '>' must be integers\n");
+            $$.basetype = BOOLTYPE;
+            $$.gentype = NOTYPE;
+            $$.number = -1;
+            $$.endnum = -1;
+         }
+ 	| exp LT exp
+         {  /* '<' requires integers */
+ 
+            if (( $1.basetype != INTTYPE ) || ( $3.basetype != INTTYPE ) ||
+                ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+               printf("\n***Error: operands of '<' must be integers\n");
+            $$.basetype = BOOLTYPE;
+            $$.gentype = NOTYPE;
+            $$.number = -1;
+            $$.endnum = -1;
+         }
+ 	| exp LEQ exp
+         {  /* '<=' requires integers */
+ 
+ 	   if (( $1.basetype != INTTYPE ) || ( $3.basetype != INTTYPE ) ||
+ 	       ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+ 	      printf("\n***Error: operands of '<=' must be integers\n");
+ 	   $$.basetype = BOOLTYPE;
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1;
+         }
+         | exp AND exp
+         {  /* AND requires booleans */
+ 
+ 	   if (( $1.basetype != BOOLTYPE ) || ( $3.basetype != BOOLTYPE ) ||
+ 	       ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+ 	      printf("\n***Error: operands of AND must be boolean\n");
+            $$.basetype = BOOLTYPE;
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1;
+         }
+ 	| exp OR exp
+         {  /* OR requires booleans */
+ 
+ 	   if (( $1.basetype != BOOLTYPE ) || ( $3.basetype != BOOLTYPE ) ||
+ 	       ( $1.gentype != NOTYPE ) || ( $3.gentype != NOTYPE ))
+ 	      printf("\n***Error: operands of OR must be boolean\n");
+ 	   $$.basetype = BOOLTYPE;
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1;
+ 	}
+         | NOT exp
+         {  /* NOT requires a boolean */
+ 
+ 	   if (( $2.basetype != BOOLTYPE ) || ( $2.gentype != NOTYPE ))
+ 	      printf("\n***Error: right operand of NOT must be boolean\n");
+ 	   $$.basetype = $2.basetype;
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1;
+         }
+ 	| '(' exp ')'                    
+         {  /* Simply pass up the type of the expression within the
+ 	      parentheses */
+ 
+            $$.basetype = $2.basetype;
+ 	   $$.gentype = $2.gentype;
+ 	   $$.number = $2.number;
+ 	   $$.endnum = $2.endnum;
+         }
+ 	| ID '(' explist ')'                    
+         {  /* This should be a function in an expression */
+ 
+            symTabEntry s;     
+  
+            s = lookupALL($1.str);
+ 	   if ( s == NULL )
+ 	   {
+ 	      printf("\n***Error: undeclared identifier: %s\n",$1.str);
+ 	      $$.basetype = VOIDTYPE;
+ 	      $$.gentype = NOTYPE;
+ 	      $$.number = -1;
+ 	      $$.endnum = -1;
+ 	   }
+ 	   else
+ 	   {
+ 	      if ( s -> gentype == FUNCTYPE ) /* Make sure it is a function */
+ 	      {
+ 	         int check;
+ 		 
+ 		 check = checkparams( s -> formals , $3 );
+ 		 $$.basetype = s -> basetype;  /* Take the return type */
+ 		 $$.gentype = NOTYPE;          /* of the function      */
+ 		 $$.number = -1;
+ 		 $$.endnum = -1;
+ 	      }
+ 	      else
+ 	      {  /* Not a function : ERROR !!  */
+ 
+ 		 printf("\n***Error: id %s is not a function\n",$1.str);
+ 		 $$.basetype = VOIDTYPE;
+ 		 $$.gentype = NOTYPE;
+ 		 $$.number = -1;
+ 		 $$.endnum = -1;
+ 	      }
+ 	   }
+         }
+ 	| ID                    
+         {  /* This can be a variable or a function with no parameters */
+  
+ 	   symTabEntry s;
+ 
+ 	   s = lookupALL($1.str);
+ 	   if ( s == NULL)
+ 	   {
+ 	      printf("\n***Error: undeclared identifier: %s\n",$1.str);
+ 	      $$.basetype = VOIDTYPE;
+ 	      $$.gentype = NOTYPE;
+ 	      $$.number = -1;
+ 	      $$.endnum = -1;
+ 	   }
+ 	   else
+ 	   {  /* No procedures allowed in expressions */
+ 
+ 	      if (s -> gentype == PROCTYPE )
+ 	      {
+ 	         printf("\n***Error: illegal type for expression\n");
+ 		 $$.basetype = VOIDTYPE;
+ 		 $$.gentype = NOTYPE;
+ 		 $$.number = -1;
+ 		 $$.endnum = 1;
+ 	      }
+ 	      if ( s -> gentype == ARRAYTYPE )
+ 	      {
+ 		 $$.basetype = s -> basetype;
+ 		 $$.gentype = ARRAYTYPE;
+ 		 $$.number = s -> number;
+ 		 $$.endnum = s -> endnum;
+ 	      }
+ 	      if ( s -> gentype == FUNCTYPE )
+ 	      {  /* Can be a function ONLY if there are no formal parameters */
+ 
+ 		 if ( s -> formals != NULL )
+ 		    printf("\n***Error: too few actual parameters\n");
+ 		 $$.basetype = s -> basetype;
+ 		 $$.gentype = NOTYPE;
+ 		 $$.number = -1;
+ 		 $$.endnum = -1;
+ 	      }
+ 	      if ( s -> gentype == NOTYPE )
+ 	      {
+ 		 $$.basetype = s -> basetype;
+ 		 $$.gentype = NOTYPE;
+ 		 $$.number = -1;
+ 		 $$.endnum = -1;
+ 	      }
+ 	   }
+ 	}
+ 	| ID '[' exp ']'                    
+         {  /* This should be an array only */
+   
+ 	   symTabEntry s;
+ 
+            s = lookupALL($1.str);
+ 	   if ( s == NULL)
+ 	   {
+ 	      printf("\n***Error: undeclared identifier: %s\n",$1.str);
+ 	      $$.basetype = VOIDTYPE;
+ 	      $$.gentype = NOTYPE;
+ 	      $$.number = -1;
+ 	      $$.endnum = -1;
+ 	   }
+ 	   else
+ 	   {  /* Check variable AND the subscript */
+ 
+               if ( s -> gentype != ARRAYTYPE )
+ 	         printf("\n***Error: id %s is not an array\n",$1.str);
+ 	      if (( $3.basetype != INTTYPE ) || ( $3.gentype != NOTYPE ))
+ 		 printf("\n***Error: subscript exp not type integer\n");
+ 	      $$.basetype = s -> basetype;
+ 	      $$.gentype = NOTYPE;
+ 	      $$.number = -1;
+ 	      $$.endnum = -1;
+ 	   }
+         }
+ 	| constant { $$ = $1; /* Simply send up the constant's type */ };
+ 
+ var	: ID
+         {  /* Left hand side without '[' and ']' can ONLY be a variable OR
+ 	      the function from the CURRENT scope */
+ 
+ 	   symTabEntry s;
+ 	   
+ 	   s = lookupALL($1.str);
+ 	   if ( s == NULL)
+ 	   {
+ 	      printf("\n***Error: undeclared identifier: %s\n",$1.str);
+ 	      $$.basetype = VOIDTYPE;
+ 	      $$.gentype = NOTYPE;
+ 	      $$.number = -1;
+ 	      $$.endnum = -1;
+ 	   }
+ 	   else
+ 	   {  /* Function can only be on the left side if it is
+ 		 defining the current function */
+ 
+ 	      if ( s -> gentype == FUNCTYPE )
+ 	      {
+ 		 if ( s == current -> procedure )
+ 		 {
+ 		    $$.basetype = s -> basetype;
+ 		    $$.gentype = NOTYPE;
+ 		    $$.number = -1;
+ 		    $$.endnum = -1;
+ 		 }
+ 		 else
+ 		 {  /* Otherwise, it is an error */
+ 
+ 	            printf("\n***Error: function name on left side of :=\n");
+ 		    $$.basetype = VOIDTYPE;
+ 		    $$.gentype = NOTYPE;
+ 		    $$.number = -1;
+ 		    $$.number = -1;
+ 		 }
+ 	      }
+ 	      else
+ 	      {
+ 	         if ( s -> gentype == NOTYPE )
+ 	         {
+ 	            $$.basetype = s -> basetype;
+ 		    $$.gentype = NOTYPE;
+ 		    $$.number = s -> number;
+                     $$.endnum = s -> endnum;
+ 	         }
+ 	         else
+ 		 {  /* No arrays or procedures on the left side */
+ 
+ 		    printf("\n***Error: assignment to nonscalar\n");
+ 		    $$.basetype = VOIDTYPE;
+ 		    $$.gentype = NOTYPE;
+ 		    $$.number = -1;
+ 		    $$.endnum = -1;
+ 		 }
+ 	      }
+ 	   }
+ 	}
+ 	| ID '[' exp ']'
+         {  /* This should be an array AND an index */
+ 
+ 	   symTabEntry s;
+ 
+ 	   s = lookupALL($1.str);
+ 	   if ( s == NULL )
+ 	   {
+ 	      printf("\n***Error: undeclared identifier: %s\n",$1.str);
+ 	      $$.basetype = VOIDTYPE;
+ 	      $$.gentype = NOTYPE;
+ 	      $$.number = -1;
+ 	      $$.endnum = -1;
+ 	   }
+            else
+ 	   {  /* Check to make sure it IS an array and the index is
+ 		 an integer */
+ 
+ 	      if ( s -> gentype == ARRAYTYPE )
+ 	      {
+ 	         if (( $3.basetype != INTTYPE ) || ( $3.gentype != NOTYPE ))
+ 		    printf("\n***Error: subscript exp is not type integer\n");
+                  $$.basetype = s -> basetype;
+ 		 $$.gentype = NOTYPE;
+ 		 $$.number = -1;
+ 		 $$.endnum = -1;
+ 	      }
+ 	      else
+ 	      {  /* This is not an array */
+ 		 printf("\n***Error: id %s is not an array\n",$1.str);
+ 		 $$.basetype = VOIDTYPE;
+ 		 $$.gentype = NOTYPE;
+ 		 $$.number = -1;
+ 		 $$.endnum = -1;
+ 	      }
+ 	   }
+         };
+ 
+ constant: ICONST
+         {  $$.basetype = INTTYPE; /* Basic integer */
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+            $$.endnum = -1; }
+ 	| CCONST
+         {  
+ 	   if ( strlen($1.str) == 3 )  /* Single character */
+ 	      $$.basetype = CHARTYPE;
+ 	   else
+ 	      $$.basetype = STRINGTYPE; /* String */
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+            $$.endnum = -1; }
+ 	| TRUE_TOK
+         { $$.basetype = BOOLTYPE;  /* TRUE and FALSE are both booleans */
+ 	   $$.gentype = NOTYPE;
+ 	   $$.number = -1;
+ 	   $$.endnum = -1; }
+ 	| FALSE_TOK
+         {  $$.basetype = BOOLTYPE;
+            $$.gentype = NOTYPE;
+            $$.number = -1;
+            $$.endnum = -1; };
+ 
+ %%
+ 
+ void
+ yyerror(char* s) {
+     fprintf(stderr,"%s\n",s);
+     }
+ 
+ int
+ main() {
+     printf("1\t");
+     yyparse();
+     return 1;
+     }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/print.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/print.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/print.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,226 ----
+ /* Print information on generated parser, for bison,
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #include <stdio.h>
+ #include "machine.h"
+ #include "new.h"
+ #include "files.h"
+ #include "gram.h"
+ #include "state.h"
+ 
+ 
+ extern char **tags;
+ extern int nstates;
+ extern short *accessing_symbol;
+ extern core **state_table;
+ extern shifts **shift_table;
+ extern errs **err_table;
+ extern reductions **reduction_table;
+ extern char *consistent;
+ extern char any_conflicts;
+ extern char *conflicts;
+ 
+ extern void conflict_log(void);
+ extern void verbose_conflict_log(void);
+ extern void print_reductions(int state);
+ 
+ void print_token(int extnum,int token);
+ void print_state(int state);
+ void print_core(int state);
+ void print_actions(int state);
+ 
+ void terse(void)
+ {
+   if (any_conflicts)
+     {
+       conflict_log();
+     }
+ }
+ 
+ void verbose(void)
+ {
+   register int i;
+ 
+   if (any_conflicts)
+     verbose_conflict_log();
+ 
+   fprintf(foutput, "\n\ntoken types:\n");
+   print_token (-1, 0);
+   if (translations)
+     {
+       for (i = 0; i <= max_user_token_number; i++)
+ 	/* Don't mention all the meaningless ones.  */
+ 	if (token_translations[i] != 2)
+ 	  print_token (i, token_translations[i]);
+     }
+   else
+     for (i = 1; i < ntokens; i++)
+       print_token (i, i);
+ 
+   for (i = 0; i < nstates; i++)
+     {
+       print_state(i);
+     }
+ }
+ 
+ void print_token(int extnum,int token)
+ {
+   fprintf(foutput, " type %d is %s\n", extnum, tags[token]);
+ }
+ 
+ void print_state(int state)
+ {
+   fprintf(foutput, "\n\nstate %d\n\n", state);
+   print_core(state);
+   print_actions(state);
+ }
+ 
+ void print_core(int state)
+ {
+   register int i;
+   register int k;
+   register int rule;
+   register core *statep;
+   register short *sp;
+   register short *sp1;
+ 
+   statep = state_table[state];
+   k = statep->nitems;
+ 
+   if (k == 0) return;
+ 
+   for (i = 0; i < k; i++)
+     {
+       sp1 = sp = ritem + statep->items[i];
+ 
+       while (*sp > 0)
+ 	sp++;
+ 
+       rule = -(*sp);
+       fprintf(foutput, "    %s  ->  ", tags[rlhs[rule]]);
+ 
+       for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
+ 	{
+ 	  fprintf(foutput, "%s ", tags[*sp]);
+ 	}
+ 
+       putc('.', foutput);
+ 
+       while (*sp > 0)
+ 	{
+ 	  fprintf(foutput, " %s", tags[*sp]);
+ 	  sp++;
+ 	}
+ 
+       fprintf (foutput, "   (%d)", rule);
+       putc('\n', foutput);
+     }
+ 
+   putc('\n', foutput);
+ }
+ 
+ void print_actions(int state)
+ {
+   register int i;
+   register int k;
+   register int state1;
+   register int symbol;
+   register shifts *shiftp;
+   register errs *errp;
+   register reductions *redp;
+   register int rule;
+ 
+   shiftp = shift_table[state];
+   redp = reduction_table[state];
+   errp = err_table[state];
+ 
+   if (!shiftp && !redp)
+     {
+       fprintf(foutput, "    NO ACTIONS\n");
+       return;
+     }
+ 
+   if (shiftp)
+     {
+       k = shiftp->nshifts;
+ 
+       for (i = 0; i < k; i++)
+ 	{
+ 	  if (! shiftp->shifts[i]) continue;
+ 	  state1 = shiftp->shifts[i];
+ 	  symbol = accessing_symbol[state1];
+ /*	  if (ISVAR(symbol)) break;  */
+ 	  fprintf(foutput, "    %-4s\tshift  %d\n", tags[symbol], state1);
+ 	}
+ 
+       if (i > 0)
+ 	putc('\n', foutput);
+     }
+   else
+     {
+       i = 0;
+       k = 0;
+     }
+ 
+   if (errp)
+     {
+       k = errp->nerrs;
+ 
+       for (i = 0; i < k; i++)
+ 	{
+ 	  if (! errp->errs[i]) continue;
+ 	  symbol = errp->errs[i];
+ 	  fprintf(foutput, "    %-4s\terror (nonassociative)\n", tags[symbol]);
+ 	}
+ 
+       if (i > 0)
+ 	putc('\n', foutput);
+     }
+   else
+     {
+       i = 0;
+       k = 0;
+     }
+ 
+   if (consistent[state] && redp)
+     {
+       rule = redp->rules[0];
+       symbol = rlhs[rule];
+       fprintf(foutput, "    $default\treduce  %d  (%s)\n\n",
+      	        rule, tags[symbol]);
+     }
+   else if (redp)
+     {
+       print_reductions(state);
+     }
+ 
+   if (i < k)
+     {
+       for (; i < k; i++)
+ 	{
+ 	  if (! shiftp->shifts[i]) continue;
+ 	  state1 = shiftp->shifts[i];
+ 	  symbol = accessing_symbol[state1];
+ 	  fprintf(foutput, "    %-4s\tgoto  %d\n", tags[symbol], state1);
+ 	}
+ 
+       putc('\n', foutput);
+     }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/reader.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/reader.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/reader.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,1738 ----
+ /* Input parser for bison
+    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* read in the grammar specification and record it in the format described in gram.h.
+   All guards are copied into the fguard file and all actions into faction,
+   in each case forming the body of a C function (yyguard or yyaction)
+   which contains a switch statement to decide which guard or action to execute.
+ 
+ The entry point is reader().  */
+ 
+ #include <stdio.h>
+ #include <ctype.h>
+ #include "files.h"
+ #include "new.h"
+ #include "symtab.h"
+ #include "lex.h"
+ #include "gram.h"
+ 
+ 
+ #define	LTYPESTR	"\n#ifndef YYLTYPE\ntypedef\n  struct yyltype\n\
+     {\n      int first_line;\n      int first_column;\n\
+       int last_line;\n      int last_column;\n    }\n\
+   yyltype;\n\n#define YYLTYPE yyltype\n#endif\n\n"
+ 
+ /* Number of slots allocated (but not necessarily used yet) in `rline'  */
+ int rline_allocated;
+ 
+ extern int definesflag;
+ extern int nolinesflag;
+ extern bucket *symval;
+ extern int numval;
+ extern int failure;
+ extern int expected_conflicts;
+ 
+ typedef
+   struct symbol_list
+     {
+       struct symbol_list *next;
+       bucket *sym;
+       bucket *ruleprec;
+     }
+   symbol_list;
+ 
+ 
+ 
+ int lineno;
+ symbol_list *grammar;
+ int start_flag;
+ bucket *startval;
+ char **tags;
+ 
+ static int typed;  /* nonzero if %union has been seen.  */
+ 
+ static int lastprec;  /* incremented for each %left, %right or %nonassoc seen */
+ 
+ static int gensym_count;  /* incremented for each generated symbol */
+ 
+ static bucket *errtoken;
+ 
+ /* Nonzero if any action or guard uses the @n construct.  */
+ static int yylsp_needed;
+ 
+ extern void init_lex(void);
+ extern void tabinit(void);
+ extern void output_headers(void);
+ extern void output_trailers(void);
+ extern void free_symtab(void);
+ extern int skip_white_space(void);
+ extern int parse_percent_token(void);
+ extern void open_extra_files(void);
+ extern void fatal(char *s);
+ extern void fatals(char *fmt,int x1,int x2,int x3,int x4,int x5,int x6,
+                    int x7,int x8);
+ extern int lex(void);
+ extern void done(int k);
+ 
+ void read_declarations(void);
+ void output_ltype(void);
+ void readgram(void);
+ void packsymbols(void);
+ void packgram(void);
+ void copy_definition(void);
+ void parse_token_decl(int what_is,int what_is_not);
+ void parse_type_decl(void);
+ void parse_start_decl(void);
+ void parse_union_decl(void);
+ void parse_expect_decl(void);
+ void parse_assoc_decl(int assoc);
+ int read_signed_integer(FILE *stream);
+ void copy_action(symbol_list *rule,int stack_offset);
+ void unlex(int token);
+ int get_type(void);
+ void record_rule_line(void);
+ void output_token_defines(FILE *file);
+ 
+ void reader(void)
+ {
+ 
+   start_flag = 0;
+   startval = NULL;  /* start symbol not specified yet. */
+ 
+   translations = 0;  /* initially assume token number translation not needed.  */
+ 
+   nsyms = 1;
+   nvars = 0;
+   nrules = 0;
+   nitems = 0;
+   rline_allocated = 10;
+   rline = NEW2(rline_allocated, short);
+ 
+   typed = 0;
+   lastprec = 0;
+ 
+   gensym_count = 0;
+ 
+   semantic_parser = 0;
+   pure_parser = 0;
+   yylsp_needed = 0;
+ 
+   grammar = NULL;
+ 
+   init_lex();
+   lineno = 1;
+ 
+   /* initialize the symbol table.  */
+   tabinit();
+   /* construct the error token */
+   errtoken = getsym("error");
+   errtoken->class = STOKEN;
+   /* construct a token that represents all undefined literal tokens. */
+   /* it is always token number 2.  */
+   getsym("$illegal.")->class = STOKEN;
+   /* Read the declaration section.  Copy %{ ... %} groups to ftable and fdefines file.
+      Also notice any %token, %left, etc. found there.  */
+   fprintf(ftable, "\n/*  A Bison parser, made from %s  */\n\n", infile);
+   read_declarations();
+   /* output the definition of YYLTYPE into the fattrs and fdefines files.  */
+   output_ltype();
+   /* start writing the guard and action files, if they are needed.  */
+   output_headers();
+   /* read in the grammar, build grammar in list form.  write out guards and actions.  */
+   readgram();
+   /* write closing delimiters for actions and guards.  */
+   output_trailers();
+   if (yylsp_needed)
+     fprintf(ftable, "#define YYLSP_NEEDED\n\n");
+   /* assign the symbols their symbol numbers.
+      Write #defines for the token symbols into fdefines if requested.  */
+   packsymbols();
+   /* convert the grammar into the format described in gram.h.  */
+   packgram();
+   /* free the symbol table data structure
+      since symbols are now all referred to by symbol number.  */
+   free_symtab();
+ }
+ 
+ 
+ 
+ /* read from finput until %% is seen.  Discard the %%.
+ Handle any % declarations,
+ and copy the contents of any %{ ... %} groups to fattrs.  */
+ 
+ void read_declarations(void)
+ {
+   register int c;
+   register int tok;
+ 
+   for (;;)
+     {
+       c = skip_white_space();
+ 
+       if (c == '%')
+ 	{
+ 	  tok = parse_percent_token();
+ 
+ 	  switch (tok)
+ 	    {
+ 	    case TWO_PERCENTS:
+ 	      return;
+ 
+ 	    case PERCENT_LEFT_CURLY:
+ 	      copy_definition();
+ 	      break;
+ 
+ 	    case TOKEN:
+ 	      parse_token_decl (STOKEN, SNTERM);
+ 	      break;
+ 	
+ 	    case NTERM:
+ 	      parse_token_decl (SNTERM, STOKEN);
+ 	      break;
+ 	
+ 	    case TYPE:
+ 	      parse_type_decl();
+ 	      break;
+ 	
+ 	    case START:
+ 	      parse_start_decl();
+ 	      break;
+ 	
+ 	    case UNION:
+ 	      parse_union_decl();
+ 	      break;
+ 	
+ 	    case EXPECT:
+ 	      parse_expect_decl();
+ 	      break;
+ 	
+ 	    case LEFT:
+ 	      parse_assoc_decl(LEFT_ASSOC);
+ 	      break;
+ 
+ 	    case RIGHT:
+ 	      parse_assoc_decl(RIGHT_ASSOC);
+ 	      break;
+ 
+ 	    case NONASSOC:
+ 	      parse_assoc_decl(NON_ASSOC);
+ 	      break;
+ 
+ 	    case SEMANTIC_PARSER:
+ 	      semantic_parser = 1;
+ 	      open_extra_files();
+ 	      break;
+ 
+ 	    case PURE_PARSER:
+ 	      pure_parser = 1;
+ 	      break;
+ 
+ 	    default:
+ 	      fatal("junk after % in definition section");
+ 	    }
+ 	}
+       else if (c == EOF)
+         fatal("no input grammar");
+       else/* JF changed msg */
+         fatals("Unrecognized char '%c' in declaration section",c,0,0,0,0,0,
+                0,0);
+ 
+     }
+ }
+ 
+ 
+ /* copy the contents of a %{ ... %} into the definitions file.
+ The %{ has already been read.  Return after reading the %}.  */
+ void copy_definition(void)
+ {
+   register int c;
+   register int match;
+   register int ended;
+   register int after_percent;  /* -1 while reading a character if prev char was % */
+ 
+   if (!nolinesflag)
+     fprintf(fattrs, "#line %d \"%s\"\n", lineno, infile);
+ 
+   after_percent = 0;
+ 
+   c = getc(finput);
+ 
+   for (;;)
+     {
+       switch (c)
+ 	{
+ 	case '\n':
+ 	  putc(c, fattrs);
+ 	  lineno++;
+ 	  break;
+ 
+ 	case '%':
+           after_percent = -1;
+ 	  break;
+ 	      
+ 	case '\'':
+ 	case '"':
+ 	  match = c;
+ 	  putc(c, fattrs);
+ 	  c = getc(finput);
+ 
+ 	  while (c != match)
+ 	    {
+ 	      if (c == EOF || c == '\n')
+ 		fatal("unterminated string");
+ 
+ 	      putc(c, fattrs);
+ 	      
+ 	      if (c == '\\')
+ 		{
+ 		  c = getc(finput);
+ 		  if (c == EOF || c == '\n')
+ 		    fatal("unterminated string");
+ 		  putc(c, fattrs);
+ 		  if (c == '\n')
+ 		    lineno++;
+ 		}
+ 
+ 	      c = getc(finput);
+ 	    }
+ 
+ 	  putc(c, fattrs);
+ 	  break;
+ 
+ 	case '/':
+ 	  putc(c, fattrs);
+ 	  c = getc(finput);
+ 	  if (c != '*')
+ 	    continue;
+ 
+ 	  putc(c, fattrs);
+ 	  c = getc(finput);
+ 
+ 	  ended = 0;
+ 	  while (!ended)
+ 	    {
+ 	      if (c == '*')
+ 		{
+ 		  while (c == '*')
+ 		    {
+ 		      putc(c, fattrs);
+ 		      c = getc(finput);
+ 		    }
+ 
+ 		  if (c == '/')
+ 		    {
+ 		      putc(c, fattrs);
+ 		      ended = 1;
+ 		    }
+ 		}
+ 	      else if (c == '\n')
+ 		{
+ 		  lineno++;
+ 		  putc(c, fattrs);
+ 		  c = getc(finput);
+ 		}
+ 	      else if (c == EOF)
+ 		fatal("unterminated comment in %{ definition");
+ 	      else
+ 		{
+ 		  putc(c, fattrs);
+ 		  c = getc(finput);
+ 		}
+ 	    }
+ 
+ 	  break;
+ 
+ 	case EOF:
+ 	  fatal("unterminated %{ definition");
+ 
+ 	default:
+ 	  putc(c, fattrs);
+ 	}
+ 
+       c = getc(finput);
+ 
+       if (after_percent)
+ 	{
+ 	  if (c == '}')
+ 	    return;
+ 	  putc('%', fattrs);
+ 	}
+       after_percent = 0;
+ 
+     }
+ 
+ }
+ 
+ /* parse what comes after %token or %nterm.
+ For %token, what_is is STOKEN and what_is_not is SNTERM.
+ For %nterm, the arguments are reversed.  */
+ 
+ void parse_token_decl(int what_is,int what_is_not)
+ {
+ /*   register int start_lineno; JF */
+   register int token = 0;
+   register int prev;
+   register char *typename = 0;
+   int k;
+   extern char token_buffer[];
+ 
+ /*   start_lineno = lineno; JF */
+ 
+   for (;;)
+     {
+       if(ungetc(skip_white_space(), finput) == '%')
+ 	return;
+ 
+ /*      if (lineno != start_lineno)
+ 	return; JF */
+ 
+       /* we have not passed a newline, so the token now starting is in this declaration */
+       prev = token;
+ 
+       token = lex();
+       if (token == COMMA)
+ 	continue;
+       if (token == TYPENAME)
+ 	{
+ 	  k = strlen(token_buffer);
+ 	  if (typename) free (typename);
+ 	  typename = NEW2(k + 1, char);
+ 	  strcpy(typename, token_buffer);
+ 	}
+       else if (token == IDENTIFIER)
+ 	{
+ 	  if (symval->class == what_is_not)
+ 	    fatals("symbol %s redefined", symval->tag,0,0,0,0,0,0,0);
+ 	  symval->class = what_is;
+ 	  if (what_is == SNTERM)
+ 	    symval->value = nvars++;
+ 
+ 	  if (typename)
+ 	    {
+ 	      if (symval->type_name == NULL)
+ 		symval->type_name = typename;
+ 	      else
+ 		fatals("type redeclaration for %s", symval->tag,0,0,0,0,0,0,0);
+ 	    }
+ 	}
+       else if (prev == IDENTIFIER && token == NUMBER)
+         {
+ 	  symval->user_token_number = numval;
+ 	  translations = 1;
+         }
+       else
+ 	fatal("invalid text in %token or %nterm declaration");
+     }
+ 
+ }
+ 
+ /* parse what comes after %start */
+ 
+ void parse_start_decl(void)
+ {
+   if (start_flag)
+     fatal("multiple %start declarations");
+   start_flag = 1;
+   if (lex() != IDENTIFIER)
+     fatal("invalid %start declaration");
+   startval = symval;
+ }
+ 
+ /* read in a %type declaration and record its information for get_type_name to access */
+ 
+ void parse_type_decl(void)
+ {
+   register int k;
+   register char *name;
+ /*   register int start_lineno; JF */
+ 
+   extern char token_buffer[];
+ 
+   if (lex() != TYPENAME)
+     fatal("ill-formed %type declaration");
+ 
+   k = strlen(token_buffer);
+   name = NEW2(k + 1, char);
+   strcpy(name, token_buffer);
+ 
+ /*   start_lineno = lineno; */
+ 
+   for (;;)
+     {
+       register int t;
+ 
+       if(ungetc(skip_white_space(), finput) == '%')
+ 	return;
+ 
+ /*       if (lineno != start_lineno)
+ 	return; JF */
+ 
+       /* we have not passed a newline, so the token now starting is in this declaration */
+ 
+       t = lex();
+ 
+       switch (t)
+ 	{
+ 
+ 	case COMMA:
+ 	  break;
+ 
+ 	case IDENTIFIER:
+ 	  if (symval->type_name == NULL)
+ 	    symval->type_name = name;
+ 	  else
+ 	    fatals("type redeclaration for %s", symval->tag,0,0,0,0,0,0,0);
+ 
+ 	  break;
+ 
+ 	default:
+ 	  fatal("invalid %type declaration");
+ 	}
+     }
+ }
+ 
+ /* read in a %left, %right or %nonassoc declaration and record its information.  */
+ /* assoc is either LEFT_ASSOC, RIGHT_ASSOC or NON_ASSOC.  */
+ 
+ void parse_assoc_decl(int assoc)
+ {
+   register int k;
+   register char *name = NULL;
+ /*  register int start_lineno; JF */
+   register int prev = 0;	/* JF added = 0 to keep lint happy */
+ 
+   extern char token_buffer[];
+ 
+   lastprec++;  /* assign a new precedence level.  */
+ 
+ /*   start_lineno = lineno; */
+ 
+   for (;;)
+     {
+       register int t;
+ 
+       if(ungetc(skip_white_space(), finput) == '%')
+ 	return;
+ 
+       /* if (lineno != start_lineno)
+ 	return; JF */
+ 
+       /* we have not passed a newline, so the token now starting is in this declaration */
+ 
+       t = lex();
+ 
+       switch (t)
+ 	{
+ 
+ 	case TYPENAME:
+ 	  k = strlen(token_buffer);
+ 	  name = NEW2(k + 1, char);
+ 	  strcpy(name, token_buffer);
+ 	  break;
+ 
+ 	case COMMA:
+ 	  break;
+ 
+ 	case IDENTIFIER:
+ 	  symval->prec = lastprec;
+ 	  symval->assoc = assoc;
+ 	  if (symval->class == SNTERM)
+ 	    fatals("symbol %s redefined", symval->tag,0,0,0,0,0,0,0);
+ 	  symval->class = STOKEN;
+ 	  if (name)
+ 	    { /* record the type, if one is specified */
+ 	      if (symval->type_name == NULL)
+ 		symval->type_name = name;
+ 	      else
+ 		fatals("type redeclaration for %s", symval->tag,0,0,0,0,0,0,0);
+ 	    }
+ 	  break;
+ 
+ 	case NUMBER:
+ 	  if (prev == IDENTIFIER)
+             {
+ 	      symval->user_token_number = numval;
+ 	      translations = 1;
+             }
+           else	  
+ 	    fatal("invalid text in association declaration");
+ 	  break;
+ 
+ 	case SEMICOLON:
+ 	  return;
+ 
+ 	default:
+ 	  fatal("malformatted association declaration");
+ 	}
+ 
+       prev = t;
+ 
+     }
+ }
+ 
+ 
+ 
+ /* copy the union declaration into fattrs (and fdefines),
+    where it is made into the
+    definition of YYSTYPE, the type of elements of the parser value stack.  */
+ 
+ void parse_union_decl(void)
+ {
+   register int c;
+   register int count;
+   register int in_comment;
+ 
+   if (typed)
+     fatal("multiple %union declarations");
+ 
+   typed = 1;
+ 
+   if (!nolinesflag)
+     fprintf(fattrs, "\n#line %d \"%s\"\n", lineno, infile);
+   else
+     fprintf(fattrs, "\n");
+ 
+   fprintf(fattrs, "typedef union");
+   if (fdefines)
+     fprintf(fdefines, "typedef union");
+ 
+   count = 0;
+   in_comment = 0;
+ 
+   c = getc(finput);
+ 
+   while (c != EOF)
+     {
+       putc(c, fattrs);
+       if (fdefines)
+ 	putc(c, fdefines);
+ 
+       switch (c)
+ 	{
+ 	case '\n':
+ 	  lineno++;
+ 	  break;
+ 
+ 	case '/':
+ 	  c = getc(finput);
+ 	  if (c != '*')
+ 	    ungetc(c, finput);
+ 	  else
+ 	    {
+ 	      putc('*', fattrs);
+ 	      if (fdefines)
+ 		putc('*', fdefines);
+ 	      c = getc(finput);
+ 	      in_comment = 1;
+ 	      while (in_comment)
+ 		{
+ 		  if (c == EOF)
+ 		    fatal("unterminated comment");
+ 
+ 		  putc(c, fattrs);
+ 		  if (fdefines)
+ 		    putc(c, fdefines);
+ 		  if (c == '*')
+ 		    {
+ 		      c = getc(finput);
+ 		      if (c == '/')
+ 			{
+ 			  putc('/', fattrs);
+ 			  if (fdefines)
+ 			    putc('/', fdefines);
+ 			  in_comment = 0;
+ 			}
+ 		    }
+ 		  else
+ 		    c = getc(finput);
+ 		}
+ 	    }
+ 	  break;
+ 
+ 
+ 	case '{':
+ 	  count++;
+ 	  break;
+ 
+ 	case '}':
+ 	  count--;
+ 	  if (count == 0)
+ 	    {
+ 	      fprintf(fattrs, " YYSTYPE;\n");
+ 	      if (fdefines)
+ 		fprintf(fdefines, " YYSTYPE;\n");
+ 	      /* JF don't choke on trailing semi */
+ 	      c=skip_white_space();
+ 	      if(c!=';') ungetc(c,finput);
+ 	      return;
+ 	    }
+ 	}
+ 
+       c = getc(finput);
+     }
+ }
+ 
+ /* parse the declaration %expect N which says to expect N
+    shift-reduce conflicts.  */
+ 
+ void parse_expect_decl(void)
+ {
+   register int c;
+   register int count;
+   char buffer[20];
+ 
+   c = getc(finput);
+   while (c == ' ' || c == '\t')
+     c = getc(finput);
+ 
+   count = 0;
+   while (c >= '0' && c <= '9')
+     {
+       if (count < 20)
+ 	buffer[count++] = c;
+       c = getc(finput);
+     }
+ 
+   ungetc (c, finput);
+ 
+   expected_conflicts = atoi (buffer);
+ }
+ 
+ /* that's all of parsing the declaration section */
+ 
+ void output_ltype(void)
+ {
+   fprintf(fattrs, LTYPESTR);/* JF added YYABORT() */
+   if (fdefines)
+     fprintf(fdefines, LTYPESTR);/* JF added YYABORT() */
+ 
+   fprintf(fattrs, "#define\tYYACCEPT\tgoto yyaccept\n");
+   fprintf(fattrs, "#define\tYYABORT\tgoto yyabort\n");
+   fprintf(fattrs, "#define\tYYERROR\tgoto yyerrlab\n");
+   fprintf(fattrs, "#define\tyytext\t(*_yytext)\nextern char **_yytext;\n");
+   fprintf(fattrs, "#define\tyylval\t(*_yylval)\nextern YYSTYPE *_yylval;\n");
+   fprintf(fattrs, "#define\tyylloc\t(*_yylloc)\nextern YYLTYPE *_yylloc;\n");
+   fprintf(fattrs, "#define\tyyppval\t(*_yyppval)\nextern int *_yyppval;\n");
+ 
+   if (fdefines)
+     {
+       fprintf(fdefines, "#define\tYYACCEPT\tgoto yyaccept\n");
+       fprintf(fdefines, "#define\tYYABORT\tgoto yyabort\n");
+       fprintf(fdefines, "#define\tYYERROR\tgoto yyerrlab\n");
+       fprintf(fdefines, "#define\tyytext\t(*_yytext)\nextern char **_yytext;\n");
+       fprintf(fdefines, "#define\tyylval\t(*_yylval)\nextern YYSTYPE *_yylval;\n");
+       fprintf(fdefines, "#define\tyylloc\t(*_yylloc)\nextern YYLTYPE *_yylloc;\n");
+       fprintf(fdefines, "#define\tyyppval\t(*_yyppval)\nextern int *_yyppval;\n");
+     }
+ }
+ 
+ 
+ 
+ /* Get the data type (alternative in the union) of the value for symbol n in rule rule.  */
+ 
+ char *get_type_name(int n,symbol_list *rule)
+ {
+   static char *msg = "invalid $ value";
+ 
+   register int i;
+   register symbol_list *rp;
+ 
+   if (n < 0)
+     fatal(msg);
+ 
+   rp = rule;
+   i = 0;
+ 
+   while (i < n)
+     {
+       rp = rp->next;
+       if (rp == NULL || rp->sym == NULL)
+ 	fatal(msg);
+       i++;
+     }
+ 
+   return (rp->sym->type_name);
+ }
+ 
+ 
+ 
+ /* after %guard is seen in the input file,
+ copy the actual guard into the guards file.
+ If the guard is followed by an action, copy that into the actions file.
+ stack_offset is the number of values in the current rule so far,
+ which says where to find $0 with respect to the top of the stack,
+ for the simple parser in which the stack is not popped until after the guard is run.  */
+ 
+ void copy_guard(symbol_list *rule,int stack_offset)
+ {
+   register int c;
+   register int n;
+   register int count;
+   register int match;
+   register int ended;
+   register char *type_name;
+   int brace_flag = 0;
+ 
+   extern char token_buffer[];
+ 
+   /* offset is always 0 if parser has already popped the stack pointer */
+   if (semantic_parser) stack_offset = 0;
+ 
+   fprintf(fguard, "\ncase %d:\n", nrules);
+   if (!nolinesflag)
+     fprintf(fguard, "#line %d \"%s\"\n", lineno, infile);
+   putc('{', fguard);
+ 
+   count = 0;
+   c = getc(finput);
+ 
+   while (brace_flag ? (count > 0) : (c != ';'))
+     {
+       switch (c)
+ 	{
+ 	case '\n':
+ 	  putc(c, fguard);
+ 	  lineno++;
+ 	  break;
+ 
+ 	case '{':
+ 	  putc(c, fguard);
+ 	  count++;
+ 	  break;
+ 
+ 	case '}':
+ 	  putc(c, fguard);
+ 	  brace_flag = 1;
+ 	  if (count > 0)
+ 	    count--;
+ 	  else
+ 	    fatal("unmatched right brace ('}')");
+           break;
+ 
+ 	case '\'':
+ 	case '"':
+ 	  match = c;
+ 	  putc(c, fguard);
+ 	  c = getc(finput);
+ 
+ 	  while (c != match)
+ 	    {
+ 	      if (c == EOF || c == '\n')
+ 		fatal("unterminated string");
+ 
+ 	      putc(c, fguard);
+ 	      
+ 	      if (c == '\\')
+ 		{
+ 		  c = getc(finput);
+ 		  if (c == EOF || c == '\n')
+ 		    fatal("unterminated string");
+ 		  putc(c, fguard);
+ 		  if (c == '\n')
+ 		    lineno++;
+ 		}
+ 
+ 	      c = getc(finput);
+ 	    }
+ 
+ 	  putc(c, fguard);
+ 	  break;
+ 
+ 	case '/':
+ 	  putc(c, fguard);
+ 	  c = getc(finput);
+ 	  if (c != '*')
+ 	    continue;
+ 
+ 	  putc(c, fguard);
+ 	  c = getc(finput);
+ 
+ 	  ended = 0;
+ 	  while (!ended)
+ 	    {
+ 	      if (c == '*')
+ 		{
+ 		  while (c == '*')
+ 		    {
+ 		      putc(c, fguard);
+ 		      c = getc(finput);
+ 		    }
+ 
+ 		  if (c == '/')
+ 		    {
+ 		      putc(c, fguard);
+ 		      ended = 1;
+ 		    }
+ 		}
+ 	      else if (c == '\n')
+ 		{
+ 		  lineno++;
+ 		  putc(c, fguard);
+ 		  c = getc(finput);
+ 		}
+ 	      else if (c == EOF)
+ 		fatal("unterminated comment");
+ 	      else
+ 		{
+ 		  putc(c, fguard);
+ 		  c = getc(finput);
+ 		}
+ 	    }
+ 
+ 	  break;
+ 
+ 	case '$':
+ 	  c = getc(finput);
+ 	  type_name = NULL;
+ 
+ 	  if (c == '<')
+ 	    {
+ 	      register char *cp = token_buffer;
+ 
+ 	      while ((c = getc(finput)) != '>' && c > 0)
+ 		*cp++ = c;
+ 	      *cp = 0;
+ 	      type_name = token_buffer;
+ 
+ 	      c = getc(finput);
+ 	    }
+ 
+ 	  if (c == '$')
+ 	    {
+ 	      fprintf(fguard, "yyval");
+ 	      if (!type_name) type_name = rule->sym->type_name;
+ 	      if (type_name)
+ 		fprintf(fguard, ".%s", type_name);
+ 	      if(!type_name && typed)	/* JF */
+ 		fprintf(stderr,"%s:%d:  warning:  $$ of '%s' has no declared type.\n",infile,lineno,rule->sym->tag);
+ 	    }
+ 
+ 	  else if (isdigit(c) || c == '-')
+ 	    {
+ 	      ungetc (c, finput);
+ 	      n = read_signed_integer(finput);
+ 	      c = getc(finput);
+ 
+ 	      if (!type_name && n > 0)
+ 		type_name = get_type_name(n, rule);
+ 
+ 	      fprintf(fguard, "yyp->yyvsp[%d]", n - stack_offset);
+ 	      if (type_name)
+ 		fprintf(fguard, ".%s", type_name);
+ 	      if(!type_name && typed)	/* JF */
+ 		fprintf(stderr,"%s:%d:  warning:  $%d of '%s' has no declared type.\n",infile,lineno,n,rule->sym->tag);
+ 	      continue;
+ 	    }
+ 	  else
+ 	    fatals("$%c is invalid",c,0,0,0,0,0,0,0);	/* JF changed style */
+ 
+ 	  break;
+ 
+ 	case '@':
+ 	  c = getc(finput);
+ 	  if (isdigit(c) || c == '-')
+ 	    {
+ 	      ungetc (c, finput);
+ 	      n = read_signed_integer(finput);
+ 	      c = getc(finput);
+ 	    }
+ 	  else
+ 	    fatals("@%c is invalid",c,0,0,0,0,0,0,0);	/* JF changed style */
+ 
+ 	  fprintf(fguard, "yyp->yylsp[%d]", n - stack_offset);
+ 	  yylsp_needed = 1;
+ 
+ 	  continue;
+ 
+ 	case EOF:
+ 	  fatal("unterminated %guard clause");
+ 
+ 	default:
+ 	  putc(c, fguard);
+ 	}
+ 
+       if (c != '}' || count != 0)
+ 	c = getc(finput);
+     }
+ 
+   c = skip_white_space();
+ 
+   fprintf(fguard, ";\n    break;}");
+   if (c == '{')
+     copy_action(rule, stack_offset);
+   else if (c == '=')
+     {
+       c = getc(finput);
+       if (c == '{')
+ 	copy_action(rule, stack_offset);
+     }
+   else
+     ungetc(c, finput);
+ }
+ 
+ 
+ 
+ /* Assuming that a { has just been seen, copy everything up to the matching }
+ into the actions file.
+ stack_offset is the number of values in the current rule so far,
+ which says where to find $0 with respect to the top of the stack.  */
+ 
+ void copy_action(symbol_list *rule,int stack_offset)
+ {
+   register int c;
+   register int n;
+   register int count;
+   register int match;
+   register int ended;
+   register char *type_name;
+   extern char token_buffer[];
+ 
+   /* offset is always 0 if parser has already popped the stack pointer */
+   if (semantic_parser) stack_offset = 0;
+ 
+   fprintf(faction, "\ncase %d:\n", nrules);
+   if (!nolinesflag)
+     fprintf(faction, "#line %d \"%s\"\n", lineno, infile);
+   putc('{', faction);
+ 
+   count = 1;
+   c = getc(finput);
+ 
+   while (count > 0)
+     {
+       while (c != '}')
+         {
+           switch (c)
+ 	    {
+ 	    case '\n':
+ 	      putc(c, faction);
+ 	      lineno++;
+ 	      break;
+ 
+ 	    case '{':
+ 	      putc(c, faction);
+ 	      count++;
+ 	      break;
+ 
+ 	    case '\'':
+ 	    case '"':
+ 	      match = c;
+ 	      putc(c, faction);
+ 	      c = getc(finput);
+ 
+ 	      while (c != match)
+ 		{
+ 		  if (c == EOF || c == '\n')
+ 		    fatal("unterminated string");
+ 
+ 		  putc(c, faction);
+ 
+ 		  if (c == '\\')
+ 		    {
+ 		      c = getc(finput);
+ 		      if (c == EOF)
+ 			fatal("unterminated string");
+ 		      putc(c, faction);
+ 		      if (c == '\n')
+ 			lineno++;
+ 		    }
+ 
+ 		  c = getc(finput);
+ 		}
+ 
+ 	      putc(c, faction);
+ 	      break;
+ 
+ 	    case '/':
+ 	      putc(c, faction);
+ 	      c = getc(finput);
+ 	      if (c != '*')
+ 		continue;
+ 
+ 	      putc(c, faction);
+ 	      c = getc(finput);
+ 
+ 	      ended = 0;
+ 	      while (!ended)
+ 		{
+ 		  if (c == '*')
+ 		    {
+ 		      while (c == '*')
+ 		        {
+ 			  putc(c, faction);
+ 			  c = getc(finput);
+ 			}
+ 
+ 		      if (c == '/')
+ 			{
+ 			  putc(c, faction);
+ 			  ended = 1;
+ 			}
+ 		    }
+ 		  else if (c == '\n')
+ 		    {
+ 		      lineno++;
+ 		      putc(c, faction);
+ 		      c = getc(finput);
+ 		    }
+ 		  else if (c == EOF)
+ 		    fatal("unterminated comment");
+ 		  else
+ 		    {
+ 		      putc(c, faction);
+ 		      c = getc(finput);
+ 		    }
+ 		}
+ 
+ 	      break;
+ 
+ 	    case '$':
+ 	      c = getc(finput);
+ 	      type_name = NULL;
+ 
+ 	      if (c == '<')
+ 		{
+ 		  register char *cp = token_buffer;
+ 
+ 		  while ((c = getc(finput)) != '>' && c > 0)
+ 		    *cp++ = c;
+ 		  *cp = 0;
+ 		  type_name = token_buffer;
+ 
+ 		  c = getc(finput);
+ 		}
+ 	      if (c == '$')
+ 		{
+ 		  fprintf(faction, "yyval");
+ 		  if (!type_name) type_name = get_type_name(0, rule);
+ 		  if (type_name)
+ 		    fprintf(faction, ".%s", type_name);
+ 		  if(!type_name && typed)	/* JF */
+ 		    fprintf(stderr,"%s:%d:  warning:  $$ of '%s' has no declared type.\n",infile,lineno,rule->sym->tag);
+ 		}
+ 	      else if (isdigit(c) || c == '-')
+ 		{
+ 		  ungetc (c, finput);
+ 		  n = read_signed_integer(finput);
+ 		  c = getc(finput);
+ 
+ 		  if (!type_name && n > 0)
+ 		    type_name = get_type_name(n, rule);
+ 
+ 		  fprintf(faction, "yyp->yyvsp[%d]", n - stack_offset);
+ 		  if (type_name)
+ 		    fprintf(faction, ".%s", type_name);
+ 		  if(!type_name && typed)	/* JF */
+ 		    fprintf(stderr,"%s:%d:  warning:  $%d of '%s' has no declared type.\n",infile,lineno,n,rule->sym->tag);
+ 		  continue;
+ 		}
+ 	      else
+ 		fatals("$%c is invalid",c,0,0,0,0,0,0,0);
+               /* JF changed format */
+ 
+ 	      break;
+ 
+ 	    case '@':
+ 	      c = getc(finput);
+ 	      if (isdigit(c) || c == '-')
+ 		{
+ 		  ungetc (c, finput);
+ 		  n = read_signed_integer(finput);
+ 		  c = getc(finput);
+ 		}
+ 	      else
+ 		fatal("invalid @-construct");
+ 
+ 	      fprintf(faction, "yyp->yylsp[%d]", n - stack_offset);
+ 	      yylsp_needed = 1;
+ 
+ 	      continue;
+ 
+ 	    case EOF:
+ 	      fatal("unmatched '{'");
+ 
+ 	    default:
+ 	      putc(c, faction);
+ 	    }
+ 
+           c = getc(finput);
+         }
+ 
+       /* above loop exits when c is '}' */
+ 
+       if (--count)
+         {
+ 	  putc(c, faction);
+ 	  c = getc(finput);
+ 	}
+     }
+ 
+   fprintf(faction, ";\n    break;}");
+ }
+ 
+ 
+ 
+ /* generate a dummy symbol, a nonterminal,
+ whose name cannot conflict with the user's names. */
+ 
+ bucket *gensym(void)
+ {
+   register bucket *sym;
+ 
+   extern char token_buffer[];
+   sprintf (token_buffer, "@%d", ++gensym_count);
+   sym = getsym(token_buffer);
+   sym->class = SNTERM;
+   sym->value = nvars++;
+   return (sym);
+ }
+ 
+ /* Parse the input grammar into a one symbol_list structure.
+ Each rule is represented by a sequence of symbols: the left hand side
+ followed by the contents of the right hand side, followed by a null pointer
+ instead of a symbol to terminate the rule.
+ The next symbol is the lhs of the following rule.
+ 
+ All guards and actions are copied out to the appropriate files,
+ labelled by the rule number they apply to.  */
+ 
+ void readgram(void)
+ {
+   register int t;
+   register bucket *lhs;
+   register symbol_list *p;
+   register symbol_list *p1;
+   register bucket *bp;
+ 
+   symbol_list *crule;	/* points to first symbol_list of current rule.  */
+ 			/* its symbol is the lhs of the rule.   */
+   symbol_list *crule1;  /* points to the symbol_list preceding crule.  */
+ 
+   p1 = NULL;
+ 
+   t = lex();
+ 
+   while (t != TWO_PERCENTS && t != ENDFILE)
+     {
+       if (t == IDENTIFIER || t == BAR)
+ 	{
+ 	  register int actionflag = 0;
+ 	  int rulelength = 0;  /* number of symbols in rhs of this rule so far  */
+ 	  int xactions = 0;	/* JF for error checking */
+ 	  bucket *first_rhs = 0;
+ 
+ 	  if (t == IDENTIFIER)
+ 	    {
+ 	      lhs = symval;
+     
+ 	      t = lex();
+ 	      if (t != COLON)
+ 		fatal("ill-formed rule");
+ 	    }
+ 
+ 	  if (nrules == 0)
+ 	    {
+ 	      if (t == BAR)
+ 		fatal("grammar starts with vertical bar");
+ 
+ 	      if (!start_flag)
+ 		startval = lhs;
+ 	    }
+ 
+ 	  /* start a new rule and record its lhs.  */
+ 
+ 	  nrules++;
+ 	  nitems++;
+ 
+ 	  record_rule_line ();
+ 
+ 	  p = NEW(symbol_list);
+ 	  p->sym = lhs;
+ 
+ 	  crule1 = p1;
+ 	  if (p1)
+ 	    p1->next = p;
+ 	  else
+ 	    grammar = p;
+ 
+ 	  p1 = p;
+ 	  crule = p;
+ 
+ 	  /* mark the rule's lhs as a nonterminal if not already so.  */
+ 
+ 	  if (lhs->class == SUNKNOWN)
+ 	    {
+ 	      lhs->class = SNTERM;
+ 	      lhs->value = nvars;
+ 	      nvars++;
+ 	    }
+ 	  else if (lhs->class == STOKEN)
+ 	    fatals("rule given for %s, which is a token", lhs->tag,0,0,0,0,
+                    0,0,0);
+ 
+ 	  /* read the rhs of the rule.  */
+ 
+ 	  for (;;)
+ 	    {
+ 	      t = lex();
+ 
+ 	      if (! (t == IDENTIFIER || t == LEFT_CURLY)) break;
+ 
+ 	      /* if next token is an identifier, see if a colon follows it.
+ 		 If one does, exit this rule now.  */
+ 	      if (t == IDENTIFIER)
+ 		{
+ 		  register bucket *ssave;
+ 		  register int t1;
+ 
+ 		  ssave = symval;
+ 		  t1 = lex();
+ 		  unlex(t1);
+ 		  symval = ssave;
+ 		  if (t1 == COLON) break;
+ 
+ 		  if(!first_rhs)	/* JF */
+ 		  	first_rhs = symval;
+ 		  /* not followed by colon => process as part of this rule's rhs.  */
+ 		  if (actionflag)
+ 		    {
+ 		      register bucket *sdummy;
+ 
+ 		      /* if this symbol was preceded by an action, */
+ 		      /* make a dummy nonterminal to replace that action in this rule */
+ 		      /* and make another rule to associate the action to the dummy.  */
+ 		      /* Since the action was written out with this rule's number, */
+ 		      /* we must write give the new rule this number */
+ 		      /* by inserting the new rule before it.  */
+ 
+ 		      /* make a dummy nonterminal, a gensym.  */
+ 		      sdummy = gensym();
+ 
+ 		      /* make a new rule, whose body is empty, before the current one.  */
+ 		      /* so that the action just read can belong to it.  */
+ 		      nrules++;
+ 		      nitems++;
+ 		      record_rule_line ();
+ 		      p = NEW(symbol_list);
+ 		      if (crule1)
+ 			crule1->next = p;
+ 		      else grammar = p;
+ 		      p->sym = sdummy;
+ 		      crule1 = NEW(symbol_list);
+ 		      p->next = crule1;
+ 		      crule1->next = crule;
+ 		      
+ 		      /* insert the dummy generated by that rule into this rule.  */
+ 		      nitems++;
+ 		      p = NEW(symbol_list);
+ 		      p->sym = sdummy;
+ 		      p1->next = p;
+ 		      p1 = p;
+ 
+ 		      actionflag = 0;
+ 		    }
+ 		  nitems++;
+ 		  p = NEW(symbol_list);
+ 		  p->sym = symval;
+ 		  p1->next = p;
+ 		  p1 = p;
+ 		}
+ 	      else /* handle an action.  */
+ 		{
+ 		  copy_action(crule, rulelength);
+ 		  actionflag = 1;
+ 		  xactions++;	/* JF */
+ 		}
+ 	      rulelength++;
+ 	    }
+ 
+ 	  /* Put an empty link in the list to mark the end of this rule  */
+ 	  p = NEW(symbol_list);
+ 	  p1->next = p;
+ 	  p1 = p;
+ 
+ 	  if (t == PREC)
+ 	    {
+ 	      t = lex();
+ 	      crule->ruleprec = symval;
+ 	      t = lex();
+ 	    }
+ 	  if (t == GUARD)
+ 	    {
+ 	      if (! semantic_parser)
+ 		fatal("%guard present but %semantic_parser not specified");
+ 
+ 	      copy_guard(crule, rulelength);
+ 	      t = lex();
+ 	    }
+ 	  else if (t == LEFT_CURLY)
+ 	    {
+ 	      if (actionflag) fatal("two actions at end of one rule");
+ 	      copy_action(crule, rulelength);
+ 	      t = lex();
+ 	    }
+ 	  /* JF if we'd end up using default, get a warning */
+ 	  else if(!xactions && first_rhs && lhs->type_name!=first_rhs->type_name) {
+ 	    if(lhs->type_name == 0 || first_rhs->type_name == 0 ||
+ 				      strcmp(lhs->type_name,first_rhs->type_name))
+ 	      fprintf(stderr,"%s:%d:  warning:  type clash ('%s' '%s') on default action\n",
+ 		      infile,
+ 		      lineno,
+ 		      lhs->type_name ? lhs->type_name : "",
+ 		      first_rhs->type_name ? first_rhs->type_name : "");
+ 	  }
+ 	  if (t == SEMICOLON)
+ 	    t = lex();
+ 	}
+       /* these things can appear as alternatives to rules.  */
+       else if (t == TOKEN)
+ 	{
+ 	  parse_token_decl(STOKEN, SNTERM);
+ 	  t = lex();
+ 	}
+       else if (t == NTERM)
+ 	{
+ 	  parse_token_decl(SNTERM, STOKEN);
+ 	  t = lex();
+ 	}
+       else if (t == TYPE)
+ 	{
+ 	  t = get_type();
+ 	}
+       else if (t == UNION)
+ 	{
+ 	  parse_union_decl();
+ 	  t = lex();
+ 	}
+       else if (t == EXPECT)
+ 	{
+ 	  parse_expect_decl();
+ 	  t = lex();
+ 	}
+       else if (t == START)
+ 	{
+ 	  parse_start_decl();
+ 	  t = lex();
+ 	}
+       else
+ 	fatal("invalid input");
+     }
+ 
+   if (nrules == 0)
+     fatal("no input grammar");
+ 
+   if (typed == 0)/* JF put out same default YYSTYPE as YACC does */
+     {
+       fprintf(fattrs, "#ifndef YYSTYPE\n#define YYSTYPE int\n#endif\n");
+       if (fdefines)
+ 	fprintf(fdefines, "#ifndef YYSTYPE\n#define YYSTYPE int\n#endif\n");
+     }
+ 
+   /* Report any undefined symbols and consider them nonterminals.  */
+ 
+   for (bp = firstsymbol; bp; bp = bp->next)
+     if (bp->class == SUNKNOWN)
+       {
+ 	fprintf(stderr, "symbol %s used, not defined as token, and no rules for it\n",
+ 			bp->tag);
+ 	failure = 1;
+ 	bp->class = SNTERM;
+ 	bp->value = nvars++;
+       }
+ 
+   ntokens = nsyms - nvars;
+ }
+ 
+ 
+ void record_rule_line(void)
+ {
+   /* Record each rule's source line number in rline table.  */
+ 
+   if (nrules >= rline_allocated)
+     {
+       rline_allocated = nrules * 2;
+       rline = (short *) realloc (rline,
+ 				 rline_allocated * sizeof (short));
+       if (rline == 0)
+ 	{
+ 	  fprintf (stderr, "bison: memory exhausted\n");
+ 	  done (1);
+ 	}
+     }
+   rline[nrules] = lineno;
+ }
+ 
+ /* read in a %type declaration and record its information for get_type_name to access */
+ 
+ int get_type(void)
+ {
+   register int k;
+   register int t;
+   register char *name;
+ 
+   extern char token_buffer[];
+ 
+   t = lex();
+ 
+   if (t != TYPENAME)
+     fatal("ill-formed %type declaration");
+ 
+   k = strlen(token_buffer);
+   name = NEW2(k + 1, char);
+   strcpy(name, token_buffer);
+ 
+   for (;;)
+     {
+       t = lex();
+ 
+       switch (t)
+ 	{
+ 	case SEMICOLON:
+ 	  return (lex());
+ 
+ 	case COMMA:
+ 	  break;
+ 
+ 	case IDENTIFIER:
+ 	  if (symval->type_name == NULL)
+ 	    symval->type_name = name;
+ 	  else
+ 	    fatals("type redeclaration for %s", symval->tag,0,0,0,0,0,0,0);
+ 
+ 	  break;
+ 
+ 	default:
+ 	  return (t);
+ 	}
+     }
+ }
+ 
+ /* assign symbol numbers, and write definition of token names into fdefines.
+ Set up vectors tags and sprec of names and precedences of symbols.  */
+ 
+ void packsymbols(void)
+ {
+   register bucket *bp;
+   register int tokno = 1;
+   register int i;
+   register int last_user_token_number;
+ 
+   /* int lossage = 0; JF set but not used */
+ 
+   tags = NEW2(nsyms + 1, char *);
+   tags[0] = "$";
+ 
+   sprec = NEW2(nsyms, short);
+   sassoc = NEW2(nsyms, short);
+ 
+   max_user_token_number = 255;
+   last_user_token_number = 255;
+ 
+   for (bp = firstsymbol; bp; bp = bp->next)
+     {
+       if (bp->class == SNTERM)
+ 	{
+ 	  bp->value += ntokens;
+ 	}
+       else
+ 	{
+ 	  if (translations && !(bp->user_token_number))
+ 	    bp->user_token_number = ++last_user_token_number;
+ 	  if (bp->user_token_number > max_user_token_number)
+ 	    max_user_token_number = bp->user_token_number;
+ 	  bp->value = tokno++;
+ 	}
+ 
+       tags[bp->value] = bp->tag;
+       sprec[bp->value] = bp->prec;
+       sassoc[bp->value] = bp->assoc;
+ 
+     }
+ 
+   if (translations)
+     {
+       register int i;
+ 
+       token_translations = NEW2(max_user_token_number+1, short);
+ 
+       /* initialize all entries for literal tokens to 2,
+ 	 the internal token number for $illegal., which represents all invalid inputs.  */
+       for (i = 0; i <= max_user_token_number; i++)
+         token_translations[i] = 2;      
+     }
+ 
+   for (bp = firstsymbol; bp; bp = bp->next)
+     {
+       if (bp->value >= ntokens) continue;
+       if (translations)
+ 	{
+ 	  if (token_translations[bp->user_token_number] != 2)
+ 	    {
+ 	    	/* JF made this a call to fatals() */
+ 	      fatals( "tokens %s and %s both assigned number %d",
+ 			      tags[token_translations[bp->user_token_number]],
+ 			      bp->tag,
+ 			      bp->user_token_number,0,0,0,0,0);
+ 	    }
+ 	  token_translations[bp->user_token_number] = bp->value;
+ 	}
+     }
+ 
+   error_token_number = errtoken->value;
+ 
+   output_token_defines(ftable);
+ 
+   if (startval->class == SUNKNOWN)
+     fatals("the start symbol %s is undefined", startval->tag,0,0,0,0,0,0,0);
+   else if (startval->class == STOKEN)
+     fatals("the start symbol %s is a token", startval->tag,0,0,0,0,0,0,0);
+ 
+   start_symbol = startval->value;
+ 
+   if (definesflag)
+     {
+       output_token_defines(fdefines);
+ 
+       if (semantic_parser)
+ 	for (i = ntokens; i < nsyms; i++)
+ 	  {
+ 	    /* don't make these for dummy nonterminals made by gensym.  */
+ 	    if (*tags[i] != '@')
+ 	      fprintf(fdefines, "#define\tNT%s\t%d\n", tags[i], i);
+ 	  }
+ 
+       fclose(fdefines);
+       fdefines = NULL;
+     }
+ }
+       
+ void output_token_defines(FILE *file)
+ {
+   bucket *bp;
+ 
+   for (bp = firstsymbol; bp; bp = bp->next)
+     {
+       if (bp->value >= ntokens) continue;
+ 
+       /* For named tokens, but not literal ones, define the name.  */
+       /* The value is the user token number.  */
+ 
+       if ('\'' != *tags[bp->value] && bp != errtoken)
+ 	{
+ 	  register char *cp = tags[bp->value];
+ 	  register char c;
+ 
+ 	  /* Don't #define nonliteral tokens whose names contain periods.  */
+ 
+ 	  while ((c = *cp++) && c != '.');
+ 	  if (!c)
+ 	    {
+               fprintf(file, "#define\t%s\t%d\n", tags[bp->value],
+ 			    (translations ? bp->user_token_number : bp->value));
+ 	      if (semantic_parser)
+                 fprintf(file, "#define\tT%s\t%d\n", tags[bp->value],
+ 			      bp->value);
+ 	    }
+ 	}
+     }
+ 
+   putc('\n', file);
+ }
+ 
+ /* convert the rules into the representation using rrhs, rlhs and ritems.  */
+ 
+ void packgram(void)
+ {
+   register int itemno;
+   register int ruleno;
+   register symbol_list *p;
+ /*  register bucket *bp; JF unused */
+ 
+   bucket *ruleprec;
+ 
+   ritem = NEW2(nitems + 1, short);
+   rlhs = NEW2(nrules, short) - 1;
+   rrhs = NEW2(nrules, short) - 1;
+   rprec = NEW2(nrules, short) - 1;
+   rassoc = NEW2(nrules, short) - 1;
+ 
+   itemno = 0;
+   ruleno = 1;
+ 
+   p = grammar;
+   while (p)
+     {
+       rlhs[ruleno] = p->sym->value;
+       rrhs[ruleno] = itemno;
+       ruleprec = p->ruleprec;
+ 
+       p = p->next;
+       while (p && p->sym)
+ 	{
+ 	  ritem[itemno++] = p->sym->value;
+ 	  /* a rule gets the precedence and associativity of the last token in it.  */
+           if (p->sym->class == STOKEN)
+ 	    {
+ 	      rprec[ruleno] = p->sym->prec;
+ 	      rassoc[ruleno] = p->sym->assoc;
+ 	    }
+ 	  if (p) p = p->next;
+ 	}
+ 
+       /* if this rule has a %prec, specified symbol's precedence replaces the default */
+       if (ruleprec)
+ 	{
+           rprec[ruleno] = ruleprec->prec;
+           rassoc[ruleno] = ruleprec->assoc;
+ 	}
+ 
+       ritem[itemno++] = -ruleno;
+       ruleno++;
+ 
+       if (p) p = p->next;
+     }
+ 
+   ritem[itemno] = 0;
+ }
+ 
+ /* Read a signed integer from STREAM and return its value.  */
+ 
+ int read_signed_integer(FILE *stream)
+ {
+   register int c = getc(stream);
+   register int sign = 1;
+   register int n;
+ 
+   if (c == '-')
+     {
+       c = getc(stream);
+       sign = -1;
+     }
+   n = 0;
+   while (isdigit(c))
+     {
+       n = 10*n + (c - '0');
+       c = getc(stream);
+     }
+ 
+   ungetc(c, stream);
+ 
+   return n * sign;
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/state.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/state.h:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/state.h	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,137 ----
+ /* Type definitions for nondeterministic finite state machine for bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ /* These type definitions are used to represent a nondeterministic
+    finite state machine that parses the specified grammar.
+    This information is generated by the function generate_states
+    in the file LR0.
+ 
+ Each state of the machine is described by a set of items --
+ particular positions in particular rules -- that are the possible
+ places where parsing could continue when the machine is in this state.
+ These symbols at these items are the allowable inputs that can follow now.
+ 
+ A core represents one state.  States are numbered in the number field.
+ When generate_states is finished, the starting state is state 0
+ and nstates is the number of states.  (A transition to a state
+ whose state number is nstates indicates termination.)  All the cores
+ are chained together and first_state points to the first one (state 0).
+ 
+ For each state there is a particular symbol which must have been the
+ last thing accepted to reach that state.  It is the accessing_symbol
+ of the core.
+ 
+ Each core contains a vector of nitems items which are the indices
+ in the ritems vector of the items that are selected in this state.
+ 
+ The link field is used for chaining buckets that hash states by
+ their itemsets.  This is for recognizing equivalent states and
+ combining them when the states are generated.
+ 
+ The two types of transitions are shifts (push the lookahead token
+ and read another) and reductions (combine the last n things on the
+ stack via a rule, replace them with the symbol that the rule derives,
+ and leave the lookahead token alone).  When the states are generated,
+ these transitions are represented in two other lists.
+ 
+ Each shifts structure describes the possible shift transitions out
+ of one state, the state whose number is in the number field.
+ The shifts structures are linked through next and first_shift points to them.
+ Each contains a vector of numbers of the states that shift transitions
+ can go to.  The accessing_symbol fields of those states' cores say what kind
+ of input leads to them.
+ 
+ A shift to state zero should be ignored.  Conflict resolution
+ deletes shifts by changing them to zero.
+ 
+ Each reductions structure describes the possible reductions at the state
+ whose number is in the number field.  The data is a list of nreds rules,
+ represented by their rule numbers.   first_reduction points to the list
+ of these structures.
+ 
+ Conflict resolution can decide that certain tokens in certain
+ states should explicitly be errors (for implementing %nonassoc).
+ For each state, the tokens that are errors for this reason
+ are recorded in an errs structure, which has the state number
+ in its number field.  The rest of the errs structure is full
+ of token numbers.
+ 
+ There is at least one shift transition present in state zero.
+ It leads to a next-to-final state whose accessing_symbol is
+ the grammar's start symbol.  The next-to-final state has one shift
+ to the final state, whose accessing_symbol is zero (end of input).
+ The final state has one shift, which goes to the termination state
+ (whose number is nstates, and for which there is no core structure).
+ The reason for the extra state at the end is to placate the parser's
+ strategy of making all decisions one token ahead of its actions.  */
+ 
+ 
+ typedef
+   struct core
+     {
+       struct core *next;
+       struct core *link;
+       short number;
+       short accessing_symbol;
+       short nitems;
+       short items[1];
+     }
+   core;
+ 
+ 
+ 
+ typedef
+   struct shifts
+     {
+       struct shifts *next;
+       short number;
+       short nshifts;
+       short shifts[1];
+     }
+   shifts;
+ 
+ 
+ 
+ typedef
+   struct errs
+     {
+       short nerrs;
+       short errs[1];
+     }
+   errs;
+ 
+ 
+ 
+ typedef
+   struct reductions
+     {
+       struct reductions *next;
+       short number;
+       short nreds;
+       short rules[1];
+     }
+   reductions;
+ 
+ 
+ 
+ extern int nstates;
+ extern core *first_state;
+ extern shifts *first_shift;
+ extern reductions *first_reduction;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/symtab.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/symtab.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/symtab.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,139 ----
+ /* Symbol table manager for Bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #include <stdio.h>
+ #ifdef USG
+ #include <string.h>
+ #else /* NOT USG */
+ #include <strings.h>
+ #endif /* NOT USG */
+ 
+ #include "new.h"
+ #include "symtab.h"
+ #include "gram.h"
+ 
+ 
+ bucket **symtab;
+ bucket *firstsymbol;
+ bucket *lastsymbol;
+ 
+ 
+ 
+ int hash(char *key)
+ {
+   register char *cp;
+   register int k;
+ 
+   cp = key;
+   k = 0;
+   while (*cp)
+     k = ((k << 1) ^ (*cp++)) & 0x3fff;
+ 
+   return (k % TABSIZE);
+ }
+ 
+ 
+ 
+ char *copys(char *s)
+ {
+   register int i;
+   register char *cp;
+   register char *result;
+ 
+   i = 1;
+   for (cp = s; *cp; cp++)
+     i++;
+ 
+   result =  mallocate((unsigned int)i);
+   strcpy(result, s);
+   return (result);
+ }
+ 
+ void tabinit(void)
+ {
+ /*   register int i; JF unused */
+ 
+   symtab = NEW2(TABSIZE, bucket *);
+ 
+   firstsymbol = NULL;
+   lastsymbol = NULL;
+ }
+ 
+ bucket *getsym(char *key)
+ {
+   register int hashval;
+   register bucket *bp;
+   register int found;
+ 
+   hashval = hash(key);
+   bp = symtab[hashval];
+ 
+   found = 0;
+   while (bp != NULL && found == 0)
+     {
+       if (strcmp(key, bp->tag) == 0)
+ 	found = 1;
+       else
+ 	bp = bp->link;
+     }
+ 
+   if (found == 0)
+     {
+       nsyms++;
+ 
+       bp = NEW(bucket);
+       bp->link = symtab[hashval];
+       bp->next = NULL;
+       bp->tag = copys(key);
+       bp->class = SUNKNOWN;
+ 
+       if (firstsymbol == NULL)
+ 	{
+ 	  firstsymbol = bp;
+ 	  lastsymbol = bp;
+ 	}
+       else
+ 	{
+ 	  lastsymbol->next = bp;
+ 	  lastsymbol = bp;
+ 	}
+ 
+       symtab[hashval] = bp;
+     }
+ 
+   return (bp);
+ }
+ 
+ void free_symtab(void)
+ {
+   register int i;
+   register bucket *bp,*bptmp;/* JF don't use ptr after free */
+ 
+   for (i = 0; i < TABSIZE; i++)
+     {
+       bp = symtab[i];
+       while (bp)
+ 	{
+ 	  bptmp=bp->link;
+ 	  FREE(bp);
+ 	  bp = bptmp;
+ 	}
+     }
+ }


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/symtab.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/symtab.h:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/symtab.h	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,50 ----
+ /* Definitions for symtab.c and callers, part of bison,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #define	TABSIZE	1009
+ 
+ 
+ /*  symbol classes  */
+ 
+ #define SUNKNOWN 0
+ #define STOKEN	 1
+ #define SNTERM	 2
+ 
+ 
+ typedef
+   struct bucket
+     {
+       struct bucket *link;
+       struct bucket *next;
+       char *tag;
+       char *type_name;
+       short value;
+       short prec;
+       short assoc;
+       short user_token_number;
+       char class;
+     }
+   bucket;
+ 
+ 
+ extern bucket **symtab;
+ extern bucket *firstsymbol;
+ 
+ extern bucket *getsym();


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/types.h
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/types.h:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/types.h	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,27 ----
+ /* Define data type for representing bison's grammar input as it is parsed,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ typedef
+   struct shorts
+     {
+       struct shorts *next;
+       short value;
+     }
+   shorts;


Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/warshall.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/warshall.c:1.1
*** /dev/null	Tue Oct  5 13:32:02 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/bison/warshall.c	Tue Oct  5 13:31:50 2004
***************
*** 0 ****
--- 1,112 ----
+ /* Generate transitive closure of a matrix,
+    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
+ 
+ BISON is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY.  No author or distributor accepts responsibility to anyone
+ for the consequences of using it or for whether it serves any
+ particular purpose or works at all, unless he says so in writing.
+ Refer to the BISON General Public License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute BISON,
+ but only under the conditions described in the BISON General Public
+ License.  A copy of this license is supposed to have been given to you
+ along with BISON so you can know your rights and responsibilities.  It
+ should be in a file named COPYING.  Among other things, the copyright
+ notice and this notice must be preserved on all copies.
+ 
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!  */
+ 
+ #include <stdio.h>
+ #include "machine.h"
+ 
+ 
+ /* given n by n matrix of bits R, modify its contents
+    to be the transive closure of what was given.  */
+ 
+ void TC(unsigned *R,int n)
+ {
+   register int rowsize;
+   register unsigned mask;
+   register unsigned *rowj;
+   register unsigned *rp;
+   register unsigned *rend;
+   register unsigned *ccol;
+ 
+   unsigned *relend;
+   unsigned *cword;
+   unsigned *rowi;
+ 
+   rowsize = WORDSIZE(n) * sizeof(unsigned);
+   relend = (unsigned *) ((char *) R + (n * rowsize));
+ 
+   cword = R;
+   mask = 1;
+   rowi = R;
+   while (rowi < relend)
+     {
+       ccol = cword;
+       rowj = R;
+ 
+       while (rowj < relend)
+ 	{
+ 	  if (*ccol & mask)
+ 	    {
+ 	      rp = rowi;
+ 	      rend = (unsigned *) ((char *) rowj + rowsize);
+ 
+ 	      while (rowj < rend)
+ 		*rowj++ |= *rp++;
+ 	    }
+ 	  else
+ 	    {
+ 	      rowj = (unsigned *) ((char *) rowj + rowsize);
+ 	    }
+ 
+ 	  ccol = (unsigned *) ((char *) ccol + rowsize);
+ 	}
+ 
+       mask <<= 1;
+       if (mask == 0)
+ 	{
+ 	  mask = 1;
+ 	  cword++;
+ 	}
+ 
+       rowi = (unsigned *) ((char *) rowi + rowsize);
+     }
+ }
+ 
+ 
+ /* Reflexive Transitive Closure.  Same as TC
+    and then set all the bits on the diagonal of R.  */
+ 
+ void RTC(unsigned *R,int n)
+ {
+   register int rowsize;
+   register unsigned mask;
+   register unsigned *rp;
+   register unsigned *relend;
+ 
+   TC(R, n);
+ 
+   rowsize = WORDSIZE(n) * sizeof(unsigned);
+   relend = (unsigned *) ((char *) R + n*rowsize);
+ 
+   mask = 1;
+   rp = R;
+   while (rp < relend)
+     {
+       *rp |= mask;
+ 
+       mask <<= 1;
+       if (mask == 0)
+ 	{
+ 	  mask = 1;
+ 	  rp++;
+ 	}
+ 
+       rp = (unsigned *) ((char *) rp + rowsize);
+     }
+ }






More information about the llvm-commits mailing list