+\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;
+
+ semantic_parser = 0;
+ pure_parser = 0;
+
+ grammar = NULL;
+
+ init_lex ();
+ lineno = 1;
+
+ /* Initialize the macro obstack. */
+ obstack_init (¯o_obstack);
+
+ /* 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. */
+ read_declarations ();
+ /* Read in the grammar, build grammar in list form. Write out
+ guards and actions. */
+ readgram ();
+ /* Some C code is given at the end of the grammar file. */
+ read_additionnal_code ();
+ /* Now we know whether we need the line-number stack. If we do,
+ write its type into the .tab.h file. */
+#if 0
+ if (defines_flag)
+ reader_output_yylsp (&defines_obstack);
+#endif
+ /* 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 ();
+}