bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] yacc: remove trailing end of line at end of file


From: Akim Demaille
Subject: [PATCH 1/2] yacc: remove trailing end of line at end of file
Date: Thu, 2 Aug 2012 13:54:16 +0200

There are still spurious spaces at the end of some lines.  But this is
addressed in the master branch, and I am reluctant to try to backport
this.

* data/yacc.c, data/glr.c, data/lalr1.cc, data/glr.cc: here.
* tests/calc.at (AT_CHECK_SPACES): New.
Use it.
Be sure not to introduce trailing empty lines in the *.y files.
* NEWS: Doc it.
* cfg.mk (syntax-check): Remove the exception.
---
 NEWS             |  4 ++++
 cfg.mk           |  1 -
 data/glr.c       |  6 ++----
 data/glr.cc      |  4 +---
 data/lalr1.cc    |  2 +-
 data/yacc.c      |  2 +-
 src/parse-gram.c |  5 ++---
 src/parse-gram.h |  2 +-
 tests/calc.at    | 20 +++++++++++++++++---
 9 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/NEWS b/NEWS
index 316abb0..0ce9dd4 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,10 @@ GNU Bison NEWS
   Trailing end-of-lines in %parse-param or %lex-param would result in
   invalid C++.  This is fixed.
 
+** Spurious spaces and end-of-lines
+
+  The generated files no longer end (nor start) with empty lines.
+
 * Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
 
  Bison no longer executes user-specified M4 code when processing a grammar.
diff --git a/cfg.mk b/cfg.mk
index 53855ae..3a70379 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -70,7 +70,6 @@ $(call exclude,                                               
                \
   prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$     \
   prohibit_always-defined_macros+=?|^tests/regression.at$$             \
   prohibit_defined_have_decl_tests=?|^lib/timevar.c$$                  \
-  prohibit_empty_lines_at_EOF=^src/parse-gram.[ch]$$                   \
   prohibit_magic_number_exit=^doc/bison.texi$$                         \
   prohibit_magic_number_exit+=?|^tests/(conflicts|regression).at$$     \
   require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$           \
diff --git a/data/glr.c b/data/glr.c
index 08f6cd8..97efe89 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -2599,9 +2599,7 @@ yypdumpstack (yyGLRStack* yystackp)
   YYFPRINTF (stderr, "\n");
 }
 #endif
-]
-
-b4_epilogue
+]b4_epilogue[]dnl
 dnl
 dnl glr.cc produces its own header.
 dnl
@@ -2614,5 +2612,5 @@ b4_copyright([Skeleton interface for Bison GLR parsers in 
C],
 ]b4_cpp_guard_open([b4_spec_defines_file])[
 ]b4_shared_declarations[
 ]b4_cpp_guard_close([b4_spec_defines_file])[
-]])])
+]])])dnl
 m4_divert_pop(0)
diff --git a/data/glr.cc b/data/glr.cc
index 78a7ae5..826bc80 100644
--- a/data/glr.cc
+++ b/data/glr.cc
@@ -211,9 +211,7 @@ m4_pushdef([b4_parse_param], 
m4_defn([b4_parse_param_orig]))dnl
 
 #endif
 ]m4_popdef([b4_parse_param])dnl
-b4_namespace_close[
-
-]])
+b4_namespace_close])
 
 
 # Let glr.c believe that the user arguments include the parser itself.
diff --git a/data/lalr1.cc b/data/lalr1.cc
index c163903..82e6824 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -1104,5 +1104,5 @@ b4_error_verbose_if([int yystate, int yytoken],
   const ]b4_parser_class_name[::token_number_type 
]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
 
 ]b4_namespace_close[
-]b4_epilogue
+]b4_epilogue[]dnl
 m4_divert_pop(0)
diff --git a/data/yacc.c b/data/yacc.c
index 1cd9ffb..0175688 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -2045,7 +2045,7 @@ yypushreturn:]])[
 }
 
 
-]b4_epilogue
+]b4_epilogue[]dnl
 b4_defines_if(
 address@hidden(b4_spec_defines_file@)@
 b4_copyright([Bison interface for Yacc-like parsers in C],
diff --git a/src/parse-gram.c b/src/parse-gram.c
index 207938d..a04f2f2 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 2.6.1.6-b045.  */
+/* A Bison parser, made by GNU Bison 2.6.1.12-3153-dirty.  */
 
 /* Bison implementation for Yacc-like parsers in C
    
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "2.6.1.6-b045"
+#define YYBISON_VERSION "2.6.1.12-3153-dirty"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -3225,4 +3225,3 @@ char_name (char c)
       return quotearg_style (escape_quoting_style, buf);
     }
 }
-
diff --git a/src/parse-gram.h b/src/parse-gram.h
index 50cfe23..0cc4d54 100644
--- a/src/parse-gram.h
+++ b/src/parse-gram.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 2.6.1.6-b045.  */
+/* A Bison parser, made by GNU Bison 2.6.1.12-3153-dirty.  */
 
 /* Bison interface for Yacc-like parsers in C
    
diff --git a/tests/calc.at b/tests/calc.at
index 31ee44e..3aab868 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -386,11 +386,9 @@ AT_YYERROR_SEES_LOC_IF([
   fprintf (stderr, ": ");])
   fprintf (stderr, "%s\n", s);
 }])[
-
 ]AT_DEFINES_IF([],
 [AT_CALC_LEX
-AT_CALC_MAIN])[
-]])
+AT_CALC_MAIN])])
 
 AT_DEFINES_IF([AT_DATA_SOURCE([[calc-lex.c]AT_SKEL_CC_IF([[c]])],
 [[#include "calc.h]AT_SKEL_CC_IF([[h]])["
@@ -500,6 +498,20 @@ AT_CHECK([cat stderr], 0, [expout])
 ])
 
 
+# AT_CHECK_SPACES([FILE])
+# -----------------------
+# Make sure we did not introduce bad spaces.  Checked here because all
+# the skeletons are (or should be) exercized here.
+m4_define([AT_CHECK_SPACES],
+[# No initial empty lines.
+AT_CHECK([sed -ne '/./q;=;p;' $1])
+# No trailing spaces.
+# FIXME: For 2.7: AT_CHECK([sed -ne '/[ ]$/{=;p;}' $1])
+# No final empty lines.
+AT_CHECK([sed -ne '${/^$/{=;p;};}' $1])
+])
+
+
 # AT_CHECK_CALC([BISON-OPTIONS])
 # ------------------------------
 # Start a testing chunk which compiles `calc' grammar with
@@ -514,6 +526,8 @@ AT_BISON_OPTION_PUSHDEFS([$1])
 
 AT_DATA_CALC_Y([$1])
 AT_FULL_COMPILE([calc], AT_DEFINES_IF([[lex], [main]]))
+AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([cc], [c])])
+AT_DEFINES_IF([AT_CHECK_SPACES([calc.AT_SKEL_CC_IF([hh], [h])])])
 
 # Test the priorities.
 _AT_CHECK_CALC([$1],
-- 
1.7.11.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]