bison-patches
[Top][All Lists]
Advanced

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

[PATCH] Use b4_subtract where possible.


From: Akim Demaille
Subject: [PATCH] Use b4_subtract where possible.
Date: Mon, 17 Nov 2008 08:48:00 +0100

        * data/lalr1.cc (b4_subtract): Move to...
        * data/bison.m4: here.
        * data/glr.c (b4_rhs_data): Use it.
        * data/yacc.c (b4_rhs_value, b4_rhs_location): Use it.
---
 ChangeLog     |    8 ++++++++
 data/bison.m4 |   14 +++++++++-----
 data/glr.c    |    2 +-
 data/lalr1.cc |   10 ----------
 data/yacc.c   |    4 ++--
 5 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 608c2ce..3531117 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2008-11-18  Akim Demaille  <address@hidden>
 
+       Use b4_subtract where possible.
+       * data/lalr1.cc (b4_subtract): Move to...
+       * data/bison.m4: here.
+       * data/glr.c (b4_rhs_data): Use it.
+       * data/yacc.c (b4_rhs_value, b4_rhs_location): Use it.
+
+2008-11-18  Akim Demaille  <address@hidden>
+
        Remove incorrect mode specification.
        * data/glr.cc: Don't pretend it's C code.
 
diff --git a/data/bison.m4 b/data/bison.m4
index 7cb43b8..c7392b3 100644
--- a/data/bison.m4
+++ b/data/bison.m4
@@ -212,6 +212,15 @@ m4_define([b4_ints_in],
 [m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
 
 
+# b4_subtract(LHS, RHS)
+# ---------------------
+# Evaluate LHS - RHS if they are integer literals, otherwise expand
+# to (LHS) - (RHS).
+m4_define([b4_subtract],
+[m4_bmatch([$1$2], [^[0123456789]*$],
+           [m4_eval([$1 - $2])],
+           [($1) - ($2)])])
+
 
 ## ------------------ ##
 ## Decoding options.  ##
@@ -257,11 +266,6 @@ b4_define_flag_if([nondeterministic])      # Whether 
conflicts should be handled.
 b4_define_flag_if([yacc])              # Whether POSIX Yacc is emulated.
 
 
-## ------------------------- ##
-## Assigning token numbers.  ##
-## ------------------------- ##
-
-
 ## ----------- ##
 ## Synclines.  ##
 ## ----------- ##
diff --git a/data/glr.c b/data/glr.c
index f8a32a8..910a8ee 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -117,7 +117,7 @@ m4_define([b4_lhs_value],
 # Expand to the semantic stack place that contains value and location
 # of symbol number NUM in a rule of length RULE-LENGTH.
 m4_define([b4_rhs_data],
-[((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate])
+[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
 
 
 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 6e5042d..58ebe94 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -18,16 +18,6 @@
 
 m4_include(b4_pkgdatadir/[c++.m4])
 
-# b4_subtract(LHS, RHS)
-# ---------------------
-# Evaluate LHS - RHS if they are integer literals, otherwise expand
-# to (LHS) - (RHS).
-m4_define([b4_subtract],
-[m4_bmatch([$1$2], [^[0123456789]*$],
-           [m4_eval([$1 - $2])],
-           [($1) - ($2)])])
-
-
 # b4_args(ARG1, ...)
 # _b4_args(ARG1, ...)
 # -------------------
diff --git a/data/yacc.c b/data/yacc.c
index 36028e2..872e63f 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -124,7 +124,7 @@ m4_define([b4_lhs_value],
 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
 # symbols on RHS.
 m4_define([b4_rhs_value],
-[b4_symbol_value(address@hidden($2) - ($1)@}], [$3])])
+          [b4_symbol_value(address@hidden([$2], [$1])@}], [$3])])
 
 
 
@@ -144,7 +144,7 @@ m4_define([b4_lhs_location],
 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
 # on RHS.
 m4_define([b4_rhs_location],
-[(address@hidden($2) - ($1)@})])
+          [(address@hidden([$2], [$1])@})])
 
 
 
-- 
1.6.0.2.588.g3102





reply via email to

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