]>
Commit | Line | Data |
---|---|---|
55b929ca | 1 | m4_divert(-1) -*- Autoconf -*- |
fb8135fa AD |
2 | |
3 | # C M4 Macros for Bison. | |
e2a21b6f | 4 | # Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. |
fb8135fa AD |
5 | |
6 | # This program is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 2 of the License, or | |
9 | # (at your option) any later version. | |
10 | ||
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | ||
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program; if not, write to the Free Software | |
0fb669f9 PE |
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
19 | # 02110-1301 USA | |
fb8135fa AD |
20 | |
21 | ||
2a8d363a AD |
22 | ## ---------------- ## |
23 | ## Identification. ## | |
24 | ## ---------------- ## | |
fb8135fa AD |
25 | |
26 | # b4_copyright(TITLE, YEARS) | |
27 | # -------------------------- | |
28 | m4_define([b4_copyright], | |
fa3f2a88 | 29 | [/* A Bison parser, made by GNU Bison b4_version. */ |
fb8135fa | 30 | |
6e93d810 PE |
31 | /* $1 |
32 | ||
33 | m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ]) | |
fb8135fa AD |
34 | |
35 | This program is free software; you can redistribute it and/or modify | |
36 | it under the terms of the GNU General Public License as published by | |
37 | the Free Software Foundation; either version 2, or (at your option) | |
38 | any later version. | |
39 | ||
40 | This program is distributed in the hope that it will be useful, | |
41 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
42 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
43 | GNU General Public License for more details. | |
44 | ||
45 | You should have received a copy of the GNU General Public License | |
46 | along with this program; if not, write to the Free Software | |
0fb669f9 | 47 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
6e93d810 PE |
48 | Boston, MA 02110-1301, USA. */ |
49 | ||
50 | /* As a special exception, you may create a larger work that contains | |
51 | part or all of the Bison parser skeleton and distribute that work | |
52 | under terms of your choice, so long as that work isn't itself a | |
53 | parser generator using the skeleton or a modified version thereof | |
54 | as a parser skeleton. Alternatively, if you modify or redistribute | |
55 | the parser skeleton itself, you may (at your option) remove this | |
56 | special exception, which will cause the skeleton and the resulting | |
57 | Bison output files to be licensed under the GNU General Public | |
58 | License without this special exception. | |
59 | ||
60 | This special exception was added by the Free Software Foundation in | |
61 | version 2.2 of Bison. */]) | |
fb8135fa AD |
62 | |
63 | ||
2a8d363a AD |
64 | # b4_identification |
65 | # ----------------- | |
66 | m4_define([b4_identification], | |
67 | [/* Identify Bison output. */ | |
68 | [#]define YYBISON 1 | |
69 | ||
55f64b82 PE |
70 | /* Bison version. */ |
71 | [#]define YYBISON_VERSION "b4_version" | |
72 | ||
2a8d363a | 73 | /* Skeleton name. */ |
fa3f2a88 | 74 | [#]define YYSKELETON_NAME b4_skeleton |
2a8d363a AD |
75 | |
76 | /* Pure parsers. */ | |
327afc7c | 77 | [#]define YYPURE b4_pure_flag |
2a8d363a AD |
78 | |
79 | /* Using locations. */ | |
80 | [#]define YYLSP_NEEDED b4_locations_flag | |
81 | ]) | |
82 | ||
83 | ||
84 | ||
7ec2d4cd AD |
85 | ## ---------------- ## |
86 | ## Default values. ## | |
87 | ## ---------------- ## | |
88 | ||
89 | m4_define_default([b4_epilogue], []) | |
90 | ||
1b818f33 AD |
91 | # If the %union is not named, its name is YYSTYPE. |
92 | m4_define_default([b4_union_name], [YYSTYPE]) | |
7ec2d4cd | 93 | |
cd48d21d AD |
94 | # The initial column and line. |
95 | m4_define_default([b4_location_initial_column], [1]) | |
96 | m4_define_default([b4_location_initial_line], [1]) | |
97 | ||
98 | ||
2a8d363a AD |
99 | ## ------------------------ ## |
100 | ## Pure/impure interfaces. ## | |
101 | ## ------------------------ ## | |
102 | ||
103 | ||
104 | # b4_user_args | |
105 | # ------------ | |
106 | m4_define([b4_user_args], | |
107 | [m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])]) | |
108 | ||
109 | ||
110 | # b4_parse_param | |
111 | # -------------- | |
112 | # If defined, b4_parse_param arrives double quoted, but below we prefer | |
113 | # it to be single quoted. | |
114 | m4_define_default([b4_parse_param]) | |
115 | m4_define([b4_parse_param], | |
116 | b4_parse_param)) | |
117 | ||
8f7e3cf9 | 118 | |
613d8952 AD |
119 | # b4_parse_param_for(DECL, FORMAL, BODY) |
120 | # --------------------------------------- | |
121 | # Iterate over the user parameters, binding the declaration to DECL, | |
122 | # the formal name to FORMAL, and evaluating the BODY. | |
123 | m4_define([b4_parse_param_for], | |
124 | [m4_foreach([$1_$2], m4_defn([b4_parse_param]), | |
125 | [m4_pushdef([$1], m4_fst($1_$2))dnl | |
126 | m4_pushdef([$2], m4_shift($1_$2))dnl | |
127 | $3[]dnl | |
128 | m4_popdef([$2])dnl | |
129 | m4_popdef([$1])dnl | |
130 | ])]) | |
131 | ||
132 | # b4_parse_param_use | |
133 | # ------------------ | |
134 | # `YYUSE' all the parse-params. | |
613d8952 AD |
135 | m4_define([b4_parse_param_use], |
136 | [b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal); | |
137 | ])dnl | |
138 | ]) | |
2a8d363a | 139 | |
fb8135fa AD |
140 | ## ------------ ## |
141 | ## Data Types. ## | |
142 | ## ------------ ## | |
143 | ||
fb8135fa | 144 | |
a762e609 AD |
145 | # b4_ints_in(INT1, INT2, LOW, HIGH) |
146 | # --------------------------------- | |
147 | # Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise. | |
148 | m4_define([b4_ints_in], | |
149 | [m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])]) | |
150 | ||
151 | ||
152 | # b4_int_type(MIN, MAX) | |
153 | # --------------------- | |
154 | # Return the smallest int type able to handle numbers ranging from | |
155 | # MIN to MAX (included). | |
156 | m4_define([b4_int_type], | |
157 | [m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char], | |
f1886bb2 | 158 | b4_ints_in($@, [-128], [127]), [1], [signed char], |
a762e609 | 159 | |
779e7ceb PE |
160 | b4_ints_in($@, [0], [65535]), [1], [unsigned short int], |
161 | b4_ints_in($@, [-32768], [32767]), [1], [short int], | |
a762e609 AD |
162 | |
163 | m4_eval([0 <= $1]), [1], [unsigned int], | |
164 | ||
02650b7f | 165 | [int])]) |
a762e609 | 166 | |
06e8700a JD |
167 | # b4_safest_int_type |
168 | # ------------------ | |
169 | # The safest int type to cast to when it's necessary to compare a signed int | |
170 | # type against an int type set by b4_int_type. | |
171 | m4_define([b4_safest_int_type],[int]) | |
f1886bb2 | 172 | |
a762e609 AD |
173 | # b4_int_type_for(NAME) |
174 | # --------------------- | |
175 | # Return the smallest int type able to handle numbers ranging from | |
176 | # `NAME_min' to `NAME_max' (included). | |
177 | m4_define([b4_int_type_for], | |
178 | [b4_int_type($1_min, $1_max)]) | |
fb8135fa AD |
179 | |
180 | ||
0245f82d AD |
181 | ## ------------------ ## |
182 | ## Decoding options. ## | |
183 | ## ------------------ ## | |
184 | ||
327afc7c AD |
185 | # b4_flag_if(FLAG, IF-TRUE, IF-FALSE) |
186 | # ----------------------------------- | |
187 | # Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail. | |
188 | m4_define([b4_flag_if], | |
189 | [m4_case(b4_$1_flag, | |
190 | [0], [$3], | |
191 | [1], [$2], | |
192 | [m4_fatal([invalid $1 value: ]$1)])]) | |
0245f82d AD |
193 | |
194 | ||
327afc7c AD |
195 | # b4_define_flag_if(FLAG) |
196 | # ----------------------- | |
197 | # Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the | |
198 | # value of the Boolean FLAG. | |
199 | m4_define([b4_define_flag_if], | |
200 | [_b4_define_flag_if($[1], $[2], [$1])]) | |
201 | ||
202 | # _b4_define_flag_if($1, $2, FLAG) | |
203 | # -------------------------------- | |
204 | # This macro works around the impossibility to define macros | |
205 | # inside macros, because issuing `[$1]' is not possible in M4 :(. | |
206 | # This sucks hard, GNU M4 should really provide M5 like $$1. | |
207 | m4_define([_b4_define_flag_if], | |
208 | [m4_if([$1$2], $[1]$[2], [], | |
209 | [m4_fatal([$0: Invalid arguments: $@])])dnl | |
1b818f33 | 210 | m4_define([b4_$3_if], |
327afc7c AD |
211 | [b4_flag_if([$3], [$1], [$2])])]) |
212 | ||
213 | ||
214 | # b4_FLAG_if(IF-TRUE, IF-FALSE) | |
0245f82d | 215 | # ----------------------------- |
327afc7c AD |
216 | # Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise. |
217 | b4_define_flag_if([defines]) # Whether headers are requested. | |
a5d80ba5 | 218 | b4_define_flag_if([error_verbose]) # Whether error are verbose. |
327afc7c AD |
219 | b4_define_flag_if([locations]) # Whether locations are tracked. |
220 | b4_define_flag_if([pure]) # Whether the interface is pure. | |
b931235e | 221 | b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. |
0245f82d AD |
222 | |
223 | ||
224 | ||
fb8135fa AD |
225 | ## ------------------------- ## |
226 | ## Assigning token numbers. ## | |
227 | ## ------------------------- ## | |
228 | ||
229 | # b4_token_define(TOKEN-NAME, TOKEN-NUMBER) | |
230 | # ----------------------------------------- | |
231 | # Output the definition of this token as #define. | |
232 | m4_define([b4_token_define], | |
233 | [#define $1 $2 | |
234 | ]) | |
235 | ||
236 | ||
cf147260 AD |
237 | # b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) |
238 | # ------------------------------------------------------- | |
239 | # Output the definition of the tokens (if there are) as #defines. | |
240 | m4_define([b4_token_defines], | |
241 | [m4_if([$@], [[]], [], | |
242 | [/* Tokens. */ | |
243 | m4_map([b4_token_define], [$@])]) | |
244 | ]) | |
245 | ||
246 | ||
fb8135fa AD |
247 | # b4_token_enum(TOKEN-NAME, TOKEN-NUMBER) |
248 | # --------------------------------------- | |
249 | # Output the definition of this token as an enum. | |
250 | m4_define([b4_token_enum], | |
251 | [$1 = $2]) | |
252 | ||
253 | ||
cf147260 AD |
254 | # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) |
255 | # ----------------------------------------------------- | |
256 | # Output the definition of the tokens (if there are) as enums. | |
257 | m4_define([b4_token_enums], | |
fb8135fa AD |
258 | [m4_if([$@], [[]], [], |
259 | [/* Tokens. */ | |
6b8c3254 PE |
260 | #ifndef YYTOKENTYPE |
261 | # define YYTOKENTYPE | |
fb8135fa AD |
262 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
263 | know about them. */ | |
264 | enum yytokentype { | |
265 | m4_map_sep([ b4_token_enum], [, | |
266 | ], | |
02650b7f | 267 | [$@]) |
fb8135fa | 268 | }; |
095b9f05 | 269 | #endif |
cf147260 AD |
270 | ])]) |
271 | ||
272 | ||
273 | # b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) | |
274 | # ------------------------------------------------------------- | |
b931235e JD |
275 | # Output the definition of the tokens (if there are any) as enums and, if POSIX |
276 | # Yacc is enabled, as #defines. | |
cf147260 | 277 | m4_define([b4_token_enums_defines], |
b931235e | 278 | [b4_token_enums($@)b4_yacc_if([b4_token_defines($@)], []) |
fb8135fa | 279 | ]) |
4a2a22f4 AD |
280 | |
281 | ||
ae7453f2 | 282 | |
0245f82d AD |
283 | ## --------------------------------------------- ## |
284 | ## Defining C functions in both K&R and ANSI-C. ## | |
285 | ## --------------------------------------------- ## | |
4a2a22f4 AD |
286 | |
287 | ||
1b9c21fb PE |
288 | # b4_modern_c |
289 | # ----------- | |
290 | # A predicate useful in #if to determine whether C is ancient or modern. | |
291 | # | |
292 | # If __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run | |
293 | # as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic | |
294 | # reasons, but it defines __C99__FUNC__ so check that as well. | |
295 | # Microsoft C normally doesn't define these macros, but it defines _MSC_VER. | |
7a0db73e | 296 | # Consider a C++ compiler to be modern if it defines __cplusplus. |
1b9c21fb PE |
297 | # |
298 | m4_define([b4_c_modern], | |
02650b7f PE |
299 | [[(defined __STDC__ || defined __C99__FUNC__ \ |
300 | || defined __cplusplus || defined _MSC_VER)]]) | |
1b9c21fb | 301 | |
0245f82d AD |
302 | # b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...) |
303 | # ---------------------------------------------------------- | |
4a2a22f4 | 304 | # Declare the function NAME. |
0245f82d | 305 | m4_define([b4_c_function_def], |
1b9c21fb | 306 | [#if b4_c_modern |
0245f82d | 307 | b4_c_ansi_function_def($@) |
4a2a22f4 | 308 | #else |
0245f82d AD |
309 | $2 |
310 | $1 (b4_c_knr_formal_names(m4_shiftn(2, $@))) | |
311 | b4_c_knr_formal_decls(m4_shiftn(2, $@)) | |
4a2a22f4 AD |
312 | #endif[]dnl |
313 | ]) | |
314 | ||
315 | ||
0245f82d AD |
316 | # b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...) |
317 | # --------------------------------------------------------------- | |
318 | # Declare the function NAME in ANSI. | |
319 | m4_define([b4_c_ansi_function_def], | |
320 | [$2 | |
321 | $1 (b4_c_ansi_formals(m4_shiftn(2, $@)))[]dnl | |
322 | ]) | |
323 | ||
324 | ||
325 | # b4_c_ansi_formals([DECL1, NAME1], ...) | |
326 | # -------------------------------------- | |
4a2a22f4 | 327 | # Output the arguments ANSI-C definition. |
0245f82d AD |
328 | m4_define([b4_c_ansi_formals], |
329 | [m4_case([$@], | |
02650b7f PE |
330 | [], [void], |
331 | [[]], [void], | |
332 | [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])]) | |
4a2a22f4 | 333 | |
0245f82d AD |
334 | m4_define([b4_c_ansi_formal], |
335 | [$1]) | |
4a2a22f4 AD |
336 | |
337 | ||
0245f82d AD |
338 | # b4_c_knr_formal_names([DECL1, NAME1], ...) |
339 | # ------------------------------------------ | |
4a2a22f4 | 340 | # Output the argument names. |
0245f82d AD |
341 | m4_define([b4_c_knr_formal_names], |
342 | [m4_map_sep([b4_c_knr_formal_name], [, ], [$@])]) | |
4a2a22f4 | 343 | |
0245f82d | 344 | m4_define([b4_c_knr_formal_name], |
4a2a22f4 AD |
345 | [$2]) |
346 | ||
347 | ||
0245f82d AD |
348 | # b4_c_knr_formal_decls([DECL1, NAME1], ...) |
349 | # ------------------------------------------ | |
4a2a22f4 | 350 | # Output the K&R argument declarations. |
0245f82d AD |
351 | m4_define([b4_c_knr_formal_decls], |
352 | [m4_map_sep([b4_c_knr_formal_decl], | |
02650b7f | 353 | [ |
4a2a22f4 | 354 | ], |
02650b7f | 355 | [$@])]) |
4a2a22f4 | 356 | |
0245f82d AD |
357 | m4_define([b4_c_knr_formal_decl], |
358 | [ $1;]) | |
21964f43 AD |
359 | |
360 | ||
361 | ||
0245f82d AD |
362 | ## ------------------------------------------------------------ ## |
363 | ## Declaring (prototyping) C functions in both K&R and ANSI-C. ## | |
364 | ## ------------------------------------------------------------ ## | |
21964f43 AD |
365 | |
366 | ||
0245f82d AD |
367 | # b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...) |
368 | # ----------------------------------------------------------- | |
369 | # Declare the function NAME. | |
370 | m4_define([b4_c_function_decl], | |
02650b7f | 371 | [#if defined __STDC__ || defined __cplusplus |
0245f82d AD |
372 | b4_c_ansi_function_decl($@) |
373 | #else | |
374 | $2 $1 (); | |
375 | #endif[]dnl | |
376 | ]) | |
21964f43 AD |
377 | |
378 | ||
0245f82d AD |
379 | # b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...) |
380 | # ---------------------------------------------------------------- | |
381 | # Declare the function NAME. | |
382 | m4_define([b4_c_ansi_function_decl], | |
383 | [$2 $1 (b4_c_ansi_formals(m4_shiftn(2, $@)));[]dnl | |
384 | ]) | |
385 | ||
386 | ||
387 | ||
388 | ||
389 | ## --------------------- ## | |
390 | ## Calling C functions. ## | |
391 | ## --------------------- ## | |
392 | ||
393 | ||
394 | # b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...) | |
395 | # ----------------------------------------------------------- | |
396 | # Call the function NAME with arguments NAME1, NAME2 etc. | |
397 | m4_define([b4_c_function_call], | |
398 | [$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl | |
399 | ]) | |
400 | ||
401 | ||
402 | # b4_c_args([DECL1, NAME1], ...) | |
403 | # ------------------------------ | |
404 | # Output the arguments NAME1, NAME2... | |
405 | m4_define([b4_c_args], | |
406 | [m4_map_sep([b4_c_arg], [, ], [$@])]) | |
407 | ||
408 | m4_define([b4_c_arg], | |
409 | [$2]) | |
437c2d80 AD |
410 | |
411 | ||
412 | ## ----------- ## | |
413 | ## Synclines. ## | |
414 | ## ----------- ## | |
415 | ||
8ec0a172 AD |
416 | # b4_basename(NAME) |
417 | # ----------------- | |
b8445a15 | 418 | # Similar to POSIX basename; the differences don't matter here. |
8ec0a172 AD |
419 | # Beware that NAME is not evaluated. |
420 | m4_define([b4_basename], | |
b8445a15 PE |
421 | [m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])]) |
422 | ||
8ec0a172 | 423 | |
437c2d80 AD |
424 | # b4_syncline(LINE, FILE) |
425 | # ----------------------- | |
426 | m4_define([b4_syncline], | |
b8445a15 | 427 | [b4_flag_if([synclines], |
8ec0a172 AD |
428 | [/* Line __line__ of b4_basename(m4_quote(__file__)). */ |
429 | [#]line $1 $2])]) | |
b0400cc6 AD |
430 | |
431 | ||
8ec0a172 AD |
432 | # b4_user_code(USER-CODE) |
433 | # ----------------------- | |
434 | # Emit code from the user, ending it with synclines. | |
435 | m4_define([b4_user_code], | |
436 | [$1 | |
437 | b4_syncline([@oline@], [@ofile@])]) | |
438 | ||
439 | ||
440 | # b4_define_user_code(MACRO) | |
441 | # -------------------------- | |
442 | # From b4_MACRO, build b4_user_MACRO that includes the synclines. | |
443 | m4_define([b4_define_user_code], | |
444 | [m4_define([b4_user_$1], | |
445 | [b4_user_code([b4_$1])])]) | |
446 | ||
447 | ||
448 | # b4_user_actions | |
449 | # b4_user_initial_action | |
450 | # b4_user_post_prologue | |
451 | # b4_user_start_header | |
452 | # b4_user_stype | |
453 | # ---------------------- | |
454 | # Macros that issue user code, ending with synclines. | |
455 | b4_define_user_code([actions]) | |
456 | b4_define_user_code([initial_action]) | |
457 | b4_define_user_code([post_prologue]) | |
458 | b4_define_user_code([start_header]) | |
459 | b4_define_user_code([stype]) | |
460 | ||
613d8952 AD |
461 | |
462 | ## -------------- ## | |
463 | ## User actions. ## | |
464 | ## -------------- ## | |
465 | ||
b0400cc6 AD |
466 | # b4_symbol_actions(FILENAME, LINENO, |
467 | # SYMBOL-TAG, SYMBOL-NUM, | |
468 | # SYMBOL-ACTION, SYMBOL-TYPENAME) | |
469 | # ------------------------------------------------- | |
470 | m4_define([b4_symbol_actions], | |
60c82948 PE |
471 | [m4_pushdef([b4_dollar_dollar], |
472 | [m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl | |
7bd6c77e | 473 | m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl |
b0400cc6 AD |
474 | case $4: /* $3 */ |
475 | b4_syncline([$2], [$1]) | |
02650b7f | 476 | $5; |
b0400cc6 | 477 | b4_syncline([@oline@], [@ofile@]) |
02650b7f | 478 | break; |
b0400cc6 AD |
479 | m4_popdef([b4_at_dollar])dnl |
480 | m4_popdef([b4_dollar_dollar])dnl | |
481 | ]) | |
482 | ||
483 | ||
14740648 PE |
484 | # b4_yydestruct_generate(FUNCTION-DECLARATOR) |
485 | # ------------------------------------------- | |
b0400cc6 | 486 | # Generate the "yydestruct" function, which declaration is issued using |
14740648 | 487 | # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C |
b0400cc6 | 488 | # or "b4_c_function_def" for K&R. |
cf147260 | 489 | m4_define_default([b4_yydestruct_generate], |
b0400cc6 AD |
490 | [[/*-----------------------------------------------. |
491 | | Release the memory associated to this symbol. | | |
492 | `-----------------------------------------------*/ | |
493 | ||
12ce2df6 | 494 | /*ARGSUSED*/ |
b0400cc6 AD |
495 | ]$1([yydestruct], |
496 | [static void], | |
a0e68930 | 497 | [[const char *yymsg], [yymsg]], |
7bd6c77e | 498 | [[int yytype], [yytype]], |
4b367315 | 499 | [[YYSTYPE *yyvaluep], [yyvaluep]][]dnl |
327afc7c | 500 | b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl |
4b367315 | 501 | m4_ifset([b4_parse_param], [, b4_parse_param]))[ |
b0400cc6 | 502 | { |
2a4647a3 | 503 | YYUSE (yyvaluep); |
327afc7c | 504 | ]b4_locations_if([ YYUSE (yylocationp); |
613d8952 AD |
505 | ])dnl |
506 | b4_parse_param_use[]dnl | |
507 | [ | |
a0e68930 AD |
508 | if (!yymsg) |
509 | yymsg = "Deleting"; | |
510 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | |
511 | ||
b0400cc6 AD |
512 | switch (yytype) |
513 | { | |
514 | ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ | |
515 | default: | |
02650b7f | 516 | break; |
b0400cc6 AD |
517 | } |
518 | }]dnl | |
519 | ]) | |
7bd6c77e AD |
520 | |
521 | ||
a0af42fc AD |
522 | # b4_yy_symbol_print_generate(FUNCTION-DECLARATOR) |
523 | # ------------------------------------------------ | |
524 | # Generate the "yy_symbol_print" function, which declaration is issued using | |
14740648 | 525 | # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C |
7bd6c77e | 526 | # or "b4_c_function_def" for K&R. |
a0af42fc AD |
527 | m4_define_default([b4_yy_symbol_print_generate], |
528 | [[ | |
529 | /*--------------------------------. | |
14740648 PE |
530 | | Print this symbol on YYOUTPUT. | |
531 | `--------------------------------*/ | |
7bd6c77e | 532 | |
12ce2df6 | 533 | /*ARGSUSED*/ |
a0af42fc | 534 | ]$1([yy_symbol_value_print], |
7bd6c77e | 535 | [static void], |
02650b7f PE |
536 | [[FILE *yyoutput], [yyoutput]], |
537 | [[int yytype], [yytype]], | |
50cce58e PE |
538 | [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl |
539 | b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl | |
4b367315 | 540 | m4_ifset([b4_parse_param], [, b4_parse_param]))[ |
7bd6c77e | 541 | { |
05449a2c JD |
542 | if (!yyvaluep) |
543 | return; | |
327afc7c | 544 | ]b4_locations_if([ YYUSE (yylocationp); |
7bd6c77e | 545 | ])dnl |
613d8952 | 546 | b4_parse_param_use[]dnl |
a0af42fc | 547 | [# ifdef YYPRINT |
619404e3 AD |
548 | if (yytype < YYNTOKENS) |
549 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | |
c66dfadd PE |
550 | # else |
551 | YYUSE (yyoutput); | |
619404e3 | 552 | # endif |
7bd6c77e AD |
553 | switch (yytype) |
554 | { | |
3fc16193 AD |
555 | ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl |
556 | [ default: | |
02650b7f | 557 | break; |
7bd6c77e | 558 | } |
a0af42fc AD |
559 | } |
560 | ||
561 | ||
562 | /*--------------------------------. | |
563 | | Print this symbol on YYOUTPUT. | | |
564 | `--------------------------------*/ | |
565 | ||
566 | ]$1([yy_symbol_print], | |
567 | [static void], | |
02650b7f PE |
568 | [[FILE *yyoutput], [yyoutput]], |
569 | [[int yytype], [yytype]], | |
50cce58e PE |
570 | [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl |
571 | b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl | |
a0af42fc AD |
572 | m4_ifset([b4_parse_param], [, b4_parse_param]))[ |
573 | { | |
574 | if (yytype < YYNTOKENS) | |
575 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | |
576 | else | |
577 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | |
578 | ||
327afc7c | 579 | ]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp); |
a0af42fc AD |
580 | YYFPRINTF (yyoutput, ": "); |
581 | ])dnl | |
582 | [ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl | |
327afc7c | 583 | b4_locations_if([, yylocationp])[]b4_user_args[); |
2f4f028d | 584 | YYFPRINTF (yyoutput, ")"); |
4b367315 AD |
585 | }]dnl |
586 | ]) |