support $<tag>$ in printers and destructors

* src/scan-code.l (SC_SYMBOL_ACTION): Accept $<tag>$, not just $$.
* data/c.m4 (b4_dollar_dollar_): New.
(b4_symbol_actions): Let b4_dollar_dollar use b4_dollar_dollar_.
* NEWS, doc/bison.texi: Document it.
* tests/actions.at: Check this for C and C++.
This commit is contained in:
Akim Demaille
2012-07-26 16:52:35 +02:00
parent 65a99eca25
commit 4982f078bf
6 changed files with 182 additions and 15 deletions

View File

@@ -417,13 +417,28 @@ m4_define([b4_case],
$2
break;])
# b4_dollar_dollar_(NAME, FIELD, DEFAULT-FIELD)
# ---------------------------------------------
# If FIELD (or DEFAULT-FIELD) is non-null, read it in pointer NAME,
# otherwise just dereference.
m4_define([b4_dollar_dollar_],
[m4_if([$2], [[]],
[m4_ifval([$3], [($1->$3)],
[(*$1)])],
[($1->$2)])])
# b4_symbol_actions(FILENAME, LINENO,
# SYMBOL-TAG, SYMBOL-NUM,
# SYMBOL-ACTION, SYMBOL-TYPENAME)
# -------------------------------------------------
# Issue the code for a symbol action (e.g., %printer).
#
# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are
# invoked where $<TYPE-NAME>$ and @$ were specified by the user.
m4_define([b4_symbol_actions],
[m4_pushdef([b4_dollar_dollar],
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
[b4_dollar_dollar_([yyvaluep], m4_dquote($][1), [$6])])dnl
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
case $4: /* $3 */
b4_syncline([$2], [$1])