bison-patches
[Top][All Lists]
Advanced

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

[PATCH 1/4] simplify the generated #line


From: Akim Demaille
Subject: [PATCH 1/4] simplify the generated #line
Date: Sat, 16 Mar 2019 10:02:06 +0100

Currently we generate things like:

    #line 683 "src/parse-gram.y" /* yacc.c:316  */

The first part is of course very important: compilers point the users
to their grammar file rather than into the generated parser.  The
second part points to the skeleton part that generated this piece of
code.

This generates dependencies on the Bison skeletons hence lots of
useless 'git diff'.  This location is useless for the regular
user (who does not care about the skeletons) and is actually not
useful for Bison developpers too (I, Akim, never used this to locate
the code in skeletons that generated output).  So disable it
completely.  If someone thinks this was actually useful, a %define
variable should be provided to control the level of verbosity of
'#line', in replacement of --no-lines.

So now, generate:

    #line 683 "src/parse-gram.y"

* data/skeletons/bison.m4 (b4_sync_end): Emit nothing.
---
 data/skeletons/bison.m4 | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4
index e3591875..cefe6a91 100644
--- a/data/skeletons/bison.m4
+++ b/data/skeletons/bison.m4
@@ -588,10 +588,11 @@ m4_define([b4_basename],
 
 # b4_syncline(LINE, FILE)
 # -----------------------
+# Emit "#line LINE FILE /* __LINE__ __FILE__ */".
 m4_define([b4_syncline],
 [b4_flag_if([synclines],
-[b4_sync_start([$1], [$2]) b4_sync_end([__line__],
-                                       [b4_basename(m4_quote(__file__))])[]dnl
+[b4_sync_start([$1], [$2])[]dnl
+b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])[]dnl
 ])])
 
 # b4_sync_start(LINE, FILE)
@@ -603,7 +604,17 @@ m4_define([b4_sync_start], [b4_comment([$2:$1])])
 # -----------------------
 # Syncline for the current place, which ends.  Typically a comment
 # left for the reader.
-m4_define([b4_sync_end],   [b4_comment([$2:$1])])
+m4_define([b4_sync_end],   [ b4_comment([$2:$1])]
+)
+# This generates dependencies on the Bison skeletons hence lots of
+# useless 'git diff'.  This location is useless for the regular
+# user (who does not care about the skeletons) and is actually not
+# useful for Bison developpers too (I, Akim, never used this to locate
+# the code in skeletons that generated output).  So disable it
+# completely.  If someone thinks this was actually useful, a %define
+# variable should be provided to control the level of verbosity of
+# '#line', in replacement of --no-lines.
+m4_define([b4_sync_end])
 
 
 # b4_user_code(USER-CODE)
-- 
2.21.0




reply via email to

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