]> git.saurik.com Git - bison.git/blobdiff - data/c.m4
formatting changes
[bison.git] / data / c.m4
index fd2203ebbe595688859f109704fd3425f565c6ca..c2f1a053fb9897c281bc2c285b1615b0ccdbffb1 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -163,7 +163,7 @@ m4_define([b4_int_type],
 
        m4_eval([0 <= $1]),                [1], [unsigned int],
 
-                                              [int])])
+                                               [int])])
 
 
 # b4_int_type_for(NAME)
@@ -184,7 +184,7 @@ m4_define([b4_table_value_equals],
 [m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
                || m4_indir([b4_]$1[_max]) < $3), [1],
        [[YYID (0)]],
-       [[((]$2[) == (]$3[))]])])
+       [(!!(($2) == ($3)))])])
 
 
 ## ---------##
@@ -256,7 +256,7 @@ m4_define([b4_token_enums],
    enum ]b4_api_prefix[tokentype {
 ]m4_map_sep([     b4_token_enum], [,
 ],
-          [$@])[
+           [$@])[
    };
 #endif
 ]])])
@@ -320,7 +320,7 @@ $1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
 m4_define([b4_c_ansi_formals],
 [m4_if([$#], [0], [void],
        [$#$1], [1], [void],
-              [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
+               [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
 
 m4_define([b4_c_ansi_formal],
 [$1])
@@ -341,9 +341,9 @@ m4_define([b4_c_knr_formal_name],
 # Output the K&R argument declarations.
 m4_define([b4_c_knr_formal_decls],
 [m4_map_sep([b4_c_knr_formal_decl],
-           [
+            [
 ],
-           [$@])])
+            [$@])])
 
 m4_define([b4_c_knr_formal_decl],
 [    $1;])
@@ -355,9 +355,18 @@ m4_define([b4_c_knr_formal_decl],
 ## ------------------------------------------------------------ ##
 
 
+# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
+# ----------------------------------------------------------------
+# Declare the function NAME ANSI C style.
+m4_define([b4_c_ansi_function_decl],
+[$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl
+])
+
+
+
 # b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
 # -----------------------------------------------------------
-# Declare the function NAME.
+# Declare the function NAME in both K&R and ANSI C.
 m4_define([b4_c_function_decl],
 [#if defined __STDC__ || defined __cplusplus
 b4_c_ansi_function_decl($@)
@@ -367,15 +376,6 @@ $2 $1 ();
 ])
 
 
-# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
-# ----------------------------------------------------------------
-# Declare the function NAME.
-m4_define([b4_c_ansi_function_decl],
-[$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl
-])
-
-
-
 
 ## --------------------- ##
 ## Calling C functions.  ##
@@ -432,9 +432,9 @@ m4_define([b4_symbol_actions],
 [b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl
       case $4: /* $3 */
 b4_syncline([$2], [$1])
-       $5;
+        $5;
 b4_syncline([@oline@], [@ofile@])
-       break;
+        break;
 b4_dollar_popdef[]dnl
 ])
 
@@ -471,7 +471,7 @@ b4_parse_param_use[]dnl
     {
 ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
       default:
-       break;
+        break;
     }
 }]dnl
 ])
@@ -491,9 +491,9 @@ m4_define_default([b4_yy_symbol_print_generate],
 /*ARGSUSED*/
 ]$1([yy_symbol_value_print],
     [static void],
-              [[FILE *yyoutput],                       [yyoutput]],
-              [[int yytype],                           [yytype]],
-              [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
+               [[FILE *yyoutput],                       [yyoutput]],
+               [[int yytype],                           [yytype]],
+               [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
 b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
 m4_ifset([b4_parse_param], [, b4_parse_param]))[
 {
@@ -514,7 +514,7 @@ b4_parse_param_use[]dnl
     {
 ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
 [      default:
-       break;
+        break;
     }
 }
 
@@ -525,9 +525,9 @@ b4_parse_param_use[]dnl
 
 ]$1([yy_symbol_print],
     [static void],
-              [[FILE *yyoutput],                       [yyoutput]],
-              [[int yytype],                           [yytype]],
-              [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
+               [[FILE *yyoutput],                       [yyoutput]],
+               [[int yytype],                           [yytype]],
+               [[YYSTYPE const * const yyvaluep],       [yyvaluep]][]dnl
 b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
 m4_ifset([b4_parse_param], [, b4_parse_param]))[
 {
@@ -602,7 +602,7 @@ m4_define([b4_YYDEBUG_define],
 #  endif
 # else /* ! defined YYDEBUG */
 #  define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[
-# endif /* ! defined ]b4_api_PREFIX[DEBUG */
+# endif /* ! defined YYDEBUG */
 #endif  /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
 ])
 
@@ -643,3 +643,46 @@ m4_define([b4_yylloc_default_define],
     while (YYID (0))
 #endif
 ]])
+
+# b4_yy_location_print_define
+# ---------------------------
+# Define YY_LOCATION_PRINT.
+m4_define([b4_yy_location_print_define],
+[b4_locations_if([[
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+   This macro was not mandated originally: define only if we know
+   we won't break user code: when these are the locations we know.  */
+
+#ifndef YY_LOCATION_PRINT
+# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
+#  define YY_LOCATION_PRINT(File, Loc)                                   \
+  do {                                                                   \
+    fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column);       \
+    if ((Loc).first_line < (Loc).last_line)                              \
+      fprintf (File, "-%d.%d", (Loc).last_line,  (Loc).last_column - 1); \
+    else if ((Loc).first_column < (Loc).last_column - 1)                 \
+      fprintf (File, "-%d", (Loc).last_column - 1);                      \
+  } while (0)
+# else
+#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif]],
+[[/* This macro is provided for backward compatibility. */
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif]])
+])
+
+# b4_yyloc_default
+# ----------------
+# Expand to a possible default value for yylloc.
+m4_define([b4_yyloc_default],
+[[
+# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
+  = { ]m4_join([, ],
+               m4_defn([b4_location_initial_line]),
+               m4_defn([b4_location_initial_column]),
+               m4_defn([b4_location_initial_line]),
+               m4_defn([b4_location_initial_column]))[ }
+# endif
+]])