]>
git.saurik.com Git - bison.git/blob - src/main.c
3ef6683ecaf58d0478efeb3a24deb9ec32c768db
   1 /* Top level entry point of bison, 
   2    Copyright (C) 1984, 1986, 1989, 1992, 1995 Free Software Foundation, Inc. 
   4 This file is part of Bison, the GNU Compiler Compiler. 
   6 Bison is free software; you can redistribute it and/or modify 
   7 it under the terms of the GNU General Public License as published by 
   8 the Free Software Foundation; either version 2, or (at your option) 
  11 Bison is distributed in the hope that it will be useful, 
  12 but WITHOUT ANY WARRANTY; without even the implied warranty of 
  13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  14 GNU General Public License for more details. 
  16 You should have received a copy of the GNU General Public License 
  17 along with Bison; see the file COPYING.  If not, write to 
  18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */ 
  23 #include "machine.h"    /* for MAXSHORT */ 
  26 extern  int verboseflag
; 
  28 /* Nonzero means failure has been detected; don't write a parser file.  */ 
  31 /* The name this program was run with, for messages.  */ 
  34 extern void getargs(), openfiles(), reader(), reduce_grammar(); 
  35 extern void set_derives(), set_nullable(), generate_states(); 
  36 extern void lalr(), initialize_conflicts(), verbose(), terse(); 
  37 extern void output(), done(); 
  40 /* VMS complained about using `int'.  */ 
  47   program_name 
= argv
[0]; 
  48   setlocale (LC_ALL
, ""); 
  49   bindtextdomain (PACKAGE
, LOCALEDIR
); 
  57   /* read the input.  Copy some parts of it to fguard, faction, ftable and fattrs. 
  59      The other parts are recorded in the grammar; see gram.h.  */ 
  64   /* find useless nonterminals and productions and reduce the grammar.  In 
  68   /* record other info about the grammar.  In files derives and nullable.  */ 
  72   /* convert to nondeterministic finite state machine.  In file LR0. 
  73      See state.h for more info.  */ 
  76   /* make it deterministic.  In file lalr.  */ 
  79   /* Find and record any conflicts: places where one token of lookahead is not 
  80      enough to disambiguate the parsing.  In file conflicts. 
  81      Also resolve s/r conflicts based on precedence declarations.  */ 
  82   initialize_conflicts(); 
  84   /* print information about results, if requested.  In file print. */ 
  90   /* output the tables and the parser to ftable.  In file output. */ 
  96 /* functions to report errors which prevent a parser from being generated */ 
  99 /* Return a string containing a printable version of C: 
 100    either C itself, or the corresponding \DDD code.  */ 
 107   if (c 
< ' ' || c 
>= '\177') 
 108     sprintf(buf
, "\\%o", c
); 
 117 /* Generate a string from the integer I. 
 118    Return a ptr to internal memory containing the string.  */ 
 125   sprintf(buf
, "%d", i
); 
 129 /* Print the message S for a fatal error.  */ 
 138     fprintf(stderr
, _("fatal error: %s\n"), s
); 
 140     fprintf(stderr
, _("\"%s\", line %d: %s\n"), infile
, lineno
, s
); 
 145 /* Print a message for a fatal error.  Use FMT to construct the message 
 146    and incorporate string X1.  */ 
 153   sprintf(buffer
, fmt
, x1
); 
 157 /* Print a warning message S.  */ 
 166     fprintf(stderr
, _("error: %s\n"), s
); 
 168     fprintf(stderr
, _("(\"%s\", line %d) error: %s\n"), 
 174 /* Print a warning message containing the string for the integer X1. 
 175    The message is given by the format FMT.  */ 
 183   sprintf(buffer
, fmt
, x1
); 
 187 /* Print a warning message containing the string X1. 
 188    The message is given by the format FMT.  */ 
 195   sprintf(buffer
, fmt
, x1
); 
 199 /* Print a warning message containing the two strings X1 and X2. 
 200         The message is given by the format FMT.  */ 
 207   sprintf(buffer
, fmt
, x1
, x2
); 
 211 /* Print a warning message containing the 3 strings X1, X2, X3. 
 212    The message is given by the format FMT.  */ 
 215 warnsss(fmt
, x1
, x2
, x3
) 
 216      char *fmt
, *x1
, *x2
, *x3
; 
 219   sprintf(buffer
, fmt
, x1
, x2
, x3
); 
 223 /* Print a message for the fatal occurence of more than MAXSHORT 
 224    instances of whatever is denoted by the string S.  */ 
 231   sprintf(buffer
, _("limit of %d exceeded, too many %s"), MAXSHORT
, s
); 
 235 /* Abort for an internal error denoted by string S.  */ 
 241   fprintf(stderr
, _("internal error, %s\n"), s
);