/* Input parser for bison
- Copyright 1984, 1986, 1989, 1992, 1998, 2000, 2001
+ Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
/* Above loop exits when C is '}'. */
if (--count)
- {
- obstack_1grow (&action_obstack, c);
- c = getc (finput);
- }
+ obstack_1grow (&action_obstack, c);
}
obstack_1grow (&action_obstack, '\0');
unlex (t1);
symval = ssave;
if (t1 == tok_colon)
- break;
+ {
+ complain (_("previous rule lacks an ending `;'"));
+ break;
+ }
if (!first_rhs) /* JF */
first_rhs = symval;
p = symbol_list_new (sdummy);
/* Attach its lineno to that of the host rule. */
p->line = crule->line;
+ /* Move the action from the host rule to this one. */
+ p->action = crule->action;
+ p->action_line = crule->action_line;
+ crule->action = NULL;
+
if (crule1)
crule1->next = p;
else
/* Warn if there is no default for $$ but we need one. */
else if (!xactions && !first_rhs && lhs->type_name != 0)
complain (_("empty rule for typed nonterminal, and no action"));
+ if (t == tok_two_percents || t == tok_eof)
+ complain (_("previous rule lacks an ending `;'"));
if (t == tok_semicolon)
t = lex ();
}
}
-/*---------------------------------------------------------------.
-| Save the definition of token names in the `TOKENDEFS' muscle. |
-`---------------------------------------------------------------*/
-
-static void
-symbols_save (void)
-{
- struct obstack tokendefs;
- bucket *bp;
- obstack_init (&tokendefs);
-
- for (bp = firstsymbol; bp; bp = bp->next)
- {
- char *symbol = bp->tag; /* get symbol */
-
- if (bp->value >= ntokens)
- continue;
- if (bp->user_token_number == SALIAS)
- continue;
- if ('\'' == *symbol)
- continue; /* skip literal character */
- if (bp == errtoken)
- continue; /* skip error token */
- if ('\"' == *symbol)
- {
- /* use literal string only if given a symbol with an alias */
- if (bp->alias)
- symbol = bp->alias->tag;
- else
- continue;
- }
-
- /* Don't #define nonliteral tokens whose names contain periods. */
- if (strchr (symbol, '.'))
- continue;
-
- obstack_fgrow2 (&tokendefs, "# define %s\t%d\n",
- symbol, bp->user_token_number);
- if (semantic_parser)
- /* FIXME: This is probably wrong, and should be just as
- above. --akim. */
- obstack_fgrow2 (&tokendefs, "# define T%s\t%d\n", symbol, bp->value);
- }
-
- obstack_1grow (&tokendefs, 0);
- muscle_insert ("tokendef", xstrdup (obstack_finish (&tokendefs)));
- obstack_free (&tokendefs, NULL);
-}
-
-
/*---------------------------------------------------------------.
| Convert the rules into the representation using RRHS, RLHS and |
| RITEMS. |
/* Assign the symbols their symbol numbers. Write #defines for the
token symbols into FDEFINES if requested. */
packsymbols ();
- /* Save them. */
- symbols_save ();
/* Convert the grammar into the format described in gram.h. */
packgram ();
/* The grammar as a symbol_list is no longer needed. */
LIST_FREE (symbol_list, grammar);
}
+
+void
+grammar_free (void)
+{
+ XFREE (ritem);
+ free (rules + 1);
+ /* Free the symbol table data structure. */
+ free_symtab ();
+}