]>
Commit | Line | Data |
---|---|---|
08af01c2 | 1 | -*- Autoconf -*- |
fb8135fa AD |
2 | |
3 | # C M4 Macros for Bison. | |
a3764451 EB |
4 | # Copyright (C) 2002, 2004, 2005, 2006, 2007, 2008 Free Software |
5 | # Foundation, Inc. | |
fb8135fa | 6 | |
f16b0819 | 7 | # This program is free software: you can redistribute it and/or modify |
fb8135fa | 8 | # it under the terms of the GNU General Public License as published by |
f16b0819 | 9 | # the Free Software Foundation, either version 3 of the License, or |
fb8135fa | 10 | # (at your option) any later version. |
f16b0819 | 11 | # |
fb8135fa AD |
12 | # This program is distributed in the hope that it will be useful, |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
f16b0819 | 16 | # |
fb8135fa | 17 | # You should have received a copy of the GNU General Public License |
f16b0819 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
fb8135fa | 19 | |
2a8d363a AD |
20 | ## ---------------- ## |
21 | ## Identification. ## | |
22 | ## ---------------- ## | |
fb8135fa | 23 | |
6ab1adbe AD |
24 | # b4_comment_(TEXT, OPEN, CONTINUE, END) |
25 | # ------------------------------------- | |
30bb2edc AD |
26 | # Put TEXT in comment. Avoid trailing spaces: don't indent empty lines. |
27 | # Avoid adding indentation to the first line, as the indentation comes | |
6ab1adbe AD |
28 | # from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]). |
29 | # | |
30 | # Prefix all the output lines with PREFIX. | |
31 | m4_define([b4_comment_], [$2[]m4_bpatsubst([$1], [ | |
30bb2edc | 32 | \(.\)], [ |
6ab1adbe AD |
33 | $3\1])$4]) |
34 | ||
35 | ||
36 | # b4_c_comment(TEXT, [PREFIX]) | |
37 | # ---------------------------- | |
38 | # Put TEXT in comment. Avoid trailing spaces: don't indent empty lines. | |
39 | # Avoid adding indentation to the first line, as the indentation comes | |
40 | # from "/*". That's why we don't patsubst([$1], [^\(.\)], [ \1]). | |
41 | # | |
42 | # Prefix all the output lines with PREFIX. | |
43 | m4_define([b4_c_comment], | |
44 | [b4_comment_([$1], [$2/* ], [$2 ], [$2 */])]) | |
45 | ||
46 | ||
47 | # b4_comment(TEXT, [PREFIX]) | |
48 | # -------------------------- | |
49 | # By default, C comments. | |
50 | m4_define([b4_comment], [b4_c_comment($@)]) | |
51 | ||
fb8135fa | 52 | |
2a8d363a AD |
53 | # b4_identification |
54 | # ----------------- | |
d9df47b6 JD |
55 | # Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or |
56 | # b4_pull_flag if they use the values of the %define variables api.pure or | |
57 | # api.push_pull. | |
2a8d363a | 58 | m4_define([b4_identification], |
d9df47b6 JD |
59 | [[/* Identify Bison output. */ |
60 | #define YYBISON 1 | |
2a8d363a | 61 | |
55f64b82 | 62 | /* Bison version. */ |
d9df47b6 | 63 | #define YYBISON_VERSION "]b4_version[" |
55f64b82 | 64 | |
2a8d363a | 65 | /* Skeleton name. */ |
d9df47b6 | 66 | #define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[ |
2a8d363a AD |
67 | |
68 | /* Pure parsers. */ | |
d9df47b6 JD |
69 | #define YYPURE ]b4_pure_flag])[]m4_ifdef([b4_push_flag], [[ |
70 | ||
71 | /* Push parsers. */ | |
72 | #define YYPUSH ]b4_push_flag])[]m4_ifdef([b4_pull_flag], [[ | |
73 | ||
74 | /* Pull parsers. */ | |
75 | #define YYPULL ]b4_pull_flag])[ | |
2a8d363a AD |
76 | |
77 | /* Using locations. */ | |
d9df47b6 JD |
78 | #define YYLSP_NEEDED ]b4_locations_flag[ |
79 | ]]) | |
2a8d363a AD |
80 | |
81 | ||
7ec2d4cd AD |
82 | ## ---------------- ## |
83 | ## Default values. ## | |
84 | ## ---------------- ## | |
85 | ||
1b818f33 AD |
86 | # If the %union is not named, its name is YYSTYPE. |
87 | m4_define_default([b4_union_name], [YYSTYPE]) | |
7ec2d4cd | 88 | |
90b9908d PB |
89 | # If the %name-prefix is not given, it is yy. |
90 | m4_define_default([b4_prefix], [yy]) | |
cd48d21d | 91 | |
2a8d363a AD |
92 | ## ------------------------ ## |
93 | ## Pure/impure interfaces. ## | |
94 | ## ------------------------ ## | |
95 | ||
2a8d363a AD |
96 | # b4_user_args |
97 | # ------------ | |
98 | m4_define([b4_user_args], | |
99 | [m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])]) | |
100 | ||
101 | ||
102 | # b4_parse_param | |
103 | # -------------- | |
104 | # If defined, b4_parse_param arrives double quoted, but below we prefer | |
105 | # it to be single quoted. | |
2a8d363a | 106 | m4_define([b4_parse_param], |
7ecec4dd | 107 | b4_parse_param) |
2a8d363a | 108 | |
8f7e3cf9 | 109 | |
613d8952 AD |
110 | # b4_parse_param_for(DECL, FORMAL, BODY) |
111 | # --------------------------------------- | |
112 | # Iterate over the user parameters, binding the declaration to DECL, | |
113 | # the formal name to FORMAL, and evaluating the BODY. | |
114 | m4_define([b4_parse_param_for], | |
115 | [m4_foreach([$1_$2], m4_defn([b4_parse_param]), | |
6bbb2ed5 | 116 | [m4_pushdef([$1], m4_unquote(m4_car($1_$2)))dnl |
613d8952 AD |
117 | m4_pushdef([$2], m4_shift($1_$2))dnl |
118 | $3[]dnl | |
119 | m4_popdef([$2])dnl | |
120 | m4_popdef([$1])dnl | |
121 | ])]) | |
122 | ||
123 | # b4_parse_param_use | |
124 | # ------------------ | |
125 | # `YYUSE' all the parse-params. | |
613d8952 AD |
126 | m4_define([b4_parse_param_use], |
127 | [b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal); | |
128 | ])dnl | |
129 | ]) | |
2a8d363a | 130 | |
8e1687ae | 131 | |
fb8135fa AD |
132 | ## ------------ ## |
133 | ## Data Types. ## | |
134 | ## ------------ ## | |
135 | ||
a762e609 AD |
136 | # b4_int_type(MIN, MAX) |
137 | # --------------------- | |
138 | # Return the smallest int type able to handle numbers ranging from | |
139 | # MIN to MAX (included). | |
140 | m4_define([b4_int_type], | |
141 | [m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char], | |
f1886bb2 | 142 | b4_ints_in($@, [-128], [127]), [1], [signed char], |
a762e609 | 143 | |
779e7ceb PE |
144 | b4_ints_in($@, [0], [65535]), [1], [unsigned short int], |
145 | b4_ints_in($@, [-32768], [32767]), [1], [short int], | |
a762e609 AD |
146 | |
147 | m4_eval([0 <= $1]), [1], [unsigned int], | |
148 | ||
02650b7f | 149 | [int])]) |
a762e609 | 150 | |
f1886bb2 | 151 | |
a762e609 AD |
152 | # b4_int_type_for(NAME) |
153 | # --------------------- | |
154 | # Return the smallest int type able to handle numbers ranging from | |
155 | # `NAME_min' to `NAME_max' (included). | |
156 | m4_define([b4_int_type_for], | |
157 | [b4_int_type($1_min, $1_max)]) | |
fb8135fa | 158 | |
cf98343c AD |
159 | |
160 | ||
8e1687ae PE |
161 | ## ---------## |
162 | ## Values. ## | |
163 | ## ---------## | |
164 | ||
165 | # b4_null | |
166 | --------- | |
167 | # Return a null pointer constant. NULL infringes on the user name | |
168 | # space in C, so use 0 rather than NULL. | |
169 | m4_define([b4_null], [0]) | |
170 | ||
171 | ||
cf98343c AD |
172 | |
173 | ||
fb8135fa AD |
174 | ## ------------------------- ## |
175 | ## Assigning token numbers. ## | |
176 | ## ------------------------- ## | |
177 | ||
178 | # b4_token_define(TOKEN-NAME, TOKEN-NUMBER) | |
179 | # ----------------------------------------- | |
180 | # Output the definition of this token as #define. | |
181 | m4_define([b4_token_define], | |
5679f311 | 182 | [#define b4_percent_define_get([token.prefix])$1 $2 |
fb8135fa AD |
183 | ]) |
184 | ||
185 | ||
cf147260 AD |
186 | # b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) |
187 | # ------------------------------------------------------- | |
188 | # Output the definition of the tokens (if there are) as #defines. | |
189 | m4_define([b4_token_defines], | |
6bbb2ed5 | 190 | [m4_if([$#$1], [1], [], |
cf147260 AD |
191 | [/* Tokens. */ |
192 | m4_map([b4_token_define], [$@])]) | |
193 | ]) | |
194 | ||
195 | ||
fb8135fa AD |
196 | # b4_token_enum(TOKEN-NAME, TOKEN-NUMBER) |
197 | # --------------------------------------- | |
198 | # Output the definition of this token as an enum. | |
199 | m4_define([b4_token_enum], | |
5679f311 | 200 | [b4_percent_define_get([token.prefix])$1 = $2]) |
fb8135fa AD |
201 | |
202 | ||
cf147260 AD |
203 | # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) |
204 | # ----------------------------------------------------- | |
205 | # Output the definition of the tokens (if there are) as enums. | |
206 | m4_define([b4_token_enums], | |
6bbb2ed5 | 207 | [m4_if([$#$1], [1], [], |
fb8135fa | 208 | [/* Tokens. */ |
6b8c3254 PE |
209 | #ifndef YYTOKENTYPE |
210 | # define YYTOKENTYPE | |
fb8135fa AD |
211 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
212 | know about them. */ | |
213 | enum yytokentype { | |
214 | m4_map_sep([ b4_token_enum], [, | |
215 | ], | |
02650b7f | 216 | [$@]) |
fb8135fa | 217 | }; |
095b9f05 | 218 | #endif |
cf147260 AD |
219 | ])]) |
220 | ||
221 | ||
222 | # b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) | |
223 | # ------------------------------------------------------------- | |
b931235e JD |
224 | # Output the definition of the tokens (if there are any) as enums and, if POSIX |
225 | # Yacc is enabled, as #defines. | |
cf147260 | 226 | m4_define([b4_token_enums_defines], |
b931235e | 227 | [b4_token_enums($@)b4_yacc_if([b4_token_defines($@)], []) |
fb8135fa | 228 | ]) |
4a2a22f4 AD |
229 | |
230 | ||
1fa5d8bb AD |
231 | ## ----------------- ## |
232 | ## Semantic Values. ## | |
233 | ## ----------------- ## | |
234 | ||
235 | ||
236 | # b4_symbol_value(VAL, [TYPE]) | |
237 | # ---------------------------- | |
238 | # Given a semantic value VAL ($$, $1 etc.), extract its value of type | |
239 | # TYPE if TYPE is given, otherwise just return VAL. The result can be | |
240 | # used safetly, it is put in parens to avoid nasty precedence issues. | |
241 | # TYPE is *not* put in braces, provide some if needed. | |
242 | m4_define([b4_symbol_value], | |
243 | [($1[]m4_ifval([$2], [.$2]))]) | |
244 | ||
245 | ||
ae7453f2 | 246 | |
0245f82d AD |
247 | ## --------------------------------------------- ## |
248 | ## Defining C functions in both K&R and ANSI-C. ## | |
249 | ## --------------------------------------------- ## | |
4a2a22f4 AD |
250 | |
251 | ||
1b9c21fb PE |
252 | # b4_modern_c |
253 | # ----------- | |
254 | # A predicate useful in #if to determine whether C is ancient or modern. | |
255 | # | |
256 | # If __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run | |
257 | # as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic | |
258 | # reasons, but it defines __C99__FUNC__ so check that as well. | |
259 | # Microsoft C normally doesn't define these macros, but it defines _MSC_VER. | |
7a0db73e | 260 | # Consider a C++ compiler to be modern if it defines __cplusplus. |
1b9c21fb PE |
261 | # |
262 | m4_define([b4_c_modern], | |
02650b7f PE |
263 | [[(defined __STDC__ || defined __C99__FUNC__ \ |
264 | || defined __cplusplus || defined _MSC_VER)]]) | |
1b9c21fb | 265 | |
0245f82d AD |
266 | # b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...) |
267 | # ---------------------------------------------------------- | |
4a2a22f4 | 268 | # Declare the function NAME. |
0245f82d | 269 | m4_define([b4_c_function_def], |
1b9c21fb | 270 | [#if b4_c_modern |
0245f82d | 271 | b4_c_ansi_function_def($@) |
4a2a22f4 | 272 | #else |
0245f82d | 273 | $2 |
a3764451 EB |
274 | $1 (b4_c_knr_formal_names(m4_shift2($@))) |
275 | b4_c_knr_formal_decls(m4_shift2($@)) | |
4a2a22f4 AD |
276 | #endif[]dnl |
277 | ]) | |
278 | ||
279 | ||
0245f82d AD |
280 | # b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...) |
281 | # --------------------------------------------------------------- | |
282 | # Declare the function NAME in ANSI. | |
283 | m4_define([b4_c_ansi_function_def], | |
284 | [$2 | |
a3764451 | 285 | $1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl |
0245f82d AD |
286 | ]) |
287 | ||
288 | ||
289 | # b4_c_ansi_formals([DECL1, NAME1], ...) | |
290 | # -------------------------------------- | |
4a2a22f4 | 291 | # Output the arguments ANSI-C definition. |
0245f82d | 292 | m4_define([b4_c_ansi_formals], |
6bbb2ed5 EB |
293 | [m4_if([$#], [0], [void], |
294 | [$#$1], [1], [void], | |
02650b7f | 295 | [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])]) |
4a2a22f4 | 296 | |
0245f82d AD |
297 | m4_define([b4_c_ansi_formal], |
298 | [$1]) | |
4a2a22f4 AD |
299 | |
300 | ||
0245f82d AD |
301 | # b4_c_knr_formal_names([DECL1, NAME1], ...) |
302 | # ------------------------------------------ | |
4a2a22f4 | 303 | # Output the argument names. |
0245f82d AD |
304 | m4_define([b4_c_knr_formal_names], |
305 | [m4_map_sep([b4_c_knr_formal_name], [, ], [$@])]) | |
4a2a22f4 | 306 | |
0245f82d | 307 | m4_define([b4_c_knr_formal_name], |
4a2a22f4 AD |
308 | [$2]) |
309 | ||
310 | ||
0245f82d AD |
311 | # b4_c_knr_formal_decls([DECL1, NAME1], ...) |
312 | # ------------------------------------------ | |
4a2a22f4 | 313 | # Output the K&R argument declarations. |
0245f82d AD |
314 | m4_define([b4_c_knr_formal_decls], |
315 | [m4_map_sep([b4_c_knr_formal_decl], | |
02650b7f | 316 | [ |
4a2a22f4 | 317 | ], |
02650b7f | 318 | [$@])]) |
4a2a22f4 | 319 | |
0245f82d AD |
320 | m4_define([b4_c_knr_formal_decl], |
321 | [ $1;]) | |
21964f43 AD |
322 | |
323 | ||
324 | ||
0245f82d AD |
325 | ## ------------------------------------------------------------ ## |
326 | ## Declaring (prototyping) C functions in both K&R and ANSI-C. ## | |
327 | ## ------------------------------------------------------------ ## | |
21964f43 AD |
328 | |
329 | ||
0245f82d AD |
330 | # b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...) |
331 | # ----------------------------------------------------------- | |
332 | # Declare the function NAME. | |
333 | m4_define([b4_c_function_decl], | |
02650b7f | 334 | [#if defined __STDC__ || defined __cplusplus |
0245f82d AD |
335 | b4_c_ansi_function_decl($@) |
336 | #else | |
337 | $2 $1 (); | |
338 | #endif[]dnl | |
339 | ]) | |
21964f43 AD |
340 | |
341 | ||
0245f82d AD |
342 | # b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...) |
343 | # ---------------------------------------------------------------- | |
344 | # Declare the function NAME. | |
345 | m4_define([b4_c_ansi_function_decl], | |
a3764451 | 346 | [$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl |
0245f82d AD |
347 | ]) |
348 | ||
349 | ||
350 | ||
351 | ||
352 | ## --------------------- ## | |
353 | ## Calling C functions. ## | |
354 | ## --------------------- ## | |
355 | ||
356 | ||
357 | # b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...) | |
358 | # ----------------------------------------------------------- | |
359 | # Call the function NAME with arguments NAME1, NAME2 etc. | |
360 | m4_define([b4_c_function_call], | |
a3764451 | 361 | [$1 (b4_c_args(m4_shift2($@)))[]dnl |
0245f82d AD |
362 | ]) |
363 | ||
364 | ||
365 | # b4_c_args([DECL1, NAME1], ...) | |
366 | # ------------------------------ | |
367 | # Output the arguments NAME1, NAME2... | |
368 | m4_define([b4_c_args], | |
369 | [m4_map_sep([b4_c_arg], [, ], [$@])]) | |
370 | ||
371 | m4_define([b4_c_arg], | |
372 | [$2]) | |
437c2d80 AD |
373 | |
374 | ||
375 | ## ----------- ## | |
376 | ## Synclines. ## | |
377 | ## ----------- ## | |
378 | ||
90b9908d | 379 | # b4_sync_start(LINE, FILE) |
8ec0a172 | 380 | # ----------------------- |
90b9908d | 381 | m4_define([b4_sync_start], [[#]line $1 $2]) |
8ec0a172 | 382 | |
613d8952 AD |
383 | |
384 | ## -------------- ## | |
385 | ## User actions. ## | |
386 | ## -------------- ## | |
387 | ||
8e1687ae PE |
388 | # b4_case(LABEL, STATEMENTS) |
389 | # -------------------------- | |
390 | m4_define([b4_case], | |
391 | [ case $1: | |
392 | $2 | |
2141aded | 393 | b4_syncline([@oline@], [@ofile@]) |
8e1687ae PE |
394 | break;]) |
395 | ||
b0400cc6 AD |
396 | # b4_symbol_actions(FILENAME, LINENO, |
397 | # SYMBOL-TAG, SYMBOL-NUM, | |
398 | # SYMBOL-ACTION, SYMBOL-TYPENAME) | |
399 | # ------------------------------------------------- | |
400 | m4_define([b4_symbol_actions], | |
60c82948 | 401 | [m4_pushdef([b4_dollar_dollar], |
1fa5d8bb | 402 | [b4_symbol_value([(*yyvaluep)], [$6])])dnl |
7bd6c77e | 403 | m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl |
b0400cc6 AD |
404 | case $4: /* $3 */ |
405 | b4_syncline([$2], [$1]) | |
02650b7f | 406 | $5; |
b0400cc6 | 407 | b4_syncline([@oline@], [@ofile@]) |
02650b7f | 408 | break; |
b0400cc6 AD |
409 | m4_popdef([b4_at_dollar])dnl |
410 | m4_popdef([b4_dollar_dollar])dnl | |
411 | ]) | |
412 | ||
413 | ||
14740648 PE |
414 | # b4_yydestruct_generate(FUNCTION-DECLARATOR) |
415 | # ------------------------------------------- | |
b0400cc6 | 416 | # Generate the "yydestruct" function, which declaration is issued using |
14740648 | 417 | # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C |
b0400cc6 | 418 | # or "b4_c_function_def" for K&R. |
cf147260 | 419 | m4_define_default([b4_yydestruct_generate], |
b0400cc6 AD |
420 | [[/*-----------------------------------------------. |
421 | | Release the memory associated to this symbol. | | |
422 | `-----------------------------------------------*/ | |
423 | ||
12ce2df6 | 424 | /*ARGSUSED*/ |
b0400cc6 AD |
425 | ]$1([yydestruct], |
426 | [static void], | |
a0e68930 | 427 | [[const char *yymsg], [yymsg]], |
7bd6c77e | 428 | [[int yytype], [yytype]], |
4b367315 | 429 | [[YYSTYPE *yyvaluep], [yyvaluep]][]dnl |
327afc7c | 430 | b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl |
4b367315 | 431 | m4_ifset([b4_parse_param], [, b4_parse_param]))[ |
b0400cc6 | 432 | { |
2a4647a3 | 433 | YYUSE (yyvaluep); |
327afc7c | 434 | ]b4_locations_if([ YYUSE (yylocationp); |
613d8952 AD |
435 | ])dnl |
436 | b4_parse_param_use[]dnl | |
437 | [ | |
a0e68930 AD |
438 | if (!yymsg) |
439 | yymsg = "Deleting"; | |
440 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | |
441 | ||
b0400cc6 AD |
442 | switch (yytype) |
443 | { | |
444 | ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ | |
445 | default: | |
02650b7f | 446 | break; |
b0400cc6 AD |
447 | } |
448 | }]dnl | |
449 | ]) | |
7bd6c77e AD |
450 | |
451 | ||
a0af42fc AD |
452 | # b4_yy_symbol_print_generate(FUNCTION-DECLARATOR) |
453 | # ------------------------------------------------ | |
454 | # Generate the "yy_symbol_print" function, which declaration is issued using | |
14740648 | 455 | # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C |
7bd6c77e | 456 | # or "b4_c_function_def" for K&R. |
a0af42fc AD |
457 | m4_define_default([b4_yy_symbol_print_generate], |
458 | [[ | |
459 | /*--------------------------------. | |
14740648 PE |
460 | | Print this symbol on YYOUTPUT. | |
461 | `--------------------------------*/ | |
7bd6c77e | 462 | |
12ce2df6 | 463 | /*ARGSUSED*/ |
a0af42fc | 464 | ]$1([yy_symbol_value_print], |
7bd6c77e | 465 | [static void], |
02650b7f PE |
466 | [[FILE *yyoutput], [yyoutput]], |
467 | [[int yytype], [yytype]], | |
50cce58e PE |
468 | [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl |
469 | b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl | |
4b367315 | 470 | m4_ifset([b4_parse_param], [, b4_parse_param]))[ |
7bd6c77e | 471 | { |
05449a2c JD |
472 | if (!yyvaluep) |
473 | return; | |
327afc7c | 474 | ]b4_locations_if([ YYUSE (yylocationp); |
7bd6c77e | 475 | ])dnl |
613d8952 | 476 | b4_parse_param_use[]dnl |
a0af42fc | 477 | [# ifdef YYPRINT |
619404e3 AD |
478 | if (yytype < YYNTOKENS) |
479 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | |
c66dfadd PE |
480 | # else |
481 | YYUSE (yyoutput); | |
619404e3 | 482 | # endif |
7bd6c77e AD |
483 | switch (yytype) |
484 | { | |
3fc16193 AD |
485 | ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl |
486 | [ default: | |
02650b7f | 487 | break; |
7bd6c77e | 488 | } |
a0af42fc AD |
489 | } |
490 | ||
491 | ||
492 | /*--------------------------------. | |
493 | | Print this symbol on YYOUTPUT. | | |
494 | `--------------------------------*/ | |
495 | ||
496 | ]$1([yy_symbol_print], | |
497 | [static void], | |
02650b7f PE |
498 | [[FILE *yyoutput], [yyoutput]], |
499 | [[int yytype], [yytype]], | |
50cce58e PE |
500 | [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl |
501 | b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl | |
a0af42fc AD |
502 | m4_ifset([b4_parse_param], [, b4_parse_param]))[ |
503 | { | |
504 | if (yytype < YYNTOKENS) | |
505 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | |
506 | else | |
507 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | |
508 | ||
327afc7c | 509 | ]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp); |
a0af42fc AD |
510 | YYFPRINTF (yyoutput, ": "); |
511 | ])dnl | |
512 | [ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl | |
327afc7c | 513 | b4_locations_if([, yylocationp])[]b4_user_args[); |
2f4f028d | 514 | YYFPRINTF (yyoutput, ")"); |
4b367315 AD |
515 | }]dnl |
516 | ]) |