mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 06:43:03 +00:00
* src/gram.h (rule_t): guard' and guard_line' are new members.
* src/reader.c (symbol_list): `guard' and `guard_line' are new members. (symbol_list_new): Adjust. (copy_action): action_line is the first line, not the last. (copy_guard): Just as for actions, store the `action' only, not the switch/case/break flesh. Don't parse the user action that might follow the guard, let... (readgram): do it, i.e., now, there can be an action after a guard. In other words the guard is just explicitly optional. (packgram): Adjust. * src/output.c (guards_output): New. (output_parser): Call it when needed. (output): Also free the guard and attrs obstacks. * src/files.c, src/files.h (obstack_save): Remove. (output_files): Remove. As a result, if one needs the former `.act' file, using an appropriate skeleton which requires actions and guards is now required. * src/main.c (main): Adjust. * tests/semantic.at: New. * tests/regression.at: Use `input.y' as input file name. Avoid 8+3 problems by requiring input.c when the test needs the parser.
This commit is contained in:
42
src/output.c
42
src/output.c
@@ -536,6 +536,38 @@ actions_output (FILE *out, size_t *line)
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------.
|
||||
| Output the guards to OOUT. |
|
||||
`----------------------------*/
|
||||
|
||||
static void
|
||||
guards_output (FILE *out, size_t *line)
|
||||
{
|
||||
int rule;
|
||||
for (rule = 1; rule < nrules + 1; ++rule)
|
||||
if (rule_table[rule].action)
|
||||
{
|
||||
fprintf (out, " case %d:\n", rule);
|
||||
|
||||
if (!no_lines_flag)
|
||||
fprintf (out, muscle_find ("linef"),
|
||||
rule_table[rule].guard_line,
|
||||
quotearg_style (c_quoting_style,
|
||||
muscle_find ("filename")));
|
||||
fprintf (out, "{ %s; }\n break;\n\n",
|
||||
rule_table[rule].guard);
|
||||
|
||||
/* We always output 4 '\n' per action. */
|
||||
*line += 4;
|
||||
/* Plus one if !no_lines_flag. */
|
||||
if (!no_lines_flag)
|
||||
++*line;
|
||||
/* Get the number of lines written by the user. */
|
||||
*line += get_lines_number (rule_table[rule].guard);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
save_column (int symbol, int default_state)
|
||||
{
|
||||
@@ -928,6 +960,8 @@ output_parser (const char *skel_filename, FILE *out)
|
||||
muscle_value = muscle_find (muscle_key);
|
||||
if (!strcmp (muscle_key, "actions"))
|
||||
actions_output (out, &output_line);
|
||||
else if (!strcmp (muscle_key, "guards"))
|
||||
guards_output (out, &output_line);
|
||||
else if (!strcmp (muscle_key, "line"))
|
||||
fprintf (out, "%d", output_line);
|
||||
else if (!strcmp (muscle_key, "skeleton-line"))
|
||||
@@ -1091,7 +1125,9 @@ output (void)
|
||||
header_output ();
|
||||
|
||||
free (rule_table + 1);
|
||||
obstack_free (&muscle_obstack, 0);
|
||||
obstack_free (&format_obstack, 0);
|
||||
obstack_free (&action_obstack, 0);
|
||||
obstack_free (&muscle_obstack, NULL);
|
||||
obstack_free (&format_obstack, NULL);
|
||||
obstack_free (&action_obstack, NULL);
|
||||
obstack_free (&guard_obstack, NULL);
|
||||
obstack_free (&attrs_obstack, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user