+\f
+/*-------------------------------------------------------------------.
+| Read in the grammar specification and record it in the format |
+| described in gram.h. All guards are copied into the GUARD_OBSTACK |
+| and all actions into ACTION_OBSTACK, 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. |
+`-------------------------------------------------------------------*/
+
+void
+reader (void)
+{
+ start_flag = 0;
+ startval = NULL; /* start symbol not specified yet. */
+
+#if 0
+ /* initially assume token number translation not needed. */
+ translations = 0;
+#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 = XCALLOC (short, rline_allocated);
+
+ typed = 0;
+ lastprec = 0;
+
+ gensym_count = 0;
+
+ semantic_parser = 0;
+ pure_parser = 0;
+
+ grammar = NULL;
+
+ init_lex ();
+ lineno = 1;
+
+ /* Initialize the symbol table. */
+ tabinit ();
+ /* Construct the error token */
+ errtoken = getsym ("error");
+ errtoken->class = token_sym;
+ 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 = token_sym;
+ undeftoken->user_token_number = 2;
+
+ /* Read the declaration section. Copy %{ ... %} groups to
+ TABLE_OBSTACK and FDEFINES file. Also notice any %token, %left,
+ etc. found there. */
+ obstack_1grow (&table_obstack, '\n');
+ obstack_fgrow3 (&table_obstack, "\
+/* %s, made from %s\n\
+ by GNU bison %s. */\n\
+\n",
+ no_parser_flag ? "Bison-generated parse tables" : "A Bison parser",
+ infile, VERSION);
+
+ obstack_sgrow (&table_obstack,
+ "#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 (defines_flag)
+ reader_output_yylsp (&defines_obstack);
+ /* Write closing delimiters for actions and guards. */
+ output_trailers ();
+ if (locations_flag)
+ obstack_sgrow (&table_obstack, "#define YYLSP_NEEDED 1\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 ();
+}
+
+
+/*------------------------------------------------------------------.
+| Define YYLTYPE. Cannot be in the skeleton since we might have to |
+| output it in the headers if --defines is used. |
+`------------------------------------------------------------------*/
+
+void
+reader_output_yylsp (struct obstack *oout)
+{
+ if (locations_flag)
+ obstack_sgrow (oout, "\
+\n\
+#ifndef YYLTYPE\n\
+typedef struct yyltype\n\
+{\n\
+ int first_line;\n\
+ int first_column;\n\
+\n\
+ int last_line;\n\
+ int last_column;\n\
+} yyltype;\n\
+\n\
+# define YYLTYPE yyltype\n\
+#endif\n\
+\n");
+}