1 -*- Autoconf -*- 2 3# Language-independent M4 Macros for Bison. 4 5# Copyright (C) 2002, 2004-2015, 2018-2021 Free Software Foundation, 6# Inc. 7 8# This program is free software: you can redistribute it and/or modify 9# it under the terms of the GNU General Public License as published by 10# the Free Software Foundation, either version 3 of the License, or 11# (at your option) any later version. 12# 13# This program is distributed in the hope that it will be useful, 14# but WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16# GNU General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License 19# along with this program. If not, see <https://www.gnu.org/licenses/>. 20 21 22 23# m4_gsub(STRING, RE1, SUBST1, RE2, SUBST2, ...) 24# ---------------------------------------------- 25# m4 equivalent of 26# 27# $_ = STRING; 28# s/RE1/SUBST1/g; 29# s/RE2/SUBST2/g; 30# ... 31# 32# Really similar to m4_bpatsubsts, but behaves properly with quotes. 33# See m4.at's "Generating Comments". Super inelegant, but so far, I 34# did not find any better solution. 35m4_define([b4_gsub], 36[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst([[[[$1]]]], 37 [$2], [$3]), 38 [$4], [$5]), 39 [$6], [$7])]) 40 41# m4_shift2 and m4_shift3 are provided by m4sugar. 42m4_define([m4_shift4], [m4_shift(m4_shift(m4_shift(m4_shift($@))))]) 43 44 45## ---------------- ## 46## Identification. ## 47## ---------------- ## 48 49# b4_generated_by 50# --------------- 51m4_define([b4_generated_by], 52[b4_comment([A Bison parser, made by GNU Bison b4_version_string.]) 53]) 54 55# b4_copyright(TITLE, [YEARS]) 56# ---------------------------- 57# If YEARS are not defined, use b4_copyright_years. 58m4_define([b4_copyright], 59[b4_generated_by 60b4_comment([$1 61 62]m4_dquote(m4_text_wrap([Copyright (C) 63]m4_ifval([$2], [[$2]], [m4_defn([b4_copyright_years])])[ 64Free Software Foundation, Inc.]))[ 65 66This program is free software: you can redistribute it and/or modify 67it under the terms of the GNU General Public License as published by 68the Free Software Foundation, either version 3 of the License, or 69(at your option) any later version. 70 71This program is distributed in the hope that it will be useful, 72but WITHOUT ANY WARRANTY; without even the implied warranty of 73MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 74GNU General Public License for more details. 75 76You should have received a copy of the GNU General Public License 77along with this program. If not, see <https://www.gnu.org/licenses/>.]) 78 79b4_comment([As a special exception, you may create a larger work that contains 80part or all of the Bison parser skeleton and distribute that work 81under terms of your choice, so long as that work isn't itself a 82parser generator using the skeleton or a modified version thereof 83as a parser skeleton. Alternatively, if you modify or redistribute 84the parser skeleton itself, you may (at your option) remove this 85special exception, which will cause the skeleton and the resulting 86Bison output files to be licensed under the GNU General Public 87License without this special exception. 88 89This special exception was added by the Free Software Foundation in 90version 2.2 of Bison.]) 91]) 92 93 94# b4_disclaimer 95# ------------- 96# Issue a warning about private implementation details. 97m4_define([b4_disclaimer], 98[b4_comment([DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, 99especially those whose name start with YY_ or yy_. They are 100private implementation details that can be changed or removed.]) 101]) 102 103 104 105# b4_required_version_if(VERSION, IF_NEWER, IF_OLDER) 106# --------------------------------------------------- 107# If the version %require'd by the user is VERSION (or newer) expand 108# IF_NEWER, otherwise IF_OLDER. VERSION should be an integer, e.g., 109# 302 for 3.2. 110m4_define([b4_required_version_if], 111[m4_if(m4_eval($1 <= b4_required_version), 112 [1], [$2], [$3])]) 113 114 115## -------- ## 116## Output. ## 117## -------- ## 118 119# b4_output_begin(FILE1, FILE2) 120# ----------------------------- 121# Enable output, i.e., send to diversion 0, expand after "#", and 122# generate the tag to output into FILE. Must be followed by EOL. 123# FILE is FILE1 concatenated to FILE2. FILE2 can be empty, or be 124# absolute: do the right thing. 125m4_define([b4_output_begin], 126[m4_changecom() 127m4_divert_push(0)dnl 128@output(m4_unquote([$1])@,m4_unquote([$2])@)@dnl 129]) 130 131 132# b4_output_end 133# ------------- 134# Output nothing, restore # as comment character (no expansions after #). 135m4_define([b4_output_end], 136[m4_divert_pop(0) 137m4_changecom([#]) 138]) 139 140 141# b4_divert_kill(CODE) 142# -------------------- 143# Expand CODE for its side effects, discard its output. 144m4_define([b4_divert_kill], 145[m4_divert_text([KILL], [$1])]) 146 147 148# b4_define_silent(MACRO, CODE) 149# ----------------------------- 150# Same as m4_define, but throw away the expansion of CODE. 151m4_define([b4_define_silent], 152[m4_define([$1], [b4_divert_kill([$2])])]) 153 154 155## ---------------- ## 156## Error handling. ## 157## ---------------- ## 158 159# The following error handling macros print error directives that should not 160# become arguments of other macro invocations since they would likely then be 161# mangled. Thus, they print to stdout directly. 162 163# b4_cat(TEXT) 164# ------------ 165# Write TEXT to stdout. Precede the final newline with an @ so that it's 166# escaped. For example: 167# 168# b4_cat([[@complain(invalid input@)]]) 169m4_define([b4_cat], 170[m4_syscmd([cat <<'_m4eof' 171]m4_bpatsubst(m4_dquote($1), [_m4eof], [_m4@`eof])[@ 172_m4eof 173])dnl 174m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])]) 175 176# b4_error(KIND, START, END, FORMAT, [ARG1], [ARG2], ...) 177# ------------------------------------------------------- 178# Write @KIND(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout. 179# 180# For example: 181# 182# b4_error([[complain]], [[input.y:2.3]], [[input.y:5.4]], 183# [[invalid %s]], [[foo]]) 184m4_define([b4_error], 185[b4_cat([[@complain][(]$1[@,]$2[@,]$3[@,]$4[]]dnl 186[m4_if([$#], [4], [], 187 [m4_foreach([b4_arg], 188 m4_dquote(m4_shift4($@)), 189 [[@,]b4_arg])])[@)]])]) 190 191# b4_warn(FORMAT, [ARG1], [ARG2], ...) 192# ------------------------------------ 193# Write @warn(FORMAT@,ARG1@,ARG2@,...@) to stdout. 194# 195# For example: 196# 197# b4_warn([[invalid value for '%s': %s]], [[foo]], [[3]]) 198# 199# As a simple test suite, this: 200# 201# m4_divert(-1) 202# m4_define([asdf], [ASDF]) 203# m4_define([fsa], [FSA]) 204# m4_define([fdsa], [FDSA]) 205# b4_warn_at([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]]) 206# b4_warn_at([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]]) 207# b4_warn_at() 208# b4_warn_at(1) 209# b4_warn_at(1, 2) 210# 211# Should produce this without newlines: 212# 213# @warn_at([asdf), asdf]@,@,@,[fsa), fsa]@,[fdsa), fdsa]@) 214# @warn(asdf), asdf@,@,@,fsa), fsa@,fdsa), fdsa@) 215# @warn(@) 216# @warn(1@) 217# @warn(1@,2@) 218m4_define([b4_warn], 219[b4_warn_at([], [], $@)]) 220 221# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...) 222# --------------------------------------------------- 223# Write @warn(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout. 224# 225# For example: 226# 227# b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]]) 228m4_define([b4_warn_at], 229[b4_error([[warn]], $@)]) 230 231# b4_complain(FORMAT, [ARG1], [ARG2], ...) 232# ---------------------------------------- 233# Bounce to b4_complain_at. 234# 235# See b4_warn example. 236m4_define([b4_complain], 237[b4_complain_at([], [], $@)]) 238 239# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...) 240# ------------------------------------------------------- 241# Write @complain(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout. 242# 243# See b4_warn_at example. 244m4_define([b4_complain_at], 245[b4_error([[complain]], $@)]) 246 247# b4_fatal(FORMAT, [ARG1], [ARG2], ...) 248# ------------------------------------- 249# Bounce to b4_fatal_at. 250# 251# See b4_warn example. 252m4_define([b4_fatal], 253[b4_fatal_at([], [], $@)]) 254 255# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...) 256# ---------------------------------------------------- 257# Write @fatal(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout and exit. 258# 259# See b4_warn_at example. 260m4_define([b4_fatal_at], 261[b4_error([[fatal]], $@)dnl 262m4_exit(1)]) 263 264 265## ------------ ## 266## Data Types. ## 267## ------------ ## 268 269# b4_ints_in(INT1, INT2, LOW, HIGH) 270# --------------------------------- 271# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise. 272m4_define([b4_ints_in], 273[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])]) 274 275 276# b4_subtract(LHS, RHS) 277# --------------------- 278# Evaluate LHS - RHS if they are integer literals, otherwise expand 279# to (LHS) - (RHS). 280m4_define([b4_subtract], 281[m4_bmatch([$1$2], [^[0123456789]*$], 282 [m4_eval([$1 - $2])], 283 [($1) - ($2)])]) 284 285# b4_join(ARG1, ...) 286# _b4_join(ARG1, ...) 287# ------------------- 288# Join with comma, skipping empty arguments. 289# b4_join calls itself recursively until it sees the first non-empty 290# argument, then calls _b4_join (i.e., `_$0`) which prepends each 291# non-empty argument with a comma. 292m4_define([b4_join], 293[m4_if([$#$1], 294 [1], [], 295 [m4_ifval([$1], 296 [$1[]_$0(m4_shift($@))], 297 [$0(m4_shift($@))])])]) 298 299# _b4_join(ARGS1, ...) 300# -------------------- 301m4_define([_b4_join], 302[m4_if([$#$1], 303 [1], [], 304 [m4_ifval([$1], [, $1])[]$0(m4_shift($@))])]) 305 306 307 308 309# b4_integral_parser_tables_map(MACRO) 310# ------------------------------------- 311# Map MACRO on all the integral tables. MACRO is expected to have 312# the signature MACRO(TABLE-NAME, CONTENT, COMMENT). 313m4_define([b4_integral_parser_tables_map], 314[$1([pact], [b4_pact], 315 [[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 316STATE-NUM.]]) 317 318$1([defact], [b4_defact], 319 [[YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. 320Performed when YYTABLE does not specify something else to do. Zero 321means the default is an error.]]) 322 323$1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]]) 324 325$1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]]) 326 327$1([table], [b4_table], 328 [[YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If 329positive, shift that token. If negative, reduce the rule whose 330number is the opposite. If YYTABLE_NINF, syntax error.]]) 331 332$1([check], [b4_check]) 333 334$1([stos], [b4_stos], 335 [[YYSTOS[STATE-NUM] -- The (internal number of the) accessing 336symbol of state STATE-NUM.]]) 337 338$1([r1], [b4_r1], 339 [[YYR1[YYN] -- Symbol number of symbol that rule YYN derives.]]) 340 341$1([r2], [b4_r2], 342 [[YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.]]) 343]) 344 345 346# b4_parser_tables_declare 347# b4_parser_tables_define 348# ------------------------ 349# Define/declare the (deterministic) parser tables. 350m4_define([b4_parser_tables_declare], 351[b4_integral_parser_tables_map([b4_integral_parser_table_declare])]) 352 353m4_define([b4_parser_tables_define], 354[b4_integral_parser_tables_map([b4_integral_parser_table_define])]) 355 356 357 358## ------------------ ## 359## Decoding options. ## 360## ------------------ ## 361 362# b4_flag_if(FLAG, IF-TRUE, IF-FALSE) 363# ----------------------------------- 364# Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail. 365m4_define([b4_flag_if], 366[m4_case(b4_$1_flag, 367 [0], [$3], 368 [1], [$2], 369 [m4_fatal([invalid $1 value: ]b4_$1_flag)])]) 370 371 372# b4_define_flag_if(FLAG) 373# ----------------------- 374# Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the 375# value of the Boolean FLAG. 376m4_define([b4_define_flag_if], 377[_b4_define_flag_if($[1], $[2], [$1])]) 378 379# _b4_define_flag_if($1, $2, FLAG) 380# -------------------------------- 381# Work around the impossibility to define macros inside macros, 382# because issuing '[$1]' is not possible in M4. GNU M4 should provide 383# $$1 a la M5/TeX. 384m4_define([_b4_define_flag_if], 385[m4_if([$1$2], $[1]$[2], [], 386 [m4_fatal([$0: Invalid arguments: $@])])dnl 387m4_define([b4_$3_if], 388 [b4_flag_if([$3], [$1], [$2])])]) 389 390 391# b4_FLAG_if(IF-TRUE, IF-FALSE) 392# ----------------------------- 393# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise. 394b4_define_flag_if([defines]) # Whether headers are requested. 395b4_define_flag_if([glr]) # Whether a GLR parser is requested. 396b4_define_flag_if([has_translations]) # Whether some tokens are internationalized. 397b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled. 398b4_define_flag_if([token_table]) # Whether yytoken_table is demanded. 399b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. 400 401 402# b4_glr_cc_if([IF-TRUE], [IF-FALSE]) 403# ----------------------------------- 404m4_define([b4_glr_cc_if], 405 [m4_if(b4_skeleton, ["glr.cc"], $@)]) 406 407 408## --------- ## 409## Symbols. ## 410## --------- ## 411 412# For a description of the Symbol handling, see README.md. 413# 414# The following macros provide access to symbol related values. 415 416# __b4_symbol(NUM, FIELD) 417# ----------------------- 418# Fetch FIELD of symbol #NUM. Fail if undefined. 419m4_define([__b4_symbol], 420[m4_indir([b4_symbol($1, $2)])]) 421 422 423# _b4_symbol(NUM, FIELD) 424# ---------------------- 425# Fetch FIELD of symbol #NUM (or "orig NUM", see README.md). 426# Fail if undefined. 427m4_define([_b4_symbol], 428[m4_ifdef([b4_symbol($1, number)], 429 [__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)], 430 [__b4_symbol([$1], [$2])])]) 431 432 433# b4_symbol_token_kind(NUM) 434# ------------------------- 435# The token kind of this symbol. 436m4_define([b4_symbol_token_kind], 437[b4_percent_define_get([api.token.prefix])dnl 438_b4_symbol([$1], [id])]) 439 440 441# b4_symbol_kind_base(NUM) 442# ------------------------ 443# Build the name of the kind of this symbol. It must always exist, 444# otherwise some symbols might not be represented in the enum, which 445# might be compiled into too small a type to contain all the symbol 446# numbers. 447m4_define([b4_symbol_prefix], [b4_percent_define_get([api.symbol.prefix])]) 448m4_define([b4_symbol_kind_base], 449[b4_percent_define_get([api.symbol.prefix])dnl 450m4_case([$1], 451 [-2], [[YYEMPTY]], 452 [0], [[YYEOF]], 453 [1], [[YYerror]], 454 [2], [[YYUNDEF]], 455 [m4_case(b4_symbol([$1], [tag]), 456 [$accept], [[YYACCEPT]], 457 [b4_symbol_if([$1], [has_id], _b4_symbol([$1], [id]), 458 [m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])]) 459 460 461# b4_symbol_kind(NUM) 462# ------------------- 463# Same as b4_symbol_kind, but possibly with a prefix in some 464# languages. E.g., EOF's kind_base and kind are YYSYMBOL_YYEOF in C, 465# but are S_YYEMPTY and symbol_kind::S_YYEMPTY in C++. 466m4_copy([b4_symbol_kind_base], [b4_symbol_kind]) 467 468 469# b4_symbol_slot(NUM) 470# ------------------- 471# The name of union member that contains the value of these symbols. 472# Currently, we are messy, this should actually be type_tag, but type_tag 473# has several meanings. 474m4_define([b4_symbol_slot], 475[m4_case(b4_percent_define_get([[api.value.type]]), 476 [union], [b4_symbol([$1], [type_tag])], 477 [variant], [b4_symbol([$1], [type_tag])], 478 [b4_symbol([$1], [type])])]) 479 480 481# b4_symbol(NUM, FIELD) 482# --------------------- 483# Fetch FIELD of symbol #NUM (or "orig NUM"). Fail if undefined. 484# 485# If FIELD = id, prepend the token prefix. 486m4_define([b4_symbol], 487[m4_case([$2], 488 [id], [b4_symbol_token_kind([$1])], 489 [kind_base], [b4_symbol_kind_base([$1])], 490 [kind], [b4_symbol_kind([$1])], 491 [slot], [b4_symbol_slot([$1])], 492 [_b4_symbol($@)])]) 493 494 495# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE) 496# ------------------------------------------- 497# If FIELD about symbol #NUM is 1 expand IF-TRUE, if is 0, expand IF-FALSE. 498# Otherwise an error. 499m4_define([b4_symbol_if], 500[m4_case(b4_symbol([$1], [$2]), 501 [1], [$3], 502 [0], [$4], 503 [m4_fatal([$0: field $2 of $1 is not a Boolean:] b4_symbol([$1], [$2]))])]) 504 505 506# b4_symbol_tag_comment(SYMBOL-NUM) 507# --------------------------------- 508# Issue a comment giving the tag of symbol NUM. 509m4_define([b4_symbol_tag_comment], 510[b4_comment([b4_symbol([$1], [tag])]) 511]) 512 513 514# b4_symbol_action(SYMBOL-NUM, ACTION) 515# ------------------------------------ 516# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM. 517m4_define([b4_symbol_action], 518[b4_symbol_if([$1], [has_$2], 519[b4_dollar_pushdef([(*yyvaluep)], 520 [$1], 521 [], 522 [(*yylocationp)])dnl 523 _b4_symbol_case([$1])[]dnl 524b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl 525b4_symbol([$1], [$2]) 526b4_syncline([@oline@], [@ofile@])dnl 527 break; 528 529b4_dollar_popdef[]dnl 530])]) 531 532 533# b4_symbol_destructor(SYMBOL-NUM) 534# b4_symbol_printer(SYMBOL-NUM) 535# -------------------------------- 536m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])]) 537m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])]) 538 539 540# b4_symbol_actions(ACTION, [KIND = yykind]) 541# ------------------------------------------ 542# Emit the symbol actions for ACTION ("destructor" or "printer"). 543# Dispatch on KIND. 544m4_define([b4_symbol_actions], 545[m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl 546m4_ifval(m4_defn([b4_actions_]), 547[switch (m4_default([$2], [yykind])) 548 { 549m4_defn([b4_actions_])[]dnl 550 default: 551 break; 552 }dnl 553], 554[YY_USE (m4_default([$2], [yykind]));])dnl 555m4_popdef([b4_actions_])dnl 556]) 557 558# _b4_symbol_case(SYMBOL-NUM) 559# --------------------------- 560# Issue a "case NUM" for SYMBOL-NUM. Ends with its EOL to make it 561# easier to use with m4_map, but then, use []dnl to suppress the last 562# one. 563m4_define([_b4_symbol_case], 564[case b4_symbol([$1], [kind]): b4_symbol_tag_comment([$1])]) 565]) 566 567 568# b4_symbol_foreach(MACRO) 569# ------------------------ 570# Invoke MACRO(SYMBOL-NUM) for each SYMBOL-NUM. 571m4_define([b4_symbol_foreach], 572 [m4_map([$1], m4_defn([b4_symbol_numbers]))]) 573 574# b4_symbol_map(MACRO) 575# -------------------- 576# Return a list (possibly empty elements) of MACRO invoked for each 577# SYMBOL-NUM. 578m4_define([b4_symbol_map], 579[m4_map_args_sep([$1(], [)], [,], b4_symbol_numbers)]) 580 581 582# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE) 583# ------------------------------------------- 584# Whether NUM denotes a token kind that has an exported definition 585# (i.e., shows in enum yytokentype). 586m4_define([b4_token_visible_if], 587[b4_symbol_if([$1], [is_token], 588 [b4_symbol_if([$1], [has_id], [$2], [$3])], 589 [$3])]) 590 591 592# b4_token_has_definition(NUM) 593# ---------------------------- 594# 1 if NUM is visible, nothing otherwise. 595m4_define([b4_token_has_definition], 596[b4_token_visible_if([$1], [1])]) 597 598# b4_any_token_visible_if([IF-TRUE], [IF-FALSE]) 599# ---------------------------------------------- 600# Whether there is a token that needs to be defined. 601m4_define([b4_any_token_visible_if], 602[m4_ifval(b4_symbol_foreach([b4_token_has_definition]), 603 [$1], [$2])]) 604 605 606# b4_token_format(FORMAT, NUM) 607# ---------------------------- 608# If token NUM has a visible ID, format FORMAT with ID, USER_NUMBER. 609m4_define([b4_token_format], 610[b4_token_visible_if([$2], 611[m4_format([[$1]], 612 b4_symbol([$2], [id]), 613 b4_symbol([$2], b4_api_token_raw_if([[number]], [[code]])))])]) 614 615 616# b4_last_enum_token 617# ------------------ 618# The code of the last token visible token. 619m4_define([_b4_last_enum_token], 620[b4_token_visible_if([$1], 621 [m4_define([b4_last_enum_token], [$1])])]) 622b4_symbol_foreach([_b4_last_enum_token]) 623 624# b4_last_symbol 625# -------------- 626# The code of the last symbol. 627m4_define([b4_last_symbol], m4_eval(b4_tokens_number + b4_nterms_number - 1)) 628 629## ------- ## 630## Types. ## 631## ------- ## 632 633# _b4_type_action(NUMS) 634# --------------------- 635# Run actions for the symbol NUMS that all have the same type-name. 636# Skip NUMS that have no type-name. 637# 638# To specify the action to run, define b4_dollar_dollar(SYMBOL-NUM, 639# TAG, TYPE). 640m4_define([_b4_type_action], 641[b4_symbol_if([$1], [has_type], 642[m4_map([ _b4_symbol_case], [$@])[]dnl 643 b4_dollar_dollar([b4_symbol([$1], [number])], 644 [b4_symbol([$1], [tag])], 645 [b4_symbol([$1], [type])]); 646 break; 647 648])]) 649 650# b4_type_foreach(MACRO, [SEP]) 651# ----------------------------- 652# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set. 653m4_define([b4_type_foreach], 654 [m4_map_sep([$1], [$2], m4_defn([b4_type_names]))]) 655 656 657 658## ----------- ## 659## Synclines. ## 660## ----------- ## 661 662# b4_basename(NAME) 663# ----------------- 664# Similar to POSIX basename; the differences don't matter here. 665# Beware that NAME is not evaluated. 666m4_define([b4_basename], 667[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])]) 668 669 670# b4_syncline(LINE, FILE)dnl 671# -------------------------- 672# Should always be following by a dnl. 673# 674# Emit "#line LINE FILE /* __LINE__ __FILE__ */". 675m4_define([b4_syncline], 676[b4_flag_if([synclines], 677[b4_sync_start([$1], [$2])[]dnl 678b4_sync_end([__line__], [b4_basename(m4_quote(__file__))]) 679])]) 680 681# b4_sync_start(LINE, FILE) 682# ----------------------- 683# Syncline for the new place. Typically a directive for the compiler. 684m4_define([b4_sync_start], [b4_comment([$2:$1])]) 685 686# b4_sync_end(LINE, FILE) 687# ----------------------- 688# Syncline for the current place, which ends. Typically a comment 689# left for the reader. 690m4_define([b4_sync_end], [ b4_comment([$2:$1])] 691) 692# This generates dependencies on the Bison skeletons hence lots of 693# useless 'git diff'. This location is useless for the regular 694# user (who does not care about the skeletons) and is actually not 695# useful for Bison developers too (I, Akim, never used this to locate 696# the code in skeletons that generated output). So disable it 697# completely. If someone thinks this was actually useful, a %define 698# variable should be provided to control the level of verbosity of 699# '#line', in replacement of --no-lines. 700m4_define([b4_sync_end]) 701 702 703# b4_user_code(USER-CODE) 704# ----------------------- 705# Emit code from the user, ending it with synclines. 706m4_define([b4_user_code], 707[$1 708b4_syncline([@oline@], [@ofile@])]) 709 710 711# b4_define_user_code(MACRO, COMMENT) 712# ----------------------------------- 713# From b4_MACRO, if defined, build b4_user_MACRO that includes the synclines. 714m4_define([b4_define_user_code], 715[m4_define([b4_user_$1], 716 [m4_ifdef([b4_$1], 717 [m4_ifval([$2], 718 [b4_comment([$2]) 719])b4_user_code([b4_$1])])])]) 720 721# b4_user_actions 722# b4_user_initial_action 723# b4_user_post_prologue 724# b4_user_pre_prologue 725# b4_user_union_members 726# ---------------------- 727# Macros that issue user code, ending with synclines. 728b4_define_user_code([actions]) 729b4_define_user_code([initial_action], [User initialization code.]) 730b4_define_user_code([post_prologue], [Second part of user prologue.]) 731b4_define_user_code([pre_prologue], [First part of user prologue.]) 732b4_define_user_code([union_members]) 733 734 735# b4_check_user_names(WHAT, USER-LIST, BISON-NAMESPACE) 736# ----------------------------------------------------- 737# Complain if any name of type WHAT is used by the user (as recorded in 738# USER-LIST) but is not used by Bison (as recorded by macros in the 739# namespace BISON-NAMESPACE). 740# 741# USER-LIST must expand to a list specifying all user occurrences of all names 742# of type WHAT. Each item in the list must be a triplet specifying one 743# occurrence: name, start boundary, and end boundary. Empty string names are 744# fine. An empty list is fine. 745# 746# For example, to define b4_foo_user_names to be used for USER-LIST with three 747# name occurrences and with correct quoting: 748# 749# m4_define([b4_foo_user_names], 750# [[[[[[bar]], [[parser.y:1.7]], [[parser.y:1.16]]]], 751# [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]], 752# [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]]) 753# 754# The macro BISON-NAMESPACE(bar) must be defined iff the name bar of type WHAT 755# is used by Bison (in the front-end or in the skeleton). Empty string names 756# are fine, but it would be ugly for Bison to actually use one. 757# 758# For example, to use b4_foo_bison_names for BISON-NAMESPACE and define that 759# the names bar and baz are used by Bison: 760# 761# m4_define([b4_foo_bison_names(bar)]) 762# m4_define([b4_foo_bison_names(baz)]) 763# 764# To invoke b4_check_user_names with TYPE foo, with USER-LIST 765# b4_foo_user_names, with BISON-NAMESPACE b4_foo_bison_names, and with correct 766# quoting: 767# 768# b4_check_user_names([[foo]], [b4_foo_user_names], 769# [[b4_foo_bison_names]]) 770m4_define([b4_check_user_names], 771[m4_foreach([b4_occurrence], $2, 772[m4_pushdef([b4_occurrence], b4_occurrence)dnl 773m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl 774m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl 775m4_pushdef([b4_end], m4_shift2(b4_occurrence))dnl 776m4_ifndef($3[(]m4_quote(b4_user_name)[)], 777 [b4_complain_at([b4_start], [b4_end], 778 [[%s '%s' is not used]], 779 [$1], [b4_user_name])])[]dnl 780m4_popdef([b4_occurrence])dnl 781m4_popdef([b4_user_name])dnl 782m4_popdef([b4_start])dnl 783m4_popdef([b4_end])dnl 784])]) 785 786 787 788## --------------------- ## 789## b4_percent_define_*. ## 790## --------------------- ## 791 792 793# b4_percent_define_use(VARIABLE) 794# ------------------------------- 795# Declare that VARIABLE was used. 796m4_define([b4_percent_define_use], 797[m4_define([b4_percent_define_bison_variables(]$1[)])dnl 798]) 799 800# b4_percent_define_get(VARIABLE, [DEFAULT]) 801# ------------------------------------------ 802# Mimic muscle_percent_define_get in ../src/muscle-tab.h. That is, if 803# the %define variable VARIABLE is defined, emit its value. Contrary 804# to its C counterpart, return DEFAULT otherwise. Also, record 805# Bison's usage of VARIABLE by defining 806# b4_percent_define_bison_variables(VARIABLE). 807# 808# For example: 809# 810# b4_percent_define_get([[foo]]) 811m4_define([b4_percent_define_get], 812[b4_percent_define_use([$1])dnl 813_b4_percent_define_ifdef([$1], 814 [m4_indir([b4_percent_define(]$1[)])], 815 [$2])]) 816 817# b4_percent_define_get_loc(VARIABLE) 818# ----------------------------------- 819# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is, 820# if the %define variable VARIABLE is undefined, complain fatally since that's 821# a Bison or skeleton error. Otherwise, return its definition location in a 822# form appropriate for the first two arguments of b4_warn_at, b4_complain_at, or 823# b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no 824# reason to suspect that the user-supplied value has yet influenced the output. 825# 826# For example: 827# 828# b4_complain_at(b4_percent_define_get_loc([[foo]]), [[invalid foo]]) 829m4_define([b4_percent_define_get_loc], 830[m4_ifdef([b4_percent_define_loc(]$1[)], 831 [m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl 832b4_loc[]dnl 833m4_popdef([b4_loc])], 834 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 835 836# b4_percent_define_get_kind(VARIABLE) 837# ------------------------------------ 838# Get the kind (code, keyword, string) of VARIABLE, i.e., how its 839# value was defined (braces, not delimiters, quotes). 840# 841# If the %define variable VARIABLE is undefined, complain fatally 842# since that's a Bison or skeleton error. Don't record this as a 843# Bison usage of VARIABLE as there's no reason to suspect that the 844# user-supplied value has yet influenced the output. 845m4_define([b4_percent_define_get_kind], 846[m4_ifdef([b4_percent_define_kind(]$1[)], 847 [m4_indir([b4_percent_define_kind(]$1[)])], 848 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 849 850# b4_percent_define_get_syncline(VARIABLE)dnl 851# ------------------------------------------- 852# Should always be following by a dnl. 853# 854# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly. 855# That is, if the %define variable VARIABLE is undefined, complain fatally 856# since that's a Bison or skeleton error. Otherwise, return its definition 857# location as a b4_syncline invocation. Don't record this as a Bison usage of 858# VARIABLE as there's no reason to suspect that the user-supplied value has yet 859# influenced the output. 860# 861# For example: 862# 863# b4_percent_define_get_syncline([[foo]]) 864m4_define([b4_percent_define_get_syncline], 865[m4_ifdef([b4_percent_define_syncline(]$1[)], 866 [m4_indir([b4_percent_define_syncline(]$1[)])], 867 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 868 869# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE]) 870# ------------------------------------------------------ 871# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand 872# IF-FALSE. Don't record usage of VARIABLE. 873# 874# For example: 875# 876# _b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]]) 877m4_define([_b4_percent_define_ifdef], 878[m4_ifdef([b4_percent_define(]$1[)], 879 [$2], 880 [$3])]) 881 882# b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE]) 883# ------------------------------------------------------ 884# Mimic muscle_percent_define_ifdef in ../src/muscle-tab.h exactly. That is, 885# if the %define variable VARIABLE is defined, expand IF-TRUE, else expand 886# IF-FALSE. Also, record Bison's usage of VARIABLE by defining 887# b4_percent_define_bison_variables(VARIABLE). 888# 889# For example: 890# 891# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]]) 892m4_define([b4_percent_define_ifdef], 893[_b4_percent_define_ifdef([$1], 894 [b4_percent_define_use([$1])$2], 895 [$3])]) 896 897 898# b4_percent_define_check_file_complain(VARIABLE) 899# ----------------------------------------------- 900# Warn about %define variable VARIABLE having an incorrect 901# value. 902m4_define([b4_percent_define_check_file_complain], 903[b4_complain_at(b4_percent_define_get_loc([$1]), 904 [[%%define variable '%s' requires 'none' or '"..."' values]], 905 [$1])]) 906 907 908# b4_percent_define_check_file(MACRO, VARIABLE, DEFAULT) 909# ------------------------------------------------------ 910# If the %define variable VARIABLE: 911# - is undefined, then if DEFAULT is non-empty, define MACRO to DEFAULT 912# - is a string, define MACRO to its value 913# - is the keyword 'none', do nothing 914# - otherwise, warn about the incorrect value. 915m4_define([b4_percent_define_check_file], 916[b4_percent_define_ifdef([$2], 917 [m4_case(b4_percent_define_get_kind([$2]), 918 [string], 919 [m4_define([$1], b4_percent_define_get([$2]))], 920 [keyword], 921 [m4_if(b4_percent_define_get([$2]), [none], [], 922 [b4_percent_define_check_file_complain([$2])])], 923 [b4_percent_define_check_file_complain([$2])]) 924 ], 925 [m4_ifval([$3], 926 [m4_define([$1], [$3])])]) 927]) 928 929 930 931## --------- ## 932## Options. ## 933## --------- ## 934 935 936# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE]) 937# -------------------------------------------------------- 938# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is, 939# if the %define variable VARIABLE is defined to "" or "true", expand IF-TRUE. 940# If it is defined to "false", expand IF-FALSE. Complain if it is undefined 941# (a Bison or skeleton error since the default value should have been set 942# already) or defined to any other value (possibly a user error). Also, record 943# Bison's usage of VARIABLE by defining 944# b4_percent_define_bison_variables(VARIABLE). 945# 946# For example: 947# 948# b4_percent_define_flag_if([[foo]], [[it's true]], [[it's false]]) 949m4_define([b4_percent_define_flag_if], 950[b4_percent_define_ifdef([$1], 951 [m4_case(b4_percent_define_get([$1]), 952 [], [$2], [true], [$2], [false], [$3], 953 [m4_expand_once([b4_complain_at(b4_percent_define_get_loc([$1]), 954 [[invalid value for %%define Boolean variable '%s']], 955 [$1])], 956 [[b4_percent_define_flag_if($1)]])])], 957 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 958 959 960# b4_percent_define_default(VARIABLE, DEFAULT, [KIND = keyword]) 961# -------------------------------------------------------------- 962# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is, 963# if the %define variable VARIABLE is undefined, set its value to DEFAULT. 964# Don't record this as a Bison usage of VARIABLE as there's no reason to 965# suspect that the value has yet influenced the output. 966# 967# For example: 968# 969# b4_percent_define_default([[foo]], [[default value]]) 970m4_define([b4_percent_define_default], 971[_b4_percent_define_ifdef([$1], [], 972 [m4_define([b4_percent_define(]$1[)], [$2])dnl 973 m4_define([b4_percent_define_kind(]$1[)], 974 [m4_default([$3], [keyword])])dnl 975 m4_define([b4_percent_define_loc(]$1[)], 976 [[[[<skeleton default value>:-1.-1]], 977 [[<skeleton default value>:-1.-1]]]])dnl 978 m4_define([b4_percent_define_syncline(]$1[)], [[]])])]) 979 980 981# b4_percent_define_if_define(NAME, [VARIABLE = NAME]) 982# ---------------------------------------------------- 983# Define b4_NAME_if that executes its $1 or $2 depending whether 984# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped 985# to '_'. 986m4_define([_b4_percent_define_if_define], 987[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]), 988 [b4_percent_define_flag_if(m4_default([$2], [$1]), 989 [$3], [$4])])]) 990m4_define([b4_percent_define_if_define], 991[b4_percent_define_default([m4_default([$2], [$1])], [[false]]) 992_b4_percent_define_if_define([$1], [$2], $[1], $[2])]) 993 994 995# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain]) 996# --------------------------------------------------------------------- 997m4_define([b4_percent_define_check_kind], 998[_b4_percent_define_ifdef([$1], 999 [m4_if(b4_percent_define_get_kind([$1]), [$2], [], 1000 [b4_error([m4_default([$3], [complain])], 1001 b4_percent_define_get_loc([$1]), 1002 [m4_case([$2], 1003 [code], [[%%define variable '%s' requires '{...}' values]], 1004 [keyword], [[%%define variable '%s' requires keyword values]], 1005 [string], [[%%define variable '%s' requires '"..."' values]])], 1006 [$1])])])dnl 1007]) 1008 1009 1010# b4_percent_define_check_values(VALUES) 1011# -------------------------------------- 1012# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly 1013# except that the VALUES structure is more appropriate for M4. That is, VALUES 1014# is a list of sublists of strings. For each sublist, the first string is the 1015# name of a %define variable, and all remaining strings in that sublist are the 1016# valid values for that variable. Complain if such a variable is undefined (a 1017# Bison error since the default value should have been set already) or defined 1018# to any other value (possibly a user error). Don't record this as a Bison 1019# usage of the variable as there's no reason to suspect that the value has yet 1020# influenced the output. 1021# 1022# For example: 1023# 1024# b4_percent_define_check_values([[[[foo]], [[foo-value1]], [[foo-value2]]]], 1025# [[[[bar]], [[bar-value1]]]]) 1026m4_define([b4_percent_define_check_values], 1027[m4_foreach([b4_sublist], m4_quote($@), 1028 [_b4_percent_define_check_values(b4_sublist)])]) 1029 1030m4_define([_b4_percent_define_check_values], 1031[_b4_percent_define_ifdef([$1], 1032 [b4_percent_define_check_kind(]$1[, [keyword], [deprecated])dnl 1033 m4_pushdef([b4_good_value], [0])dnl 1034 m4_if($#, 1, [], 1035 [m4_foreach([b4_value], m4_dquote(m4_shift($@)), 1036 [m4_if(m4_indir([b4_percent_define(]$1[)]), b4_value, 1037 [m4_define([b4_good_value], [1])])])])dnl 1038 m4_if(b4_good_value, [0], 1039 [b4_complain_at(b4_percent_define_get_loc([$1]), 1040 [[invalid value for %%define variable '%s': '%s']], 1041 [$1], 1042 m4_dquote(m4_indir([b4_percent_define(]$1[)]))) 1043 m4_foreach([b4_value], m4_dquote(m4_shift($@)), 1044 [b4_error([[note]], b4_percent_define_get_loc([$1]), [] 1045 [[accepted value: '%s']], 1046 m4_dquote(b4_value))])])dnl 1047 m4_popdef([b4_good_value])], 1048 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 1049 1050# b4_percent_code_get([QUALIFIER]) 1051# -------------------------------- 1052# If any %code blocks for QUALIFIER are defined, emit them beginning with a 1053# comment and ending with synclines and a newline. If QUALIFIER is not 1054# specified or empty, do this for the unqualified %code blocks. Also, record 1055# Bison's usage of QUALIFIER (if specified) by defining 1056# b4_percent_code_bison_qualifiers(QUALIFIER). 1057# 1058# For example, to emit any unqualified %code blocks followed by any %code 1059# blocks for the qualifier foo: 1060# 1061# b4_percent_code_get 1062# b4_percent_code_get([[foo]]) 1063m4_define([b4_percent_code_get], 1064[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl 1065m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl 1066m4_ifdef(b4_macro_name, 1067[b4_comment(m4_if([$#], [0], [[[Unqualified %code blocks.]]], 1068 [[["%code ]$1[" blocks.]]])) 1069b4_user_code([m4_indir(b4_macro_name)])])dnl 1070m4_popdef([b4_macro_name])]) 1071 1072# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE]) 1073# ----------------------------------------------------- 1074# If any %code blocks for QUALIFIER (or unqualified %code blocks if 1075# QUALIFIER is empty) are defined, expand IF-TRUE, else expand IF-FALSE. 1076# Also, record Bison's usage of QUALIFIER (if specified) by defining 1077# b4_percent_code_bison_qualifiers(QUALIFIER). 1078m4_define([b4_percent_code_ifdef], 1079[m4_ifdef([b4_percent_code(]$1[)], 1080 [m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2], 1081 [$3])]) 1082 1083 1084## ------------------ ## 1085## Common variables. ## 1086## ------------------ ## 1087 1088 1089# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT]) 1090# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT]) 1091# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT]) 1092# ---------------------------------------------------------- 1093b4_percent_define_if_define([api.token.raw]) 1094b4_percent_define_if_define([token_ctor], [api.token.constructor]) 1095b4_percent_define_if_define([locations]) # Whether locations are tracked. 1096b4_percent_define_if_define([parse.assert]) 1097b4_percent_define_if_define([parse.trace]) 1098 1099 1100# b4_bison_locations_if([IF-TRUE]) 1101# -------------------------------- 1102# Expand IF-TRUE if using locations, and using the default location 1103# type. 1104m4_define([b4_bison_locations_if], 1105[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])]) 1106 1107 1108 1109# %define parse.error "(custom|detailed|simple|verbose)" 1110# ------------------------------------------------------ 1111b4_percent_define_default([[parse.error]], [[simple]]) 1112b4_percent_define_check_values([[[[parse.error]], 1113 [[custom]], [[detailed]], [[simple]], [[verbose]]]]) 1114 1115# b4_parse_error_case(CASE1, THEN1, CASE2, THEN2, ..., ELSE) 1116# ---------------------------------------------------------- 1117m4_define([b4_parse_error_case], 1118[m4_case(b4_percent_define_get([[parse.error]]), $@)]) 1119 1120# b4_parse_error_bmatch(PATTERN1, THEN1, PATTERN2, THEN2, ..., ELSE) 1121# ------------------------------------------------------------------ 1122m4_define([b4_parse_error_bmatch], 1123[m4_bmatch(b4_percent_define_get([[parse.error]]), $@)]) 1124 1125 1126 1127# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT]) 1128# ---------------------------------------------- 1129b4_percent_define_if_define([variant]) 1130m4_define([b4_variant_flag], [[0]]) 1131b4_percent_define_ifdef([[api.value.type]], 1132 [m4_case(b4_percent_define_get_kind([[api.value.type]]), [keyword], 1133 [m4_case(b4_percent_define_get([[api.value.type]]), [variant], 1134 [m4_define([b4_variant_flag], [[1]])])])]) 1135b4_define_flag_if([variant]) 1136 1137 1138## ----------------------------------------------------------- ## 1139## After processing the skeletons, check that all the user's ## 1140## %define variables and %code qualifiers were used by Bison. ## 1141## ----------------------------------------------------------- ## 1142 1143m4_define([b4_check_user_names_wrap], 1144[m4_ifdef([b4_percent_]$1[_user_]$2[s], 1145 [b4_check_user_names([[%]$1 $2], 1146 [b4_percent_]$1[_user_]$2[s], 1147 [[b4_percent_]$1[_bison_]$2[s]])])]) 1148 1149m4_wrap_lifo([ 1150b4_check_user_names_wrap([[define]], [[variable]]) 1151b4_check_user_names_wrap([[code]], [[qualifier]]) 1152]) 1153 1154 1155## ---------------- ## 1156## Default values. ## 1157## ---------------- ## 1158 1159# m4_define_default([b4_lex_param], []) dnl breaks other skeletons 1160m4_define_default([b4_epilogue], []) 1161m4_define_default([b4_parse_param], []) 1162 1163# The initial column and line. 1164m4_define_default([b4_location_initial_column], [1]) 1165m4_define_default([b4_location_initial_line], [1]) 1166 1167 1168## --------------- ## 1169## Sanity checks. ## 1170## --------------- ## 1171 1172# api.location.type={...} (C, C++ and Java). 1173b4_percent_define_check_kind([api.location.type], [code], [deprecated]) 1174 1175# api.position.type={...} (Java). 1176b4_percent_define_check_kind([api.position.type], [code], [deprecated]) 1177 1178# api.prefix >< %name-prefix. 1179b4_percent_define_check_kind([api.prefix], [code], [deprecated]) 1180b4_percent_define_ifdef([api.prefix], 1181[m4_ifdef([b4_prefix], 1182[b4_complain_at(b4_percent_define_get_loc([api.prefix]), 1183 [['%s' and '%s' cannot be used together]], 1184 [%name-prefix], 1185 [%define api.prefix])])]) 1186 1187# api.token.prefix={...} 1188# Make it a warning for those who used betas of Bison 3.0. 1189b4_percent_define_check_kind([api.token.prefix], [code], [deprecated]) 1190 1191# api.value.type >< %union. 1192b4_percent_define_ifdef([api.value.type], 1193[m4_ifdef([b4_union_members], 1194[b4_complain_at(b4_percent_define_get_loc([api.value.type]), 1195 [['%s' and '%s' cannot be used together]], 1196 [%union], 1197 [%define api.value.type])])]) 1198 1199# api.value.type=union >< %yacc. 1200b4_percent_define_ifdef([api.value.type], 1201[m4_if(b4_percent_define_get([api.value.type]), [union], 1202[b4_yacc_if(dnl 1203[b4_complain_at(b4_percent_define_get_loc([api.value.type]), 1204 [['%s' and '%s' cannot be used together]], 1205 [%yacc], 1206 [%define api.value.type "union"])])])]) 1207 1208# api.value.union.name. 1209b4_percent_define_check_kind([api.value.union.name], [keyword]) 1210 1211# parse.error (custom|detailed) >< token-table. 1212b4_token_table_if( 1213[b4_parse_error_bmatch([custom\|detailed], 1214[b4_complain_at(b4_percent_define_get_loc([parse.error]), 1215 [['%s' and '%s' cannot be used together]], 1216 [%token-table], 1217 [%define parse.error (custom|detailed)])])]) 1218