1 -*- Autoconf -*- 2 3# C++ skeleton for Bison 4 5# Copyright (C) 2002-2021 Free Software Foundation, Inc. 6 7# This program is free software: you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation, either version 3 of the License, or 10# (at your option) any later version. 11# 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. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <https://www.gnu.org/licenses/>. 19 20# Sanity checks, before defaults installed by c.m4. 21b4_percent_define_ifdef([[api.value.union.name]], 22 [b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]), 23 [named %union is invalid in C++])]) 24 25b4_percent_define_default([[api.symbol.prefix]], [[S_]]) 26 27m4_include(b4_skeletonsdir/[c.m4]) 28 29b4_percent_define_check_kind([api.namespace], [code], [deprecated]) 30b4_percent_define_check_kind([api.parser.class], [code], [deprecated]) 31 32 33## ----- ## 34## C++. ## 35## ----- ## 36 37# b4_comment(TEXT, [PREFIX]) 38# -------------------------- 39# Put TEXT in comment. Prefix all the output lines with PREFIX. 40m4_define([b4_comment], 41[_b4_comment([$1], [$2// ], [$2// ])]) 42 43 44# b4_inline(hh|cc) 45# ---------------- 46# Expand to `inline\n ` if $1 is hh. 47m4_define([b4_inline], 48[m4_case([$1], 49 [cc], [], 50 [hh], [[inline 51 ]], 52 [m4_fatal([$0: invalid argument: $1])])]) 53 54 55# b4_cxx_portability 56# ------------------ 57m4_define([b4_cxx_portability], 58[#if defined __cplusplus 59# define YY_CPLUSPLUS __cplusplus 60#else 61# define YY_CPLUSPLUS 199711L 62#endif 63 64// Support move semantics when possible. 65#if 201103L <= YY_CPLUSPLUS 66# define YY_MOVE std::move 67# define YY_MOVE_OR_COPY move 68# define YY_MOVE_REF(Type) Type&& 69# define YY_RVREF(Type) Type&& 70# define YY_COPY(Type) Type 71#else 72# define YY_MOVE 73# define YY_MOVE_OR_COPY copy 74# define YY_MOVE_REF(Type) Type& 75# define YY_RVREF(Type) const Type& 76# define YY_COPY(Type) const Type& 77#endif 78 79// Support noexcept when possible. 80#if 201103L <= YY_CPLUSPLUS 81# define YY_NOEXCEPT noexcept 82# define YY_NOTHROW 83#else 84# define YY_NOEXCEPT 85# define YY_NOTHROW throw () 86#endif 87 88// Support constexpr when possible. 89#if 201703 <= YY_CPLUSPLUS 90# define YY_CONSTEXPR constexpr 91#else 92# define YY_CONSTEXPR 93#endif[]dnl 94]) 95 96 97## ---------------- ## 98## Default values. ## 99## ---------------- ## 100 101b4_percent_define_default([[api.parser.class]], [[parser]]) 102 103# Don't do that so that we remember whether we're using a user 104# request, or the default value. 105# 106# b4_percent_define_default([[api.location.type]], [[location]]) 107 108b4_percent_define_default([[api.filename.type]], [[const std::string]]) 109# Make it a warning for those who used betas of Bison 3.0. 110b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix])) 111 112b4_percent_define_default([[define_location_comparison]], 113 [m4_if(b4_percent_define_get([[filename_type]]), 114 [std::string], [[true]], [[false]])]) 115 116 117 118## ----------- ## 119## Namespace. ## 120## ----------- ## 121 122m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])]) 123 124 125# Don't permit an empty b4_namespace_ref. Any '::parser::foo' appended to it 126# would compile as an absolute reference with 'parser' in the global namespace. 127# b4_namespace_open would open an anonymous namespace and thus establish 128# internal linkage. This would compile. However, it's cryptic, and internal 129# linkage for the parser would be specified in all translation units that 130# include the header, which is always generated. If we ever need to permit 131# internal linkage somehow, surely we can find a cleaner approach. 132m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [], 133[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]), 134 [[namespace reference is empty]])]) 135 136# Instead of assuming the C++ compiler will do it, Bison should reject any 137# invalid b4_namespace_ref that would be converted to a valid 138# b4_namespace_open. The problem is that Bison doesn't always output 139# b4_namespace_ref to uncommented code but should reserve the ability to do so 140# in future releases without risking breaking any existing user grammars. 141# Specifically, don't allow empty names as b4_namespace_open would just convert 142# those into anonymous namespaces, and that might tempt some users. 143m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [], 144[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]), 145 [[namespace reference has consecutive "::"]])]) 146m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [], 147[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]), 148 [[namespace reference has a trailing "::"]])]) 149 150m4_define([b4_namespace_open], 151[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl 152[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref), 153 [^\(.\)[ ]*::], [\1])), 154 [::], [ { namespace ])[ {]])]) 155 156m4_define([b4_namespace_close], 157[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl 158m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]), 159 [^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*], 160 [\1])), 161 [::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])]) 162 163 164## ------------- ## 165## Token kinds. ## 166## ------------- ## 167 168 169# b4_token_enums 170# -------------- 171# Output the definition of the token kinds. 172m4_define([b4_token_enums], 173[[enum token_kind_type 174 { 175 ]b4_symbol([-2], [id])[ = -2, 176]b4_symbol_foreach([b4_token_enum])dnl 177[ };]dnl 178]) 179 180 181 182## -------------- ## 183## Symbol kinds. ## 184## -------------- ## 185 186# b4_declare_symbol_enum 187# ---------------------- 188# The definition of the symbol internal numbers as an enum. 189# Defining YYEMPTY here is important: it forces the compiler 190# to use a signed type, which matters for yytoken. 191m4_define([b4_declare_symbol_enum], 192[[enum symbol_kind_type 193 { 194 YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens. 195 ]b4_symbol(empty, kind_base)[ = -2, 196]b4_symbol_foreach([ b4_symbol_enum])dnl 197[ };]]) 198 199 200 201## ----------------- ## 202## Semantic Values. ## 203## ----------------- ## 204 205 206 207# b4_value_type_declare 208# --------------------- 209# Declare value_type. 210m4_define([b4_value_type_declare], 211[b4_value_type_setup[]dnl 212[ /// Symbol semantic values. 213]m4_bmatch(b4_percent_define_get_kind([[api.value.type]]), 214[code], 215[[ typedef ]b4_percent_define_get([[api.value.type]])[ value_type;]], 216[m4_bmatch(b4_percent_define_get([[api.value.type]]), 217[union\|union-directive], 218[[ union value_type 219 { 220]b4_user_union_members[ 221 };]])])dnl 222]) 223 224 225# b4_public_types_declare 226# ----------------------- 227# Define the public types: token, semantic value, location, and so forth. 228# Depending on %define token_lex, may be output in the header or source file. 229m4_define([b4_public_types_declare], 230[b4_glr2_cc_if( 231[b4_value_type_declare], 232[[#ifdef ]b4_api_PREFIX[STYPE 233# ifdef __GNUC__ 234# pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %define api.value.type" 235# endif 236 typedef ]b4_api_PREFIX[STYPE value_type; 237#else 238]b4_value_type_declare[ 239#endif 240 /// Backward compatibility (Bison 3.8). 241 typedef value_type semantic_type; 242]])[]b4_locations_if([ 243 /// Symbol locations. 244 typedef b4_percent_define_get([[api.location.type]], 245 [[location]]) location_type;])[ 246 247 /// Syntax errors thrown from user actions. 248 struct syntax_error : std::runtime_error 249 { 250 syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m) 251 : std::runtime_error (m)]b4_locations_if([ 252 , location (l)])[ 253 {} 254 255 syntax_error (const syntax_error& s) 256 : std::runtime_error (s.what ())]b4_locations_if([ 257 , location (s.location)])[ 258 {} 259 260 ~syntax_error () YY_NOEXCEPT YY_NOTHROW;]b4_locations_if([ 261 262 location_type location;])[ 263 }; 264 265 /// Token kinds. 266 struct token 267 { 268 ]b4_token_enums[]b4_glr2_cc_if([], [[ 269 /// Backward compatibility alias (Bison 3.6). 270 typedef token_kind_type yytokentype;]])[ 271 }; 272 273 /// Token kind, as returned by yylex. 274 typedef token::token_kind_type token_kind_type;]b4_glr2_cc_if([], [[ 275 276 /// Backward compatibility alias (Bison 3.6). 277 typedef token_kind_type token_type;]])[ 278 279 /// Symbol kinds. 280 struct symbol_kind 281 { 282 ]b4_declare_symbol_enum[ 283 }; 284 285 /// (Internal) symbol kind. 286 typedef symbol_kind::symbol_kind_type symbol_kind_type; 287 288 /// The number of tokens. 289 static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS; 290]]) 291 292 293# b4_symbol_type_define 294# --------------------- 295# Define symbol_type, the external type for symbols used for symbol 296# constructors. 297m4_define([b4_symbol_type_define], 298[[ /// A complete symbol. 299 /// 300 /// Expects its Base type to provide access to the symbol kind 301 /// via kind (). 302 /// 303 /// Provide access to semantic value]b4_locations_if([ and location])[. 304 template <typename Base> 305 struct basic_symbol : Base 306 { 307 /// Alias to Base. 308 typedef Base super_type; 309 310 /// Default constructor. 311 basic_symbol () YY_NOEXCEPT 312 : value ()]b4_locations_if([ 313 , location ()])[ 314 {} 315 316#if 201103L <= YY_CPLUSPLUS 317 /// Move constructor. 318 basic_symbol (basic_symbol&& that) 319 : Base (std::move (that)) 320 , value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([ 321 , location (std::move (that.location))])[ 322 {]b4_variant_if([ 323 b4_symbol_variant([this->kind ()], [value], [move], 324 [std::move (that.value)]) 325 ])[} 326#endif 327 328 /// Copy constructor. 329 basic_symbol (const basic_symbol& that);]b4_variant_if([[ 330 331 /// Constructors for typed symbols. 332]b4_type_foreach([b4_basic_symbol_constructor_define], [ 333])], [[ 334 /// Constructor for valueless symbols. 335 basic_symbol (typename Base::kind_type t]b4_locations_if([, 336 YY_MOVE_REF (location_type) l])[); 337 338 /// Constructor for symbols with semantic value. 339 basic_symbol (typename Base::kind_type t, 340 YY_RVREF (value_type) v]b4_locations_if([, 341 YY_RVREF (location_type) l])[); 342]])[ 343 /// Destroy the symbol. 344 ~basic_symbol () 345 { 346 clear (); 347 } 348 349]b4_glr2_cc_if([[ 350 /// Copy assignment. 351 basic_symbol& operator= (const basic_symbol& that) 352 { 353 Base::operator= (that);]b4_variant_if([[ 354 ]b4_symbol_variant([this->kind ()], [value], [copy], 355 [that.value])], [[ 356 value = that.value]])[;]b4_locations_if([[ 357 location = that.location;]])[ 358 return *this; 359 } 360 361 /// Move assignment. 362 basic_symbol& operator= (basic_symbol&& that) 363 { 364 Base::operator= (std::move (that));]b4_variant_if([[ 365 ]b4_symbol_variant([this->kind ()], [value], [move], 366 [std::move (that.value)])], [[ 367 value = std::move (that.value)]])[;]b4_locations_if([[ 368 location = std::move (that.location);]])[ 369 return *this; 370 } 371]])[ 372 373 /// Destroy contents, and record that is empty. 374 void clear () YY_NOEXCEPT 375 {]b4_variant_if([[ 376 // User destructor. 377 symbol_kind_type yykind = this->kind (); 378 basic_symbol<Base>& yysym = *this; 379 (void) yysym; 380 switch (yykind) 381 { 382]b4_symbol_foreach([b4_symbol_destructor])dnl 383[ default: 384 break; 385 } 386 387 // Value type destructor. 388]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[ 389 Base::clear (); 390 } 391 392]b4_parse_error_bmatch( 393[custom\|detailed], 394[[ /// The user-facing name of this symbol. 395 const char *name () const YY_NOEXCEPT 396 { 397 return ]b4_parser_class[::symbol_name (this->kind ()); 398 }]], 399[simple], 400[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ 401 /// The user-facing name of this symbol. 402 const char *name () const YY_NOEXCEPT 403 { 404 return ]b4_parser_class[::symbol_name (this->kind ()); 405 } 406#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ 407]], 408[verbose], 409[[ /// The user-facing name of this symbol. 410 std::string name () const YY_NOEXCEPT 411 { 412 return ]b4_parser_class[::symbol_name (this->kind ()); 413 }]])[]b4_glr2_cc_if([], [[ 414 415 /// Backward compatibility (Bison 3.6). 416 symbol_kind_type type_get () const YY_NOEXCEPT;]])[ 417 418 /// Whether empty. 419 bool empty () const YY_NOEXCEPT; 420 421 /// Destructive move, \a s is emptied into this. 422 void move (basic_symbol& s); 423 424 /// The semantic value. 425 value_type value;]b4_locations_if([ 426 427 /// The location. 428 location_type location;])[ 429 430 private: 431#if YY_CPLUSPLUS < 201103L 432 /// Assignment operator. 433 basic_symbol& operator= (const basic_symbol& that); 434#endif 435 }; 436 437 /// Type access provider for token (enum) based symbols. 438 struct by_kind 439 { 440 /// The symbol kind as needed by the constructor. 441 typedef token_kind_type kind_type; 442 443 /// Default constructor. 444 by_kind () YY_NOEXCEPT; 445 446#if 201103L <= YY_CPLUSPLUS 447 /// Move constructor. 448 by_kind (by_kind&& that) YY_NOEXCEPT; 449#endif 450 451 /// Copy constructor. 452 by_kind (const by_kind& that) YY_NOEXCEPT; 453 454 /// Constructor from (external) token numbers. 455 by_kind (kind_type t) YY_NOEXCEPT; 456 457]b4_glr2_cc_if([[ 458 /// Copy assignment. 459 by_kind& operator= (const by_kind& that); 460 461 /// Move assignment. 462 by_kind& operator= (by_kind&& that); 463]])[ 464 465 /// Record that this symbol is empty. 466 void clear () YY_NOEXCEPT; 467 468 /// Steal the symbol kind from \a that. 469 void move (by_kind& that); 470 471 /// The (internal) type number (corresponding to \a type). 472 /// \a empty when empty. 473 symbol_kind_type kind () const YY_NOEXCEPT;]b4_glr2_cc_if([], [[ 474 475 /// Backward compatibility (Bison 3.6). 476 symbol_kind_type type_get () const YY_NOEXCEPT;]])[ 477 478 /// The symbol kind. 479 /// \a ]b4_symbol_prefix[YYEMPTY when empty. 480 symbol_kind_type kind_; 481 };]b4_glr2_cc_if([], [[ 482 483 /// Backward compatibility for a private implementation detail (Bison 3.6). 484 typedef by_kind by_type;]])[ 485 486 /// "External" symbols: returned by the scanner. 487 struct symbol_type : basic_symbol<by_kind> 488 {]b4_variant_if([[ 489 /// Superclass. 490 typedef basic_symbol<by_kind> super_type; 491 492 /// Empty symbol. 493 symbol_type () YY_NOEXCEPT {} 494 495 /// Constructor for valueless symbols, and symbols from each type. 496]b4_type_foreach([_b4_symbol_constructor_define])dnl 497 ])[}; 498]]) 499 500 501# b4_public_types_define(hh|cc) 502# ----------------------------- 503# Provide the implementation needed by the public types. 504m4_define([b4_public_types_define], 505[[ // basic_symbol. 506 template <typename Base> 507 ]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that) 508 : Base (that) 509 , value (]b4_variant_if([], [that.value]))b4_locations_if([ 510 , location (that.location)])[ 511 {]b4_variant_if([ 512 b4_symbol_variant([this->kind ()], [value], [copy], 513 [YY_MOVE (that.value)]) 514 ])[} 515 516]b4_variant_if([], [[ 517 /// Constructor for valueless symbols. 518 template <typename Base> 519 ]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join( 520 [typename Base::kind_type t], 521 b4_locations_if([YY_MOVE_REF (location_type) l]))[) 522 : Base (t) 523 , value ()]b4_locations_if([ 524 , location (l)])[ 525 {} 526 527 template <typename Base> 528 ]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join( 529 [typename Base::kind_type t], 530 [YY_RVREF (value_type) v], 531 b4_locations_if([YY_RVREF (location_type) l]))[) 532 : Base (t) 533 , value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([ 534 , location (YY_MOVE (l))])[ 535 {]b4_variant_if([[ 536 (void) v; 537 ]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[ 538 539]b4_glr2_cc_if([], [[ 540 template <typename Base> 541 ]b4_parser_class[::symbol_kind_type 542 ]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT 543 { 544 return this->kind (); 545 } 546]])[ 547 548 template <typename Base> 549 bool 550 ]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT 551 { 552 return this->kind () == ]b4_symbol(empty, kind)[; 553 } 554 555 template <typename Base> 556 void 557 ]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s) 558 { 559 super_type::move (s); 560 ]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move], 561 [YY_MOVE (s.value)])], 562 [value = YY_MOVE (s.value);])[]b4_locations_if([ 563 location = YY_MOVE (s.location);])[ 564 } 565 566 // by_kind. 567 ]b4_inline([$1])b4_parser_class[::by_kind::by_kind () YY_NOEXCEPT 568 : kind_ (]b4_symbol(empty, kind)[) 569 {} 570 571#if 201103L <= YY_CPLUSPLUS 572 ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT 573 : kind_ (that.kind_) 574 { 575 that.clear (); 576 } 577#endif 578 579 ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT 580 : kind_ (that.kind_) 581 {} 582 583 ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT 584 : kind_ (yytranslate_ (t)) 585 {} 586 587]b4_glr2_cc_if([[ 588 ]b4_inline([$1])]b4_parser_class[::by_kind& 589 b4_parser_class[::by_kind::by_kind::operator= (const by_kind& that) 590 { 591 kind_ = that.kind_; 592 return *this; 593 } 594 595 ]b4_inline([$1])]b4_parser_class[::by_kind& 596 b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that) 597 { 598 kind_ = that.kind_; 599 that.clear (); 600 return *this; 601 } 602]])[ 603 604 ]b4_inline([$1])[void 605 ]b4_parser_class[::by_kind::clear () YY_NOEXCEPT 606 { 607 kind_ = ]b4_symbol(empty, kind)[; 608 } 609 610 ]b4_inline([$1])[void 611 ]b4_parser_class[::by_kind::move (by_kind& that) 612 { 613 kind_ = that.kind_; 614 that.clear (); 615 } 616 617 ]b4_inline([$1])[]b4_parser_class[::symbol_kind_type 618 ]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT 619 { 620 return kind_; 621 } 622 623]b4_glr2_cc_if([], [[ 624 ]b4_inline([$1])[]b4_parser_class[::symbol_kind_type 625 ]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT 626 { 627 return this->kind (); 628 } 629]])[ 630]]) 631 632 633# b4_token_constructor_define 634# ---------------------------- 635# Define make_FOO for all the token kinds. 636# Use at class-level. Redefined in variant.hh. 637m4_define([b4_token_constructor_define], []) 638 639 640# b4_yytranslate_define(cc|hh) 641# ---------------------------- 642# Define yytranslate_. Sometimes used in the header file ($1=hh), 643# sometimes in the cc file. 644m4_define([b4_yytranslate_define], 645[ b4_inline([$1])b4_parser_class[::symbol_kind_type 646 ]b4_parser_class[::yytranslate_ (int t) YY_NOEXCEPT 647 { 648]b4_api_token_raw_if( 649[[ return static_cast<symbol_kind_type> (t);]], 650[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to 651 // TOKEN-NUM as returned by yylex. 652 static 653 const ]b4_int_type_for([b4_translate])[ 654 translate_table[] = 655 { 656 ]b4_translate[ 657 }; 658 // Last valid token kind. 659 const int code_max = ]b4_code_max[; 660 661 if (t <= 0) 662 return symbol_kind::]b4_symbol_prefix[YYEOF; 663 else if (t <= code_max) 664 return static_cast <symbol_kind_type> (translate_table[t]); 665 else 666 return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[ 667 } 668]]) 669 670 671# b4_lhs_value([TYPE]) 672# -------------------- 673m4_define([b4_lhs_value], 674[b4_symbol_value([yyval], [$1])]) 675 676 677# b4_rhs_value(RULE-LENGTH, POS, [TYPE]) 678# -------------------------------------- 679# FIXME: Dead code. 680m4_define([b4_rhs_value], 681[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])]) 682 683 684# b4_lhs_location() 685# ----------------- 686# Expansion of @$. 687m4_define([b4_lhs_location], 688[(yyloc)]) 689 690 691# b4_rhs_location(RULE-LENGTH, POS) 692# --------------------------------- 693# Expansion of @POS, where the current rule has RULE-LENGTH symbols 694# on RHS. 695m4_define([b4_rhs_location], 696[(yylocation_stack_@{($1) - ($2)@})]) 697 698 699# b4_parse_param_decl 700# ------------------- 701# Extra formal arguments of the constructor. 702# Change the parameter names from "foo" into "foo_yyarg", so that 703# there is no collision bw the user chosen attribute name, and the 704# argument name in the constructor. 705m4_define([b4_parse_param_decl], 706[m4_ifset([b4_parse_param], 707 [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])]) 708 709m4_define([b4_parse_param_decl_1], 710[$1_yyarg]) 711 712 713 714# b4_parse_param_cons 715# ------------------- 716# Extra initialisations of the constructor. 717m4_define([b4_parse_param_cons], 718 [m4_ifset([b4_parse_param], 719 [ 720 b4_cc_constructor_calls(b4_parse_param)])]) 721m4_define([b4_cc_constructor_calls], 722 [m4_map_sep([b4_cc_constructor_call], [, 723 ], [$@])]) 724m4_define([b4_cc_constructor_call], 725 [$2 ($2_yyarg)]) 726 727# b4_parse_param_vars 728# ------------------- 729# Extra instance variables. 730m4_define([b4_parse_param_vars], 731 [m4_ifset([b4_parse_param], 732 [ 733 // User arguments. 734b4_cc_var_decls(b4_parse_param)])]) 735m4_define([b4_cc_var_decls], 736 [m4_map_sep([b4_cc_var_decl], [ 737], [$@])]) 738m4_define([b4_cc_var_decl], 739 [ $1;]) 740 741 742## ---------## 743## Values. ## 744## ---------## 745 746# b4_yylloc_default_define 747# ------------------------ 748# Define YYLLOC_DEFAULT. 749m4_define([b4_yylloc_default_define], 750[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. 751 If N is 0, then set CURRENT to the empty location which ends 752 the previous symbol: RHS[0] (always defined). */ 753 754# ifndef YYLLOC_DEFAULT 755# define YYLLOC_DEFAULT(Current, Rhs, N) \ 756 do \ 757 if (N) \ 758 { \ 759 (Current).begin = YYRHSLOC (Rhs, 1).begin; \ 760 (Current).end = YYRHSLOC (Rhs, N).end; \ 761 } \ 762 else \ 763 { \ 764 (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ 765 } \ 766 while (false) 767# endif 768]]) 769 770## -------- ## 771## Checks. ## 772## -------- ## 773 774b4_token_ctor_if([b4_variant_if([], 775 [b4_fatal_at(b4_percent_define_get_loc(api.token.constructor), 776 [cannot use '%s' without '%s'], 777 [%define api.token.constructor], 778 [%define api.value.type variant]))])]) 779