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 "\
/* 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;
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));
/* 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)
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)
/* 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 ();
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;
-}