mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 04:43:03 +00:00
Merge remote-tracking branch 'origin/maint'
* origin/maint: (43 commits) maint: post-release administrivia version 3.0.2 gnulib: update output: do not generate source files when late errors are caught output: record what generated files are source or report files output: do not generate source files when early errors are caught xml: also use "%empty" with html output style: formatting changes xml: also display %empty for empty right-hand sides reports: display %empty in the generated pointed-rules news: YYERROR vs variants style: scope reduction in lalr.cc lalr1.cc: formatting changes lalr1.cc: fix the support of YYERROR with variants tests: check $$'s destruction with variant, YYERROR, and no error recovery tests: simplify useless obfuscation skeletons: use better names when computing a "goto" maint: post-release administrivia version 3.0.1 aver: it is no longer "protected against NDEBUG" ... Conflicts: data/glr.c
This commit is contained in:
@@ -541,9 +541,13 @@ AnnotationList__compute_from_inadequacies (
|
||||
{
|
||||
InadequacyList__prependTo (conflict_node,
|
||||
&inadequacy_lists[s->number]);
|
||||
aver (AnnotationList__insertInto (
|
||||
annotation_node, &annotation_lists[s->number],
|
||||
s->nitems));
|
||||
{
|
||||
bool b =
|
||||
AnnotationList__insertInto (annotation_node,
|
||||
&annotation_lists[s->number],
|
||||
s->nitems);
|
||||
aver (b);
|
||||
}
|
||||
/* This aver makes sure the
|
||||
AnnotationList__computeDominantContribution check above
|
||||
does discard annotations in the simplest case of a S/R
|
||||
|
||||
102
src/complain.c
102
src/complain.c
@@ -35,14 +35,25 @@ err_status complaint_status = status_none;
|
||||
|
||||
bool warnings_are_errors = false;
|
||||
|
||||
/** Whether -Werror/-Wno-error was applied to a warning. */
|
||||
typedef enum
|
||||
{
|
||||
errority_unset = 0, /** No explict status. */
|
||||
errority_disabled = 1, /** Explictly disabled with -Wno-error=foo. */
|
||||
errority_enabled = 2 /** Explictly enabled with -Werror=foo. */
|
||||
} errority;
|
||||
|
||||
/** For each warning type, its errority. */
|
||||
static errority errority_flag[warnings_size];
|
||||
|
||||
/** Diagnostics severity. */
|
||||
typedef enum
|
||||
{
|
||||
severity_disabled = 0,
|
||||
severity_unset = 1,
|
||||
severity_warning = 2,
|
||||
severity_error = 3,
|
||||
severity_fatal = 4
|
||||
severity_disabled = 0, /**< Explicitly disabled via -Wno-foo. */
|
||||
severity_unset = 1, /**< Unspecified status. */
|
||||
severity_warning = 2, /**< A warning. */
|
||||
severity_error = 3, /**< An error (continue, but die soon). */
|
||||
severity_fatal = 4 /**< Fatal error (die now). */
|
||||
} severity;
|
||||
|
||||
|
||||
@@ -103,32 +114,26 @@ warning_argmatch (char const *arg, size_t no, size_t err)
|
||||
no = !no;
|
||||
}
|
||||
|
||||
if (no)
|
||||
{
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
if (value & 1 << b)
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
if (value & 1 << b)
|
||||
{
|
||||
if (err && no)
|
||||
/* -Wno-error=foo. */
|
||||
errority_flag[b] = errority_disabled;
|
||||
else if (err && !no)
|
||||
{
|
||||
if (err)
|
||||
{
|
||||
/* -Wno-error=foo: if foo enabled as an error,
|
||||
make it a warning. */
|
||||
if (warnings_flag[b] == severity_error)
|
||||
warnings_flag[b] = severity_warning;
|
||||
}
|
||||
else
|
||||
/* -Wno-foo. */
|
||||
warnings_flag[b] = severity_disabled;
|
||||
/* -Werror=foo: enables -Wfoo. */
|
||||
errority_flag[b] = errority_enabled;
|
||||
warnings_flag[b] = severity_warning;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
if (value & 1 << b)
|
||||
/* -Wfoo and -Werror=foo. */
|
||||
warnings_flag[b] = err ? severity_error : severity_warning;
|
||||
}
|
||||
else if (no)
|
||||
/* -Wno-foo. */
|
||||
warnings_flag[b] = severity_disabled;
|
||||
else
|
||||
/* -Wfoo. */
|
||||
warnings_flag[b] = severity_warning;
|
||||
}
|
||||
}
|
||||
|
||||
/** Decode a comma-separated list of arguments from -W.
|
||||
@@ -145,13 +150,13 @@ warnings_argmatch (char *args)
|
||||
if (STREQ (args, "error"))
|
||||
warnings_are_errors = true;
|
||||
else if (STREQ (args, "no-error"))
|
||||
{
|
||||
warnings_are_errors = false;
|
||||
warning_argmatch ("no-error=everything", 3, 6);
|
||||
}
|
||||
warnings_are_errors = false;
|
||||
else
|
||||
{
|
||||
/* The length of the possible 'no-' prefix: 3, or 0. */
|
||||
size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
|
||||
/* The length of the possible 'error=' (possibly after
|
||||
'no-') prefix: 6, or 0. */
|
||||
size_t err = STRPREFIX_LIT ("error=", args + no) ? 6 : 0;
|
||||
|
||||
warning_argmatch (args, no, err);
|
||||
@@ -173,27 +178,46 @@ complain_init (void)
|
||||
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
warnings_flag[b] = (1 << b & warnings_default
|
||||
? severity_warning
|
||||
: severity_unset);
|
||||
{
|
||||
warnings_flag[b] = (1 << b & warnings_default
|
||||
? severity_warning
|
||||
: severity_unset);
|
||||
errority_flag[b] = errority_unset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* A diagnostic with FLAGS is about to be issued. With what severity?
|
||||
(severity_fatal, severity_error, severity_disabled, or
|
||||
severity_warning.) */
|
||||
|
||||
static severity
|
||||
warning_severity (warnings flags)
|
||||
{
|
||||
if (flags & fatal)
|
||||
/* Diagnostics about fatal errors. */
|
||||
return severity_fatal;
|
||||
else if (flags & complaint)
|
||||
/* Diagnostics about errors. */
|
||||
return severity_error;
|
||||
else
|
||||
{
|
||||
/* Diagnostics about warnings. */
|
||||
severity res = severity_disabled;
|
||||
size_t b;
|
||||
for (b = 0; b < warnings_size; ++b)
|
||||
if (flags & 1 << b)
|
||||
res = res < warnings_flag[b] ? warnings_flag[b] : res;
|
||||
if (res == severity_warning && warnings_are_errors)
|
||||
res = severity_error;
|
||||
{
|
||||
res = res < warnings_flag[b] ? warnings_flag[b] : res;
|
||||
/* If the diagnostic is enabled, and -Werror is enabled,
|
||||
and -Wno-error=foo was not explicitly requested, this
|
||||
is an error. */
|
||||
if (res == severity_warning
|
||||
&& (errority_flag[b] == errority_enabled
|
||||
|| (warnings_are_errors
|
||||
&& errority_flag[b] != errority_disabled)))
|
||||
res = severity_error;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,14 +128,14 @@ void deprecated_directive (location const *loc,
|
||||
void duplicate_directive (char const *directive,
|
||||
location first, location second);
|
||||
|
||||
/** Warnings treated as errors shouldn't stop the execution as regular errors
|
||||
should (because due to their nature, it is safe to go on). Thus, there are
|
||||
three possible execution statuses. */
|
||||
/** Warnings treated as errors shouldn't stop the execution as regular
|
||||
errors should (because due to their nature, it is safe to go
|
||||
on). Thus, there are three possible execution statuses. */
|
||||
typedef enum
|
||||
{
|
||||
status_none,
|
||||
status_warning_as_error,
|
||||
status_complaint
|
||||
status_none, /**< No diagnostic issued so far. */
|
||||
status_warning_as_error, /**< A warning was issued (but no error). */
|
||||
status_complaint /**< An error was issued. */
|
||||
} err_status;
|
||||
|
||||
/** Whether an error was reported. */
|
||||
|
||||
50
src/files.c
50
src/files.c
@@ -51,8 +51,17 @@ char *spec_defines_file = NULL; /* for --defines. */
|
||||
char *parser_file_name;
|
||||
|
||||
/* All computed output file names. */
|
||||
static char **file_names = NULL;
|
||||
static int file_names_count = 0;
|
||||
typedef struct generated_file
|
||||
{
|
||||
/** File name. */
|
||||
char *name;
|
||||
/** Whether is a generated source file (e.g., *.c, *.java...), as
|
||||
opposed to the report file (e.g., *.output). When late errors
|
||||
are detected, generated source files are removed. */
|
||||
bool is_source;
|
||||
} generated_file;
|
||||
static generated_file *generated_files = NULL;
|
||||
static int generated_files_size = 0;
|
||||
|
||||
uniqstr grammar_file = NULL;
|
||||
uniqstr current_file = NULL;
|
||||
@@ -332,21 +341,21 @@ compute_output_file_names (void)
|
||||
{
|
||||
if (! spec_graph_file)
|
||||
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
|
||||
output_file_name_check (&spec_graph_file);
|
||||
output_file_name_check (&spec_graph_file, false);
|
||||
}
|
||||
|
||||
if (xml_flag)
|
||||
{
|
||||
if (! spec_xml_file)
|
||||
spec_xml_file = concat2 (all_but_tab_ext, ".xml");
|
||||
output_file_name_check (&spec_xml_file);
|
||||
output_file_name_check (&spec_xml_file, false);
|
||||
}
|
||||
|
||||
if (report_flag)
|
||||
{
|
||||
if (!spec_verbose_file)
|
||||
spec_verbose_file = concat2 (all_but_tab_ext, OUTPUT_EXT);
|
||||
output_file_name_check (&spec_verbose_file);
|
||||
output_file_name_check (&spec_verbose_file, false);
|
||||
}
|
||||
|
||||
free (all_but_tab_ext);
|
||||
@@ -355,7 +364,7 @@ compute_output_file_names (void)
|
||||
}
|
||||
|
||||
void
|
||||
output_file_name_check (char **file_name)
|
||||
output_file_name_check (char **file_name, bool source)
|
||||
{
|
||||
bool conflict = false;
|
||||
if (STREQ (*file_name, grammar_file))
|
||||
@@ -367,11 +376,11 @@ output_file_name_check (char **file_name)
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < file_names_count; i++)
|
||||
if (STREQ (file_names[i], *file_name))
|
||||
for (i = 0; i < generated_files_size; i++)
|
||||
if (STREQ (generated_files[i].name, *file_name))
|
||||
{
|
||||
complain (NULL, Wother, _("conflicting outputs to file %s"),
|
||||
quote (*file_name));
|
||||
quote (generated_files[i].name));
|
||||
conflict = true;
|
||||
}
|
||||
}
|
||||
@@ -382,12 +391,23 @@ output_file_name_check (char **file_name)
|
||||
}
|
||||
else
|
||||
{
|
||||
file_names = xnrealloc (file_names, ++file_names_count,
|
||||
sizeof *file_names);
|
||||
file_names[file_names_count-1] = xstrdup (*file_name);
|
||||
generated_files = xnrealloc (generated_files, ++generated_files_size,
|
||||
sizeof *generated_files);
|
||||
generated_files[generated_files_size-1].name = xstrdup (*file_name);
|
||||
generated_files[generated_files_size-1].is_source = source;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
unlink_generated_sources (void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < generated_files_size; i++)
|
||||
if (generated_files[i].is_source)
|
||||
/* Ignore errors. The file might not even exist. */
|
||||
unlink (generated_files[i].name);
|
||||
}
|
||||
|
||||
void
|
||||
output_file_names_free (void)
|
||||
{
|
||||
@@ -400,8 +420,8 @@ output_file_names_free (void)
|
||||
free (dir_prefix);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < file_names_count; i++)
|
||||
free (file_names[i]);
|
||||
for (i = 0; i < generated_files_size; i++)
|
||||
free (generated_files[i].name);
|
||||
}
|
||||
free (file_names);
|
||||
free (generated_files);
|
||||
}
|
||||
|
||||
10
src/files.h
10
src/files.h
@@ -63,7 +63,15 @@ extern char *all_but_ext;
|
||||
|
||||
void compute_output_file_names (void);
|
||||
void output_file_names_free (void);
|
||||
void output_file_name_check (char **file_name);
|
||||
|
||||
/** Record that we generate file \a file_name.
|
||||
* \param source whether this is a source file (*c, *.java...)
|
||||
* as opposed to a report (*.output, *.dot...).
|
||||
*/
|
||||
void output_file_name_check (char **file_name, bool source);
|
||||
|
||||
/** Remove all the generated source files. */
|
||||
void unlink_generated_sources (void);
|
||||
|
||||
FILE *xfopen (const char *name, char const *mode);
|
||||
void xfclose (FILE *ptr);
|
||||
|
||||
42
src/lalr.c
42
src/lalr.c
@@ -67,17 +67,13 @@ static goto_number **includes;
|
||||
static goto_list **lookback;
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
set_goto_map (void)
|
||||
{
|
||||
state_number s;
|
||||
goto_number *temp_map;
|
||||
goto_number *temp_map = xnmalloc (nvars + 1, sizeof *temp_map);
|
||||
|
||||
goto_map = xcalloc (nvars + 1, sizeof *goto_map);
|
||||
temp_map = xnmalloc (nvars + 1, sizeof *temp_map);
|
||||
|
||||
ngotos = 0;
|
||||
for (s = 0; s < nstates; ++s)
|
||||
{
|
||||
@@ -132,16 +128,13 @@ set_goto_map (void)
|
||||
goto_number
|
||||
map_goto (state_number s0, symbol_number sym)
|
||||
{
|
||||
goto_number high;
|
||||
goto_number low;
|
||||
goto_number middle;
|
||||
state_number s;
|
||||
|
||||
low = goto_map[sym - ntokens];
|
||||
high = goto_map[sym - ntokens + 1] - 1;
|
||||
goto_number low = goto_map[sym - ntokens];
|
||||
goto_number high = goto_map[sym - ntokens + 1] - 1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
goto_number middle;
|
||||
state_number s;
|
||||
aver (low <= high);
|
||||
middle = (low + high) / 2;
|
||||
s = from_state[middle];
|
||||
@@ -412,7 +405,6 @@ static void
|
||||
lookahead_tokens_print (FILE *out)
|
||||
{
|
||||
state_number i;
|
||||
int j, k;
|
||||
fprintf (out, "Lookahead tokens: BEGIN\n");
|
||||
for (i = 0; i < nstates; ++i)
|
||||
{
|
||||
@@ -421,21 +413,25 @@ lookahead_tokens_print (FILE *out)
|
||||
int n_lookahead_tokens = 0;
|
||||
|
||||
if (reds->lookahead_tokens)
|
||||
for (k = 0; k < reds->num; ++k)
|
||||
if (reds->lookahead_tokens[k])
|
||||
++n_lookahead_tokens;
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (reds->lookahead_tokens[j])
|
||||
++n_lookahead_tokens;
|
||||
}
|
||||
|
||||
fprintf (out, "State %d: %d lookahead tokens\n",
|
||||
i, n_lookahead_tokens);
|
||||
|
||||
if (reds->lookahead_tokens)
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
|
||||
{
|
||||
fprintf (out, " on %d (%s) -> rule %d\n",
|
||||
k, symbols[k]->tag,
|
||||
reds->rules[j]->number);
|
||||
};
|
||||
{
|
||||
int j, k;
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
|
||||
fprintf (out, " on %d (%s) -> rule %d\n",
|
||||
k, symbols[k]->tag,
|
||||
reds->rules[j]->number);
|
||||
}
|
||||
}
|
||||
fprintf (out, "Lookahead tokens: END\n");
|
||||
}
|
||||
|
||||
@@ -111,7 +111,9 @@ BUILT_SOURCES += \
|
||||
## yacc. ##
|
||||
## ------ ##
|
||||
|
||||
bin_SCRIPTS = $(YACC_SCRIPT)
|
||||
if ENABLE_YACC
|
||||
bin_SCRIPTS = src/yacc
|
||||
endif
|
||||
EXTRA_SCRIPTS = src/yacc
|
||||
MOSTLYCLEANFILES += src/yacc
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ location_caret (location loc, FILE *out)
|
||||
/* Read the actual line. Don't update the offset, so that we keep a pointer
|
||||
to the start of the line. */
|
||||
{
|
||||
char c = getc (caret_info.source);
|
||||
int c = getc (caret_info.source);
|
||||
if (c != EOF)
|
||||
{
|
||||
/* Quote the file, indent by a single column. */
|
||||
|
||||
@@ -299,8 +299,9 @@ muscle_location_grow (char const *key, location loc)
|
||||
|
||||
#define COMMON_DECODE(Value) \
|
||||
case '$': \
|
||||
aver (*++(Value) == ']'); \
|
||||
aver (*++(Value) == '['); \
|
||||
++(Value); aver (*(Value) == '['); \
|
||||
++(Value); aver (*(Value) == ']'); \
|
||||
++(Value); aver (*(Value) == '['); \
|
||||
obstack_sgrow (&muscle_obstack, "$"); \
|
||||
break; \
|
||||
case '@': \
|
||||
@@ -349,7 +350,7 @@ location_decode (char const *value)
|
||||
location loc;
|
||||
aver (value);
|
||||
aver (*value == '[');
|
||||
aver (*++value == '[');
|
||||
++value; aver (*value == '[');
|
||||
while (*++value)
|
||||
switch (*value)
|
||||
{
|
||||
@@ -360,16 +361,16 @@ location_decode (char const *value)
|
||||
case ']':
|
||||
{
|
||||
char *boundary_str;
|
||||
aver (*++value == ']');
|
||||
++value; aver (*value == ']');
|
||||
boundary_str = obstack_finish0 (&muscle_obstack);
|
||||
switch (*++value)
|
||||
{
|
||||
case ',':
|
||||
boundary_set_from_string (&loc.start, boundary_str);
|
||||
obstack_free (&muscle_obstack, boundary_str);
|
||||
aver (*++value == ' ');
|
||||
aver (*++value == '[');
|
||||
aver (*++value == '[');
|
||||
++value; aver (*value == ' ');
|
||||
++value; aver (*value == '[');
|
||||
++value; aver (*value == '[');
|
||||
break;
|
||||
case '\0':
|
||||
boundary_set_from_string (&loc.end, boundary_str);
|
||||
|
||||
@@ -706,6 +706,11 @@ output (void)
|
||||
/* Process the selected skeleton file. */
|
||||
output_skeleton ();
|
||||
|
||||
/* If late errors were generated, destroy the generated source
|
||||
files. */
|
||||
if (complaint_status)
|
||||
unlink_generated_sources ();
|
||||
|
||||
obstack_free (&format_obstack, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,11 +80,11 @@
|
||||
|
||||
#line 82 "src/parse-gram.c" /* yacc.c:339 */
|
||||
|
||||
# ifndef YY_NULL
|
||||
# ifndef YY_NULLPTR
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
# define YY_NULL nullptr
|
||||
# define YY_NULLPTR nullptr
|
||||
# else
|
||||
# define YY_NULL 0
|
||||
# define YY_NULLPTR 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
@@ -639,7 +639,7 @@ static const char *const yytname[] =
|
||||
"symbols.1", "generic_symlist", "generic_symlist_item", "tag",
|
||||
"symbol_def", "symbol_defs.1", "grammar", "rules_or_grammar_declaration",
|
||||
"rules", "$@4", "rhses.1", "rhs", "named_ref.opt", "variable", "value",
|
||||
"id", "id_colon", "symbol", "string_as_id", "epilogue.opt", YY_NULL
|
||||
"id", "id_colon", "symbol", "string_as_id", "epilogue.opt", YY_NULLPTR
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1569,11 +1569,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
yytype_int16 *yyesa, yytype_int16 **yyes,
|
||||
YYSIZE_T *yyes_capacity, yytype_int16 *yyssp, int yytoken)
|
||||
{
|
||||
YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
|
||||
YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
|
||||
YYSIZE_T yysize = yysize0;
|
||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||
/* Internationalized format string. */
|
||||
const char *yyformat = YY_NULL;
|
||||
const char *yyformat = YY_NULLPTR;
|
||||
/* Arguments of yyformat. */
|
||||
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
|
||||
/* Number of reported tokens (one for the "unexpected", one per
|
||||
@@ -1628,7 +1628,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
}
|
||||
yyarg[yycount++] = yytname[yyx];
|
||||
{
|
||||
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
|
||||
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
|
||||
if (! (yysize <= yysize1
|
||||
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
|
||||
return 2;
|
||||
|
||||
@@ -65,40 +65,39 @@ print_core (FILE *out, int level, state *s)
|
||||
sitems = itemset;
|
||||
snritems = nitemset;
|
||||
|
||||
if (!snritems) {
|
||||
xml_puts (out, level, "<itemset/>");
|
||||
return;
|
||||
}
|
||||
if (!snritems)
|
||||
{
|
||||
xml_puts (out, level, "<itemset/>");
|
||||
return;
|
||||
}
|
||||
|
||||
xml_puts (out, level, "<itemset>");
|
||||
|
||||
for (i = 0; i < snritems; i++)
|
||||
{
|
||||
bool printed = false;
|
||||
item_number *sp;
|
||||
item_number *sp1;
|
||||
rule_number r;
|
||||
item_number *sp1 = ritem + sitems[i];
|
||||
item_number *sp = sp1;
|
||||
rule *r;
|
||||
|
||||
sp1 = sp = ritem + sitems[i];
|
||||
|
||||
while (*sp >= 0)
|
||||
while (0 <= *sp)
|
||||
sp++;
|
||||
|
||||
r = item_number_as_rule_number (*sp);
|
||||
sp = rules[r].rhs;
|
||||
r = &rules[item_number_as_rule_number (*sp)];
|
||||
sp = r->rhs;
|
||||
|
||||
/* Display the lookahead tokens? */
|
||||
if (item_number_is_rule_number (*sp1))
|
||||
{
|
||||
reductions *reds = s->reductions;
|
||||
int red = state_reduction_find (s, &rules[r]);
|
||||
int red = state_reduction_find (s, r);
|
||||
/* Print item with lookaheads if there are. */
|
||||
if (reds->lookahead_tokens && red != -1)
|
||||
{
|
||||
xml_printf (out, level + 1,
|
||||
"<item rule-number=\"%d\" point=\"%d\">",
|
||||
rules[r].number, sp1 - sp);
|
||||
state_rule_lookahead_tokens_print_xml (s, &rules[r],
|
||||
r->number, sp1 - sp);
|
||||
state_rule_lookahead_tokens_print_xml (s, r,
|
||||
out, level + 2);
|
||||
xml_puts (out, level + 1, "</item>");
|
||||
printed = true;
|
||||
@@ -106,12 +105,10 @@ print_core (FILE *out, int level, state *s)
|
||||
}
|
||||
|
||||
if (!printed)
|
||||
{
|
||||
xml_printf (out, level + 1,
|
||||
"<item rule-number=\"%d\" point=\"%d\"/>",
|
||||
rules[r].number,
|
||||
sp1 - sp);
|
||||
}
|
||||
xml_printf (out, level + 1,
|
||||
"<item rule-number=\"%d\" point=\"%d\"/>",
|
||||
r->number,
|
||||
sp1 - sp);
|
||||
}
|
||||
xml_puts (out, level, "</itemset>");
|
||||
}
|
||||
@@ -136,10 +133,11 @@ print_transitions (state *s, FILE *out, int level)
|
||||
}
|
||||
|
||||
/* Nothing to report. */
|
||||
if (!n) {
|
||||
xml_puts (out, level, "<transitions/>");
|
||||
return;
|
||||
}
|
||||
if (!n)
|
||||
{
|
||||
xml_puts (out, level, "<transitions/>");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Report lookahead tokens and shifts. */
|
||||
xml_puts (out, level, "<transitions>");
|
||||
@@ -190,10 +188,11 @@ print_errs (FILE *out, int level, state *s)
|
||||
count = true;
|
||||
|
||||
/* Nothing to report. */
|
||||
if (!count) {
|
||||
xml_puts (out, level, "<errors/>");
|
||||
return;
|
||||
}
|
||||
if (!count)
|
||||
{
|
||||
xml_puts (out, level, "<errors/>");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Report lookahead tokens and errors. */
|
||||
xml_puts (out, level, "<errors>");
|
||||
@@ -287,10 +286,11 @@ print_reductions (FILE *out, int level, state *s)
|
||||
}
|
||||
|
||||
/* Nothing to report. */
|
||||
if (!report) {
|
||||
xml_puts (out, level, "<reductions/>");
|
||||
return;
|
||||
}
|
||||
if (!report)
|
||||
{
|
||||
xml_puts (out, level, "<reductions/>");
|
||||
return;
|
||||
}
|
||||
|
||||
xml_puts (out, level, "<reductions>");
|
||||
|
||||
|
||||
@@ -106,8 +106,11 @@ print_core (FILE *out, state *s)
|
||||
for (sp = rules[r].rhs; sp < sp1; sp++)
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
fputs (" .", out);
|
||||
for (/* Nothing */; *sp >= 0; ++sp)
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
if (0 <= *rules[r].rhs)
|
||||
for (/* Nothing */; 0 <= *sp; ++sp)
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
else
|
||||
fprintf (out, " %%empty");
|
||||
|
||||
/* Display the lookahead tokens? */
|
||||
if (report_flag & report_lookahead_tokens
|
||||
|
||||
@@ -85,8 +85,11 @@ print_core (struct obstack *oout, state *s)
|
||||
|
||||
obstack_1grow (oout, '.');
|
||||
|
||||
for (/* Nothing */; *sp >= 0; ++sp)
|
||||
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
|
||||
if (0 <= *r->rhs)
|
||||
for (/* Nothing */; *sp >= 0; ++sp)
|
||||
obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
|
||||
else
|
||||
obstack_printf (oout, " %%empty");
|
||||
|
||||
/* Experimental feature: display the lookahead tokens. */
|
||||
if (report_flag & report_lookahead_tokens
|
||||
|
||||
@@ -342,8 +342,19 @@ show_sub_message (warnings warning,
|
||||
{
|
||||
static struct obstack msg_buf;
|
||||
const char *tail = explicit_bracketing ? "" : cp + strlen (var->id);
|
||||
const char *id = var->hidden_by ? var->hidden_by->id : var->id;
|
||||
location id_loc = var->hidden_by ? var->hidden_by->loc : var->loc;
|
||||
const char *id;
|
||||
location id_loc;
|
||||
|
||||
if (var->hidden_by)
|
||||
{
|
||||
id = var->hidden_by->id;
|
||||
id_loc = var->hidden_by->loc;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = var->id;
|
||||
id_loc = var->loc;
|
||||
}
|
||||
|
||||
/* Create the explanation message. */
|
||||
obstack_init (&msg_buf);
|
||||
@@ -573,9 +584,6 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
return INVALID_REF;
|
||||
}
|
||||
}
|
||||
|
||||
/* Not reachable. */
|
||||
return INVALID_REF;
|
||||
}
|
||||
|
||||
/* Keeps track of the maximum number of semantic values to the left of
|
||||
|
||||
@@ -266,7 +266,7 @@ eqopt ([[:space:]]*=)?
|
||||
"%pure"[-_]"parser" DEPRECATED("%pure-parser");
|
||||
"%token"[-_]"table" DEPRECATED("%token-table");
|
||||
|
||||
"%"{id}|"%"{notletter}([[:graph:]])+ {
|
||||
"%"{id} {
|
||||
complain (loc, complaint, _("invalid directive: %s"), quote (yytext));
|
||||
}
|
||||
|
||||
|
||||
@@ -244,8 +244,9 @@ at_output (int argc, char *argv[], char **out_namep, int *out_linenop)
|
||||
xfclose (yyout);
|
||||
}
|
||||
*out_namep = xstrdup (argv[1]);
|
||||
output_file_name_check (out_namep);
|
||||
yyout = xfopen (*out_namep, "w");
|
||||
output_file_name_check (out_namep, true);
|
||||
/* If there were errors, do not generate the output. */
|
||||
yyout = xfopen (complaint_status ? "/dev/null" : *out_namep, "w");
|
||||
*out_linenop = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ uniqstr_vsprintf (char const *format, ...)
|
||||
void
|
||||
uniqstr_assert (char const *str)
|
||||
{
|
||||
uniqstr *s = hash_lookup (uniqstrs_table, str);
|
||||
if (!s || s != (uniqstr *)str)
|
||||
uniqstr s = hash_lookup (uniqstrs_table, str);
|
||||
if (!s || s != str)
|
||||
{
|
||||
error (0, 0,
|
||||
"not a uniqstr: %s", quotearg (str));
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef UNIQSTR_H_
|
||||
# define UNIQSTR_H_
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
/*-----------------------------------------.
|
||||
| Pointers to unique copies of C strings. |
|
||||
`-----------------------------------------*/
|
||||
@@ -33,7 +35,7 @@ uniqstr uniqstr_new (char const *str);
|
||||
strings, use UNIQSTR_CONCAT, which is a convenient wrapper around
|
||||
this function. */
|
||||
uniqstr uniqstr_vsprintf (char const *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
_GL_ATTRIBUTE_FORMAT_PRINTF (1, 2);
|
||||
|
||||
/* Two uniqstr values have the same value iff they are the same. */
|
||||
# define UNIQSTR_EQ(Ustr1, Ustr2) (!!((Ustr1) == (Ustr2)))
|
||||
|
||||
Reference in New Issue
Block a user