style: rename spec_defines_file as spec_header_file

The variable spec_defines_file denotes the name of the generated
header.  Its name is derived from --defines/%defines, whose name in
turn is derived from the fact that the header, in Yacc, contained the

Not only does the header now contain a lot more than just the token
definitions, but we no longer even generate macros, but an enum...

Let's modernize our vocabulary.

* src/files.h, src/files.c (spec_defines_file): Rename as...
(spec_header_file): this.
This commit is contained in:
Akim Demaille
2019-03-16 10:05:51 +01:00
parent 4e19ab9fcd
commit 58ae95670b
10 changed files with 28 additions and 28 deletions

View File

@@ -196,12 +196,12 @@ m4_if(b4_skeleton, ["glr.c"],
# glr.cc produces its own header. # glr.cc produces its own header.
b4_glr_cc_if([], b4_glr_cc_if([],
[b4_defines_if( [b4_defines_if(
[b4_output_begin([b4_spec_defines_file]) [b4_output_begin([b4_spec_header_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C], b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002-2015, 2018-2019])[ [2002-2015, 2018-2019])[
]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_cpp_guard_open([b4_spec_header_file])[
]b4_shared_declarations[ ]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[ ]b4_cpp_guard_close([b4_spec_header_file])[
]b4_output_end ]b4_output_end
])]) ])])
@@ -238,7 +238,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
]b4_null_define[ ]b4_null_define[
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], ]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
[b4_shared_declarations])[ [b4_shared_declarations])[
/* Enabling verbose error messages. */ /* Enabling verbose error messages. */

View File

@@ -351,15 +351,15 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
]) ])
b4_defines_if( b4_defines_if(
[b4_output_begin([b4_spec_defines_file]) [b4_output_begin([b4_spec_header_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C++], b4_copyright([Skeleton interface for Bison GLR parsers in C++],
[2002-2015, 2018-2019])[ [2002-2015, 2018-2019])[
// C++ GLR parser skeleton written by Akim Demaille. // C++ GLR parser skeleton written by Akim Demaille.
]b4_disclaimer[ ]b4_disclaimer[
]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_cpp_guard_open([b4_spec_header_file])[
]b4_shared_declarations[ ]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[ ]b4_cpp_guard_close([b4_spec_header_file])[
]b4_output_end]) ]b4_output_end])
# Let glr.c (and b4_shared_declarations) believe that the user # Let glr.c (and b4_shared_declarations) believe that the user

View File

