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# b4_canary(MSG) 265# -------------- 266# Issue a warning on stderr and in the output. Used in the test suite 267# to catch spurious m4 evaluations. 268m4_define([b4_canary], 269[m4_errprintn([dead canary: $1])DEAD CANARY($1)]) 270 271 272## ------------ ## 273## Data Types. ## 274## ------------ ## 275 276# b4_ints_in(INT1, INT2, LOW, HIGH) 277# --------------------------------- 278# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise. 279m4_define([b4_ints_in], 280[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])]) 281 282 283# b4_subtract(LHS, RHS) 284# --------------------- 285# Evaluate LHS - RHS if they are integer literals, otherwise expand 286# to (LHS) - (RHS). 287m4_define([b4_subtract], 288[m4_bmatch([$1$2], [^[0123456789]*$], 289 [m4_eval([$1 - $2])], 290 [($1) - ($2)])]) 291 292# b4_join(ARG1, ...) 293# _b4_join(ARG1, ...) 294# ------------------- 295# Join with comma, skipping empty arguments. 296# b4_join calls itself recursively until it sees the first non-empty 297# argument, then calls _b4_join (i.e., `_$0`) which prepends each 298# non-empty argument with a comma. 299m4_define([b4_join], 300[m4_if([$#$1], 301 [1], [], 302 [m4_ifval([$1], 303 [$1[]_$0(m4_shift($@))], 304 [$0(m4_shift($@))])])]) 305 306# _b4_join(ARGS1, ...) 307# -------------------- 308m4_define([_b4_join], 309[m4_if([$#$1], 310 [1], [], 311 [m4_ifval([$1], [, $1])[]$0(m4_shift($@))])]) 312 313 314 315 316# b4_integral_parser_tables_map(MACRO) 317# ------------------------------------- 318# Map MACRO on all the integral tables. MACRO is expected to have 319# the signature MACRO(TABLE-NAME, CONTENT, COMMENT). 320m4_define([b4_integral_parser_tables_map], 321[$1([pact], [b4_pact], 322 [[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 323STATE-NUM.]]) 324 325$1([defact], [b4_defact], 326 [[YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. 327Performed when YYTABLE does not specify something else to do. Zero 328means the default is an error.]]) 329 330$1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]]) 331 332$1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]]) 333 334$1([table], [b4_table], 335 [[YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If 336positive, shift that token. If negative, reduce the rule whose 337number is the opposite. If YYTABLE_NINF, syntax error.]]) 338 339$1([check], [b4_check]) 340 341$1([stos], [b4_stos], 342 [[YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of 343state STATE-NUM.]]) 344 345$1([r1], [b4_r1], 346 [[YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.]]) 347 348$1([r2], [b4_r2], 349 [[YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.]]) 350]) 351 352 353# b4_parser_tables_declare 354# b4_parser_tables_define 355# ------------------------ 356# Define/declare the (deterministic) parser tables. 357m4_define([b4_parser_tables_declare], 358[b4_integral_parser_tables_map([b4_integral_parser_table_declare])]) 359 360m4_define([b4_parser_tables_define], 361[b4_integral_parser_tables_map([b4_integral_parser_table_define])]) 362 363 364 365## ------------------ ## 366## Decoding options. ## 367## ------------------ ## 368 369# b4_flag_if(FLAG, IF-TRUE, IF-FALSE) 370# ----------------------------------- 371# Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail. 372m4_define([b4_flag_if], 373[m4_case(b4_$1_flag, 374 [0], [$3], 375 [1], [$2], 376 [m4_fatal([invalid $1 value: ]b4_$1_flag)])]) 377 378 379# b4_define_flag_if(FLAG) 380# ----------------------- 381# Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the 382# value of the Boolean FLAG. 383m4_define([b4_define_flag_if], 384[_b4_define_flag_if($[1], $[2], [$1])]) 385 386# _b4_define_flag_if($1, $2, FLAG) 387# -------------------------------- 388# Work around the impossibility to define macros inside macros, 389# because issuing '[$1]' is not possible in M4. GNU M4 should provide 390# $$1 a la M5/TeX. 391m4_define([_b4_define_flag_if], 392[m4_if([$1$2], $[1]$[2], [], 393 [m4_fatal([$0: Invalid arguments: $@])])dnl 394m4_define([b4_$3_if], 395 [b4_flag_if([$3], [$1], [$2])])]) 396 397 398# b4_FLAG_if(IF-TRUE, IF-FALSE) 399# ----------------------------- 400# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise. 401b4_define_flag_if([glr]) # Whether a GLR parser is requested. 402b4_define_flag_if([has_translations]) # Whether some tokens are internationalized. 403b4_define_flag_if([header]) # Whether a header is requested. 404b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled. 405b4_define_flag_if([token_table]) # Whether yytoken_table is demanded. 406b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. 407 408 409# b4_glr_cc_if([IF-TRUE], [IF-FALSE]) 410# ----------------------------------- 411m4_define([b4_glr_cc_if], 412 [m4_if(b4_skeleton, ["glr.cc"], $@)]) 413 414# b4_glr2_cc_if([IF-TRUE], [IF-FALSE]) 415# ------------------------------------ 416m4_define([b4_glr2_cc_if], 417 [m4_if(b4_skeleton, ["glr2.cc"], $@)]) 418 419## --------- ## 420## Symbols. ## 421## --------- ## 422 423# For a description of the Symbol handling, see README.md. 424# 425# The following macros provide access to symbol related values. 426 427# __b4_symbol(NUM, FIELD) 428# ----------------------- 429# Fetch FIELD of symbol #NUM. Fail if undefined. 430m4_define([__b4_symbol], 431[m4_indir([b4_symbol($1, $2)])]) 432 433 434# _b4_symbol(NUM, FIELD) 435# ---------------------- 436# Fetch FIELD of symbol #NUM (or "orig NUM", see README.md). 437# Fail if undefined. 438m4_define([_b4_symbol], 439[m4_ifdef([b4_symbol($1, number)], 440 [__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)], 441 [__b4_symbol([$1], [$2])])]) 442 443 444# b4_symbol_token_kind(NUM) 445# ------------------------- 446# The token kind of this symbol. 447m4_define([b4_symbol_token_kind], 448[b4_percent_define_get([api.token.prefix])dnl 449_b4_symbol([$1], [id])]) 450 451 452# b4_symbol_kind_base(NUM) 453# ------------------------ 454# Build the name of the kind of this symbol. It must always exist, 455# otherwise some symbols might not be represented in the enum, which 456# might be compiled into too small a type to contain all the symbol 457# numbers. 458m4_define([b4_symbol_prefix], [b4_percent_define_get([api.symbol.prefix])]) 459m4_define([b4_symbol_kind_base], 460[b4_percent_define_get([api.symbol.prefix])dnl 461m4_case([$1], 462 [-2], [[YYEMPTY]], 463 [0], [[YYEOF]], 464 [1], [[YYerror]], 465 [2], [[YYUNDEF]], 466 [m4_case(b4_symbol([$1], [tag]), 467 [$accept], [[YYACCEPT]], 468 [b4_symbol_if([$1], [has_id], _b4_symbol([$1], [id]), 469 [m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])]) 470 471 472# b4_symbol_kind(NUM) 473# ------------------- 474# Same as b4_symbol_kind, but possibly with a prefix in some 475# languages. E.g., EOF's kind_base and kind are YYSYMBOL_YYEOF in C, 476# but are S_YYEMPTY and symbol_kind::S_YYEMPTY in C++. 477m4_copy([b4_symbol_kind_base], [b4_symbol_kind]) 478 479 480# b4_symbol_slot(NUM) 481# ------------------- 482# The name of union member that contains the value of these symbols. 483# Currently, we are messy, this should actually be type_tag, but type_tag 484# has several meanings. 485m4_define([b4_symbol_slot], 486[m4_case(b4_percent_define_get([[api.value.type]]), 487 [union], [b4_symbol([$1], [type_tag])], 488 [variant], [b4_symbol([$1], [type_tag])], 489 [b4_symbol([$1], [type])])]) 490 491 492# b4_symbol(NUM, FIELD) 493# --------------------- 494# Fetch FIELD of symbol #NUM (or "orig NUM", or "empty"). Fail if undefined. 495# 496# If FIELD = id, prepend the token prefix. 497m4_define([b4_symbol], 498[m4_if([$1], [empty], [b4_symbol([-2], [$2])], 499 [$1], [eof], [b4_symbol([0], [$2])], 500 [$1], [error], [b4_symbol([1], [$2])], 501 [$1], [undef], [b4_symbol([2], [$2])], 502 [m4_case([$2], 503 [id], [b4_symbol_token_kind([$1])], 504 [kind_base], [b4_symbol_kind_base([$1])], 505 [kind], [b4_symbol_kind([$1])], 506 [slot], [b4_symbol_slot([$1])], 507 [_b4_symbol($@)])])]) 508 509 510# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE) 511# ------------------------------------------- 512# If FIELD about symbol #NUM is 1 expand IF-TRUE, if is 0, expand IF-FALSE. 513# Otherwise an error. 514m4_define([b4_symbol_if], 515[m4_case(b4_symbol([$1], [$2]), 516 [1], [$3], 517 [0], [$4], 518 [m4_fatal([$0: field $2 of $1 is not a Boolean:] b4_symbol([$1], [$2]))])]) 519 520 521# b4_symbol_tag_comment(SYMBOL-NUM) 522# --------------------------------- 523# Issue a comment giving the tag of symbol NUM. 524m4_define([b4_symbol_tag_comment], 525[b4_comment([b4_symbol([$1], [tag])]) 526]) 527 528 529# b4_symbol_action(SYMBOL-NUM, ACTION) 530# ------------------------------------ 531# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM. 532m4_define([b4_symbol_action], 533[b4_symbol_if([$1], [has_$2], 534[b4_dollar_pushdef([(*yyvaluep)], 535 [$1], 536 [], 537 [(*yylocationp)])dnl 538 _b4_symbol_case([$1])[]dnl 539b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl 540b4_symbol([$1], [$2]) 541b4_syncline([@oline@], [@ofile@])dnl 542 break; 543 544b4_dollar_popdef[]dnl 545])]) 546 547 548# b4_symbol_destructor(SYMBOL-NUM) 549# b4_symbol_printer(SYMBOL-NUM) 550# -------------------------------- 551m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])]) 552m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])]) 553 554 555# b4_symbol_actions(ACTION, [KIND = yykind]) 556# ------------------------------------------ 557# Emit the symbol actions for ACTION ("destructor" or "printer"). 558# Dispatch on KIND. 559m4_define([b4_symbol_actions], 560[m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl 561m4_ifval(m4_defn([b4_actions_]), 562[switch (m4_default([$2], [yykind])) 563 { 564m4_defn([b4_actions_])[]dnl 565 default: 566 break; 567 }dnl 568], 569[b4_use(m4_default([$2], [yykind]));])dnl 570m4_popdef([b4_actions_])dnl 571]) 572 573# _b4_symbol_case(SYMBOL-NUM) 574# --------------------------- 575# Issue a "case NUM" for SYMBOL-NUM. Ends with its EOL to make it 576# easier to use with m4_map, but then, use []dnl to suppress the last 577# one. 578m4_define([_b4_symbol_case], 579[case b4_symbol([$1], [kind]): b4_symbol_tag_comment([$1])]) 580]) 581 582 583# b4_symbol_foreach(MACRO) 584# ------------------------ 585# Invoke MACRO(SYMBOL-NUM) for each SYMBOL-NUM. 586m4_define([b4_symbol_foreach], 587 [m4_map([$1], m4_defn([b4_symbol_numbers]))]) 588 589# b4_symbol_map(MACRO) 590# -------------------- 591# Return a list (possibly empty elements) of MACRO invoked for each 592# SYMBOL-NUM. 593m4_define([b4_symbol_map], 594[m4_map_args_sep([$1(], [)], [,], b4_symbol_numbers)]) 595 596 597# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE) 598# ------------------------------------------- 599# Whether NUM denotes a token kind that has an exported definition 600# (i.e., shows in enum yytokentype). 601m4_define([b4_token_visible_if], 602[b4_symbol_if([$1], [is_token], 603 [b4_symbol_if([$1], [has_id], [$2], [$3])], 604 [$3])]) 605 606 607# b4_token_has_definition(NUM) 608# ---------------------------- 609# 1 if NUM is visible, nothing otherwise. 610m4_define([b4_token_has_definition], 611[b4_token_visible_if([$1], [1])]) 612 613# b4_any_token_visible_if([IF-TRUE], [IF-FALSE]) 614# ---------------------------------------------- 615# Whether there is a token that needs to be defined. 616m4_define([b4_any_token_visible_if], 617[m4_ifval(b4_symbol_foreach([b4_token_has_definition]), 618 [$1], [$2])]) 619 620 621# b4_token_format(FORMAT, NUM) 622# ---------------------------- 623# If token NUM has a visible ID, format FORMAT with ID, USER_NUMBER. 624m4_define([b4_token_format], 625[b4_token_visible_if([$2], 626[m4_format([[$1]], 627 b4_symbol([$2], [id]), 628 b4_symbol([$2], b4_api_token_raw_if([[number]], [[code]])))])]) 629 630 631# b4_last_enum_token 632# ------------------ 633# The code of the last token visible token. 634m4_define([_b4_last_enum_token], 635[b4_token_visible_if([$1], 636 [m4_define([b4_last_enum_token], [$1])])]) 637b4_symbol_foreach([_b4_last_enum_token]) 638 639# b4_last_symbol 640# -------------- 641# The code of the last symbol. 642m4_define([b4_last_symbol], m4_eval(b4_tokens_number + b4_nterms_number - 1)) 643 644## ------- ## 645## Types. ## 646## ------- ## 647 648# _b4_type_action(NUMS) 649# --------------------- 650# Run actions for the symbol NUMS that all have the same type-name. 651# Skip NUMS that have no type-name. 652# 653# To specify the action to run, define b4_dollar_dollar(SYMBOL-NUM, 654# TAG, TYPE). 655m4_define([_b4_type_action], 656[b4_symbol_if([$1], [has_type], 657[m4_map([ _b4_symbol_case], [$@])[]dnl 658 b4_dollar_dollar([b4_symbol([$1], [number])], 659 [b4_symbol([$1], [tag])], 660 [b4_symbol([$1], [type])]); 661 break; 662 663])]) 664 665# b4_type_foreach(MACRO, [SEP]) 666# ----------------------------- 667# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set. 668m4_define([b4_type_foreach], 669 [m4_map_sep([$1], [$2], m4_defn([b4_type_names]))]) 670 671 672 673## ----------- ## 674## Synclines. ## 675## ----------- ## 676 677# b4_basename(NAME) 678# ----------------- 679# Similar to POSIX basename; the differences don't matter here. 680# Beware that NAME is not evaluated. 681m4_define([b4_basename], 682[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])]) 683 684 685# b4_syncline(LINE, FILE)dnl 686# -------------------------- 687# Should always be following by a dnl. 688# 689# Emit "#line LINE FILE /* __LINE__ __FILE__ */". 690m4_define([b4_syncline], 691[b4_flag_if([synclines], 692[b4_sync_start([$1], [$2])[]dnl 693b4_sync_end([__line__], [b4_basename(m4_quote(__file__))]) 694])]) 695 696# b4_sync_start(LINE, FILE) 697# ----------------------- 698# Syncline for the new place. Typically a directive for the compiler. 699m4_define([b4_sync_start], [b4_comment([$2:$1])]) 700 701# b4_sync_end(LINE, FILE) 702# ----------------------- 703# Syncline for the current place, which ends. Typically a comment 704# left for the reader. 705m4_define([b4_sync_end], [ b4_comment([$2:$1])] 706) 707# This generates dependencies on the Bison skeletons hence lots of 708# useless 'git diff'. This location is useless for the regular 709# user (who does not care about the skeletons) and is actually not 710# useful for Bison developers too (I, Akim, never used this to locate 711# the code in skeletons that generated output). So disable it 712# completely. If someone thinks this was actually useful, a %define 713# variable should be provided to control the level of verbosity of 714# '#line', in replacement of --no-lines. 715m4_define([b4_sync_end]) 716 717 718# b4_user_code(USER-CODE) 719# ----------------------- 720# Emit code from the user, ending it with synclines. 721m4_define([b4_user_code], 722[$1 723b4_syncline([@oline@], [@ofile@])]) 724 725 726# b4_define_user_code(MACRO, COMMENT) 727# ----------------------------------- 728# From b4_MACRO, if defined, build b4_user_MACRO that includes the synclines. 729m4_define([b4_define_user_code], 730[m4_define([b4_user_$1], 731 [m4_ifdef([b4_$1], 732 [m4_ifval([$2], 733 [b4_comment([$2]) 734])b4_user_code([b4_$1])])])]) 735 736# b4_user_actions 737# b4_user_initial_action 738# b4_user_post_prologue 739# b4_user_pre_prologue 740# b4_user_union_members 741# ---------------------- 742# Macros that issue user code, ending with synclines. 743b4_define_user_code([actions]) 744b4_define_user_code([initial_action], [User initialization code.]) 745b4_define_user_code([post_prologue], [Second part of user prologue.]) 746b4_define_user_code([pre_prologue], [First part of user prologue.]) 747b4_define_user_code([union_members]) 748 749 750# b4_check_user_names(WHAT, USER-LIST, BISON-NAMESPACE) 751# ----------------------------------------------------- 752# Complain if any name of type WHAT is used by the user (as recorded in 753# USER-LIST) but is not used by Bison (as recorded by macros in the 754# namespace BISON-NAMESPACE). 755# 756# USER-LIST must expand to a list specifying all user occurrences of all names 757# of type WHAT. Each item in the list must be a triplet specifying one 758# occurrence: name, start boundary, and end boundary. Empty string names are 759# fine. An empty list is fine. 760# 761# For example, to define b4_foo_user_names to be used for USER-LIST with three 762# name occurrences and with correct quoting: 763# 764# m4_define([b4_foo_user_names], 765# [[[[[[bar]], [[parser.y:1.7]], [[parser.y:1.16]]]], 766# [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]], 767# [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]]) 768# 769# The macro BISON-NAMESPACE(bar) must be defined iff the name bar of type WHAT 770# is used by Bison (in the front-end or in the skeleton). Empty string names 771# are fine, but it would be ugly for Bison to actually use one. 772# 773# For example, to use b4_foo_bison_names for BISON-NAMESPACE and define that 774# the names bar and baz are used by Bison: 775# 776# m4_define([b4_foo_bison_names(bar)]) 777# m4_define([b4_foo_bison_names(baz)]) 778# 779# To invoke b4_check_user_names with TYPE foo, with USER-LIST 780# b4_foo_user_names, with BISON-NAMESPACE b4_foo_bison_names, and with correct 781# quoting: 782# 783# b4_check_user_names([[foo]], [b4_foo_user_names], 784# [[b4_foo_bison_names]]) 785m4_define([b4_check_user_names], 786[m4_foreach([b4_occurrence], $2, 787[m4_pushdef([b4_occurrence], b4_occurrence)dnl 788m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl 789m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl 790m4_pushdef([b4_end], m4_shift2(b4_occurrence))dnl 791m4_ifndef($3[(]m4_quote(b4_user_name)[)], 792 [b4_complain_at([b4_start], [b4_end], 793 [[%s '%s' is not used]], 794 [$1], [b4_user_name])])[]dnl 795m4_popdef([b4_occurrence])dnl 796m4_popdef([b4_user_name])dnl 797m4_popdef([b4_start])dnl 798m4_popdef([b4_end])dnl 799])]) 800 801 802 803## --------------------- ## 804## b4_percent_define_*. ## 805## --------------------- ## 806 807 808# b4_percent_define_use(VARIABLE) 809# ------------------------------- 810# Declare that VARIABLE was used. 811m4_define([b4_percent_define_use], 812[m4_define([b4_percent_define_bison_variables(]$1[)])dnl 813]) 814 815# b4_percent_define_get(VARIABLE, [DEFAULT]) 816# ------------------------------------------ 817# Mimic muscle_percent_define_get in ../src/muscle-tab.h. That is, if 818# the %define variable VARIABLE is defined, emit its value. Contrary 819# to its C counterpart, return DEFAULT otherwise. Also, record 820# Bison's usage of VARIABLE by defining 821# b4_percent_define_bison_variables(VARIABLE). 822# 823# For example: 824# 825# b4_percent_define_get([[foo]]) 826m4_define([b4_percent_define_get], 827[b4_percent_define_use([$1])dnl 828_b4_percent_define_ifdef([$1], 829 [m4_indir([b4_percent_define(]$1[)])], 830 [$2])]) 831 832# b4_percent_define_get_loc(VARIABLE) 833# ----------------------------------- 834# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is, 835# if the %define variable VARIABLE is undefined, complain fatally since that's 836# a Bison or skeleton error. Otherwise, return its definition location in a 837# form appropriate for the first two arguments of b4_warn_at, b4_complain_at, or 838# b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no 839# reason to suspect that the user-supplied value has yet influenced the output. 840# 841# For example: 842# 843# b4_complain_at(b4_percent_define_get_loc([[foo]]), [[invalid foo]]) 844m4_define([b4_percent_define_get_loc], 845[m4_ifdef([b4_percent_define_loc(]$1[)], 846 [m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl 847b4_loc[]dnl 848m4_popdef([b4_loc])], 849 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 850 851# b4_percent_define_get_kind(VARIABLE) 852# ------------------------------------ 853# Get the kind (code, keyword, string) of VARIABLE, i.e., how its 854# value was defined (braces, not delimiters, quotes). 855# 856# If the %define variable VARIABLE is undefined, complain fatally 857# since that's a Bison or skeleton error. Don't record this as a 858# Bison usage of VARIABLE as there's no reason to suspect that the 859# user-supplied value has yet influenced the output. 860m4_define([b4_percent_define_get_kind], 861[m4_ifdef([b4_percent_define_kind(]$1[)], 862 [m4_indir([b4_percent_define_kind(]$1[)])], 863 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 864 865# b4_percent_define_get_syncline(VARIABLE)dnl 866# ------------------------------------------- 867# Should always be following by a dnl. 868# 869# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly. 870# That is, if the %define variable VARIABLE is undefined, complain fatally 871# since that's a Bison or skeleton error. Otherwise, return its definition 872# location as a b4_syncline invocation. Don't record this as a Bison usage of 873# VARIABLE as there's no reason to suspect that the user-supplied value has yet 874# influenced the output. 875# 876# For example: 877# 878# b4_percent_define_get_syncline([[foo]]) 879m4_define([b4_percent_define_get_syncline], 880[m4_ifdef([b4_percent_define_syncline(]$1[)], 881 [m4_indir([b4_percent_define_syncline(]$1[)])], 882 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 883 884# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE]) 885# ------------------------------------------------------ 886# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand 887# IF-FALSE. Don't record usage of 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[m4_ifdef([b4_percent_define(]$1[)], 894 [$2], 895 [$3])]) 896 897# b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE]) 898# ------------------------------------------------------ 899# Mimic muscle_percent_define_ifdef in ../src/muscle-tab.h exactly. That is, 900# if the %define variable VARIABLE is defined, expand IF-TRUE, else expand 901# IF-FALSE. Also, record Bison's usage of VARIABLE by defining 902# b4_percent_define_bison_variables(VARIABLE). 903# 904# For example: 905# 906# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]]) 907m4_define([b4_percent_define_ifdef], 908[_b4_percent_define_ifdef([$1], 909 [b4_percent_define_use([$1])$2], 910 [$3])]) 911 912 913# b4_percent_define_check_file_complain(VARIABLE) 914# ----------------------------------------------- 915# Warn about %define variable VARIABLE having an incorrect 916# value. 917m4_define([b4_percent_define_check_file_complain], 918[b4_complain_at(b4_percent_define_get_loc([$1]), 919 [[%%define variable '%s' requires 'none' or '"..."' values]], 920 [$1])]) 921 922 923# b4_percent_define_check_file(MACRO, VARIABLE, DEFAULT) 924# ------------------------------------------------------ 925# If the %define variable VARIABLE: 926# - is undefined, then if DEFAULT is non-empty, define MACRO to DEFAULT 927# - is a string, define MACRO to its value 928# - is the keyword 'none', do nothing 929# - otherwise, warn about the incorrect value. 930m4_define([b4_percent_define_check_file], 931[b4_percent_define_ifdef([$2], 932 [m4_case(b4_percent_define_get_kind([$2]), 933 [string], 934 [m4_define([$1], b4_percent_define_get([$2]))], 935 [keyword], 936 [m4_if(b4_percent_define_get([$2]), [none], [], 937 [b4_percent_define_check_file_complain([$2])])], 938 [b4_percent_define_check_file_complain([$2])]) 939 ], 940 [m4_ifval([$3], 941 [m4_define([$1], [$3])])]) 942]) 943 944 945 946## --------- ## 947## Options. ## 948## --------- ## 949 950 951# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE]) 952# -------------------------------------------------------- 953# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is, 954# if the %define variable VARIABLE is defined to "" or "true", expand IF-TRUE. 955# If it is defined to "false", expand IF-FALSE. Complain if it is undefined 956# (a Bison or skeleton error since the default value should have been set 957# already) or defined to any other value (possibly a user error). Also, record 958# Bison's usage of VARIABLE by defining 959# b4_percent_define_bison_variables(VARIABLE). 960# 961# For example: 962# 963# b4_percent_define_flag_if([[foo]], [[it's true]], [[it's false]]) 964m4_define([b4_percent_define_flag_if], 965[b4_percent_define_ifdef([$1], 966 [m4_case(b4_percent_define_get([$1]), 967 [], [$2], [true], [$2], [false], [$3], 968 [m4_expand_once([b4_complain_at(b4_percent_define_get_loc([$1]), 969 [[invalid value for %%define Boolean variable '%s']], 970 [$1])], 971 [[b4_percent_define_flag_if($1)]])])], 972 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 973 974 975# b4_percent_define_default(VARIABLE, DEFAULT, [KIND = keyword]) 976# -------------------------------------------------------------- 977# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is, 978# if the %define variable VARIABLE is undefined, set its value to DEFAULT. 979# Don't record this as a Bison usage of VARIABLE as there's no reason to 980# suspect that the value has yet influenced the output. 981# 982# For example: 983# 984# b4_percent_define_default([[foo]], [[default value]]) 985m4_define([_b4_percent_define_define], 986[m4_define([b4_percent_define(]$1[)], [$2])dnl 987m4_define([b4_percent_define_kind(]$1[)], 988 [m4_default([$3], [keyword])])dnl 989m4_define([b4_percent_define_loc(]$1[)], 990 [[[[<skeleton default value>:-1.-1]], 991 [[<skeleton default value>:-1.-1]]]])dnl 992m4_define([b4_percent_define_syncline(]$1[)], [[]])]) 993 994m4_define([b4_percent_define_default], 995[_b4_percent_define_ifdef([$1], [], 996 [_b4_percent_define_define($@)])]) 997 998 999# b4_percent_define_if_define(NAME, [VARIABLE = NAME]) 1000# ---------------------------------------------------- 1001# Define b4_NAME_if that executes its $1 or $2 depending whether 1002# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped 1003# to '_'. 1004m4_define([_b4_percent_define_if_define], 1005[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]), 1006 [b4_percent_define_default([m4_default([$2], [$1])], [[false]])dnl 1007b4_percent_define_flag_if(m4_default([$2], [$1]), 1008 [$3], [$4])])]) 1009 1010m4_define([b4_percent_define_if_define], 1011[_b4_percent_define_if_define([$1], [$2], $[1], $[2])]) 1012 1013 1014# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain]) 1015# --------------------------------------------------------------------- 1016m4_define([b4_percent_define_check_kind], 1017[_b4_percent_define_ifdef([$1], 1018 [m4_if(b4_percent_define_get_kind([$1]), [$2], [], 1019 [b4_error([m4_default([$3], [complain])], 1020 b4_percent_define_get_loc([$1]), 1021 [m4_case([$2], 1022 [code], [[%%define variable '%s' requires '{...}' values]], 1023 [keyword], [[%%define variable '%s' requires keyword values]], 1024 [string], [[%%define variable '%s' requires '"..."' values]])], 1025 [$1])])])dnl 1026]) 1027 1028 1029# b4_percent_define_check_values(VALUES) 1030# -------------------------------------- 1031# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly 1032# except that the VALUES structure is more appropriate for M4. That is, VALUES 1033# is a list of sublists of strings. For each sublist, the first string is the 1034# name of a %define variable, and all remaining strings in that sublist are the 1035# valid values for that variable. Complain if such a variable is undefined (a 1036# Bison error since the default value should have been set already) or defined 1037# to any other value (possibly a user error). Don't record this as a Bison 1038# usage of the variable as there's no reason to suspect that the value has yet 1039# influenced the output. 1040# 1041# For example: 1042# 1043# b4_percent_define_check_values([[[[foo]], [[foo-value1]], [[foo-value2]]]], 1044# [[[[bar]], [[bar-value1]]]]) 1045m4_define([b4_percent_define_check_values], 1046[m4_foreach([b4_sublist], m4_quote($@), 1047 [_b4_percent_define_check_values(b4_sublist)])]) 1048 1049m4_define([_b4_percent_define_check_values], 1050[_b4_percent_define_ifdef([$1], 1051 [b4_percent_define_check_kind(]$1[, [keyword], [deprecated])dnl 1052 m4_pushdef([b4_good_value], [0])dnl 1053 m4_if($#, 1, [], 1054 [m4_foreach([b4_value], m4_dquote(m4_shift($@)), 1055 [m4_if(m4_indir([b4_percent_define(]$1[)]), b4_value, 1056 [m4_define([b4_good_value], [1])])])])dnl 1057 m4_if(b4_good_value, [0], 1058 [b4_complain_at(b4_percent_define_get_loc([$1]), 1059 [[invalid value for %%define variable '%s': '%s']], 1060 [$1], 1061 m4_dquote(m4_indir([b4_percent_define(]$1[)]))) 1062 m4_foreach([b4_value], m4_dquote(m4_shift($@)), 1063 [b4_error([[note]], b4_percent_define_get_loc([$1]), [] 1064 [[accepted value: '%s']], 1065 m4_dquote(b4_value))])])dnl 1066 m4_popdef([b4_good_value])], 1067 [b4_fatal([[$0: undefined %%define variable '%s']], [$1])])]) 1068 1069# b4_percent_code_get([QUALIFIER]) 1070# -------------------------------- 1071# If any %code blocks for QUALIFIER are defined, emit them beginning with a 1072# comment and ending with synclines and a newline. If QUALIFIER is not 1073# specified or empty, do this for the unqualified %code blocks. Also, record 1074# Bison's usage of QUALIFIER (if specified) by defining 1075# b4_percent_code_bison_qualifiers(QUALIFIER). 1076# 1077# For example, to emit any unqualified %code blocks followed by any %code 1078# blocks for the qualifier foo: 1079# 1080# b4_percent_code_get 1081# b4_percent_code_get([[foo]]) 1082m4_define([b4_percent_code_get], 1083[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl 1084m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl 1085m4_ifdef(b4_macro_name, 1086[b4_comment(m4_if([$#], [0], [[[Unqualified %code blocks.]]], 1087 [[["%code ]$1[" blocks.]]])) 1088b4_user_code([m4_indir(b4_macro_name)])])dnl 1089m4_popdef([b4_macro_name])]) 1090 1091# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE]) 1092# ----------------------------------------------------- 1093# If any %code blocks for QUALIFIER (or unqualified %code blocks if 1094# QUALIFIER is empty) are defined, expand IF-TRUE, else expand IF-FALSE. 1095# Also, record Bison's usage of QUALIFIER (if specified) by defining 1096# b4_percent_code_bison_qualifiers(QUALIFIER). 1097m4_define([b4_percent_code_ifdef], 1098[m4_ifdef([b4_percent_code(]$1[)], 1099 [m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2], 1100 [$3])]) 1101 1102 1103## ------------------ ## 1104## Common variables. ## 1105## ------------------ ## 1106 1107 1108# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT]) 1109# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT]) 1110# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT]) 1111# ---------------------------------------------------------- 1112b4_percent_define_if_define([api.token.raw]) 1113b4_percent_define_if_define([token_ctor], [api.token.constructor]) 1114b4_percent_define_if_define([locations]) # Whether locations are tracked. 1115b4_percent_define_if_define([parse.assert]) 1116b4_percent_define_if_define([parse.trace]) 1117b4_percent_define_if_define([posix]) 1118 1119 1120# b4_bison_locations_if([IF-TRUE]) 1121# -------------------------------- 1122# Expand IF-TRUE if using locations, and using the default location 1123# type. 1124m4_define([b4_bison_locations_if], 1125[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])]) 1126 1127 1128 1129# %define parse.error "(custom|detailed|simple|verbose)" 1130# ------------------------------------------------------ 1131b4_percent_define_default([[parse.error]], [[simple]]) 1132b4_percent_define_check_values([[[[parse.error]], 1133 [[custom]], [[detailed]], [[simple]], [[verbose]]]]) 1134 1135# b4_parse_error_case(CASE1, THEN1, CASE2, THEN2, ..., ELSE) 1136# ---------------------------------------------------------- 1137m4_define([b4_parse_error_case], 1138[m4_case(b4_percent_define_get([[parse.error]]), $@)]) 1139 1140# b4_parse_error_bmatch(PATTERN1, THEN1, PATTERN2, THEN2, ..., ELSE) 1141# ------------------------------------------------------------------ 1142m4_define([b4_parse_error_bmatch], 1143[m4_bmatch(b4_percent_define_get([[parse.error]]), $@)]) 1144 1145 1146 1147# b4_union_if([IF-UNION-ARE-USED], [IF-NOT]) 1148# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT]) 1149# ---------------------------------------------- 1150# Depend on whether api.value.type is union, or variant. 1151m4_define([b4_union_flag], [[0]]) 1152m4_define([b4_variant_flag], [[0]]) 1153b4_percent_define_ifdef([[api.value.type]], 1154 [m4_case(b4_percent_define_get_kind([[api.value.type]]), [keyword], 1155 [m4_case(b4_percent_define_get([[api.value.type]]), 1156 [union], [m4_define([b4_union_flag], [[1]])], 1157 [variant], [m4_define([b4_variant_flag], [[1]])])])]) 1158b4_define_flag_if([union]) 1159b4_define_flag_if([variant]) 1160 1161 1162## ----------------------------------------------------------- ## 1163## After processing the skeletons, check that all the user's ## 1164## %define variables and %code qualifiers were used by Bison. ## 1165## ----------------------------------------------------------- ## 1166 1167m4_define([b4_check_user_names_wrap], 1168[m4_ifdef([b4_percent_]$1[_user_]$2[s], 1169 [b4_check_user_names([[%]$1 $2], 1170 [b4_percent_]$1[_user_]$2[s], 1171 [[b4_percent_]$1[_bison_]$2[s]])])]) 1172 1173m4_wrap_lifo([ 1174b4_check_user_names_wrap([[define]], [[variable]]) 1175b4_check_user_names_wrap([[code]], [[qualifier]]) 1176]) 1177 1178 1179## ---------------- ## 1180## Default values. ## 1181## ---------------- ## 1182 1183# m4_define_default([b4_lex_param], []) dnl breaks other skeletons 1184m4_define_default([b4_epilogue], []) 1185m4_define_default([b4_parse_param], []) 1186 1187# The initial column and line. 1188m4_define_default([b4_location_initial_column], [1]) 1189m4_define_default([b4_location_initial_line], [1]) 1190 1191 1192## --------------- ## 1193## Sanity checks. ## 1194## --------------- ## 1195 1196# api.location.type={...} (C, C++ and Java). 1197b4_percent_define_check_kind([api.location.type], [code], [deprecated]) 1198 1199# api.position.type={...} (Java). 1200b4_percent_define_check_kind([api.position.type], [code], [deprecated]) 1201 1202# api.prefix >< %name-prefix. 1203b4_percent_define_check_kind([api.prefix], [code], [deprecated]) 1204b4_percent_define_ifdef([api.prefix], 1205[m4_ifdef([b4_prefix], 1206[b4_complain_at(b4_percent_define_get_loc([api.prefix]), 1207 [['%s' and '%s' cannot be used together]], 1208 [%name-prefix], 1209 [%define api.prefix])])]) 1210 1211# api.token.prefix={...} 1212# Make it a warning for those who used betas of Bison 3.0. 1213b4_percent_define_check_kind([api.token.prefix], [code], [deprecated]) 1214 1215# api.value.type >< %union. 1216b4_percent_define_ifdef([api.value.type], 1217[m4_ifdef([b4_union_members], 1218[b4_complain_at(b4_percent_define_get_loc([api.value.type]), 1219 [['%s' and '%s' cannot be used together]], 1220 [%union], 1221 [%define api.value.type])])]) 1222 1223# api.value.type=union >< %yacc. 1224b4_percent_define_ifdef([api.value.type], 1225[m4_if(b4_percent_define_get([api.value.type]), [union], 1226[b4_yacc_if(dnl 1227[b4_complain_at(b4_percent_define_get_loc([api.value.type]), 1228 [['%s' and '%s' cannot be used together]], 1229 [%yacc], 1230 [%define api.value.type "union"])])])]) 1231 1232# api.value.union.name. 1233b4_percent_define_check_kind([api.value.union.name], [keyword]) 1234 1235# parse.error (custom|detailed) >< token-table. 1236b4_token_table_if( 1237[b4_parse_error_bmatch([custom\|detailed], 1238[b4_complain_at(b4_percent_define_get_loc([parse.error]), 1239 [['%s' and '%s' cannot be used together]], 1240 [%token-table], 1241 [%define parse.error (custom|detailed)])])]) 1242