mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
fixits: handle %file-prefix
* src/files.h, src/files.c (spec_file_prefix_loc): New. * src/scan-gram.l (%file-prefix): Delegate diagnostics to... * src/parse-gram.y (handle_file_prefix): here. * src/complain.c (duplicate_directive): Quote the directive. * tests/input.at: Adjust.
This commit is contained in:
@@ -407,7 +407,7 @@ duplicate_directive (char const *directive,
|
||||
if (feature_flag & feature_caret)
|
||||
complain_indent (&second, Wother, &i, _("duplicate directive"));
|
||||
else
|
||||
complain_indent (&second, Wother, &i, _("duplicate directive: %s"), directive);
|
||||
complain_indent (&second, Wother, &i, _("duplicate directive: %s"), quote (directive));
|
||||
i += SUB_INDENT;
|
||||
complain_indent (&first, Wother, &i, _("previous declaration"));
|
||||
fixits_register (&second, "");
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
char const *spec_outfile = NULL; /* for -o. */
|
||||
char const *spec_file_prefix = NULL; /* for -b. */
|
||||
location spec_file_prefix_loc = EMPTY_LOCATION_INIT;
|
||||
char const *spec_name_prefix = NULL; /* for -p. */
|
||||
char *spec_verbose_file = NULL; /* for --verbose. */
|
||||
char *spec_graph_file = NULL; /* for -g. */
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef FILES_H_
|
||||
# define FILES_H_
|
||||
|
||||
# include "location.h"
|
||||
# include "uniqstr.h"
|
||||
|
||||
/* File name specified with -o for the output file, or 0 if no -o. */
|
||||
@@ -34,6 +35,7 @@ extern const char *spec_name_prefix;
|
||||
|
||||
/* File name prefix specified with -b, or 0 if no -b. */
|
||||
extern char const *spec_file_prefix;
|
||||
extern location spec_file_prefix_loc;
|
||||
|
||||
/* --verbose. */
|
||||
extern char *spec_verbose_file;
|
||||
|
||||
@@ -85,6 +85,11 @@
|
||||
/* Handle a %error-verbose directive. */
|
||||
static void handle_error_verbose (location const *loc, char const *directive);
|
||||
|
||||
/* Handle a %file-prefix directive. */
|
||||
static void handle_file_prefix (location const *loc,
|
||||
location const *dir_loc,
|
||||
char const *directive, char const *value);
|
||||
|
||||
/* Handle a %name-prefix directive. */
|
||||
static void handle_name_prefix (location const *loc,
|
||||
char const *directive, char const *value);
|
||||
@@ -204,7 +209,7 @@
|
||||
|
||||
%type <uniqstr>
|
||||
BRACKETED_ID ID ID_COLON
|
||||
PERCENT_ERROR_VERBOSE PERCENT_FLAG PERCENT_NAME_PREFIX
|
||||
PERCENT_ERROR_VERBOSE PERCENT_FILE_PREFIX PERCENT_FLAG PERCENT_NAME_PREFIX
|
||||
PERCENT_YACC
|
||||
TAG tag tag.opt variable
|
||||
%printer { fputs ($$, yyo); } <uniqstr>
|
||||
@@ -312,7 +317,7 @@ prologue_declaration:
|
||||
| "%error-verbose" { handle_error_verbose (&@$, $1); }
|
||||
| "%expect" INT { expected_sr_conflicts = $2; }
|
||||
| "%expect-rr" INT { expected_rr_conflicts = $2; }
|
||||
| "%file-prefix" STRING { spec_file_prefix = $2; }
|
||||
| "%file-prefix" STRING { handle_file_prefix (&@$, &@1, $1, $2); }
|
||||
| "%glr-parser"
|
||||
{
|
||||
nondeterministic_parser = true;
|
||||
@@ -872,6 +877,30 @@ handle_error_verbose (location const *loc, char const *directive)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
handle_file_prefix (location const *loc,
|
||||
location const *dir_loc,
|
||||
char const *directive, char const *value)
|
||||
{
|
||||
bison_directive (loc, directive);
|
||||
bool warned = false;
|
||||
|
||||
if (location_empty (spec_file_prefix_loc))
|
||||
{
|
||||
spec_file_prefix_loc = *loc;
|
||||
spec_file_prefix = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
duplicate_directive (directive, spec_file_prefix_loc, *loc);
|
||||
warned = true;
|
||||
}
|
||||
|
||||
if (!warned
|
||||
&& STRNEQ (directive, "%file-prefix"))
|
||||
deprecated_directive (dir_loc, directive, "%file-prefix");
|
||||
}
|
||||
|
||||
static void
|
||||
handle_name_prefix (location const *loc,
|
||||
char const *directive, char const *value)
|
||||
|
||||
@@ -228,7 +228,7 @@ eqopt ({sp}=)?
|
||||
"%empty" return BISON_DIRECTIVE (EMPTY);
|
||||
"%expect" return BISON_DIRECTIVE (EXPECT);
|
||||
"%expect-rr" return BISON_DIRECTIVE (EXPECT_RR);
|
||||
"%file-prefix" return BISON_DIRECTIVE (FILE_PREFIX);
|
||||
"%file-prefix" RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext));
|
||||
"%fixed-output-files" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext));
|
||||
"%initial-action" return BISON_DIRECTIVE (INITIAL_ACTION);
|
||||
"%glr-parser" return BISON_DIRECTIVE (GLR_PARSER);
|
||||
@@ -273,7 +273,7 @@ eqopt ({sp}=)?
|
||||
"%default"[-_]"prec" DEPRECATED ("%default-prec");
|
||||
"%error"[-_]"verbose" RETURN_VALUE (PERCENT_ERROR_VERBOSE, uniqstr_new (yytext));
|
||||
"%expect"[-_]"rr" DEPRECATED ("%expect-rr");
|
||||
"%file-prefix"{eqopt} DEPRECATED ("%file-prefix");
|
||||
"%file-prefix"{eqopt} RETURN_VALUE (PERCENT_FILE_PREFIX, uniqstr_new (yytext));
|
||||
"%fixed"[-_]"output"[-_]"files" RETURN_VALUE (PERCENT_YACC, uniqstr_new (yytext));
|
||||
"%no"[-_]"default"[-_]"prec" DEPRECATED ("%no-default-prec");
|
||||
"%no"[-_]"lines" DEPRECATED ("%no-lines");
|
||||
|
||||
Reference in New Issue
Block a user