[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Compute at M4 time some of the subtractions.
From: |
Akim Demaille |
Subject: |
[PATCH] Compute at M4 time some of the subtractions. |
Date: |
Thu, 13 Nov 2008 06:08:28 -0000 |
* data/lalr1.cc (b4_substract): New.
(b4_rhs_data): Use it.
---
ChangeLog | 6 ++++++
data/lalr1.cc | 11 ++++++++++-
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 134e862..56f3931 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2008-11-13 Akim Demaille <address@hidden>
+ Compute at M4 time some of the subtractions.
+ * data/lalr1.cc (b4_substract): New.
+ (b4_rhs_data): Use it.
+
+2008-11-13 Akim Demaille <address@hidden>
+
symbol::token.
This is allows the user to get the type of a token return by
yylex.
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 15a4258..97ba371 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -18,6 +18,15 @@
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, ...)
@@ -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],
- address@hidden($1) - ($2)@}])
+ address@hidden($@)@}])
# b4_rhs_state(RULE-LENGTH, NUM)
--
1.6.0.2.588.g3102
- [PATCH] Compute at M4 time some of the subtractions.,
Akim Demaille <=