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

@@ -474,7 +474,7 @@ m4_define([b4_sync_start], [[#]line $1 $2])
m4_define([b4_case],
[ case $1:
$2
b4_syncline([@oline@], [@ofile@])
b4_syncline([@oline@], [@ofile@])dnl
break;])
@@ -484,7 +484,7 @@ m4_define([b4_predicate_case],
[ case $1:
if (! (
$2)) YYERROR;
b4_syncline([@oline@], [@ofile@])
b4_syncline([@oline@], [@ofile@])dnl
break;])
@@ -713,13 +713,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE;
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
[union\|union-directive],
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
]b4_percent_define_get_syncline([[api.value.union.name]])[
union ]b4_percent_define_get([[api.value.union.name]])[
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
[union ]b4_percent_define_get([[api.value.union.name]])[
{
]b4_user_union_members[
};
]b4_percent_define_get_syncline([[api.value.union.name]])[
typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
[typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
#endif