* 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 <demaille@gostai.com>
+
+ 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 <demaille@gostai.com>
Remove incorrect mode specification.
2008-11-18 Akim Demaille <demaille@gostai.com>
Remove incorrect mode specification.
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
[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. ##
## ------------------ ##
## Decoding options. ##
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
-## ------------------------- ##
-## Assigning token numbers. ##
-## ------------------------- ##
-
-
## ----------- ##
## Synclines. ##
## ----------- ##
## ----------- ##
## Synclines. ##
## ----------- ##
# 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],
# 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])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
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, ...)
# -------------------
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
m4_define([b4_rhs_value],
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
m4_define([b4_rhs_value],
-[b4_symbol_value([yyvsp@{($2) - ($1)@}], [$3])])
+ [b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3])])
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
-[(yylsp@{($2) - ($1)@})])
+ [(yylsp@{b4_subtract([$2], [$1])@})])