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