]> git.saurik.com Git - bison.git/blobdiff - src/reader.c
* src/atgeneral.m4: Update from Autoconf.
[bison.git] / src / reader.c
index 232e0b0cb8b233788aae1caf1d7159bc2f4c90ce..c026da285c403b19b300cfa40e91c1da64bab954 100644 (file)
 
    The entry point is reader ().  */
 
-#include <stdio.h>
 #include "system.h"
+#include "getargs.h"
 #include "files.h"
 #include "alloc.h"
 #include "symtab.h"
 #include "lex.h"
 #include "gram.h"
-#include "machine.h"
 #include "complain.h"
 
 #define        LTYPESTR        "\
@@ -62,10 +61,6 @@ typedef\n\
 /* Number of slots allocated (but not necessarily used yet) in `rline'  */
 static int rline_allocated;
 
-extern int definesflag;
-extern int nolinesflag;
-extern int noparserflag;
-extern int rawtoknumflag;
 extern bucket *symval;
 extern int numval;
 extern int expected_conflicts;
@@ -117,7 +112,6 @@ static void record_rule_line PARAMS((void));
 static void packsymbols PARAMS((void));
 static void output_token_defines PARAMS((FILE *));
 static void packgram PARAMS((void));
-static int read_signed_integer PARAMS((FILE *));
 
 #if 0
 static int get_type PARAMS((void));
@@ -146,6 +140,10 @@ static bucket *undeftoken;
 /* Nonzero if any action or guard uses the @n construct.  */
 static int yylsp_needed;
 
+\f
+/*===================\
+| Low level lexing.  |
+\===================*/
 
 static void
 skip_to_char (int target)
@@ -157,15 +155,45 @@ skip_to_char (int target)
     complain (_("   Skipping to next %c"), target);
 
   do
-    c = skip_white_space();
+    c = skip_white_space ();
   while (c != target && c != EOF);
   if (c != EOF)
-    ungetc(c, finput);
+    ungetc (c, finput);
 }
 
 
-/* Dump the string from FIN to FOUT.  MATCH is the delimiter of
-   the string (either ' or ").  */
+/*---------------------------------------------------------.
+| Read a signed integer from STREAM and return its value.  |
+`---------------------------------------------------------*/
+
+static inline int
+read_signed_integer (FILE *stream)
+{
+  register int c = getc (stream);
+  register int sign = 1;
+  register int n = 0;
+
+  if (c == '-')
+    {
+      c = getc (stream);
+      sign = -1;
+    }
+
+  while (isdigit (c))
+    {
+      n = 10 * n + (c - '0');
+      c = getc (stream);
+    }
+
+  ungetc (c, stream);
+
+  return sign * n;
+}
+\f
+/*-------------------------------------------------------------------.
+| Dump the string from FINPUT to FOUTPUT.  MATCH is the delimiter of |
+| the string (either ' or ").                                        |
+`-------------------------------------------------------------------*/
 
 static inline void
 copy_string (FILE *fin, FILE *fout, int match)
@@ -350,7 +378,7 @@ reader (void)
   /* Write closing delimiters for actions and guards.  */
   output_trailers ();
   if (yylsp_needed)
-    fprintf ("#define YYLSP_NEEDED\n\n", ftable);
+    fputs ("#define YYLSP_NEEDED\n\n", ftable);
   /* Assign the symbols their symbol numbers.  Write #defines for the
      token symbols into FDEFINES if requested.  */
   packsymbols ();
@@ -1950,29 +1978,3 @@ packgram (void)
 
   ritem[itemno] = 0;
 }
-\f
-/* Read a signed integer from STREAM and return its value.  */
-
-static 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;
-}