]>
Commit | Line | Data |
---|---|---|
08af01c2 | 1 | -*- Autoconf -*- |
90b9908d PB |
2 | |
3 | # Language-independent M4 Macros for Bison. | |
7d424de1 | 4 | |
34136e65 | 5 | # Copyright (C) 2002, 2004-2012 Free Software Foundation, Inc. |
90b9908d | 6 | |
f16b0819 | 7 | # This program is free software: you can redistribute it and/or modify |
90b9908d | 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 |
90b9908d | 10 | # (at your option) any later version. |
f16b0819 | 11 | # |
90b9908d PB |
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 | # |
90b9908d | 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/>. |
90b9908d PB |
19 | |
20 | ||
21 | ## ---------------- ## | |
22 | ## Identification. ## | |
23 | ## ---------------- ## | |
24 | ||
a9ce3f54 AD |
25 | # b4_copyright(TITLE, [YEARS]) |
26 | # ---------------------------- | |
27 | # If YEARS are not defined, use b4_copyright_years. | |
90b9908d PB |
28 | m4_define([b4_copyright], |
29 | [b4_comment([A Bison parser, made by GNU Bison b4_version.]) | |
30 | ||
31 | b4_comment([$1 | |
32 | ||
a9ce3f54 AD |
33 | ]m4_dquote(m4_text_wrap([Copyright (C) |
34 | ]m4_ifval([$2], [[$2]], [m4_defn([b4_copyright_years])])[ | |
35 | Free Software Foundation, Inc.]))[ | |
90b9908d | 36 | |
f16b0819 | 37 | This program is free software: you can redistribute it and/or modify |
90b9908d | 38 | it under the terms of the GNU General Public License as published by |
f16b0819 PE |
39 | the Free Software Foundation, either version 3 of the License, or |
40 | (at your option) any later version. | |
90b9908d PB |
41 | |
42 | This program is distributed in the hope that it will be useful, | |
43 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
44 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
45 | GNU General Public License for more details. | |
46 | ||
47 | You should have received a copy of the GNU General Public License | |
f16b0819 | 48 | along with this program. If not, see <http://www.gnu.org/licenses/>.]) |
90b9908d PB |
49 | |
50 | b4_comment([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.])]) | |
62 | ||
63 | ||
1c7ec959 AD |
64 | ## -------- ## |
65 | ## Output. ## | |
66 | ## -------- ## | |
67 | ||
68 | # b4_output_begin(FILE) | |
69 | # --------------------- | |
70 | # Enable output, i.e., send to diversion 0, expand after "#", and | |
71 | # generate the tag to output into FILE. Must be followed by EOL. | |
72 | m4_define([b4_output_begin], | |
73 | [m4_changecom() | |
74 | m4_divert_push(0)dnl | |
75 | @output(m4_unquote([$1])@)@dnl | |
76 | ]) | |
77 | ||
78 | ||
79 | # b4_output_end() | |
80 | # --------------- | |
81 | # Output nothing, restore # as comment character (no expansions after #). | |
82 | m4_define([b4_output_end], | |
83 | [m4_divert_pop(0) | |
84 | m4_changecom([#]) | |
85 | ]) | |
86 | ||
87 | ||
08af01c2 JD |
88 | ## ---------------- ## |
89 | ## Error handling. ## | |
90 | ## ---------------- ## | |
91 | ||
7dc4a694 JD |
92 | # The following error handling macros print error directives that should not |
93 | # become arguments of other macro invocations since they would likely then be | |
94 | # mangled. Thus, they print to stdout directly. | |
95 | ||
96 | # b4_cat(TEXT) | |
97 | # ------------ | |
98 | # Write TEXT to stdout. Precede the final newline with an @ so that it's | |
99 | # escaped. For example: | |
100 | # | |
101 | # b4_cat([[@complain(invalid input@)]]) | |
102 | m4_define([b4_cat], | |
103 | [m4_syscmd([cat <<'_m4eof' | |
104 | ]m4_bpatsubst(m4_dquote($1), [_m4eof], [_m4@`eof])[@ | |
66f0441d JD |
105 | _m4eof |
106 | ])dnl | |
7dc4a694 JD |
107 | m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])]) |
108 | ||
c4e3a162 AD |
109 | # b4_error(KIND, START, END, FORMAT, [ARG1], [ARG2], ...) |
110 | # ------------------------------------------------------- | |
111 | # Write @KIND(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout. | |
7dc4a694 JD |
112 | # |
113 | # For example: | |
114 | # | |
c4e3a162 AD |
115 | # b4_error([[complain]], [[input.y:2.3]], [[input.y:5.4]], |
116 | # [[invalid %s]], [[foo]]) | |
08af01c2 | 117 | m4_define([b4_error], |
0505df0c | 118 | [b4_cat([[@complain][(]$1[@,]$2[@,]$3[@,]$4[]]dnl |
7dc4a694 JD |
119 | [m4_if([$#], [4], [], |
120 | [m4_foreach([b4_arg], | |
121 | m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))), | |
122 | [[@,]b4_arg])])[@)]])]) | |
3fc65ead | 123 | |
08af01c2 | 124 | # b4_warn(FORMAT, [ARG1], [ARG2], ...) |
7eb8a0bc | 125 | # ------------------------------------ |
7dc4a694 JD |
126 | # Write @warn(FORMAT@,ARG1@,ARG2@,...@) to stdout. |
127 | # | |
128 | # For example: | |
129 | # | |
4aa9d1ff | 130 | # b4_warn([[invalid value for '%s': %s]], [[foo]], [[3]]) |
08af01c2 JD |
131 | # |
132 | # As a simple test suite, this: | |
133 | # | |
7dc4a694 | 134 | # m4_divert(-1) |
08af01c2 JD |
135 | # m4_define([asdf], [ASDF]) |
136 | # m4_define([fsa], [FSA]) | |
137 | # m4_define([fdsa], [FDSA]) | |
c4e3a162 AD |
138 | # b4_warn_at([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]]) |
139 | # b4_warn_at([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]]) | |
140 | # b4_warn_at() | |
141 | # b4_warn_at(1) | |
142 | # b4_warn_at(1, 2) | |
08af01c2 | 143 | # |
7dc4a694 | 144 | # Should produce this without newlines: |
08af01c2 | 145 | # |
c4e3a162 AD |
146 | # @warn_at([asdf), asdf]@,@,@,[fsa), fsa]@,[fdsa), fdsa]@) |
147 | # @warn(asdf), asdf@,@,@,fsa), fsa@,fdsa), fdsa@) | |
08af01c2 | 148 | # @warn(@) |
08af01c2 JD |
149 | # @warn(1@) |
150 | # @warn(1@,2@) | |
151 | m4_define([b4_warn], | |
c4e3a162 | 152 | [b4_error([[warn]], [], [], $@)]) |
08af01c2 | 153 | |
3fc65ead | 154 | # b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...) |
7eb8a0bc | 155 | # --------------------------------------------------- |
7dc4a694 JD |
156 | # Write @warn(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout. |
157 | # | |
158 | # For example: | |
159 | # | |
160 | # b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]]) | |
3fc65ead | 161 | m4_define([b4_warn_at], |
c4e3a162 | 162 | [b4_error([[warn]], $@)]) |
3fc65ead | 163 | |
08af01c2 | 164 | # b4_complain(FORMAT, [ARG1], [ARG2], ...) |
7eb8a0bc | 165 | # ---------------------------------------- |
c4e3a162 | 166 | # Bounce to b4_complain_at. |
08af01c2 | 167 | # |
7dc4a694 | 168 | # See b4_warn example. |
08af01c2 | 169 | m4_define([b4_complain], |
c4e3a162 | 170 | [b4_error([[complain]], [], [], $@)]) |
08af01c2 | 171 | |
3fc65ead | 172 | # b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...) |
7eb8a0bc | 173 | # ------------------------------------------------------- |
7dc4a694 JD |
174 | # Write @complain(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout. |
175 | # | |
176 | # See b4_warn_at example. | |
3fc65ead | 177 | m4_define([b4_complain_at], |
c4e3a162 | 178 | [b4_error([[complain]], $@)]) |
3fc65ead | 179 | |
08af01c2 | 180 | # b4_fatal(FORMAT, [ARG1], [ARG2], ...) |
7eb8a0bc | 181 | # ------------------------------------- |
c4e3a162 | 182 | # Bounce to b4_fatal_at. |
08af01c2 | 183 | # |
7dc4a694 | 184 | # See b4_warn example. |
08af01c2 | 185 | m4_define([b4_fatal], |
c4e3a162 | 186 | [b4_error([[fatal]], [], [], $@)dnl |
7dc4a694 | 187 | m4_exit(1)]) |
08af01c2 | 188 | |
3fc65ead | 189 | # b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...) |
7eb8a0bc | 190 | # ---------------------------------------------------- |
7dc4a694 JD |
191 | # Write @fatal(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout and exit. |
192 | # | |
193 | # See b4_warn_at example. | |
3fc65ead | 194 | m4_define([b4_fatal_at], |
c4e3a162 | 195 | [b4_error([[fatal]], $@)dnl |
7dc4a694 | 196 | m4_exit(1)]) |
3fc65ead | 197 | |
08af01c2 | 198 | |
90b9908d PB |
199 | ## ------------ ## |
200 | ## Data Types. ## | |
201 | ## ------------ ## | |
202 | ||
203 | # b4_ints_in(INT1, INT2, LOW, HIGH) | |
204 | # --------------------------------- | |
205 | # Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise. | |
206 | m4_define([b4_ints_in], | |
207 | [m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])]) | |
208 | ||
209 | ||
bd187d7b AD |
210 | # b4_subtract(LHS, RHS) |
211 | # --------------------- | |
212 | # Evaluate LHS - RHS if they are integer literals, otherwise expand | |
213 | # to (LHS) - (RHS). | |
214 | m4_define([b4_subtract], | |
215 | [m4_bmatch([$1$2], [^[0123456789]*$], | |
216 | [m4_eval([$1 - $2])], | |
217 | [($1) - ($2)])]) | |
218 | ||
710c4a65 AD |
219 | # b4_join(ARG1, ...) |
220 | # _b4_join(ARG1, ...) | |
e0c653e7 AD |
221 | # ------------------- |
222 | # Join with comma, skipping empty arguments. | |
710c4a65 AD |
223 | # b4_join calls itself recursively until it sees the first non-empty |
224 | # argument, then calls _b4_join which prepends each non-empty argument | |
e0c653e7 | 225 | # with a comma. |
710c4a65 | 226 | m4_define([b4_join], |
e0c653e7 AD |
227 | [m4_if([$#$1], |
228 | [1], [], | |
229 | [m4_ifval([$1], | |
230 | [$1[]_$0(m4_shift($@))], | |
231 | [$0(m4_shift($@))])])]) | |
232 | ||
710c4a65 | 233 | # _b4_join(ARGS1, ...) |
e0c653e7 | 234 | # -------------------- |
710c4a65 | 235 | m4_define([_b4_join], |
e0c653e7 AD |
236 | [m4_if([$#$1], |
237 | [1], [], | |
238 | [m4_ifval([$1], [, $1])[]$0(m4_shift($@))])]) | |
239 | ||
240 | ||
241 | ||
90b9908d | 242 | |
ba206cf4 AD |
243 | # b4_integral_parser_tables_map(MACRO) |
244 | # ------------------------------------- | |
0991e29b AD |
245 | # Map MACRO on all the integral tables. MACRO is expected to have |
246 | # the signature MACRO(TABLE-NAME, CONTENT, COMMENT). | |
ba206cf4 | 247 | m4_define([b4_integral_parser_tables_map], |
0991e29b AD |
248 | [$1([pact], [b4_pact], |
249 | [[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | |
250 | STATE-NUM.]]) | |
251 | ||
252 | $1([defact], [b4_defact], | |
110ef36a JD |
253 | [[YYDEFACT[S] -- default reduction number in state S. Performed when |
254 | YYTABLE does not specify something else to do. Zero means the default | |
255 | is an error.]]) | |
0991e29b AD |
256 | |
257 | $1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]]) | |
258 | ||
259 | $1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]]) | |
260 | ||
261 | $1([table], [b4_table], | |
262 | [[YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | |
263 | positive, shift that token. If negative, reduce the rule which | |
aa0cb40d | 264 | number is the opposite. If YYTABLE_NINF, syntax error.]]) |
0991e29b AD |
265 | |
266 | $1([check], [b4_check]) | |
267 | ||
268 | $1([stos], [b4_stos], | |
269 | [[STOS_[STATE-NUM] -- The (internal number of the) accessing | |
270 | symbol of state STATE-NUM.]]) | |
271 | ||
272 | $1([r1], [b4_r1], | |
273 | [[YYR1[YYN] -- Symbol number of symbol that rule YYN derives.]]) | |
274 | ||
275 | $1([r2], [b4_r2], | |
276 | [[YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.]]) | |
277 | ]) | |
278 | ||
279 | ||
ba206cf4 AD |
280 | # b4_parser_tables_declare |
281 | # b4_parser_tables_define | |
282 | # ------------------------ | |
0991e29b | 283 | # Define/declare the (deterministic) parser tables. |
ba206cf4 AD |
284 | m4_define([b4_parser_tables_declare], |
285 | [b4_integral_parser_tables_map([b4_integral_parser_table_declare])]) | |
0991e29b | 286 | |
ba206cf4 AD |
287 | m4_define([b4_parser_tables_define], |
288 | [b4_integral_parser_tables_map([b4_integral_parser_table_define])]) | |
0991e29b AD |
289 | |
290 | ||
291 | ||
90b9908d PB |
292 | ## ------------------ ## |
293 | ## Decoding options. ## | |
294 | ## ------------------ ## | |
295 | ||
296 | # b4_flag_if(FLAG, IF-TRUE, IF-FALSE) | |
297 | # ----------------------------------- | |
298 | # Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail. | |
299 | m4_define([b4_flag_if], | |
300 | [m4_case(b4_$1_flag, | |
301 | [0], [$3], | |
e9690142 JD |
302 | [1], [$2], |
303 | [m4_fatal([invalid $1 value: ]$1)])]) | |
90b9908d PB |
304 | |
305 | ||
306 | # b4_define_flag_if(FLAG) | |
307 | # ----------------------- | |
308 | # Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the | |
309 | # value of the Boolean FLAG. | |
310 | m4_define([b4_define_flag_if], | |
311 | [_b4_define_flag_if($[1], $[2], [$1])]) | |
312 | ||
313 | # _b4_define_flag_if($1, $2, FLAG) | |
314 | # -------------------------------- | |
258cddbc AD |
315 | # Work around the impossibility to define macros inside macros, |
316 | # because issuing `[$1]' is not possible in M4. GNU M4 should provide | |
317 | # $$1 a la M5/TeX. | |
90b9908d PB |
318 | m4_define([_b4_define_flag_if], |
319 | [m4_if([$1$2], $[1]$[2], [], | |
320 | [m4_fatal([$0: Invalid arguments: $@])])dnl | |
321 | m4_define([b4_$3_if], | |
322 | [b4_flag_if([$3], [$1], [$2])])]) | |
323 | ||
324 | ||
325 | # b4_FLAG_if(IF-TRUE, IF-FALSE) | |
326 | # ----------------------------- | |
327 | # Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise. | |
e9690142 JD |
328 | b4_define_flag_if([defines]) # Whether headers are requested. |
329 | b4_define_flag_if([glr]) # Whether a GLR parser is requested. | |
330 | b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled. | |
258cddbc | 331 | b4_define_flag_if([token_table]) # Whether yytoken_table is demanded. |
e9690142 | 332 | b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. |
90b9908d PB |
333 | |
334 | ||
cf6fb222 AD |
335 | ## --------- ## |
336 | ## Symbols. ## | |
337 | ## --------- ## | |
338 | ||
e3990e3c AD |
339 | # In order to unify the handling of the various aspects of symbols |
340 | # (tag, type_name, whether terminal, etc.), bison.exe defines one | |
341 | # macro per (token, field), where field can has_id, id, etc.: see | |
342 | # src/output.c:prepare_symbols_definitions(). | |
343 | # | |
344 | # The following macros provide access to these values. | |
345 | ||
cf6fb222 AD |
346 | # b4_symbol_(NUM, FIELD) |
347 | # ---------------------- | |
348 | # Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if | |
349 | # undefined. | |
350 | m4_define([b4_symbol_], | |
351 | [m4_indir([b4_symbol($1, $2)])]) | |
352 | ||
353 | ||
354 | # b4_symbol(NUM, FIELD) | |
355 | # --------------------- | |
356 | # Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if | |
357 | # undefined. If FIELD = id, prepend the prefix. | |
358 | m4_define([b4_symbol], | |
359 | [m4_case([$2], | |
2a6b66c5 | 360 | [id], [m4_do([b4_percent_define_get([api.token.prefix])], |
cf6fb222 AD |
361 | [b4_symbol_([$1], [id])])], |
362 | [b4_symbol_($@)])]) | |
363 | ||
364 | ||
365 | # b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE) | |
366 | # ------------------------------------------- | |
367 | # If FIELD about symbol #NUM is 1 expand IF-TRUE, if is 0, expand IF-FALSE. | |
368 | # Otherwise an error. | |
369 | m4_define([b4_symbol_if], | |
370 | [m4_case(b4_symbol([$1], [$2]), | |
371 | [1], [$3], | |
372 | [0], [$4], | |
373 | [m4_fatal([$0: field $2 of $1 is not a Boolean:] b4_symbol([$1], [$2]))])]) | |
374 | ||
375 | ||
3bb21113 AD |
376 | # b4_symbol_action_location(SYMBOL-NUM, KIND) |
377 | # ------------------------------------------- | |
378 | # Report the location of the KIND action as FILE:LINE. | |
379 | m4_define([b4_symbol_action_location], | |
380 | [b4_symbol([$1], [$2_file]):b4_syncline([b4_symbol([$1], [$2_line])])]) | |
381 | ||
382 | ||
cf6fb222 AD |
383 | # b4_symbol_action(SYMBOL-NUM, KIND) |
384 | # ---------------------------------- | |
385 | # Run the action KIND (destructor or printer) for SYMBOL-NUM. | |
386 | # Same as in C, but using references instead of pointers. | |
387 | m4_define([b4_symbol_action], | |
388 | [b4_symbol_if([$1], [has_$2], | |
4323e0da AD |
389 | [b4_dollar_pushdef([(*yyvaluep)], |
390 | b4_symbol_if([$1], [has_type], | |
391 | [m4_dquote(b4_symbol([$1], [type]))]), | |
392 | [(*yylocationp)])dnl | |
d507251c | 393 | b4_symbol_case_([$1])[]dnl |
cf6fb222 AD |
394 | b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"]) |
395 | b4_symbol([$1], [$2]) | |
396 | b4_syncline([@oline@], [@ofile@]) | |
397 | break; | |
398 | ||
4323e0da | 399 | b4_dollar_popdef[]dnl |
cf6fb222 AD |
400 | ])]) |
401 | ||
402 | ||
403 | # b4_symbol_destructor(SYMBOL-NUM) | |
404 | # b4_symbol_printer(SYMBOL-NUM) | |
405 | # -------------------------------- | |
406 | m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])]) | |
407 | m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])]) | |
408 | ||
409 | ||
410 | # b4_symbol_case_(SYMBOL-NUM) | |
411 | # --------------------------- | |
412 | # Issue a "case NUM" for SYMBOL-NUM. | |
413 | m4_define([b4_symbol_case_], | |
414 | [ case b4_symbol([$1], [number]): // b4_symbol([$1], [tag]) | |
415 | ]) | |
416 | ||
417 | ||
418 | # b4_symbol_foreach(MACRO) | |
419 | # ------------------------ | |
420 | # Invoke MACRO(SYMBOL-NUM) for each SYMBOL-NUM. | |
421 | m4_define([b4_symbol_foreach], | |
422 | [m4_map([$1], m4_defn([b4_symbol_numbers]))]) | |
e3990e3c AD |
423 | |
424 | # b4_symbol_map(MACRO) | |
425 | # -------------------- | |
426 | # Return a list (possibly empty elements) of MACRO invoked for each | |
427 | # SYMBOL-NUM. | |
428 | m4_define([b4_symbol_map], | |
429 | [m4_map_args_sep([$1(], [)], [,], b4_symbol_numbers)]) | |
430 | ||
431 | ||
432 | # b4_token_visible_if(NUM, IF-TRUE, IF-FALSE) | |
433 | # ------------------------------------------- | |
434 | # Whether NUM denotes a token that has an exported definition (i.e., | |
435 | # shows in enum yytokentype). | |
436 | m4_define([b4_token_visible_if], | |
437 | [b4_symbol_if([$1], [is_token], | |
438 | [b4_symbol_if([$1], [has_id], [$2], [$3])], | |
439 | [$3])]) | |
440 | ||
441 | # b4_token_has_definition(NUM) | |
442 | # ---------------------------- | |
443 | # 1 if NUM is visible, nothing otherwise. | |
444 | m4_define([b4_token_has_definition], | |
445 | [b4_token_visible_if([$1], [1])]) | |
446 | ||
447 | # b4_any_token_visible_if([IF-TRUE], [IF-FALSE]) | |
448 | # ---------------------------------------------- | |
449 | # Whether there is a token that needs to be defined. | |
450 | m4_define([b4_any_token_visible_if], | |
451 | [m4_ifval(b4_symbol_foreach([b4_token_has_definition]), | |
452 | [$1], [$2])]) | |
453 | ||
454 | ||
455 | # b4_token_format(FORMAT, NUM) | |
456 | # ---------------------------- | |
457 | m4_define([b4_token_format], | |
458 | [b4_token_visible_if([$2], | |
459 | [m4_quote(m4_format([$1], | |
460 | [b4_symbol([$2], [id])], | |
461 | [b4_symbol([$2], [user_number])]))])]) | |
cf6fb222 AD |
462 | |
463 | ||
464 | ## ------- ## | |
465 | ## Types. ## | |
466 | ## ------- ## | |
467 | ||
468 | # b4_type_action_(NUMS) | |
469 | # --------------------- | |
470 | # Run actions for the symbol NUMS that all have the same type-name. | |
471 | # Skip NUMS that have no type-name. | |
472 | m4_define([b4_type_action_], | |
473 | [b4_symbol_if([$1], [has_type], | |
474 | [m4_map([b4_symbol_case_], [$@])[]dnl | |
475 | b4_dollar_dollar([b4_symbol([$1], [number])], | |
476 | [b4_symbol([$1], [tag])], | |
477 | [b4_symbol([$1], [type])]); | |
e9690142 | 478 | break; |
cf6fb222 AD |
479 | |
480 | ])]) | |
481 | ||
482 | # b4_type_foreach(MACRO) | |
483 | # ---------------------- | |
484 | # Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set. | |
485 | m4_define([b4_type_foreach], | |
486 | [m4_map([$1], m4_defn([b4_type_names]))]) | |
487 | ||
488 | ||
489 | ||
90b9908d PB |
490 | ## ----------- ## |
491 | ## Synclines. ## | |
492 | ## ----------- ## | |
493 | ||
494 | # b4_basename(NAME) | |
495 | # ----------------- | |
496 | # Similar to POSIX basename; the differences don't matter here. | |
497 | # Beware that NAME is not evaluated. | |
498 | m4_define([b4_basename], | |
499 | [m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])]) | |
500 | ||
501 | ||
502 | # b4_syncline(LINE, FILE) | |
503 | # ----------------------- | |
504 | m4_define([b4_syncline], | |
fad814bd AD |
505 | [b4_flag_if([synclines], |
506 | [b4_sync_end([__line__], [b4_basename(m4_quote(__file__))]) | |
90b9908d PB |
507 | b4_sync_start([$1], [$2])])]) |
508 | ||
509 | m4_define([b4_sync_end], [b4_comment([Line $1 of $2])]) | |
510 | m4_define([b4_sync_start], [b4_comment([Line $1 of $2])]) | |
511 | ||
512 | # b4_user_code(USER-CODE) | |
513 | # ----------------------- | |
514 | # Emit code from the user, ending it with synclines. | |
515 | m4_define([b4_user_code], | |
516 | [$1 | |
517 | b4_syncline([@oline@], [@ofile@])]) | |
518 | ||
519 | ||
520 | # b4_define_user_code(MACRO) | |
521 | # -------------------------- | |
522 | # From b4_MACRO, build b4_user_MACRO that includes the synclines. | |
523 | m4_define([b4_define_user_code], | |
524 | [m4_define([b4_user_$1], | |
525 | [b4_user_code([b4_$1])])]) | |
526 | ||
527 | ||
528 | # b4_user_actions | |
529 | # b4_user_initial_action | |
530 | # b4_user_post_prologue | |
136a0f76 | 531 | # b4_user_pre_prologue |
90b9908d PB |
532 | # b4_user_stype |
533 | # ---------------------- | |
534 | # Macros that issue user code, ending with synclines. | |
535 | b4_define_user_code([actions]) | |
536 | b4_define_user_code([initial_action]) | |
537 | b4_define_user_code([post_prologue]) | |
136a0f76 | 538 | b4_define_user_code([pre_prologue]) |
90b9908d PB |
539 | b4_define_user_code([stype]) |
540 | ||
1c7b7e1d | 541 | |
9611cfa2 | 542 | # b4_check_user_names(WHAT, USER-LIST, BISON-NAMESPACE) |
c6abeab1 JD |
543 | # ----------------------------------------------------- |
544 | # Complain if any name of type WHAT is used by the user (as recorded in | |
545 | # USER-LIST) but is not used by Bison (as recorded by macros in the | |
546 | # namespace BISON-NAMESPACE). | |
7eb8a0bc | 547 | # |
f8e7258f JD |
548 | # USER-LIST must expand to a list specifying all user occurrences of all names |
549 | # of type WHAT. Each item in the list must be a triplet specifying one | |
6afc30cc JD |
550 | # occurrence: name, start boundary, and end boundary. Empty string names are |
551 | # fine. An empty list is fine. | |
7eb8a0bc | 552 | # |
a4e25e1d | 553 | # For example, to define b4_foo_user_names to be used for USER-LIST with three |
6afc30cc | 554 | # name occurrences and with correct quoting: |
8e0a5e9e | 555 | # |
a4e25e1d | 556 | # m4_define([b4_foo_user_names], |
7eb8a0bc JD |
557 | # [[[[[[bar]], [[parser.y:1.7]], [[parser.y:1.16]]]], |
558 | # [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]], | |
559 | # [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]]) | |
1c7b7e1d | 560 | # |
9611cfa2 JD |
561 | # The macro BISON-NAMESPACE(bar) must be defined iff the name bar of type WHAT |
562 | # is used by Bison (in the front-end or in the skeleton). Empty string names | |
563 | # are fine, but it would be ugly for Bison to actually use one. | |
6afc30cc | 564 | # |
9611cfa2 JD |
565 | # For example, to use b4_foo_bison_names for BISON-NAMESPACE and define that |
566 | # the names bar and baz are used by Bison: | |
1c7b7e1d | 567 | # |
9611cfa2 JD |
568 | # m4_define([b4_foo_bison_names(bar)]) |
569 | # m4_define([b4_foo_bison_names(baz)]) | |
1c7b7e1d | 570 | # |
6afc30cc | 571 | # To invoke b4_check_user_names with TYPE foo, with USER-LIST |
9611cfa2 JD |
572 | # b4_foo_user_names, with BISON-NAMESPACE b4_foo_bison_names, and with correct |
573 | # quoting: | |
1c7b7e1d | 574 | # |
a4e25e1d | 575 | # b4_check_user_names([[foo]], [b4_foo_user_names], |
9611cfa2 | 576 | # [[b4_foo_bison_names]]) |
6afc30cc JD |
577 | m4_define([b4_check_user_names], |
578 | [m4_foreach([b4_occurrence], $2, | |
579 | [m4_pushdef([b4_occurrence], b4_occurrence)dnl | |
580 | m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl | |
581 | m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl | |
582 | m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl | |
a4e25e1d | 583 | m4_ifndef($3[(]m4_quote(b4_user_name)[)], |
c6abeab1 | 584 | [b4_complain_at([b4_start], [b4_end], |
4aa9d1ff | 585 | [[%s '%s' is not used]], |
c6abeab1 | 586 | [$1], [b4_user_name])])[]dnl |
6afc30cc JD |
587 | m4_popdef([b4_occurrence])dnl |
588 | m4_popdef([b4_user_name])dnl | |
589 | m4_popdef([b4_start])dnl | |
590 | m4_popdef([b4_end])dnl | |
591 | ])]) | |
592 | ||
67501061 AD |
593 | |
594 | ||
595 | ## --------------------- ## | |
596 | ## b4_percent_define_*. ## | |
597 | ## --------------------- ## | |
598 | ||
599 | ||
600 | # b4_percent_define_use(VARIABLE) | |
601 | # ------------------------------- | |
602 | # Declare that VARIABLE was used. | |
603 | m4_define([b4_percent_define_use], | |
604 | [m4_define([b4_percent_define_bison_variables(]$1[)])dnl | |
605 | ]) | |
606 | ||
7789b6e3 AD |
607 | # b4_percent_define_get(VARIABLE, [DEFAULT]) |
608 | # ------------------------------------------ | |
609 | # Mimic muscle_percent_define_get in ../src/muscle-tab.h. That is, if | |
610 | # the %define variable VARIABLE is defined, emit its value. Contrary | |
611 | # to its C counterpart, return DEFAULT otherwise. Also, record | |
9611cfa2 JD |
612 | # Bison's usage of VARIABLE by defining |
613 | # b4_percent_define_bison_variables(VARIABLE). | |
a4e25e1d JD |
614 | # |
615 | # For example: | |
616 | # | |
617 | # b4_percent_define_get([[foo]]) | |
618 | m4_define([b4_percent_define_get], | |
67501061 | 619 | [b4_percent_define_use([$1])dnl |
7789b6e3 AD |
620 | m4_ifdef([b4_percent_define(]$1[)], |
621 | [m4_indir([b4_percent_define(]$1[)])], | |
622 | [$2])]) | |
a4e25e1d | 623 | |
35b8730d JD |
624 | # b4_percent_define_get_loc(VARIABLE) |
625 | # ----------------------------------- | |
416a9da6 | 626 | # Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is, |
35b8730d JD |
627 | # if the %define variable VARIABLE is undefined, complain fatally since that's |
628 | # a Bison or skeleton error. Otherwise, return its definition location in a | |
629 | # form approriate for the first two arguments of b4_warn_at, b4_complain_at, or | |
630 | # b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no | |
631 | # reason to suspect that the user-supplied value has yet influenced the output. | |
632 | # | |
633 | # For example: | |
634 | # | |
635 | # b4_complain_at(b4_percent_define_get_loc([[foo]]), [[invalid foo]]) | |
636 | m4_define([b4_percent_define_get_loc], | |
637 | [m4_ifdef([b4_percent_define_loc(]$1[)], | |
638 | [m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl | |
639 | b4_loc[]dnl | |
640 | m4_popdef([b4_loc])], | |
4a9cd8f2 | 641 | [b4_fatal([[b4_percent_define_get_loc: undefined %%define variable '%s']], [$1])])]) |
35b8730d JD |
642 | |
643 | # b4_percent_define_get_syncline(VARIABLE) | |
644 | # ---------------------------------------- | |
416a9da6 | 645 | # Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly. |
35b8730d JD |
646 | # That is, if the %define variable VARIABLE is undefined, complain fatally |
647 | # since that's a Bison or skeleton error. Otherwise, return its definition | |
648 | # location as a b4_syncline invocation. Don't record this as a Bison usage of | |
649 | # VARIABLE as there's no reason to suspect that the user-supplied value has yet | |
650 | # influenced the output. | |
651 | # | |
652 | # For example: | |
653 | # | |
654 | # b4_percent_define_get_syncline([[foo]]) | |
655 | m4_define([b4_percent_define_get_syncline], | |
656 | [m4_ifdef([b4_percent_define_syncline(]$1[)], | |
657 | [m4_indir([b4_percent_define_syncline(]$1[)])], | |
4a9cd8f2 | 658 | [b4_fatal([[b4_percent_define_get_syncline: undefined %%define variable '%s']], [$1])])]) |
35b8730d | 659 | |
592d0b1e PB |
660 | # b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE]) |
661 | # ------------------------------------------------------ | |
416a9da6 | 662 | # Mimic muscle_percent_define_ifdef in ../src/muscle-tab.h exactly. That is, |
f124d423 | 663 | # if the %define variable VARIABLE is defined, expand IF-TRUE, else expand |
9611cfa2 JD |
664 | # IF-FALSE. Also, record Bison's usage of VARIABLE by defining |
665 | # b4_percent_define_bison_variables(VARIABLE). | |
666 | # | |
667 | # For example: | |
668 | # | |
669 | # b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]]) | |
592d0b1e PB |
670 | m4_define([b4_percent_define_ifdef], |
671 | [m4_ifdef([b4_percent_define(]$1[)], | |
e9690142 JD |
672 | [b4_percent_define_use([$1])$2], |
673 | [$3])]) | |
592d0b1e | 674 | |
b47b6ff7 | 675 | |
b47b6ff7 AD |
676 | ## --------- ## |
677 | ## Options. ## | |
678 | ## --------- ## | |
679 | ||
680 | ||
592d0b1e PB |
681 | # b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE]) |
682 | # -------------------------------------------------------- | |
416a9da6 | 683 | # Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is, |
9611cfa2 JD |
684 | # if the %define variable VARIABLE is defined to "" or "true", expand IF-TRUE. |
685 | # If it is defined to "false", expand IF-FALSE. Complain if it is undefined | |
686 | # (a Bison or skeleton error since the default value should have been set | |
687 | # already) or defined to any other value (possibly a user error). Also, record | |
688 | # Bison's usage of VARIABLE by defining | |
689 | # b4_percent_define_bison_variables(VARIABLE). | |
690 | # | |
691 | # For example: | |
692 | # | |
693 | # b4_percent_define_flag_if([[foo]], [[it's true]], [[it's false]]) | |
592d0b1e PB |
694 | m4_define([b4_percent_define_flag_if], |
695 | [b4_percent_define_ifdef([$1], | |
9611cfa2 JD |
696 | [m4_case(b4_percent_define_get([$1]), |
697 | [], [$2], [true], [$2], [false], [$3], | |
35b8730d | 698 | [m4_expand_once([b4_complain_at(b4_percent_define_get_loc([$1]), |
4aa9d1ff | 699 | [[invalid value for %%define Boolean variable '%s']], |
35b8730d JD |
700 | [$1])], |
701 | [[b4_percent_define_flag_if($1)]])])], | |
4a9cd8f2 | 702 | [b4_fatal([[b4_percent_define_flag_if: undefined %%define variable '%s']], [$1])])]) |
592d0b1e | 703 | |
b3a2272a | 704 | |
a4e25e1d JD |
705 | # b4_percent_define_default(VARIABLE, DEFAULT) |
706 | # -------------------------------------------- | |
416a9da6 | 707 | # Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is, |
9611cfa2 JD |
708 | # if the %define variable VARIABLE is undefined, set its value to DEFAULT. |
709 | # Don't record this as a Bison usage of VARIABLE as there's no reason to | |
710 | # suspect that the value has yet influenced the output. | |
a4e25e1d JD |
711 | # |
712 | # For example: | |
713 | # | |
714 | # b4_percent_define_default([[foo]], [[default value]]) | |
715 | m4_define([b4_percent_define_default], | |
716 | [m4_ifndef([b4_percent_define(]$1[)], | |
9611cfa2 JD |
717 | [m4_define([b4_percent_define(]$1[)], [$2])dnl |
718 | m4_define([b4_percent_define_loc(]$1[)], | |
92822aff JD |
719 | [[[[<skeleton default value>:-1.-1]], |
720 | [[<skeleton default value>:-1.-1]]]])dnl | |
721 | m4_define([b4_percent_define_syncline(]$1[)], [[]])])]) | |
6afc30cc | 722 | |
b3a2272a | 723 | |
62cb570a AD |
724 | # b4_percent_define_if_define(NAME, [VARIABLE = NAME]) |
725 | # ---------------------------------------------------- | |
726 | # Define b4_NAME_if that executes its $1 or $2 depending whether | |
4f646c37 AD |
727 | # VARIABLE was %defined. The characters `.' and `-' in VARIABLE are mapped |
728 | # to `_'. | |
b3a2272a | 729 | m4_define([b4_percent_define_if_define_], |
4f646c37 | 730 | [m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]), |
62cb570a AD |
731 | [b4_percent_define_flag_if(m4_default([$2], [$1]), |
732 | [$3], [$4])])]) | |
b3a2272a | 733 | m4_define([b4_percent_define_if_define], |
62cb570a AD |
734 | [b4_percent_define_default([m4_default([$2], [$1])], [[false]]) |
735 | b4_percent_define_if_define_([$1], [$2], $[1], $[2])]) | |
b3a2272a AD |
736 | |
737 | ||
d782395d JD |
738 | # b4_percent_define_check_values(VALUES) |
739 | # -------------------------------------- | |
416a9da6 | 740 | # Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly |
d782395d JD |
741 | # except that the VALUES structure is more appropriate for M4. That is, VALUES |
742 | # is a list of sublists of strings. For each sublist, the first string is the | |
743 | # name of a %define variable, and all remaining strings in that sublist are the | |
744 | # valid values for that variable. Complain if such a variable is undefined (a | |
745 | # Bison error since the default value should have been set already) or defined | |
746 | # to any other value (possibly a user error). Don't record this as a Bison | |
747 | # usage of the variable as there's no reason to suspect that the value has yet | |
748 | # influenced the output. | |
749 | # | |
750 | # For example: | |
751 | # | |
752 | # b4_percent_define_check_values([[[[foo]], [[foo-value1]], [[foo-value2]]]], | |
753 | # [[[[bar]], [[bar-value1]]]]) | |
754 | m4_define([b4_percent_define_check_values], | |
755 | [m4_foreach([b4_sublist], m4_quote($@), | |
756 | [_b4_percent_define_check_values(b4_sublist)])]) | |
757 | ||
758 | m4_define([_b4_percent_define_check_values], | |
759 | [m4_ifdef([b4_percent_define(]$1[)], | |
760 | [m4_pushdef([b4_good_value], [0])dnl | |
761 | m4_if($#, 1, [], | |
762 | [m4_foreach([b4_value], m4_dquote(m4_shift($@)), | |
763 | [m4_if(m4_indir([b4_percent_define(]$1[)]), b4_value, | |
764 | [m4_define([b4_good_value], [1])])])])dnl | |
765 | m4_if(b4_good_value, [0], | |
35b8730d | 766 | [b4_complain_at(b4_percent_define_get_loc([$1]), |
4aa9d1ff | 767 | [[invalid value for %%define variable '%s': '%s']], |
d782395d | 768 | [$1], |
f4909773 JD |
769 | m4_dquote(m4_indir([b4_percent_define(]$1[)]))) |
770 | m4_foreach([b4_value], m4_dquote(m4_shift($@)), | |
c6c8de16 | 771 | [b4_error([[note]], b4_percent_define_get_loc([$1]), [] |
4aa9d1ff | 772 | [[accepted value: '%s']], |
f4909773 | 773 | m4_dquote(b4_value))])])dnl |
d782395d | 774 | m4_popdef([b4_good_value])], |
4a9cd8f2 | 775 | [b4_fatal([[b4_percent_define_check_values: undefined %%define variable '%s']], [$1])])]) |
d782395d | 776 | |
a4e25e1d | 777 | # b4_percent_code_get([QUALIFIER]) |
6afc30cc JD |
778 | # -------------------------------- |
779 | # If any %code blocks for QUALIFIER are defined, emit them beginning with a | |
780 | # comment and ending with synclines and a newline. If QUALIFIER is not | |
592d0b1e | 781 | # specified or empty, do this for the unqualified %code blocks. Also, record |
9611cfa2 JD |
782 | # Bison's usage of QUALIFIER (if specified) by defining |
783 | # b4_percent_code_bison_qualifiers(QUALIFIER). | |
a4e25e1d JD |
784 | # |
785 | # For example, to emit any unqualified %code blocks followed by any %code | |
786 | # blocks for the qualifier foo: | |
787 | # | |
788 | # b4_percent_code_get | |
789 | # b4_percent_code_get([[foo]]) | |
790 | m4_define([b4_percent_code_get], | |
592d0b1e | 791 | [m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl |
9611cfa2 | 792 | m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl |
6afc30cc JD |
793 | m4_ifdef(b4_macro_name, |
794 | [b4_comment([m4_if([$#], [0], [[Unqualified %code]], | |
42ee26bb | 795 | [["%code ]$1["]])[ blocks.]]) |
a4e25e1d JD |
796 | b4_user_code([m4_indir(b4_macro_name)]) |
797 | ])dnl | |
6afc30cc JD |
798 | m4_popdef([b4_macro_name])]) |
799 | ||
592d0b1e PB |
800 | # b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE]) |
801 | # ----------------------------------------------------- | |
802 | # If any %code blocks for QUALIFIER (or unqualified %code blocks if | |
803 | # QUALIFIER is empty) are defined, expand IF-TRUE, else expand IF-FALSE. | |
9611cfa2 JD |
804 | # Also, record Bison's usage of QUALIFIER (if specified) by defining |
805 | # b4_percent_code_bison_qualifiers(QUALIFIER). | |
592d0b1e PB |
806 | m4_define([b4_percent_code_ifdef], |
807 | [m4_ifdef([b4_percent_code(]$1[)], | |
9611cfa2 | 808 | [m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2], |
e9690142 | 809 | [$3])]) |
592d0b1e | 810 | |
6afc30cc | 811 | |
ad597a78 AD |
812 | ## ------------------ ## |
813 | ## Common variables. ## | |
814 | ## ------------------ ## | |
815 | ||
5679f311 AD |
816 | # Default values for %define. |
817 | # --------------------------- | |
2a6b66c5 AD |
818 | # If the api.token.prefix, it is empty. |
819 | m4_percent_define_default([[api.token.prefix]], [[]]) | |
5679f311 | 820 | |
ad597a78 AD |
821 | # b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT]) |
822 | # b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT]) | |
e36ec1f4 | 823 | # b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT]) |
ad597a78 AD |
824 | # b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT]) |
825 | # ---------------------------------------------- | |
e36ec1f4 | 826 | b4_percent_define_if_define([token_ctor], [api.token.constructor]) |
ad597a78 AD |
827 | b4_percent_define_if_define([locations]) # Whether locations are tracked. |
828 | b4_percent_define_if_define([parse.assert]) | |
829 | b4_percent_define_if_define([parse.trace]) | |
830 | b4_percent_define_if_define([variant]) | |
831 | ||
832 | ||
833 | # b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT]) | |
834 | # ------------------------------------------------------ | |
835 | # Map %define parse.error "(simple|verbose)" to b4_error_verbose_if and | |
836 | # b4_error_verbose_flag. | |
837 | b4_percent_define_default([[parse.error]], [[simple]]) | |
838 | b4_percent_define_check_values([[[[parse.error]], | |
839 | [[simple]], [[verbose]]]]) | |
840 | m4_define([b4_error_verbose_flag], | |
82db7cdb JD |
841 | [m4_case(b4_percent_define_get([[parse.error]]), |
842 | [simple], [[0]], | |
843 | [verbose], [[1]])]) | |
ad597a78 | 844 | b4_define_flag_if([error_verbose]) |
5679f311 | 845 | |
f1246164 AD |
846 | # yytoken_table is needed to support verbose errors. |
847 | b4_error_verbose_if([m4_define([b4_token_table_flag], [1])]) | |
848 | ||
5679f311 | 849 | |
9611cfa2 JD |
850 | ## ----------------------------------------------------------- ## |
851 | ## After processing the skeletons, check that all the user's ## | |
852 | ## %define variables and %code qualifiers were used by Bison. ## | |
853 | ## ----------------------------------------------------------- ## | |
6afc30cc | 854 | |
a4e25e1d JD |
855 | m4_define([b4_check_user_names_wrap], |
856 | [m4_ifdef([b4_percent_]$1[_user_]$2[s], | |
857 | [b4_check_user_names([[%]$1 $2], | |
858 | [b4_percent_]$1[_user_]$2[s], | |
9611cfa2 | 859 | [[b4_percent_]$1[_bison_]$2[s]])])]) |
6afc30cc | 860 | |
882a1fbf | 861 | m4_wrap_lifo([ |
a4e25e1d JD |
862 | b4_check_user_names_wrap([[define]], [[variable]]) |
863 | b4_check_user_names_wrap([[code]], [[qualifier]]) | |
6afc30cc | 864 | ]) |
2a824fae AD |
865 | |
866 | ||
867 | ## ---------------- ## | |
868 | ## Default values. ## | |
869 | ## ---------------- ## | |
870 | ||
871 | # m4_define_default([b4_lex_param], []) dnl breaks other skeletons | |
872 | m4_define_default([b4_pre_prologue], []) | |
873 | m4_define_default([b4_post_prologue], []) | |
874 | m4_define_default([b4_epilogue], []) | |
875 | m4_define_default([b4_parse_param], []) | |
876 | ||
877 | # The initial column and line. | |
878 | m4_define_default([b4_location_initial_column], [1]) | |
879 | m4_define_default([b4_location_initial_line], [1]) | |
32ae07ef AD |
880 | |
881 | # Sanity checks. | |
882 | b4_percent_define_ifdef([api.prefix], | |
883 | [m4_ifdef([b4_prefix], | |
884 | [b4_complain_at(b4_percent_define_get_loc([api.prefix]), | |
885 | [['%s' and '%s' cannot be used together]], | |
886 | [%name-prefix], | |
887 | [%define api.prefix])])]) |