This file is part of Bison, the GNU Compiler Compiler.
- Bison is free software; you can redistribute it and/or modify
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Bison is distributed in the hope that it will be useful,
+ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Bison; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "system.h"
}
}
-
-/*---------------------------------------------------------------------.
-| There are two prologues: one before the first %union and one after. |
-| Augment the one specified by POST. |
-`---------------------------------------------------------------------*/
-
-void
-prologue_augment (const char *prologue, location loc, bool post)
-{
- struct obstack *oout =
- !post ? &pre_prologue_obstack : &post_prologue_obstack;
-
- obstack_fgrow1 (oout, "]b4_syncline(%d, [[", loc.start.line);
- /* FIXME: Protection of M4 characters missing here. See
- output.c:escaped_output. */
- MUSCLE_OBSTACK_SGROW (oout,
- quotearg_style (c_quoting_style, loc.start.file));
- obstack_sgrow (oout, "]])[\n");
- obstack_sgrow (oout, prologue);
-}
-
\f
/*------------------------------------------------------------------------.
static bool
symbol_should_be_used (symbol_list const *s)
{
- if (symbol_destructor_get (s->content.sym))
+ if (symbol_destructor_get (s->content.sym)->code)
return true;
if (warnings_flag & warnings_midrule_values)
return ((s->midrule && s->midrule->action_props.is_value_used)
rules = xnmalloc (nrules, sizeof *rules);
- /* Before invoking grammar_rule_check on any rule, make sure all actions have
- already been scanned in order to set `used' flags. Otherwise, checking
- that a midrule's $$ should be set will not always work properly because
- the check must forward-reference the midrule's parent rule. For the same
- reason, all the `used' flags must be set before checking whether to remove
- `$' from any midrule symbol name. */
- while (p)
- {
- code_props_translate_code (&p->action_props);
- if (p)
- p = p->next;
- }
-
- p = grammar;
while (p)
{
int rule_length = 0;
undeftoken->class = token_sym;
undeftoken->number = ntokens++;
- /* Initialize the obstacks. */
- obstack_init (&pre_prologue_obstack);
- obstack_init (&post_prologue_obstack);
-
gram_in = xfopen (grammar_file, "r");
gram__flex_debug = trace_flag & trace_scan;
token symbols into FDEFINES if requested. */
symbols_pack ();
+ /* Scan rule actions after invoking symbol_check_alias_consistency (in
+ symbols_pack above) so that token types are set correctly before the rule
+ action type checking.
+
+ Before invoking grammar_rule_check (in packgram below) on any rule, make
+ sure all actions have already been scanned in order to set `used' flags.
+ Otherwise, checking that a midrule's $$ should be set will not always work
+ properly because the check must forward-reference the midrule's parent
+ rule. For the same reason, all the `used' flags must be set before
+ checking whether to remove `$' from any midrule symbol name (also in
+ packgram). */
+ {
+ symbol_list *sym;
+ for (sym = grammar; sym; sym = sym->next)
+ code_props_translate_code (&sym->action_props);
+ }
+
/* Convert the grammar into the format described in gram.h. */
packgram ();