@@ -399,20 +399,20 @@ m4_define([b4_shared_declarations],
## -------------- ## ## -------------- ##
b4_defines_if( b4_defines_if(
[b4_output_begin([b4_spec_defines_file]) [b4_output_begin([b4_spec_header_file])
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++]) b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
[ [
/** /**
** \file ]b4_spec_defines_file[ ** \file ]b4_spec_header_file[
** Define the ]b4_namespace_ref[::parser class. ** Define the ]b4_namespace_ref[::parser class.
*/ */
// C++ LALR(1) parser skeleton written by Akim Demaille. // C++ LALR(1) parser skeleton written by Akim Demaille.
]b4_disclaimer[ ]b4_disclaimer[
]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_cpp_guard_open([b4_spec_header_file])[
]b4_shared_declarations(hh)[ ]b4_shared_declarations(hh)[
]b4_cpp_guard_close([b4_spec_defines_file]) ]b4_cpp_guard_close([b4_spec_header_file])
b4_output_end b4_output_end
]) ])
@@ -428,7 +428,7 @@ m4_if(b4_prefix, [yy], [],
]b4_user_pre_prologue[ ]b4_user_pre_prologue[
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], ]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
[b4_shared_declarations([cc])])[ [b4_shared_declarations([cc])])[
]b4_user_post_prologue[ ]b4_user_post_prologue[

View File

@@ -284,14 +284,14 @@ m4_define([b4_declare_yyparse],
# Declaration that might either go into the header (if --defines) # Declaration that might either go into the header (if --defines)
# or open coded in the parser body. # or open coded in the parser body.
m4_define([b4_shared_declarations], m4_define([b4_shared_declarations],
[b4_cpp_guard_open([b4_spec_defines_file])[ [b4_cpp_guard_open([b4_spec_header_file])[
]b4_declare_yydebug[ ]b4_declare_yydebug[
]b4_percent_code_get([[requires]])[ ]b4_percent_code_get([[requires]])[
]b4_token_enums_defines[ ]b4_token_enums_defines[
]b4_declare_yylstype[ ]b4_declare_yylstype[
]b4_declare_yyparse[ ]b4_declare_yyparse[
]b4_percent_code_get([[provides]])[ ]b4_percent_code_get([[provides]])[
]b4_cpp_guard_close([b4_spec_defines_file])[]dnl ]b4_cpp_guard_close([b4_spec_header_file])[]dnl
]) ])
@@ -300,15 +300,15 @@ m4_define([b4_shared_declarations],
# Run IF-TRUE if we generate an output file and api.header.include # Run IF-TRUE if we generate an output file and api.header.include
# is defined. # is defined.
m4_define([b4_header_include_if], m4_define([b4_header_include_if],
[m4_ifval(m4_quote(b4_spec_defines_file), [m4_ifval(m4_quote(b4_spec_header_file),
[b4_percent_define_ifdef([[api.header.include]], [b4_percent_define_ifdef([[api.header.include]],
[$1], [$1],
[$2])], [$2])],
[$2])]) [$2])])
m4_if(b4_spec_defines_file, [[y.tab.h]], m4_if(b4_spec_header_file, [[y.tab.h]],
[b4_percent_define_default([[api.header.include]], [b4_percent_define_default([[api.header.include]],
[["@basename(]b4_spec_defines_file[@)"]])]) [["@basename(]b4_spec_header_file[@)"]])])
@@ -319,7 +319,7 @@ m4_if(b4_spec_defines_file, [[y.tab.h]],
b4_defines_if([[ b4_defines_if([[
]b4_output_begin([b4_spec_defines_file])[ ]b4_output_begin([b4_spec_header_file])[
]b4_copyright([Bison interface for Yacc-like parsers in C])[ ]b4_copyright([Bison interface for Yacc-like parsers in C])[
]b4_disclaimer[ ]b4_disclaimer[
]b4_shared_declarations[ ]b4_shared_declarations[

View File

@@ -51,7 +51,7 @@ location spec_name_prefix_loc = EMPTY_LOCATION_INIT;
char *spec_verbose_file = NULL; /* for --verbose. */ char *spec_verbose_file = NULL; /* for --verbose. */
char *spec_graph_file = NULL; /* for -g. */ char *spec_graph_file = NULL; /* for -g. */
char *spec_xml_file = NULL; /* for -x. */ char *spec_xml_file = NULL; /* for -x. */
char *spec_defines_file = NULL; /* for --defines. */ char *spec_header_file = NULL; /* for --defines. */
char *parser_file_name; char *parser_file_name;
/* All computed output file names. */ /* All computed output file names. */
@@ -335,8 +335,8 @@ compute_output_file_names (void)
if (defines_flag) if (defines_flag)
{ {
if (! spec_defines_file) if (! spec_header_file)
spec_defines_file = concat2 (all_but_ext, header_extension); spec_header_file = concat2 (all_but_ext, header_extension);
} }
if (graph_flag) if (graph_flag)
@@ -429,7 +429,7 @@ output_file_names_free (void)
free (spec_verbose_file); free (spec_verbose_file);
free (spec_graph_file); free (spec_graph_file);
free (spec_xml_file); free (spec_xml_file);
free (spec_defines_file); free (spec_header_file);
free (parser_file_name); free (parser_file_name);
free (dir_prefix); free (dir_prefix);
for (int i = 0; i < generated_files_size; i++) for (int i = 0; i < generated_files_size; i++)

View File

@@ -48,7 +48,7 @@ extern char *spec_graph_file;
extern char *spec_xml_file; extern char *spec_xml_file;
/* File name specified with --defines. */ /* File name specified with --defines. */
extern char *spec_defines_file; extern char *spec_header_file;
/* Directory prefix of output file names. */ /* Directory prefix of output file names. */
extern char *dir_prefix; extern char *dir_prefix;

View File

@@ -686,8 +686,8 @@ getargs (int argc, char *argv[])
defines_flag = true; defines_flag = true;
if (optarg) if (optarg)
{ {
free (spec_defines_file); free (spec_header_file);
spec_defines_file = xstrdup (AS_FILE_NAME (optarg)); spec_header_file = xstrdup (AS_FILE_NAME (optarg));
} }
break; break;

View File

@@ -679,7 +679,7 @@ prepare (void)
#define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "") #define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "")
DEFINE (dir_prefix); DEFINE (dir_prefix);
DEFINE (parser_file_name); DEFINE (parser_file_name);
DEFINE (spec_defines_file); DEFINE (spec_header_file);
DEFINE (spec_file_prefix); DEFINE (spec_file_prefix);
DEFINE (spec_graph_file); DEFINE (spec_graph_file);
DEFINE (spec_name_prefix); DEFINE (spec_name_prefix);

View File

@@ -2348,7 +2348,7 @@ yyreduce:
#line 313 "src/parse-gram.y" /* yacc.c:1652 */ #line 313 "src/parse-gram.y" /* yacc.c:1652 */
{ {
defines_flag = true; defines_flag = true;
spec_defines_file = xstrdup ((yyvsp[0].STRING)); spec_header_file = xstrdup ((yyvsp[0].STRING));
} }
#line 2354 "src/parse-gram.c" /* yacc.c:1652 */ #line 2354 "src/parse-gram.c" /* yacc.c:1652 */
break; break;

View File

@@ -313,7 +313,7 @@ prologue_declaration:
| "%defines" STRING | "%defines" STRING
{ {
defines_flag = true; defines_flag = true;
spec_defines_file = xstrdup ($2); spec_header_file = xstrdup ($2);
} }
| "%error-verbose" { handle_error_verbose (&@$, $1); } | "%error-verbose" { handle_error_verbose (&@$, $1); }
| "%expect" INT { expected_sr_conflicts = $2; } | "%expect" INT { expected_sr_conflicts = $2; }