no-lines: avoid leaving an empty line instead of the syncline

Currently, with --no-lines, instead of "#line file line\n", we emit
"\n".  Let's emit nothing.

* data/skeletons/bison.m4 (b4_syncline): Emit at end-of-line when enabled.
* data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.cc,
* data/skeletons/lalr1.cc, src/output.c: Use dnl after b4_syncline to
avoid spurious empty lines.

* tests/synclines.at (Sync Lines): Make sure that --no-lines is like
grep -v #line.
* tests/calc.at: Make sure that a rich grammar file behaves properly
with %no-lines.
This commit is contained in:
Akim Demaille
2019-04-01 18:23:20 +02:00
parent 9832fdd6ef
commit 0f193d2d21
11 changed files with 71 additions and 37 deletions

View File

@@ -211,7 +211,7 @@ muscle_syncline_grow (char const *key, location loc)
obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
obstack_quote (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, ")[");
obstack_sgrow (&muscle_obstack, ")dnl\n[");
char const *extension = obstack_finish0 (&muscle_obstack);
muscle_grow (key, extension, "", "");
obstack_free (&muscle_obstack, extension);
@@ -227,7 +227,7 @@ void
muscle_code_grow (const char *key, const char *val, location loc)
{
muscle_syncline_grow (key, loc);
muscle_grow (key, val, "\n", "\n");
muscle_grow (key, val, "", "\n");
}

View File

@@ -374,7 +374,7 @@ user_actions_output (FILE *out)
rules[r].is_predicate ? "b4_predicate_case" : "b4_case",
r + 1, rules[r].action_location.start.line);
string_output (out, rules[r].action_location.start.file);
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
fprintf (out, ")dnl\n[ %s]])\n\n", rules[r].action);
}
fputs ("])\n\n", out);
}