all: avoid useless comments and #lines

Currently we emit useless code for places where we might issue user
content, but there is none.  This commit avoids this.  Besides, some
of the comments looked like implementation details ("Copy the first
part of user declarations"), rather than made for the reader of the
result ("First part of user prologue").

On Bison's parse-gram.c we get:

    @@ -76,10 +76,6 @@
     #define yynerrs         gram_nerrs

    -/* Copy the first part of user declarations.  */
    -
    -#line 82 "src/parse-gram.c" /* yacc.c:339  */
    -

* data/bison.m4 (b4_define_user_code): Accept a comment to document
the section.
Do not emit any code if the content is empty.
Adjust callers to not emit the comment.
Do not
* data/glr.c, data/glr.cc, data/lalr1.cc, data/lalr1.java, data/yacc.c:
Adjust.
This commit is contained in:
Akim Demaille
2018-10-21 09:40:16 +02:00
parent 85f7c08036
commit 81a9580622
6 changed files with 21 additions and 33 deletions

View File

@@ -236,7 +236,6 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])]))[
/* First part of user declarations. */
]b4_user_pre_prologue[
]b4_null_define[
@@ -259,9 +258,8 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
static YYSTYPE yyval_default;]b4_locations_if([[
static YYLTYPE yyloc_default][]b4_yyloc_default;])[
/* Copy the second part of user declarations. */
]b4_user_post_prologue
b4_percent_code_get[]dnl
]b4_user_post_prologue[
]b4_percent_code_get[]dnl
[#include <stdio.h>
#include <stdlib.h>
@@ -820,7 +818,7 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
]])[
switch (yyn)
{
]b4_user_actions[
]b4_user_actions[
default: break;
}
@@ -2266,7 +2264,6 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yylloc = yyloc_default;])[
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef])[]dnl
[