-static void
-parse_assoc_decl (associativity assoc)
-{
- char *name = NULL;
- int prev = 0;
-
- lastprec++; /* Assign a new precedence level, never 0. */
-
- for (;;)
- {
- token_t t;
- int tmp_char = ungetc (skip_white_space (), finput);
-
- if (tmp_char == '%')
- return;
- if (tmp_char == EOF)
- fatal (_("Premature EOF after %s"), token_buffer);
-
- t = lex ();
-
- switch (t)
- {
- case tok_typename:
- name = xstrdup (token_buffer);
- break;
-
- case tok_comma:
- break;
-
- case tok_identifier:
- if (symval->prec != 0)
- complain (_("redefining precedence of %s"), symval->tag);
- symval->prec = lastprec;
- symval->assoc = assoc;
- if (symval->class == nterm_sym)
- complain (_("symbol %s redefined"), symval->tag);
- symval->class = token_sym;
- if (name)
- { /* record the type, if one is specified */
- if (symval->type_name == NULL)
- symval->type_name = name;
- else if (strcmp (name, symval->type_name) != 0)
- complain (_("type redeclaration for %s"), symval->tag);
- }
- break;
-
- case tok_number:
- if (prev == tok_identifier)
- {
- symval->user_token_number = numval;
- }
- else
- {
- complain (_
- ("invalid text (%s) - number should be after identifier"),
-token_buffer);
- skip_to_char ('%');
- }
- break;
-
- case tok_semicolon:
- return;
-
- default:
- complain (_("unexpected item: %s"), token_buffer);
- skip_to_char ('%');
- }
-
- prev = t;
- }
-}
-
-
-
-/*--------------------------------------------------------------.
-| Copy the union declaration into the stype muscle |
-| (and fdefines), where it is made into the definition of |
-| YYSTYPE, the type of elements of the parser value stack. |
-`--------------------------------------------------------------*/
-
-static void
-parse_union_decl (void)
-{
- int c;
- int count = 0;
- bool done = FALSE;
- struct obstack union_obstack;
- if (typed)
- complain (_("multiple %s declarations"), "%union");
-
- typed = 1;
-
- obstack_init (&union_obstack);
- obstack_sgrow (&union_obstack, "union");
-
- while (!done)
- {
- c = xgetc (finput);
-
- /* If C contains '/', it is output by copy_comment (). */
- if (c != '/')
- obstack_1grow (&union_obstack, c);
-
- switch (c)
- {
- case '\n':
- lineno++;
- break;
-
- case '/':
- copy_comment (finput, &union_obstack);
- break;
-
- case '{':
- count++;
- break;
-
- case '}':
- /* FIXME: Errr. How could this happen???. --akim */
- if (count == 0)
- complain (_("unmatched %s"), "`}'");
- count--;
- if (!count)
- done = TRUE;
- break;
- }
- }
-
- /* JF don't choke on trailing semi */
- c = skip_white_space ();
- if (c != ';')
- ungetc (c, finput);
- obstack_1grow (&union_obstack, 0);
- muscle_insert ("stype", obstack_finish (&union_obstack));
-}
-
-
-/*-------------------------------------------------------.
-| Parse the declaration %expect N which says to expect N |
-| shift-reduce conflicts. |
-`-------------------------------------------------------*/
-
-static void
-parse_expect_decl (void)
-{
- int c = skip_white_space ();
- ungetc (c, finput);
-
- if (!isdigit (c))
- complain (_("argument of %%expect is not an integer"));
- else
- expected_conflicts = read_signed_integer (finput);
-}
-
-
-/*-------------------------------------------------------------------.
-| Parse what comes after %thong. the full syntax is |
-| |
-| %thong <type> token number literal |
-| |
-| the <type> or number may be omitted. The number specifies the |
-| user_token_number. |
-| |
-| Two symbols are entered in the table, one for the token symbol and |
-| one for the literal. Both are given the <type>, if any, from the |
-| declaration. The ->user_token_number of the first is SALIAS and |
-| the ->user_token_number of the second is set to the number, if |
-| any, from the declaration. The two symbols are linked via |
-| pointers in their ->alias fields. |
-| |
-| During OUTPUT_DEFINES_TABLE, the symbol is reported thereafter, |
-| only the literal string is retained it is the literal string that |
-| is output to yytname |
-`-------------------------------------------------------------------*/
-
-static void
-parse_thong_decl (void)
-{
- token_t token;
- struct bucket *symbol;
- char *typename = 0;
- int usrtoknum = SUNDEF;
-
- token = lex (); /* fetch typename or first token */
- if (token == tok_typename)
- {
- typename = xstrdup (token_buffer);
- value_components_used = 1;
- token = lex (); /* fetch first token */
- }
-
- /* process first token */
-
- if (token != tok_identifier)
- {
- complain (_("unrecognized item %s, expected an identifier"),
- token_buffer);
- skip_to_char ('%');
- return;
- }
- symval->class = token_sym;
- symval->type_name = typename;
- symval->user_token_number = SALIAS;
- symbol = symval;
-
- token = lex (); /* get number or literal string */
-
- if (token == tok_number)
- {
- usrtoknum = numval;
- token = lex (); /* okay, did number, now get literal */
- }
-
- /* process literal string token */
-
- if (token != tok_identifier || *symval->tag != '\"')
- {
- complain (_("expected string constant instead of %s"), token_buffer);
- skip_to_char ('%');
- return;
- }
- symval->class = token_sym;
- symval->type_name = typename;
- symval->user_token_number = usrtoknum;
-
- symval->alias = symbol;
- symbol->alias = symval;
-
- /* symbol and symval combined are only one symbol. */
- nsyms--;
-}
-
-
-static void
-parse_muscle_decl (void)
-{
- int ch = ungetc (skip_white_space (), finput);
- char *muscle_key;
- char *muscle_value;
-
- /* Read key. */
- if (!isalpha (ch) && ch != '_')
- {
- complain (_("invalid %s declaration"), "%define");
- skip_to_char ('%');
- return;
- }
- copy_identifier (finput, &muscle_obstack);
- obstack_1grow (&muscle_obstack, 0);
- muscle_key = obstack_finish (&muscle_obstack);
-
- /* Read value. */
- ch = skip_white_space ();
- if (ch != '"')
- {
- ungetc (ch, finput);
- if (ch != EOF)
- {
- complain (_("invalid %s declaration"), "%define");
- skip_to_char ('%');
- return;
- }
- else
- fatal (_("Premature EOF after %s"), "\"");
- }
- copy_string2 (finput, &muscle_obstack, '"', 0);
- obstack_1grow (&muscle_obstack, 0);
- muscle_value = obstack_finish (&muscle_obstack);
-
- /* Store the (key, value) pair in the environment. */
- muscle_insert (muscle_key, muscle_value);
-}
-
-
-
-/*---------------------------------.
-| Parse a double quoted parameter. |
-`---------------------------------*/
-
-static const char *
-parse_dquoted_param (const char *from)