]> git.saurik.com Git - bison.git/commitdiff
Compute at M4 time some of the subtractions.
authorAkim Demaille <demaille@gostai.com>
Mon, 1 Sep 2008 09:39:41 +0000 (11:39 +0200)
committerAkim Demaille <demaille@gostai.com>
Thu, 13 Nov 2008 06:04:47 +0000 (07:04 +0100)
* data/lalr1.cc (b4_substract): New.
(b4_rhs_data): Use it.

ChangeLog
data/lalr1.cc

index 134e862df451dded27db27ad19a54bc8a4a69ef8..56f39316049d3c2e6e38f409706567d44c68e6b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-13  Akim Demaille  <demaille@gostai.com>
+
+       Compute at M4 time some of the subtractions.
+       * data/lalr1.cc (b4_substract): New.
+       (b4_rhs_data): Use it.
+
 2008-11-13  Akim Demaille  <demaille@gostai.com>
 
        symbol::token.
 2008-11-13  Akim Demaille  <demaille@gostai.com>
 
        symbol::token.
index 15a42580565d7f880a45fd2044e0827cdfb39e9f..97ba371bd8795235b5f1a93fc0eeaeb5c0991c56 100644 (file)
 
 m4_include(b4_pkgdatadir/[c++.m4])
 
 
 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, ...)
 
 # b4_args(ARG1, ...)
 # _b4_args(ARG1, ...)
@@ -107,7 +116,7 @@ m4_define([b4_lhs_location],
 # Return the data corresponding to the symbol #NUM, where the current
 # rule has RULE-LENGTH symbols on RHS.
 m4_define([b4_rhs_data],
 # Return the data corresponding to the symbol #NUM, where the current
 # rule has RULE-LENGTH symbols on RHS.
 m4_define([b4_rhs_data],
-          [yystack_@{($1) - ($2)@}])
+          [yystack_@{b4_subtract($@)@}])
 
 
 # b4_rhs_state(RULE-LENGTH, NUM)
 
 
 # b4_rhs_state(RULE-LENGTH, NUM)