int error_verbose = 0;
+/* Returns the number of lines of S. */
+static size_t
+get_lines_number (const char *s)
+{
+ size_t lines = 0;
+
+ size_t i;
+ for (i = 0; s[i]; ++i)
+ {
+ if (s[i] == '\n')
+ ++lines;
+ }
+
+ return lines;
+}
+
+
/* FIXME. */
static inline void
XFREE (yyrhs);
}
+
+#if 0
+ if (!semantic_parser)
+ obstack_sgrow (&table_obstack, "\n#endif\n");
+#endif
}
`-----------------------------*/
static void
-actions_output (FILE *out)
+actions_output (FILE *out, size_t *line)
{
int rule;
for (rule = 1; rule < nrules + 1; ++rule)
fprintf (out, "{ %s%s }\n break;\n\n",
rule_table[rule].action,
yacc_flag ? ";" : "");
+
+ /* 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].action);
}
}
muscle_key = obstack_finish (&muscle_obstack);
muscle_value = muscle_find (muscle_key);
if (!strcmp (muscle_key, "actions"))
- actions_output (out);
+ actions_output (out, &line);
else if (!strcmp (muscle_key, "line"))
- fprintf (out, "%d", line + 1);
+ fprintf (out, "%d", line);
else if (muscle_value)
- fputs (muscle_value, out);
+ {
+ fputs (muscle_value, out);
+ line += get_lines_number (muscle_value);
+ }
else
{
fputs ("%%", out);
skeleton = skeleton_find ("BISON_SIMPLE", BISON_SIMPLE);
}
muscle_insert ("skeleton", skeleton);
+ muscle_insert ("parser-file-name", parser_file_name);
output_parser (skeleton, parser);
xfclose (parser);