-#include "machine.h"
-
-#define LTYPESTR "\
-\n\
-#ifndef YYLTYPE\n\
-typedef\n\
- struct yyltype\n\
-\
- {\n\
- int timestamp;\n\
- int first_line;\n\
- int first_column;\
-\n\
- int last_line;\n\
- int last_column;\n\
- char *text;\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 char *program_name;
-extern int definesflag;
-extern int nolinesflag;
-extern int noparserflag;
-extern int rawtoknumflag;
-extern bucket *symval;
-extern int numval;
-extern int expected_conflicts;
-extern char *token_buffer;
-extern int maxtoken;
-
-extern void init_lex PARAMS((void));
-extern char *grow_token_buffer PARAMS((char *));
-extern void tabinit PARAMS((void));
-extern void output_headers PARAMS((void));
-extern void output_trailers PARAMS((void));
-extern void free_symtab PARAMS((void));
-extern void open_extra_files PARAMS((void));
-extern char *int_to_string PARAMS((int));
-extern char *printable_version PARAMS((int));
-extern void fatal PARAMS((char *));
-extern void fatals PARAMS((char *, char *));
-extern void warn PARAMS((char *));
-extern void warni PARAMS((char *, int));
-extern void warns PARAMS((char *, char *));
-extern void warnss PARAMS((char *, char *, char *));
-extern void warnsss PARAMS((char *, char *, char *, char *));
-extern void unlex PARAMS((int));
-extern void done PARAMS((int));
-
-extern int skip_white_space PARAMS((void));
-extern int parse_percent_token PARAMS((void));
-extern int lex PARAMS((void));
-
-typedef
- struct symbol_list
- {
- struct symbol_list *next;
- bucket *sym;
- bucket *ruleprec;
- }
- symbol_list;
-
-
-void reader PARAMS((void));
-void reader_output_yylsp PARAMS((FILE *));
-void read_declarations PARAMS((void));
-void copy_definition PARAMS((void));
-void parse_token_decl PARAMS((int, int));
-void parse_start_decl PARAMS((void));
-void parse_type_decl PARAMS((void));
-void parse_assoc_decl PARAMS((int));
-void parse_union_decl PARAMS((void));
-void parse_expect_decl PARAMS((void));
-char *get_type_name PARAMS((int, symbol_list *));
-void copy_guard PARAMS((symbol_list *, int));
-void parse_thong_decl PARAMS((void));
-void copy_action PARAMS((symbol_list *, int));
-bucket *gensym PARAMS((void));
-void readgram PARAMS((void));
-void record_rule_line PARAMS((void));
-void packsymbols PARAMS((void));
-void output_token_defines PARAMS((FILE *));
-void packgram PARAMS((void));
-int read_signed_integer PARAMS((FILE *));
-
-#if 0
-static int get_type PARAMS((void));
-#endif
-
-int lineno;
-symbol_list *grammar;
-int start_flag;
-bucket *startval;
-char **tags;
-int *user_toknums;
-
-/* Nonzero if components of semantic values are used, implying
- they must be unions. */
-static int value_components_used;
-
-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;
-static bucket *undeftoken;
-
-/* Nonzero if any action or guard uses the @n construct. */
-static int yylsp_needed;
-
-
-static void
-skip_to_char (int target)
-{
- int c;
- if (target == '\n')
- warn(_(" Skipping to next \\n"));
- else
- warni(_(" Skipping to next %c"), target);
-
- do
- c = skip_white_space();
- while (c != target && c != EOF);
- if (c != EOF)
- ungetc(c, finput);
-}
-
-
-void
-reader (void)
-{
- start_flag = 0;
- startval = NULL; /* start symbol not specified yet. */
-
-#if 0
- translations = 0; /* initially assume token number translation not needed. */
-#endif
- /* Nowadays translations is always set to 1,
- since we give `error' a user-token-number
- to satisfy the Posix demand for YYERRCODE==256. */
- translations = 1;
-
- 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;
- errtoken->user_token_number = 256; /* Value specified by posix. */
- /* construct a token that represents all undefined literal tokens. */
- /* it is always token number 2. */
- undeftoken = getsym("$undefined.");
- undeftoken->class = STOKEN;
- undeftoken->user_token_number = 2;
- /* Read the declaration section. Copy %{ ... %} groups to ftable and fdefines file.
- Also notice any %token, %left, etc. found there. */
- if (noparserflag)
- fprintf(ftable, "\n/* Bison-generated parse tables, made from %s\n",
- infile);
- else
- fprintf(ftable, "\n/* A Bison parser, made from %s\n", infile);
- fprintf(ftable, " by %s */\n\n", VERSION_STRING);
- fprintf(ftable, "#define YYBISON 1 /* Identify Bison output. */\n\n");
- read_declarations();
- /* 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();
- /* Now we know whether we need the line-number stack.
- If we do, write its type into the .tab.h file. */
- if (fdefines)
- reader_output_yylsp(fdefines);
- /* 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();
-}
-
-void
-reader_output_yylsp (FILE *f)
-{
- if (yylsp_needed)
- fprintf(f, LTYPESTR);
-}