Annotation of win32/tools/cygwin/usr/share/bison/c.m4, revision 1.1

1.1     ! misha       1:                                                             -*- Autoconf -*-
        !             2: 
        !             3: # C M4 Macros for Bison.
        !             4: # Copyright (C) 2002, 2004-2010 Free Software Foundation, Inc.
        !             5: 
        !             6: # This program is free software: you can redistribute it and/or modify
        !             7: # it under the terms of the GNU General Public License as published by
        !             8: # the Free Software Foundation, either version 3 of the License, or
        !             9: # (at your option) any later version.
        !            10: #
        !            11: # This program is distributed in the hope that it will be useful,
        !            12: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            13: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            14: # GNU General Public License for more details.
        !            15: #
        !            16: # You should have received a copy of the GNU General Public License
        !            17: # along with this program.  If not, see <http://www.gnu.org/licenses/>.
        !            18: 
        !            19: ## ---------------- ##
        !            20: ## Identification.  ##
        !            21: ## ---------------- ##
        !            22: 
        !            23: # b4_comment(TEXT)
        !            24: # ----------------
        !            25: m4_define([b4_comment], [/* m4_bpatsubst([$1], [
        !            26: ], [
        !            27:    ])  */])
        !            28: 
        !            29: # b4_identification
        !            30: # -----------------
        !            31: # Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or
        !            32: # b4_pull_flag if they use the values of the %define variables api.pure or
        !            33: # api.push_pull.
        !            34: m4_define([b4_identification],
        !            35: [[/* Identify Bison output.  */
        !            36: #define YYBISON 1
        !            37: 
        !            38: /* Bison version.  */
        !            39: #define YYBISON_VERSION "]b4_version["
        !            40: 
        !            41: /* Skeleton name.  */
        !            42: #define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[
        !            43: 
        !            44: /* Pure parsers.  */
        !            45: #define YYPURE ]b4_pure_flag])[]m4_ifdef([b4_push_flag], [[
        !            46: 
        !            47: /* Push parsers.  */
        !            48: #define YYPUSH ]b4_push_flag])[]m4_ifdef([b4_pull_flag], [[
        !            49: 
        !            50: /* Pull parsers.  */
        !            51: #define YYPULL ]b4_pull_flag])[
        !            52: 
        !            53: /* Using locations.  */
        !            54: #define YYLSP_NEEDED ]b4_locations_flag[
        !            55: ]])
        !            56: 
        !            57: 
        !            58: ## ---------------- ##
        !            59: ## Default values.  ##
        !            60: ## ---------------- ##
        !            61: 
        !            62: # If the %union is not named, its name is YYSTYPE.
        !            63: m4_define_default([b4_union_name], [YYSTYPE])
        !            64: 
        !            65: # If the %name-prefix is not given, it is yy.
        !            66: m4_define_default([b4_prefix], [yy])
        !            67: 
        !            68: ## ------------------------ ##
        !            69: ## Pure/impure interfaces.  ##
        !            70: ## ------------------------ ##
        !            71: 
        !            72: # b4_user_args
        !            73: # ------------
        !            74: m4_define([b4_user_args],
        !            75: [m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])])
        !            76: 
        !            77: 
        !            78: # b4_parse_param
        !            79: # --------------
        !            80: # If defined, b4_parse_param arrives double quoted, but below we prefer
        !            81: # it to be single quoted.
        !            82: m4_define([b4_parse_param],
        !            83: b4_parse_param)
        !            84: 
        !            85: 
        !            86: # b4_parse_param_for(DECL, FORMAL, BODY)
        !            87: # ---------------------------------------
        !            88: # Iterate over the user parameters, binding the declaration to DECL,
        !            89: # the formal name to FORMAL, and evaluating the BODY.
        !            90: m4_define([b4_parse_param_for],
        !            91: [m4_foreach([$1_$2], m4_defn([b4_parse_param]),
        !            92: [m4_pushdef([$1], m4_unquote(m4_car($1_$2)))dnl
        !            93: m4_pushdef([$2], m4_shift($1_$2))dnl
        !            94: $3[]dnl
        !            95: m4_popdef([$2])dnl
        !            96: m4_popdef([$1])dnl
        !            97: ])])
        !            98: 
        !            99: # b4_parse_param_use
        !           100: # ------------------
        !           101: # `YYUSE' all the parse-params.
        !           102: m4_define([b4_parse_param_use],
        !           103: [b4_parse_param_for([Decl], [Formal], [  YYUSE (Formal);
        !           104: ])dnl
        !           105: ])
        !           106: 
        !           107: 
        !           108: ## ------------ ##
        !           109: ## Data Types.  ##
        !           110: ## ------------ ##
        !           111: 
        !           112: # b4_int_type(MIN, MAX)
        !           113: # ---------------------
        !           114: # Return the smallest int type able to handle numbers ranging from
        !           115: # MIN to MAX (included).
        !           116: m4_define([b4_int_type],
        !           117: [m4_if(b4_ints_in($@,      [0],   [255]), [1], [unsigned char],
        !           118:        b4_ints_in($@,   [-128],   [127]), [1], [signed char],
        !           119: 
        !           120:        b4_ints_in($@,      [0], [65535]), [1], [unsigned short int],
        !           121:        b4_ints_in($@, [-32768], [32767]), [1], [short int],
        !           122: 
        !           123:        m4_eval([0 <= $1]),                [1], [unsigned int],
        !           124: 
        !           125:                                               [int])])
        !           126: 
        !           127: 
        !           128: # b4_int_type_for(NAME)
        !           129: # ---------------------
        !           130: # Return the smallest int type able to handle numbers ranging from
        !           131: # `NAME_min' to `NAME_max' (included).
        !           132: m4_define([b4_int_type_for],
        !           133: [b4_int_type($1_min, $1_max)])
        !           134: 
        !           135: 
        !           136: 
        !           137: ## ---------##
        !           138: ## Values.  ##
        !           139: ## ---------##
        !           140: 
        !           141: # b4_null
        !           142: ---------
        !           143: # Return a null pointer constant.  NULL infringes on the user name
        !           144: # space in C, so use 0 rather than NULL.
        !           145: m4_define([b4_null], [0])
        !           146: 
        !           147: 
        !           148: 
        !           149: 
        !           150: ## ------------------------- ##
        !           151: ## Assigning token numbers.  ##
        !           152: ## ------------------------- ##
        !           153: 
        !           154: # b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
        !           155: # -----------------------------------------
        !           156: # Output the definition of this token as #define.
        !           157: m4_define([b4_token_define],
        !           158: [#define $1 $2
        !           159: ])
        !           160: 
        !           161: 
        !           162: # b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
        !           163: # -------------------------------------------------------
        !           164: # Output the definition of the tokens (if there are) as #defines.
        !           165: m4_define([b4_token_defines],
        !           166: [m4_if([$#$1], [1], [],
        !           167: [/* Tokens.  */
        !           168: m4_map([b4_token_define], [$@])])
        !           169: ])
        !           170: 
        !           171: 
        !           172: # b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
        !           173: # ---------------------------------------
        !           174: # Output the definition of this token as an enum.
        !           175: m4_define([b4_token_enum],
        !           176: [$1 = $2])
        !           177: 
        !           178: 
        !           179: # b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
        !           180: # -----------------------------------------------------
        !           181: # Output the definition of the tokens (if there are) as enums.
        !           182: m4_define([b4_token_enums],
        !           183: [m4_if([$#$1], [1], [],
        !           184: [/* Tokens.  */
        !           185: #ifndef YYTOKENTYPE
        !           186: # define YYTOKENTYPE
        !           187:    /* Put the tokens into the symbol table, so that GDB and other debuggers
        !           188:       know about them.  */
        !           189:    enum yytokentype {
        !           190: m4_map_sep([     b4_token_enum], [,
        !           191: ],
        !           192:           [$@])
        !           193:    };
        !           194: #endif
        !           195: ])])
        !           196: 
        !           197: 
        !           198: # b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
        !           199: # -------------------------------------------------------------
        !           200: # Output the definition of the tokens (if there are any) as enums and, if POSIX
        !           201: # Yacc is enabled, as #defines.
        !           202: m4_define([b4_token_enums_defines],
        !           203: [b4_token_enums($@)b4_yacc_if([b4_token_defines($@)], [])
        !           204: ])
        !           205: 
        !           206: 
        !           207: 
        !           208: ## --------------------------------------------- ##
        !           209: ## Defining C functions in both K&R and ANSI-C.  ##
        !           210: ## --------------------------------------------- ##
        !           211: 
        !           212: 
        !           213: # b4_modern_c
        !           214: # -----------
        !           215: # A predicate useful in #if to determine whether C is ancient or modern.
        !           216: #
        !           217: # If __STDC__ is defined, the compiler is modern.  IBM xlc 7.0 when run
        !           218: # as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic
        !           219: # reasons, but it defines __C99__FUNC__ so check that as well.
        !           220: # Microsoft C normally doesn't define these macros, but it defines _MSC_VER.
        !           221: # Consider a C++ compiler to be modern if it defines __cplusplus.
        !           222: #
        !           223: m4_define([b4_c_modern],
        !           224:   [[(defined __STDC__ || defined __C99__FUNC__ \
        !           225:      || defined __cplusplus || defined _MSC_VER)]])
        !           226: 
        !           227: # b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
        !           228: # ----------------------------------------------------------
        !           229: # Declare the function NAME.
        !           230: m4_define([b4_c_function_def],
        !           231: [#if b4_c_modern
        !           232: b4_c_ansi_function_def($@)
        !           233: #else
        !           234: $2
        !           235: $1 (b4_c_knr_formal_names(m4_shift2($@)))
        !           236: b4_c_knr_formal_decls(m4_shift2($@))
        !           237: #endif[]dnl
        !           238: ])
        !           239: 
        !           240: 
        !           241: # b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
        !           242: # ---------------------------------------------------------------
        !           243: # Declare the function NAME in ANSI.
        !           244: m4_define([b4_c_ansi_function_def],
        !           245: [$2
        !           246: $1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
        !           247: ])
        !           248: 
        !           249: 
        !           250: # b4_c_ansi_formals([DECL1, NAME1], ...)
        !           251: # --------------------------------------
        !           252: # Output the arguments ANSI-C definition.
        !           253: m4_define([b4_c_ansi_formals],
        !           254: [m4_if([$#], [0], [void],
        !           255:        [$#$1], [1], [void],
        !           256:               [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
        !           257: 
        !           258: m4_define([b4_c_ansi_formal],
        !           259: [$1])
        !           260: 
        !           261: 
        !           262: # b4_c_knr_formal_names([DECL1, NAME1], ...)
        !           263: # ------------------------------------------
        !           264: # Output the argument names.
        !           265: m4_define([b4_c_knr_formal_names],
        !           266: [m4_map_sep([b4_c_knr_formal_name], [, ], [$@])])
        !           267: 
        !           268: m4_define([b4_c_knr_formal_name],
        !           269: [$2])
        !           270: 
        !           271: 
        !           272: # b4_c_knr_formal_decls([DECL1, NAME1], ...)
        !           273: # ------------------------------------------
        !           274: # Output the K&R argument declarations.
        !           275: m4_define([b4_c_knr_formal_decls],
        !           276: [m4_map_sep([b4_c_knr_formal_decl],
        !           277:            [
        !           278: ],
        !           279:            [$@])])
        !           280: 
        !           281: m4_define([b4_c_knr_formal_decl],
        !           282: [    $1;])
        !           283: 
        !           284: 
        !           285: 
        !           286: ## ------------------------------------------------------------ ##
        !           287: ## Declaring (prototyping) C functions in both K&R and ANSI-C.  ##
        !           288: ## ------------------------------------------------------------ ##
        !           289: 
        !           290: 
        !           291: # b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
        !           292: # -----------------------------------------------------------
        !           293: # Declare the function NAME.
        !           294: m4_define([b4_c_function_decl],
        !           295: [#if defined __STDC__ || defined __cplusplus
        !           296: b4_c_ansi_function_decl($@)
        !           297: #else
        !           298: $2 $1 ();
        !           299: #endif[]dnl
        !           300: ])
        !           301: 
        !           302: 
        !           303: # b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
        !           304: # ----------------------------------------------------------------
        !           305: # Declare the function NAME.
        !           306: m4_define([b4_c_ansi_function_decl],
        !           307: [$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl
        !           308: ])
        !           309: 
        !           310: 
        !           311: 
        !           312: 
        !           313: ## --------------------- ##
        !           314: ## Calling C functions.  ##
        !           315: ## --------------------- ##
        !           316: 
        !           317: 
        !           318: # b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
        !           319: # -----------------------------------------------------------
        !           320: # Call the function NAME with arguments NAME1, NAME2 etc.
        !           321: m4_define([b4_c_function_call],
        !           322: [$1 (b4_c_args(m4_shift2($@)))[]dnl
        !           323: ])
        !           324: 
        !           325: 
        !           326: # b4_c_args([DECL1, NAME1], ...)
        !           327: # ------------------------------
        !           328: # Output the arguments NAME1, NAME2...
        !           329: m4_define([b4_c_args],
        !           330: [m4_map_sep([b4_c_arg], [, ], [$@])])
        !           331: 
        !           332: m4_define([b4_c_arg],
        !           333: [$2])
        !           334: 
        !           335: 
        !           336: ## ----------- ##
        !           337: ## Synclines.  ##
        !           338: ## ----------- ##
        !           339: 
        !           340: # b4_sync_start(LINE, FILE)
        !           341: # -----------------------
        !           342: m4_define([b4_sync_start], [[#]line $1 $2])
        !           343: 
        !           344: 
        !           345: ## -------------- ##
        !           346: ## User actions.  ##
        !           347: ## -------------- ##
        !           348: 
        !           349: # b4_case(LABEL, STATEMENTS)
        !           350: # --------------------------
        !           351: m4_define([b4_case],
        !           352: [  case $1:
        !           353: $2
        !           354:     break;])
        !           355: 
        !           356: # b4_symbol_actions(FILENAME, LINENO,
        !           357: #                   SYMBOL-TAG, SYMBOL-NUM,
        !           358: #                   SYMBOL-ACTION, SYMBOL-TYPENAME)
        !           359: # -------------------------------------------------
        !           360: m4_define([b4_symbol_actions],
        !           361: [m4_pushdef([b4_dollar_dollar],
        !           362:    [m4_ifval([$6], [(yyvaluep->$6)], [(*yyvaluep)])])dnl
        !           363: m4_pushdef([b4_at_dollar], [(*yylocationp)])dnl
        !           364:       case $4: /* $3 */
        !           365: b4_syncline([$2], [$1])
        !           366:        $5;
        !           367: b4_syncline([@oline@], [@ofile@])
        !           368:        break;
        !           369: m4_popdef([b4_at_dollar])dnl
        !           370: m4_popdef([b4_dollar_dollar])dnl
        !           371: ])
        !           372: 
        !           373: 
        !           374: # b4_yydestruct_generate(FUNCTION-DECLARATOR)
        !           375: # -------------------------------------------
        !           376: # Generate the "yydestruct" function, which declaration is issued using
        !           377: # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
        !           378: # or "b4_c_function_def" for K&R.
        !           379: m4_define_default([b4_yydestruct_generate],
        !           380: [[/*-----------------------------------------------.
        !           381: | Release the memory associated to this symbol.  |
        !           382: `-----------------------------------------------*/
        !           383: 
        !           384: /*ARGSUSED*/
        !           385: ]$1([yydestruct],
        !           386:     [static void],
        !           387:     [[const char *yymsg],    [yymsg]],
        !           388:     [[int yytype],           [yytype]],
        !           389:     [[YYSTYPE *yyvaluep],    [yyvaluep]][]dnl
        !           390: b4_locations_if(            [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
        !           391: m4_ifset([b4_parse_param], [, b4_parse_param]))[
        !           392: {
        !           393:   YYUSE (yyvaluep);
        !           394: ]b4_locations_if([  YYUSE (yylocationp);
        !           395: ])dnl
        !           396: b4_parse_param_use[]dnl
        !           397: [
        !           398:   if (!yymsg)
        !           399:     yymsg = "Deleting";
        !           400:   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
        !           401: 
        !           402:   switch (yytype)
        !           403:     {
        !           404: ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
        !           405:       default:
        !           406:        break;
        !           407:     }
        !           408: }]dnl
        !           409: ])
        !           410: 
        !           411: 
        !           412: # b4_yy_symbol_print_generate(FUNCTION-DECLARATOR)
        !           413: # ------------------------------------------------
        !           414: # Generate the "yy_symbol_print" function, which declaration is issued using
        !           415: # FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
        !           416: # or "b4_c_function_def" for K&R.
        !           417: m4_define_default([b4_yy_symbol_print_generate],
        !           418: [[
        !           419: /*--------------------------------.
        !           420: | Print this symbol on YYOUTPUT.  |
        !           421: `--------------------------------*/
        !           422: 
        !           423: /*ARGSUSED*/
        !           424: ]$1([yy_symbol_value_print],
        !           425:     [static void],
        !           426:               [[FILE *yyoutput],                       [yyoutput]],
        !           427:               [[int yytype],                           [yytype]],
        !           428:               [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
        !           429: b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
        !           430: m4_ifset([b4_parse_param], [, b4_parse_param]))[
        !           431: {
        !           432:   if (!yyvaluep)
        !           433:     return;
        !           434: ]b4_locations_if([  YYUSE (yylocationp);
        !           435: ])dnl
        !           436: b4_parse_param_use[]dnl
        !           437: [# ifdef YYPRINT
        !           438:   if (yytype < YYNTOKENS)
        !           439:     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
        !           440: # else
        !           441:   YYUSE (yyoutput);
        !           442: # endif
        !           443:   switch (yytype)
        !           444:     {
        !           445: ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
        !           446: [      default:
        !           447:        break;
        !           448:     }
        !           449: }
        !           450: 
        !           451: 
        !           452: /*--------------------------------.
        !           453: | Print this symbol on YYOUTPUT.  |
        !           454: `--------------------------------*/
        !           455: 
        !           456: ]$1([yy_symbol_print],
        !           457:     [static void],
        !           458:               [[FILE *yyoutput],                       [yyoutput]],
        !           459:               [[int yytype],                           [yytype]],
        !           460:               [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
        !           461: b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
        !           462: m4_ifset([b4_parse_param], [, b4_parse_param]))[
        !           463: {
        !           464:   if (yytype < YYNTOKENS)
        !           465:     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
        !           466:   else
        !           467:     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
        !           468: 
        !           469: ]b4_locations_if([  YY_LOCATION_PRINT (yyoutput, *yylocationp);
        !           470:   YYFPRINTF (yyoutput, ": ");
        !           471: ])dnl
        !           472: [  yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl
        !           473: b4_locations_if([, yylocationp])[]b4_user_args[);
        !           474:   YYFPRINTF (yyoutput, ")");
        !           475: }]dnl
        !           476: ])

E-mail: