From 48b16bbc0492820cf1fdb683b289c77f4cdadb3d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 9 Sep 2005 22:42:15 +0000 Subject: [PATCH 1/1] * doc/bison.texinfo: Correct typos in previous fix. * data/glr.c: b4_filename -> b4_file_name. * data/lalr1.cc: Likewise. Also, b4_filename_type -> b4_file_name_type. All uses changed. (class position): filename -> file_name. All uses changed. * data/yacc.c: b4_filename -> b4_file_name. * lib/bitset.h: filename -> file_name in local vars. * lib/bitset_stats.c: Likewise. * src/files.c: Likewise. * src/scan-skel.l ("@output ".*\n): Likewise. * src/files.c (file_name_split): Renamed from filename_split. * src/muscle_tab.c (muscle_init): Output b4_file_name, not b4_filename. --- ChangeLog | 11 +++++++++++ data/glr.c | 4 ++-- data/lalr1.cc | 18 +++++++++--------- data/yacc.c | 4 ++-- doc/bison.texinfo | 11 ++++++----- lib/bitset.h | 4 ++-- lib/bitset_stats.c | 16 ++++++++-------- src/files.c | 18 +++++++++--------- src/muscle_tab.c | 2 +- src/scan-skel.l | 14 +++++++------- 10 files changed, 57 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 875e6710..2acf2644 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,17 @@ (Invocation): The output of "bison hack/foo.y" goes to foo.tab.c, not to hack/foo.tab.c. (Calc++ Top Level): 2nd arg of main is not const. + * data/glr.c: b4_filename -> b4_file_name. + * data/lalr1.cc: Likewise. Also, b4_filename_type -> b4_file_name_type. + All uses changed. + (class position): filename -> file_name. All uses changed. + * data/yacc.c: b4_filename -> b4_file_name. + * lib/bitset.h: filename -> file_name in local vars. + * lib/bitset_stats.c: Likewise. + * src/files.c: Likewise. + * src/scan-skel.l ("@output ".*\n): Likewise. + * src/files.c (file_name_split): Renamed from filename_split. + * src/muscle_tab.c (muscle_init): Output b4_file_name, not b4_filename. 2005-09-08 Paul Eggert diff --git a/data/glr.c b/data/glr.c index 342e5b16..6faa86d3 100644 --- a/data/glr.c +++ b/data/glr.c @@ -179,7 +179,7 @@ b4_pre_prologue[ #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_filename]) +[b4_syncline([b4_stype_line], [b4_file_name]) typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; /* Line __line__ of glr.c. */ b4_syncline([@oline@], [@ofile@])], @@ -2306,7 +2306,7 @@ b4_token_defines(b4_tokens) #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_filename]) +[b4_syncline([b4_stype_line], [b4_file_name]) typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; /* Line __line__ of glr.c. */ b4_syncline([@oline@], [@ofile@])], diff --git a/data/lalr1.cc b/data/lalr1.cc index a8e570cc..837f7df8 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -48,7 +48,7 @@ m4_define([b4_rhs_value], [(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))]) m4_define_default([b4_location_type], [location]) -m4_define_default([b4_filename_type], [std::string]) +m4_define_default([b4_file_name_type], [std::string]) # b4_lhs_location() # ----------------- @@ -164,7 +164,7 @@ b4_syncline([@oline@], [@ofile@])[ #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_filename]) +[b4_syncline([b4_stype_line], [b4_file_name]) union YYSTYPE b4_stype; /* Line __line__ of lalr1.cc. */ b4_syncline([@oline@], [@ofile@])], @@ -1256,7 +1256,7 @@ namespace yy public: /// Construct a position. position () : - filename (0), + file_name (0), line (initial_line), column (initial_column) { @@ -1288,7 +1288,7 @@ namespace yy public: /// File name to which this position refers. - ]b4_filename_type[* filename; + ]b4_file_name_type[* file_name; /// Current line number. unsigned int line; /// Current column number. @@ -1332,8 +1332,8 @@ namespace yy inline std::ostream& operator<< (std::ostream& ostr, const position& pos) { - if (pos.filename) - ostr << *pos.filename << ':'; + if (pos.file_name) + ostr << *pos.file_name << ':'; return ostr << pos.line << '.' << pos.column; } @@ -1435,9 +1435,9 @@ namespace yy { position last = loc.end - 1; ostr << loc.begin; - if (last.filename - && (!loc.begin.filename - || *loc.begin.filename != *last.filename)) + if (last.file_name + && (!loc.begin.file_name + || *loc.begin.file_name != *last.file_name)) ostr << '-' << last; else if (loc.begin.line != last.line) ostr << '-' << last.line << '.' << last.column; diff --git a/data/yacc.c b/data/yacc.c index 0ba3af88..4f9e7a37 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -189,7 +189,7 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[ #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_filename]) +[b4_syncline([b4_stype_line], [b4_file_name]) typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])], @@ -1414,7 +1414,7 @@ b4_token_defines(b4_tokens) #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) m4_ifdef([b4_stype], -[b4_syncline([b4_stype_line], [b4_filename]) +[b4_syncline([b4_stype_line], [b4_file_name]) typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE; /* Line __line__ of yacc.c. */ b4_syncline([@oline@], [@ofile@])], diff --git a/doc/bison.texinfo b/doc/bison.texinfo index c1b04946..8babb6f8 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -3779,10 +3779,11 @@ Declare that the @var{code} must be invoked before parsing each time For instance, if your locations use a file name, you may use @example -%parse-param @{ const char *file @}; +%parse-param @{ char const *file_name @}; %initial-action @{ - @@$.begin.file = @@$.end.file = file; + @@$.begin.file_name = @@$.end.file_name = file_name; + @@$.begin.file_name = @@$.end.file_name = file_name; @}; @end example @@ -6950,7 +6951,7 @@ Symbols}. @c - %locations @c - class Position @c - class Location -@c - %define "file_type" "const symbol::Symbol" +@c - %define "file_name_type" "const symbol::Symbol" When the directive @code{%locations} is used, the C++ parser supports location tracking, see @ref{Locations, , Locations Overview}. Two @@ -6962,7 +6963,7 @@ and a @code{location}, a range composed of a pair of The name of the file. It will always be handled as a pointer, the parser will never duplicate nor deallocate it. As an experimental feature you may change it to @samp{@var{type}*} using @samp{%define -"file_type" "@var{type}"}. +"file_name_type" "@var{type}"}. @end deftypemethod @deftypemethod {position} {unsigned int} line @@ -7322,7 +7323,7 @@ automatically propagated. %initial-action @{ // Initialize the initial location. - @@$.begin.file = @@$.end.file = &driver.file; + @@$.begin.file_name = @@$.end.file_name = &driver.file; @}; @end example diff --git a/lib/bitset.h b/lib/bitset.h index 292f7894..0b6aa6b3 100644 --- a/lib/bitset.h +++ b/lib/bitset.h @@ -371,10 +371,10 @@ extern void bitset_stats_enable (void); extern void bitset_stats_disable (void); /* Read bitset stats file of accummulated stats. */ -void bitset_stats_read (const char *filename); +void bitset_stats_read (const char *file_name); /* Write bitset stats file of accummulated stats. */ -void bitset_stats_write (const char *filename); +void bitset_stats_write (const char *file_name); /* Dump bitset stats. */ extern void bitset_stats_dump (FILE *); diff --git a/lib/bitset_stats.c b/lib/bitset_stats.c index bc771584..0b59865d 100644 --- a/lib/bitset_stats.c +++ b/lib/bitset_stats.c @@ -241,17 +241,17 @@ bitset_stats_disable (void) /* Read bitset statistics file. */ void -bitset_stats_read (const char *filename) +bitset_stats_read (const char *file_name) { FILE *file; if (!bitset_stats_info) return; - if (!filename) - filename = BITSET_STATS_FILE; + if (!file_name) + file_name = BITSET_STATS_FILE; - file = fopen (filename, "r"); + file = fopen (file_name, "r"); if (file) { if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data), @@ -271,17 +271,17 @@ bitset_stats_read (const char *filename) /* Write bitset statistics file. */ void -bitset_stats_write (const char *filename) +bitset_stats_write (const char *file_name) { FILE *file; if (!bitset_stats_info) return; - if (!filename) - filename = BITSET_STATS_FILE; + if (!file_name) + file_name = BITSET_STATS_FILE; - file = fopen (filename, "w"); + file = fopen (file_name, "w"); if (file) { if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data), diff --git a/src/files.c b/src/files.c index 1c1ccf95..f2092b27 100644 --- a/src/files.c +++ b/src/files.c @@ -165,8 +165,8 @@ compute_exts_from_src (const char *ext) } -/* Decompose FILENAME in four parts: *BASE, *TAB, and *EXT, the fourth - part, (the directory) is ranging from FILENAME to the char before +/* Decompose FILE_NAME in four parts: *BASE, *TAB, and *EXT, the fourth + part, (the directory) is ranging from FILE_NAME to the char before *BASE, so we don't need an additional parameter. *EXT points to the last period in the basename, or NULL if none. @@ -175,7 +175,7 @@ compute_exts_from_src (const char *ext) `.tab' or `_tab' if present right before *EXT, or is NULL. *TAB cannot be equal to *BASE. - None are allocated, they are simply pointers to parts of FILENAME. + None are allocated, they are simply pointers to parts of FILE_NAME. Examples: '/tmp/foo.tab.c' -> *BASE = 'foo.tab.c', *TAB = '.tab.c', *EXT = @@ -194,10 +194,10 @@ compute_exts_from_src (const char *ext) 'foo' -> *BASE = 'foo', *TAB = NULL, *EXT = NULL. */ static void -filename_split (const char *filename, - const char **base, const char **tab, const char **ext) +file_name_split (const char *file_name, + const char **base, const char **tab, const char **ext) { - *base = base_name (filename); + *base = base_name (file_name); /* Look for the extension, i.e., look for the last dot. */ *ext = strrchr (*base, '.'); @@ -232,7 +232,7 @@ compute_base_names (void) files, remove the ".c" or ".tab.c" suffix. */ if (spec_outfile) { - filename_split (spec_outfile, &base, &tab, &ext); + file_name_split (spec_outfile, &base, &tab, &ext); /* The full base name goes up the EXT, excluding it. */ full_base_name = @@ -270,7 +270,7 @@ compute_base_names (void) { /* Otherwise, the short base name is computed from the input grammar: `foo/bar.yy' => `bar'. */ - filename_split (grammar_file, &base, &tab, &ext); + file_name_split (grammar_file, &base, &tab, &ext); short_base_name = xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0))); @@ -281,7 +281,7 @@ compute_base_names (void) stpcpy (stpcpy (full_base_name, short_base_name), TAB_EXT); /* Compute the extensions from the grammar file name. */ - filename_split (grammar_file, &base, &tab, &ext); + file_name_split (grammar_file, &base, &tab, &ext); if (ext && !yacc_flag) compute_exts_from_gf (ext); } diff --git a/src/muscle_tab.c b/src/muscle_tab.c index 6e7bd9bb..3e0fb289 100644 --- a/src/muscle_tab.c +++ b/src/muscle_tab.c @@ -74,7 +74,7 @@ muscle_init (void) /* Version and input file. */ MUSCLE_INSERT_STRING ("version", VERSION); - MUSCLE_INSERT_C_STRING ("filename", grammar_file); + MUSCLE_INSERT_C_STRING ("file_name", grammar_file); } diff --git a/src/scan-skel.l b/src/scan-skel.l index c08c330a..a5b5f3f1 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -45,15 +45,15 @@ %} "@output ".*\n { - char const *filename = yytext + sizeof "@output " - 1; + char const *file_name = yytext + sizeof "@output " - 1; yytext[yyleng - 1] = '\0'; - if (*filename == '@') + if (*file_name == '@') { - if (strcmp (filename, "@output_header_name@") == 0) - filename = spec_defines_file; - else if (strcmp (filename, "@output_parser_name@") == 0) - filename = parser_file_name; + if (strcmp (file_name, "@output_header_name@") == 0) + file_name = spec_defines_file; + else if (strcmp (file_name, "@output_parser_name@") == 0) + file_name = parser_file_name; else fatal ("invalid token in skeleton: %s", yytext); } @@ -63,7 +63,7 @@ free (outname); xfclose (yyout); } - outname = xstrdup (filename); + outname = xstrdup (file_name); yyout = xfopen (outname, "w"); lineno = 1; } -- 2.45.2