mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Parameterize the extraction of semantic values.
To make future changes easier, no longer rely on ".TYPE" being the way to get a semantic value. * data/c.m4 (b4_symbol_value): New. Use it. * data/c++.m4, data/yacc.c: Use it. * data/glr.c: Use b4_symbol_value. (b4_rhs_data): New. Use it.
This commit is contained in:
17
data/c.m4
17
data/c.m4
@@ -205,6 +205,21 @@ m4_define([b4_token_enums_defines],
|
||||
])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
# b4_symbol_value(VAL, [TYPE])
|
||||
# ----------------------------
|
||||
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
|
||||
# TYPE if TYPE is given, otherwise just return VAL. The result can be
|
||||
# used safetly, it is put in parens to avoid nasty precedence issues.
|
||||
# TYPE is *not* put in braces, provide some if needed.
|
||||
m4_define([b4_symbol_value],
|
||||
[($1[]m4_ifval([$2], [.$2]))])
|
||||
|
||||
|
||||
|
||||
## --------------------------------------------- ##
|
||||
## Defining C functions in both K&R and ANSI-C. ##
|
||||
@@ -360,7 +375,7 @@ $2
|
||||
# -------------------------------------------------
|
||||
m4_define([b4_symbol_actions],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
|
||||
[b4_symbol_value([(*yyvaluep)], [$6])])dnl
|
||||
m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
|
||||
case $4: /* $3 */
|
||||
b4_syncline([$2], [$1])
|
||||
|
||||
Reference in New Issue
Block a user