mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
style: c: fix a few minor issues about indentation of cpp directives
* README-hacking.md: More about cpp. * data/skeletons/c.m4, data/skeletons/yacc.c: Style changes.
This commit is contained in:
6
NEWS
6
NEWS
@@ -17,6 +17,12 @@ GNU Bison NEWS
|
|||||||
(2013-07-25), "%error-verbose" is deprecated in favor of "%define
|
(2013-07-25), "%error-verbose" is deprecated in favor of "%define
|
||||||
parse.error verbose".
|
parse.error verbose".
|
||||||
|
|
||||||
|
** Deprecated features
|
||||||
|
|
||||||
|
The YYPRINT macro, which works only with yacc.c and only for tokens, was
|
||||||
|
obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
|
||||||
|
It is deprecated and its support will be removed eventually.
|
||||||
|
|
||||||
** New features
|
** New features
|
||||||
|
|
||||||
*** Improved syntax error messages
|
*** Improved syntax error messages
|
||||||
|
|||||||
@@ -57,6 +57,31 @@ Actually, Bison has legacy code that we should replace with gnulib modules
|
|||||||
### Skeletons
|
### Skeletons
|
||||||
We try to use the "typical" coding style for each language.
|
We try to use the "typical" coding style for each language.
|
||||||
|
|
||||||
|
#### CPP
|
||||||
|
We indent the CPP directives this way:
|
||||||
|
|
||||||
|
```
|
||||||
|
#if FOO
|
||||||
|
# if BAR
|
||||||
|
# define BAZ
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
|
Don't indent with leading spaces in the skeletons (it's ok in the grammar
|
||||||
|
files though, e.g., in `%code {...}` blocks).
|
||||||
|
|
||||||
|
On occasions, use `cppi -c` to see where we stand. We don't aim at full
|
||||||
|
correctness: depending `-d`, some bits can be in the *.c file, or the *.h
|
||||||
|
file within the double-inclusion cpp-guards. In that case, favor the case
|
||||||
|
of the *.h file, but don't waste time on this.
|
||||||
|
|
||||||
|
Don't hesitate to leave a comment on the `#endif` (e.g., `#endif /* FOO
|
||||||
|
*/`), especially for long blocks.
|
||||||
|
|
||||||
|
There is no conistency on `! defined` vs. `!defined`. The day gnulib
|
||||||
|
decides, we'll follow them.
|
||||||
|
|
||||||
#### C/C++
|
#### C/C++
|
||||||
Follow the GNU Coding Standards.
|
Follow the GNU Coding Standards.
|
||||||
|
|
||||||
|
|||||||
@@ -965,8 +965,8 @@ m4_define([b4_yy_location_print_define],
|
|||||||
This macro was not mandated originally: define only if we know
|
This macro was not mandated originally: define only if we know
|
||||||
we won't break user code: when these are the locations we know. */
|
we won't break user code: when these are the locations we know. */
|
||||||
|
|
||||||
#ifndef YY_LOCATION_PRINT
|
# ifndef YY_LOCATION_PRINT
|
||||||
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
||||||
|
|
||||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||||
|
|
||||||
@@ -996,17 +996,17 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define YY_LOCATION_PRINT(File, Loc) \
|
# define YY_LOCATION_PRINT(File, Loc) \
|
||||||
yy_location_print_ (File, &(Loc))
|
yy_location_print_ (File, &(Loc))
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
# endif
|
# endif
|
||||||
#endif]],
|
# endif /* !defined YY_LOCATION_PRINT */]],
|
||||||
[[/* This macro is provided for backward compatibility. */
|
[[/* This macro is provided for backward compatibility. */
|
||||||
#ifndef YY_LOCATION_PRINT
|
# ifndef YY_LOCATION_PRINT
|
||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
#endif]])
|
# endif]])
|
||||||
])
|
])
|
||||||
|
|
||||||
# b4_yyloc_default
|
# b4_yyloc_default
|
||||||
|
|||||||
@@ -695,14 +695,14 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
|||||||
}]])[
|
}]])[
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# ifdef YYPRINT
|
#ifdef YYPRINT
|
||||||
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
||||||
(internal) symbol number NUM (which must be that of a token). */
|
(internal) symbol number NUM (which must be that of a token). */
|
||||||
static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
|
||||||
{
|
{
|
||||||
]b4_toknum[
|
]b4_toknum[
|
||||||
};
|
};
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#define YYPACT_NINF (]b4_pact_ninf[)
|
#define YYPACT_NINF (]b4_pact_ninf[)
|
||||||
|
|
||||||
@@ -1405,10 +1405,10 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
|
|||||||
|
|
||||||
switch (yycount)
|
switch (yycount)
|
||||||
{
|
{
|
||||||
# define YYCASE_(N, S) \
|
#define YYCASE_(N, S) \
|
||||||
case N: \
|
case N: \
|
||||||
yyformat = S; \
|
yyformat = S; \
|
||||||
break
|
break
|
||||||
default: /* Avoid compiler warnings. */
|
default: /* Avoid compiler warnings. */
|
||||||
YYCASE_(0, YY_("syntax error"));
|
YYCASE_(0, YY_("syntax error"));
|
||||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||||
@@ -1416,7 +1416,7 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
|
|||||||
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
|
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
|
||||||
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
|
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
|
||||||
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
|
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
|
||||||
# undef YYCASE_
|
#undef YYCASE_
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute error message size. Don't count the "%s"s, but reserve
|
/* Compute error message size. Don't count the "%s"s, but reserve
|
||||||
@@ -1698,7 +1698,7 @@ yysetstate:
|
|||||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
|
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
|
||||||
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
|
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
|
||||||
# undef YYSTACK_RELOCATE
|
# undef YYSTACK_RELOCATE
|
||||||
if (yyss1 != yyssa)
|
if (yyss1 != yyssa)
|
||||||
YYSTACK_FREE (yyss1);
|
YYSTACK_FREE (yyss1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -689,7 +689,7 @@ yysymbol_name (yysymbol_kind_t yysymbol)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# ifdef YYPRINT
|
#ifdef YYPRINT
|
||||||
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
||||||
(internal) symbol number NUM (which must be that of a token). */
|
(internal) symbol number NUM (which must be that of a token). */
|
||||||
static const yytype_int16 yytoknum[] =
|
static const yytype_int16 yytoknum[] =
|
||||||
@@ -702,7 +702,7 @@ static const yytype_int16 yytoknum[] =
|
|||||||
305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
|
305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
|
||||||
315
|
315
|
||||||
};
|
};
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
#define YYPACT_NINF (-80)
|
#define YYPACT_NINF (-80)
|
||||||
|
|
||||||
@@ -977,8 +977,8 @@ do { \
|
|||||||
This macro was not mandated originally: define only if we know
|
This macro was not mandated originally: define only if we know
|
||||||
we won't break user code: when these are the locations we know. */
|
we won't break user code: when these are the locations we know. */
|
||||||
|
|
||||||
#ifndef YY_LOCATION_PRINT
|
# ifndef YY_LOCATION_PRINT
|
||||||
# if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
|
# if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
|
||||||
|
|
||||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||||
|
|
||||||
@@ -1008,13 +1008,13 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define YY_LOCATION_PRINT(File, Loc) \
|
# define YY_LOCATION_PRINT(File, Loc) \
|
||||||
yy_location_print_ (File, &(Loc))
|
yy_location_print_ (File, &(Loc))
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
# endif /* !defined YY_LOCATION_PRINT */
|
||||||
|
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
@@ -1906,7 +1906,7 @@ yysetstate:
|
|||||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
|
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
|
||||||
YYSTACK_RELOCATE (yyls_alloc, yyls);
|
YYSTACK_RELOCATE (yyls_alloc, yyls);
|
||||||
# undef YYSTACK_RELOCATE
|
# undef YYSTACK_RELOCATE
|
||||||
if (yyss1 != yyssa)
|
if (yyss1 != yyssa)
|
||||||
YYSTACK_FREE (yyss1);
|
YYSTACK_FREE (yyss1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user