Compare commits

..
Author SHA1 Message Date
Valentin Tolmer 702c92a80b warnings: sort the messages by location
Sort the warnings by location (file, line number, column). They are built
using an obstack then stored in a list, and finally sorted just before
being printed, at the end.

* src/complain.c, src/complain.h: New warning struct, obstack, and
implementation
* src/location.c, location.h (location_obstack_caret,
location_obstack_print): New
* src/main.c: Print the warnings
* src/muscle-tab.c, src/reader.c, src/scan-code.l, src/symtab.c: Adapt for
multi-part warnings
* tests/actions.at, tests/conflicts.at, tests/existing.at, tests/input.at,
* tests/reduce.at, tests/regression.at, tests/skeleton.at: Update testsuite
2013-08-29 14:06:26 +02:00
27 changed files with 1286 additions and 2025 deletions
-26
View File
@@ -2,32 +2,6 @@ GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?] * Noteworthy changes in release ?.? (????-??-??) [?]
** New syntax: partial-order precedence relationships
Formerly, the precedence order of tokens was linear, depending only on the
order in which they were declared. With the new syntax, all the tokens are
not necessarily comparable. It is possible to declare a group of tokens with
no links outside of the group, and to later on add only those needed.
The uncomparability of tokens would allow for more feedback on new conflicts
silently resolved via precedence.
An example of the new syntax applied to arithmetic and boolean operators,
with '^' serving as both numerical power and boolean XOR:
%gprec arith {
%left '+' '-'
%left '*' '/'
}
%gprec bool {
%left OR
%left AND
}
%gprec { %right '^' }
%precr '^' > arith
%precr OR AND > '^'
Here, AND is not comparable with '+', but '^' > '+' and AND > '^'
* Noteworthy changes in release 3.0 (2013-07-25) [stable] * Noteworthy changes in release 3.0 (2013-07-25) [stable]
+2 -2
View File
@@ -740,7 +740,7 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
if (reduce_precedence if (reduce_precedence
&& (reduce_precedence < shift_precedence && (reduce_precedence < shift_precedence
|| (reduce_precedence == shift_precedence || (reduce_precedence == shift_precedence
&& token->content->prec_node->assoc == right_assoc))) && token->content->assoc == right_assoc)))
continue; continue;
if (!AnnotationList__stateMakesContribution (self, nitems, ci, if (!AnnotationList__stateMakesContribution (self, nitems, ci,
lookaheads)) lookaheads))
@@ -748,7 +748,7 @@ AnnotationList__computeDominantContribution (AnnotationList const *self,
/* This uneliminated reduction contributes, so see if it can cause /* This uneliminated reduction contributes, so see if it can cause
an error action. */ an error action. */
if (reduce_precedence == shift_precedence if (reduce_precedence == shift_precedence
&& token->content->prec_node->assoc == non_assoc) && token->content->assoc == non_assoc)
{ {
/* It's not possible to find split-stable domination over /* It's not possible to find split-stable domination over
shift after a potential %nonassoc. */ shift after a potential %nonassoc. */
+173 -35
View File
@@ -46,11 +46,28 @@ typedef enum
} severity; } severity;
/** Struct to sort the warnings according to location. */
typedef struct
{
location *loc;
char *message;
} warning;
warning **warning_list;
struct obstack obstack_warning;
#define WARNING_LIST_INCREMENT 100
int warning_count = 0;
/** For each warning type, its severity. */ /** For each warning type, its severity. */
static severity warnings_flag[warnings_size]; static severity warnings_flag[warnings_size];
static unsigned *indent_ptr = 0; static unsigned *indent_ptr = 0;
static const location *complain_loc;
/*------------------------. /*------------------------.
| --warnings's handling. | | --warnings's handling. |
`------------------------*/ `------------------------*/
@@ -176,6 +193,9 @@ complain_init (void)
warnings_flag[b] = (1 << b & warnings_default warnings_flag[b] = (1 << b & warnings_default
? severity_warning ? severity_warning
: severity_unset); : severity_unset);
warning_list = xmalloc (WARNING_LIST_INCREMENT * sizeof (*warning_list));
obstack_init (&obstack_warning);
} }
static severity static severity
@@ -211,7 +231,7 @@ warning_is_unset (warnings flags)
/** Display a "[-Wyacc]" like message on \a f. */ /** Display a "[-Wyacc]" like message on \a f. */
static void static void
warnings_print_categories (warnings warn_flags, FILE *f) warnings_print_categories (warnings warn_flags, struct obstack *obs)
{ {
/* Display only the first match, the second is "-Wall". */ /* Display only the first match, the second is "-Wall". */
size_t i; size_t i;
@@ -219,13 +239,79 @@ warnings_print_categories (warnings warn_flags, FILE *f)
if (warn_flags & warnings_types[i]) if (warn_flags & warnings_types[i])
{ {
severity s = warning_severity (warnings_types[i]); severity s = warning_severity (warnings_types[i]);
fprintf (f, " [-W%s%s]", obstack_printf (obs, " [-W%s%s]",
s == severity_error ? "error=" : "", s == severity_error ? "error=" : "",
warnings_args[i]); warnings_args[i]);
return; return;
} }
} }
static void
start_error (const location *loc, warnings flags, const char *prefix,
const char *message, va_list args)
{
unsigned pos = 0;
if (loc)
pos += location_obstack_print (*loc, &obstack_warning);
else
pos += obstack_printf (&obstack_warning, "%s", current_file ? current_file
: program_name);
pos += obstack_printf (&obstack_warning, ": ");
if (indent_ptr)
{
if (*indent_ptr)
prefix = NULL;
if (!*indent_ptr)
*indent_ptr = pos;
else if (*indent_ptr > pos)
obstack_printf (&obstack_warning, "%*s", *indent_ptr - pos, "");
indent_ptr = 0;
}
if (prefix)
obstack_printf (&obstack_warning, "%s: ", prefix);
obstack_vprintf (&obstack_warning, message, args);
if (! (flags & silent))
warnings_print_categories (flags, &obstack_warning);
{
size_t l = strlen (message);
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
{
obstack_1grow (&obstack_warning, '\n');
if (loc && feature_flag & feature_caret && !(flags & no_caret))
location_obstack_caret (*loc, &obstack_warning);
}
}
if (!complain_loc)
complain_loc = loc;
}
void
finish_complaint (void)
{
if (!((warning_count + 1) % WARNING_LIST_INCREMENT))
warning_list = xnrealloc (warning_list, warning_count + 1
+ WARNING_LIST_INCREMENT, sizeof (*warning_list));
warning_list[warning_count] = xmalloc (sizeof **warning_list);
warning *w = warning_list[warning_count];
if (complain_loc)
{
w->loc = xmalloc (sizeof *w->loc);
*w->loc = *complain_loc;
}
else
w->loc = NULL;
complain_loc = NULL;
w->message = obstack_finish0 (&obstack_warning);
warning_count ++;
}
/** Report an error message. /** Report an error message.
* *
* \param loc the location, defaulting to the current file, * \param loc the location, defaulting to the current file,
@@ -243,44 +329,38 @@ void
error_message (const location *loc, warnings flags, const char *prefix, error_message (const location *loc, warnings flags, const char *prefix,
const char *message, va_list args) const char *message, va_list args)
{ {
unsigned pos = 0; start_error (loc, flags, prefix, message, args);
finish_complaint ();
}
if (loc)
pos += location_print (*loc, stderr);
else
pos += fprintf (stderr, "%s", current_file ? current_file : program_name);
pos += fprintf (stderr, ": ");
if (indent_ptr) /** Start an error message, but don't conclude it. That can be a fatal error,
an error or just a warning. */
static void
start_complains (const location *loc, warnings flags, const char *message,
va_list args)
{
severity s = warning_severity (flags);
if ((flags & complaint) && complaint_status < status_complaint)
complaint_status = status_complaint;
if (severity_warning <= s)
{ {
if (*indent_ptr) const char* prefix =
prefix = NULL; s == severity_fatal ? _("fatal error")
if (!*indent_ptr) : s == severity_error ? _("error")
*indent_ptr = pos; : _("warning");
else if (*indent_ptr > pos) if (severity_error <= s && ! complaint_status)
fprintf (stderr, "%*s", *indent_ptr - pos, ""); complaint_status = status_warning_as_error;
indent_ptr = 0; start_error (loc, flags, prefix, message, args);
} }
if (prefix) if (flags & fatal)
fprintf (stderr, "%s: ", prefix); print_warnings_and_exit (stderr, EXIT_FAILURE);
vfprintf (stderr, message, args);
if (! (flags & silent))
warnings_print_categories (flags, stderr);
{
size_t l = strlen (message);
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
{
putc ('\n', stderr);
fflush (stderr);
if (loc && feature_flag & feature_caret && !(flags & no_caret))
location_caret (*loc, stderr);
}
}
fflush (stderr);
} }
/** Raise a complaint. That can be a fatal error, an error or just a /** Raise a complaint. That can be a fatal error, an error or just a
warning. */ warning. */
@@ -304,7 +384,7 @@ complains (const location *loc, warnings flags, const char *message,
} }
if (flags & fatal) if (flags & fatal)
exit (EXIT_FAILURE); print_warnings_and_exit (stderr, EXIT_FAILURE);
} }
void void
@@ -316,6 +396,15 @@ complain (location const *loc, warnings flags, const char *message, ...)
va_end (args); va_end (args);
} }
void
start_complain (location const *loc, warnings flags, const char *message, ...)
{
va_list args;
va_start (args, message);
start_complains (loc, flags, message, args);
va_end (args);
}
void void
complain_indent (location const *loc, warnings flags, unsigned *indent, complain_indent (location const *loc, warnings flags, unsigned *indent,
const char *message, ...) const char *message, ...)
@@ -327,6 +416,17 @@ complain_indent (location const *loc, warnings flags, unsigned *indent,
va_end (args); va_end (args);
} }
void
start_complain_indent (location const *loc, warnings flags, unsigned *indent,
const char *message, ...)
{
va_list args;
indent_ptr = indent;
va_start (args, message);
start_complains (loc, flags, message, args);
va_end (args);
}
void void
complain_args (location const *loc, warnings w, unsigned *indent, complain_args (location const *loc, warnings w, unsigned *indent,
int argc, char *argv[]) int argc, char *argv[])
@@ -373,7 +473,45 @@ duplicate_directive (char const *directive,
location first, location second) location first, location second)
{ {
unsigned i = 0; unsigned i = 0;
complain (&second, complaint, _("only one %s allowed per rule"), directive); start_complain (&second, complaint, _("only one %s allowed per rule"), directive);
i += SUB_INDENT; i += SUB_INDENT;
complain_indent (&first, complaint, &i, _("previous declaration")); complain_indent (&first, complaint, &i, _("previous declaration"));
} }
/** Compare warnings, to sort them. */
static int
warning_cmp (void const *a, void const *b)
{
warning *wa = *(warning * const *)a, *wb = *(warning * const *)b;
if (wa->loc && wb->loc)
return location_cmp (*wa->loc, *wb->loc);
/* Undefined location/line number at the end. */
else if (wa->loc)
return -1;
else if (wb->loc)
return 1;
return 0;
}
void
print_warnings (FILE *f)
{
if (obstack_object_size (&obstack_warning))
finish_complaint ();
qsort (warning_list, warning_count, sizeof *warning_list, warning_cmp);
for (int i = 0; i < warning_count; ++i)
{
fprintf (f, "%s", warning_list[i]->message);
free (warning_list[i]->loc);
free (warning_list[i]);
}
free (warning_list);
obstack_free (&obstack_warning, NULL);
}
void
print_warnings_and_exit (FILE *f, int exit_status)
{
print_warnings (f);
exit (exit_status);
}
+20
View File
@@ -106,6 +106,12 @@ typedef enum
(Never enabled, never disabled). */ (Never enabled, never disabled). */
bool warning_is_unset (warnings flags); bool warning_is_unset (warnings flags);
/** Start a complaint, with maybe a location, but don't finish it until a
normal complaint or a call to finish_complaint. */
void start_complain (location const *loc, warnings flags, char const *message,
...)
__attribute__ ((__format__ (__printf__, 3, 4)));
/** Make a complaint, with maybe a location. */ /** Make a complaint, with maybe a location. */
void complain (location const *loc, warnings flags, char const *message, ...) void complain (location const *loc, warnings flags, char const *message, ...)
__attribute__ ((__format__ (__printf__, 3, 4))); __attribute__ ((__format__ (__printf__, 3, 4)));
@@ -114,11 +120,19 @@ void complain (location const *loc, warnings flags, char const *message, ...)
void complain_args (location const *loc, warnings w, unsigned *indent, void complain_args (location const *loc, warnings w, unsigned *indent,
int argc, char *arg[]); int argc, char *arg[]);
/** Start a complaint message with location and some indentation, but don't
finish it until a normal complaint or a call to finish_complaint. */
void start_complain_indent (location const *loc, warnings flags, unsigned *indent,
char const *message, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
/** Make a complaint with location and some indentation. */ /** Make a complaint with location and some indentation. */
void complain_indent (location const *loc, warnings flags, unsigned *indent, void complain_indent (location const *loc, warnings flags, unsigned *indent,
char const *message, ...) char const *message, ...)
__attribute__ ((__format__ (__printf__, 4, 5))); __attribute__ ((__format__ (__printf__, 4, 5)));
/** Finish the current complaint. */
void finish_complaint (void);
/** Report an obsolete syntax, suggest the updated one. */ /** Report an obsolete syntax, suggest the updated one. */
void deprecated_directive (location const *loc, void deprecated_directive (location const *loc,
@@ -141,4 +155,10 @@ typedef enum
/** Whether an error was reported. */ /** Whether an error was reported. */
extern err_status complaint_status; extern err_status complaint_status;
/** Sort and print warnings, and free them. */
void print_warnings (FILE *f);
/** Sort and print warnings, free them, then exit. */
void print_warnings_and_exit (FILE *f, int exit_status);
#endif /* !COMPLAIN_H_ */ #endif /* !COMPLAIN_H_ */
+56 -77
View File
@@ -53,8 +53,7 @@ enum conflict_resolution
reduce_resolution, reduce_resolution,
left_resolution, left_resolution,
right_resolution, right_resolution,
nonassoc_resolution, nonassoc_resolution
uncomparable_resolution
}; };
@@ -91,7 +90,6 @@ log_resolution (rule *r, symbol_number token,
break; break;
case nonassoc_resolution: case nonassoc_resolution:
case uncomparable_resolution:
obstack_printf (&solved_conflicts_obstack, obstack_printf (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s" _(" Conflict between rule %d and token %s"
" resolved as an error"), " resolved as an error"),
@@ -134,12 +132,6 @@ log_resolution (rule *r, symbol_number token,
" (%%nonassoc %s)", " (%%nonassoc %s)",
symbols[token]->tag); symbols[token]->tag);
break; break;
case uncomparable_resolution:
obstack_printf (&solved_conflicts_obstack,
" (%s uncomparable with %s)",
r->prec->symbol->tag,
symbols[token]->tag);
break;
} }
obstack_sgrow (&solved_conflicts_obstack, ".\n"); obstack_sgrow (&solved_conflicts_obstack, ".\n");
@@ -169,7 +161,6 @@ log_resolution (rule *r, symbol_number token,
xml_escape (symbols[token]->tag)); xml_escape (symbols[token]->tag));
break; break;
case uncomparable_resolution:
case nonassoc_resolution: case nonassoc_resolution:
obstack_printf (&solved_conflicts_xml_obstack, obstack_printf (&solved_conflicts_xml_obstack,
" <resolution rule=\"%d\" symbol=\"%s\"" " <resolution rule=\"%d\" symbol=\"%s\""
@@ -212,13 +203,7 @@ log_resolution (rule *r, symbol_number token,
obstack_printf (&solved_conflicts_xml_obstack, obstack_printf (&solved_conflicts_xml_obstack,
"%%nonassoc %s", "%%nonassoc %s",
xml_escape (symbols[token]->tag)); xml_escape (symbols[token]->tag));
break; break;
case uncomparable_resolution:
obstack_printf (&solved_conflicts_xml_obstack,
"%s uncomparable with %s",
xml_escape_n (0, symbols[token]->tag),
xml_escape_n (1, r->prec->symbol->tag));
break;
} }
obstack_sgrow (&solved_conflicts_xml_obstack, "</resolution>\n"); obstack_sgrow (&solved_conflicts_xml_obstack, "</resolution>\n");
@@ -258,6 +243,7 @@ flush_reduce (bitset lookahead_tokens, int token)
bitset_reset (lookahead_tokens, token); bitset_reset (lookahead_tokens, token);
} }
/*------------------------------------------------------------------. /*------------------------------------------------------------------.
| Attempt to resolve shift-reduce conflict for one rule by means of | | Attempt to resolve shift-reduce conflict for one rule by means of |
| precedence declarations. It has already been checked that the | | precedence declarations. It has already been checked that the |
@@ -277,73 +263,66 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
reductions *reds = s->reductions; reductions *reds = s->reductions;
/* Find the rule to reduce by to get precedence of reduction. */ /* Find the rule to reduce by to get precedence of reduction. */
rule *redrule = reds->rules[ruleno]; rule *redrule = reds->rules[ruleno];
prec_node *redprecsym = redrule->prec->prec_node; int redprec = redrule->prec->prec;
bitset lookahead_tokens = reds->lookahead_tokens[ruleno]; bitset lookahead_tokens = reds->lookahead_tokens[ruleno];
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
if (bitset_test (lookahead_tokens, i) if (bitset_test (lookahead_tokens, i)
&& bitset_test (lookahead_set, i)) && bitset_test (lookahead_set, i)
&& symbols[i]->content->prec)
{ {
if (redprecsym && symbols[i]->content->prec_node) /* Shift-reduce conflict occurs for token number i
and it has a precedence.
The precedence of shifting is that of token i. */
if (symbols[i]->content->prec < redprec)
{ {
/* Shift-reduce conflict occurs for token number i register_precedence (redrule->prec->number, i);
and it has a precedence. log_resolution (redrule, i, reduce_resolution);
The precedence of shifting is that of token i. */ flush_shift (s, i);
if (is_prec_superior (redprecsym, symbols[i]->content->prec_node)) }
{ else if (symbols[i]->content->prec > redprec)
register_precedence (redrule->prec->number, i); {
log_resolution (redrule, i, reduce_resolution); register_precedence (i, redrule->prec->number);
flush_shift (s, i); log_resolution (redrule, i, shift_resolution);
} flush_reduce (lookahead_tokens, i);
else if (is_prec_superior (symbols[i]->content->prec_node,
redprecsym))
{
register_precedence (i, redrule->prec->number);
log_resolution (redrule, i, shift_resolution);
flush_reduce (lookahead_tokens, i);
}
else if (is_prec_equal (redprecsym, symbols[i]->content->prec_node))
/* Matching precedence levels.
For non-defined associativity, keep both: unexpected
associativity conflict.
For left associativity, keep only the reduction.
For right associativity, keep only the shift.
For nonassociativity, keep neither. */
switch (symbols[i]->content->prec_node->assoc)
{
case undef_assoc:
break;
case precedence_assoc:
break;
case right_assoc:
register_assoc (i, redrule->prec->number);
log_resolution (redrule, i, right_resolution);
flush_reduce (lookahead_tokens, i);
break;
case left_assoc:
register_assoc (i, redrule->prec->number);
log_resolution (redrule, i, left_resolution);
flush_shift (s, i);
break;
case non_assoc:
register_assoc (i, redrule->prec->number);
log_resolution (redrule, i, nonassoc_resolution);
flush_shift (s, i);
flush_reduce (lookahead_tokens, i);
/* Record an explicit error for this token. */
errors[(*nerrs)++] = symbols[i];
break;
}
else
log_resolution (redrule, i, uncomparable_resolution);
} }
else else
log_resolution (redrule, i, uncomparable_resolution); /* Matching precedence levels.
For non-defined associativity, keep both: unexpected
associativity conflict.
For left associativity, keep only the reduction.
For right associativity, keep only the shift.
For nonassociativity, keep neither. */
switch (symbols[i]->content->assoc)
{
case undef_assoc:
abort ();
case precedence_assoc:
break;
case right_assoc:
register_assoc (i, redrule->prec->number);
log_resolution (redrule, i, right_resolution);
flush_reduce (lookahead_tokens, i);
break;
case left_assoc:
register_assoc (i, redrule->prec->number);
log_resolution (redrule, i, left_resolution);
flush_shift (s, i);
break;
case non_assoc:
register_assoc (i, redrule->prec->number);
log_resolution (redrule, i, nonassoc_resolution);
flush_shift (s, i);
flush_reduce (lookahead_tokens, i);
/* Record an explicit error for this token. */
errors[(*nerrs)++] = symbols[i];
break;
}
} }
} }
@@ -375,7 +354,7 @@ set_conflicts (state *s, symbol **errors)
check for shift-reduce conflict, and try to resolve using check for shift-reduce conflict, and try to resolve using
precedence. */ precedence. */
for (i = 0; i < reds->num; ++i) for (i = 0; i < reds->num; ++i)
if (reds->rules[i]->prec /* && reds->rules[i]->prec->prec */ if (reds->rules[i]->prec && reds->rules[i]->prec->prec
&& !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set)) && !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
resolve_sr_conflict (s, i, errors, &nerrs); resolve_sr_conflict (s, i, errors, &nerrs);
+2 -4
View File
@@ -44,8 +44,6 @@ int nvars = 0;
symbol_number *token_translations = NULL; symbol_number *token_translations = NULL;
enum braces_state prec_braces = 0;
int max_user_token_number = 256; int max_user_token_number = 256;
bool bool
@@ -241,7 +239,7 @@ grammar_dump (FILE *out, const char *title)
for (i = ntokens; i < nsyms; i++) for (i = ntokens; i < nsyms; i++)
fprintf (out, "%5d %5d %5d %s\n", fprintf (out, "%5d %5d %5d %s\n",
i, i,
symbols[i]->content->prec, symbols[i]->content->prec_node->assoc, symbols[i]->content->prec, symbols[i]->content->assoc,
symbols[i]->tag); symbols[i]->tag);
fprintf (out, "\n\n"); fprintf (out, "\n\n");
} }
@@ -264,7 +262,7 @@ grammar_dump (FILE *out, const char *title)
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->", fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
i, i,
rule_i->prec ? rule_i->prec->prec : 0, rule_i->prec ? rule_i->prec->prec : 0,
rule_i->prec ? rule_i->prec->prec_node->assoc : 0, rule_i->prec ? rule_i->prec->assoc : 0,
rule_i->useful, rule_i->useful,
rhs_itemno, rhs_itemno,
rhs_itemno + rhs_count - 1, rhs_itemno + rhs_count - 1,
-11
View File
@@ -117,17 +117,6 @@ typedef int item_number;
extern item_number *ritem; extern item_number *ritem;
extern unsigned int nritems; extern unsigned int nritems;
enum braces_state
{
default_braces_state,
gprec_seen,
group_name_seen,
braces_seen
};
/* Marker for the lexer and parser, to correctly interpret braces. */
extern enum braces_state prec_braces;
/* There is weird relationship between OT1H item_number and OTOH /* There is weird relationship between OT1H item_number and OTOH
symbol_number and rule_number: we store the latter in symbol_number and rule_number: we store the latter in
item_number. symbol_number values are stored as-is, while item_number. symbol_number values are stored as-is, while
+100
View File
@@ -137,6 +137,48 @@ location_print (location loc, FILE *out)
} }
unsigned
location_obstack_print (location loc, struct obstack *obs)
{
unsigned res = 0;
int end_col = 0 != loc.end.column ? loc.end.column - 1 : 0;
res += obstack_printf (obs, "%s",
quotearg_n_style (3, escape_quoting_style, loc.start.file));
if (0 <= loc.start.line)
{
res += obstack_printf (obs, ":%d", loc.start.line);
if (0 <= loc.start.column)
res += obstack_printf (obs, ".%d", loc.start.column);
}
if (loc.start.file != loc.end.file)
{
res += obstack_printf (obs, "-%s",
quotearg_n_style (3, escape_quoting_style,
loc.end.file));
if (0 <= loc.end.line)
{
res += obstack_printf (obs, ":%d", loc.end.line);
if (0 <= end_col)
res += obstack_printf (obs, ".%d", end_col);
}
}
else if (0 <= loc.end.line)
{
if (loc.start.line < loc.end.line)
{
res += obstack_printf (obs, "-%d", loc.end.line);
if (0 <= end_col)
res += obstack_printf (obs, ".%d", end_col);
}
else if (0 <= end_col && loc.start.column < end_col)
res += obstack_printf (obs, "-%d", end_col);
}
return res;
}
/* Persistant data used by location_caret to avoid reopening and rereading the /* Persistant data used by location_caret to avoid reopening and rereading the
same file all over for each error. */ same file all over for each error. */
struct caret_info struct caret_info
@@ -215,6 +257,64 @@ location_caret (location loc, FILE *out)
} }
} }
void
location_obstack_caret (location loc, struct obstack *obs)
{
/* FIXME: find a way to support multifile locations, and only open once each
file. That would make the procedure future-proof. */
if (! (caret_info.source
|| (caret_info.source = fopen (loc.start.file, "r")))
|| loc.start.column == -1 || loc.start.line == -1)
return;
/* If the line we want to quote is seekable (the same line as the previous
location), just seek it. If it was a previous line, we lost track of it,
so return to the start of file. */
if (caret_info.line <= loc.start.line)
fseek (caret_info.source, caret_info.offset, SEEK_SET);
else
{
caret_info.line = 1;
caret_info.offset = 0;
fseek (caret_info.source, caret_info.offset, SEEK_SET);
}
/* Advance to the line's position, keeping track of the offset. */
while (caret_info.line < loc.start.line)
caret_info.line += getc (caret_info.source) == '\n';
caret_info.offset = ftell (caret_info.source);
/* 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);
if (c != EOF)
{
/* Quote the file, indent by a single column. */
obstack_1grow (obs, ' ');
do
obstack_1grow (obs, c);
while ((c = getc (caret_info.source)) != EOF && c != '\n');
obstack_1grow (obs, '\n');
{
/* The caret of a multiline location ends with the first line. */
size_t len = loc.start.line != loc.end.line
? ftell (caret_info.source) - caret_info.offset
: loc.end.column;
int i;
/* Print the carets (at least one), with the same indent as above.*/
obstack_printf (obs, " %*s", loc.start.column - 1, "");
for (i = loc.start.column; i == loc.start.column || i < len; ++i)
obstack_1grow (obs, '^');
}
obstack_1grow (obs, '\n');
}
}
}
void void
boundary_set_from_string (boundary *bound, char *loc_str) boundary_set_from_string (boundary *bound, char *loc_str)
{ {
+8
View File
@@ -24,6 +24,8 @@
# include <stdio.h> # include <stdio.h>
# include <string.h> /* strcmp */ # include <string.h> /* strcmp */
# include "system.h"
# include "uniqstr.h" # include "uniqstr.h"
/* A boundary between two characters. */ /* A boundary between two characters. */
@@ -107,6 +109,9 @@ void location_compute (location *loc,
Warning: uses quotearg's slot 3. */ Warning: uses quotearg's slot 3. */
unsigned location_print (location loc, FILE *out); unsigned location_print (location loc, FILE *out);
/* Same as location_print, only to an obstack. */
unsigned location_obstack_print (location loc, struct obstack *obs);
/* Free any allocated ressources and close any open file handles that are /* Free any allocated ressources and close any open file handles that are
left-over by the usage of location_caret. */ left-over by the usage of location_caret. */
void cleanup_caret (void); void cleanup_caret (void);
@@ -114,6 +119,9 @@ void cleanup_caret (void);
/* Output to OUT the line and caret corresponding to location LOC. */ /* Output to OUT the line and caret corresponding to location LOC. */
void location_caret (location loc, FILE *out); void location_caret (location loc, FILE *out);
/* Same as location_caret, only with an obstack. */
void location_obstack_caret (location loc, struct obstack *obs);
/* Return -1, 0, 1, depending whether a is before, equal, or /* Return -1, 0, 1, depending whether a is before, equal, or
after b. */ after b. */
static inline int static inline int
+3 -1
View File
@@ -203,7 +203,6 @@ main (int argc, char *argv[])
contains things such as user actions, prologue, epilogue etc. */ contains things such as user actions, prologue, epilogue etc. */
gram_scanner_free (); gram_scanner_free ();
muscle_free (); muscle_free ();
uniqstrs_free ();
code_scanner_free (); code_scanner_free ();
skel_scanner_free (); skel_scanner_free ();
quotearg_free (); quotearg_free ();
@@ -218,6 +217,9 @@ main (int argc, char *argv[])
timevar_stop (TV_TOTAL); timevar_stop (TV_TOTAL);
timevar_print (stderr); timevar_print (stderr);
print_warnings (stderr);
uniqstrs_free ();
cleanup_caret (); cleanup_caret ();
return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS; return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS;
+1 -1
View File
@@ -509,7 +509,7 @@ muscle_percent_define_insert (char const *var, location variable_loc,
unsigned i = 0; unsigned i = 0;
if (how_old == MUSCLE_PERCENT_DEFINE_F) if (how_old == MUSCLE_PERCENT_DEFINE_F)
goto end; goto end;
complain_indent (&variable_loc, complaint, &i, start_complain_indent (&variable_loc, complaint, &i,
_("%%define variable %s redefined"), _("%%define variable %s redefined"),
quote (variable)); quote (variable));
i += SUB_INDENT; i += SUB_INDENT;
+615 -750
View File
File diff suppressed because it is too large Load Diff
+57 -64
View File
@@ -52,7 +52,7 @@ extern int gram_debug;
#include "symlist.h" #include "symlist.h"
#include "symtab.h" #include "symtab.h"
#line 233 "src/parse-gram.y" /* yacc.c:1909 */ #line 221 "src/parse-gram.y" /* yacc.c:1909 */
typedef enum typedef enum
{ {
@@ -61,7 +61,7 @@ extern int gram_debug;
param_parse = 1 << 1, param_parse = 1 << 1,
param_both = param_lex | param_parse param_both = param_lex | param_parse
} param_type; } param_type;
#line 723 "src/parse-gram.y" /* yacc.c:1909 */ #line 645 "src/parse-gram.y" /* yacc.c:1909 */
#include "muscle-tab.h" #include "muscle-tab.h"
#line 68 "src/parse-gram.h" /* yacc.c:1909 */ #line 68 "src/parse-gram.h" /* yacc.c:1909 */
@@ -84,54 +84,49 @@ extern int gram_debug;
PERCENT_PRECEDENCE = 267, PERCENT_PRECEDENCE = 267,
PERCENT_PREC = 268, PERCENT_PREC = 268,
PERCENT_DPREC = 269, PERCENT_DPREC = 269,
PERCENT_GPREC = 270, PERCENT_MERGE = 270,
PERCENT_PRECR = 271, PERCENT_CODE = 271,
PERCENT_MERGE = 272, PERCENT_DEFAULT_PREC = 272,
PERCENT_CODE = 273, PERCENT_DEFINE = 273,
PERCENT_DEFAULT_PREC = 274, PERCENT_DEFINES = 274,
PERCENT_DEFINE = 275, PERCENT_ERROR_VERBOSE = 275,
PERCENT_DEFINES = 276, PERCENT_EXPECT = 276,
PERCENT_ERROR_VERBOSE = 277, PERCENT_EXPECT_RR = 277,
PERCENT_EXPECT = 278, PERCENT_FLAG = 278,
PERCENT_EXPECT_RR = 279, PERCENT_FILE_PREFIX = 279,
PERCENT_FLAG = 280, PERCENT_GLR_PARSER = 280,
PERCENT_FILE_PREFIX = 281, PERCENT_INITIAL_ACTION = 281,
PERCENT_GLR_PARSER = 282, PERCENT_LANGUAGE = 282,
PERCENT_INITIAL_ACTION = 283, PERCENT_NAME_PREFIX = 283,
PERCENT_LANGUAGE = 284, PERCENT_NO_DEFAULT_PREC = 284,
PERCENT_NAME_PREFIX = 285, PERCENT_NO_LINES = 285,
PERCENT_NO_DEFAULT_PREC = 286, PERCENT_NONDETERMINISTIC_PARSER = 286,
PERCENT_NO_LINES = 287, PERCENT_OUTPUT = 287,
PERCENT_NONDETERMINISTIC_PARSER = 288, PERCENT_REQUIRE = 288,
PERCENT_OUTPUT = 289, PERCENT_SKELETON = 289,
PERCENT_REQUIRE = 290, PERCENT_START = 290,
PERCENT_SKELETON = 291, PERCENT_TOKEN_TABLE = 291,
PERCENT_START = 292, PERCENT_VERBOSE = 292,
PERCENT_TOKEN_TABLE = 293, PERCENT_YACC = 293,
PERCENT_VERBOSE = 294, BRACED_CODE = 294,
PERCENT_YACC = 295, BRACED_PREDICATE = 295,
BRACED_CODE = 296, BRACKETED_ID = 296,
BRACED_PREDICATE = 297, CHAR = 297,
BRACKETED_ID = 298, EPILOGUE = 298,
CHAR = 299, EQUAL = 299,
EPILOGUE = 300, ID = 300,
EQUAL = 301, ID_COLON = 301,
ID = 302, PERCENT_PERCENT = 302,
ID_COLON = 303, PIPE = 303,
PERCENT_PERCENT = 304, PROLOGUE = 304,
PIPE = 305, SEMICOLON = 305,
PROLOGUE = 306, TAG = 306,
SEMICOLON = 307, TAG_ANY = 307,
GT = 308, TAG_NONE = 308,
TAG = 309, INT = 309,
TAG_ANY = 310, PERCENT_PARAM = 310,
TAG_NONE = 311, PERCENT_UNION = 311,
LBRACE = 312, PERCENT_EMPTY = 312
RBRACE = 313,
INT = 314,
PERCENT_PARAM = 315,
PERCENT_UNION = 316,
PERCENT_EMPTY = 317
}; };
#endif #endif
@@ -140,29 +135,27 @@ extern int gram_debug;
typedef union GRAM_STYPE GRAM_STYPE; typedef union GRAM_STYPE GRAM_STYPE;
union GRAM_STYPE union GRAM_STYPE
{ {
#line 187 "src/parse-gram.y" /* yacc.c:1909 */ #line 182 "src/parse-gram.y" /* yacc.c:1909 */
unsigned char character; unsigned char character;
#line 191 "src/parse-gram.y" /* yacc.c:1909 */ #line 186 "src/parse-gram.y" /* yacc.c:1909 */
char *code; char *code;
#line 196 "src/parse-gram.y" /* yacc.c:1909 */ #line 191 "src/parse-gram.y" /* yacc.c:1909 */
uniqstr uniqstr; uniqstr uniqstr;
#line 204 "src/parse-gram.y" /* yacc.c:1909 */ #line 199 "src/parse-gram.y" /* yacc.c:1909 */
int integer; int integer;
#line 208 "src/parse-gram.y" /* yacc.c:1909 */ #line 203 "src/parse-gram.y" /* yacc.c:1909 */
symbol *symbol; symbol *symbol;
#line 213 "src/parse-gram.y" /* yacc.c:1909 */ #line 208 "src/parse-gram.y" /* yacc.c:1909 */
assoc assoc; assoc assoc;
#line 216 "src/parse-gram.y" /* yacc.c:1909 */ #line 211 "src/parse-gram.y" /* yacc.c:1909 */
symbol_list *list; symbol_list *list;
#line 219 "src/parse-gram.y" /* yacc.c:1909 */ #line 214 "src/parse-gram.y" /* yacc.c:1909 */
named_ref *named_ref; named_ref *named_ref;
#line 224 "src/parse-gram.y" /* yacc.c:1909 */ #line 241 "src/parse-gram.y" /* yacc.c:1909 */
prec_rel_comparator prec_rel_comparator;
#line 253 "src/parse-gram.y" /* yacc.c:1909 */
param_type param; param_type param;
#line 423 "src/parse-gram.y" /* yacc.c:1909 */ #line 409 "src/parse-gram.y" /* yacc.c:1909 */
code_props_type code_type; code_props_type code_type;
#line 725 "src/parse-gram.y" /* yacc.c:1909 */ #line 647 "src/parse-gram.y" /* yacc.c:1909 */
struct struct
{ {
@@ -170,7 +163,7 @@ code_props_type code_type;
muscle_kind kind; muscle_kind kind;
} value; } value;
#line 174 "src/parse-gram.h" /* yacc.c:1909 */ #line 167 "src/parse-gram.h" /* yacc.c:1909 */
}; };
# define GRAM_STYPE_IS_TRIVIAL 1 # define GRAM_STYPE_IS_TRIVIAL 1
# define GRAM_STYPE_IS_DECLARED 1 # define GRAM_STYPE_IS_DECLARED 1
-78
View File
@@ -130,8 +130,6 @@
%token PERCENT_PREC "%prec" %token PERCENT_PREC "%prec"
%token PERCENT_DPREC "%dprec" %token PERCENT_DPREC "%dprec"
%token PERCENT_GPREC "%gprec"
%token PERCENT_PRECR "%precr"
%token PERCENT_MERGE "%merge" %token PERCENT_MERGE "%merge"
/*----------------------. /*----------------------.
@@ -177,12 +175,9 @@
%token PIPE "|" %token PIPE "|"
%token PROLOGUE "%{...%}" %token PROLOGUE "%{...%}"
%token SEMICOLON ";" %token SEMICOLON ";"
%token GT ">"
%token TAG "<tag>" %token TAG "<tag>"
%token TAG_ANY "<*>" %token TAG_ANY "<*>"
%token TAG_NONE "<>" %token TAG_NONE "<>"
%token LBRACE "{"
%token RBRACE "}"
%union {unsigned char character;} %union {unsigned char character;}
%type <character> CHAR %type <character> CHAR
@@ -219,13 +214,6 @@
%union {named_ref *named_ref;} %union {named_ref *named_ref;}
%type <named_ref> named_ref.opt %type <named_ref> named_ref.opt
%type <uniqstr> prec_group_name.opt string_or_id
%union {prec_rel_comparator prec_rel_comparator;}
%type <prec_rel_comparator> prec_rel_comparator
%type <list> precedence_relation_symbols precedence_symbol
/*---------. /*---------.
| %param. | | %param. |
`---------*/ `---------*/
@@ -377,8 +365,6 @@ params:
grammar_declaration: grammar_declaration:
precedence_declaration precedence_declaration
| precedence_group_declaration
| precedence_relation_declaration
| symbol_declaration | symbol_declaration
| "%start" symbol | "%start" symbol
{ {
@@ -471,30 +457,6 @@ symbol_declaration:
} }
; ;
/* A group of symbols for precedence declaration */
precedence_group_declaration:
"%gprec" prec_group_name.opt
{
set_current_group ($2, &@2);
}
"{" precedence_declarations "}"
{
set_current_group (DEFAULT_GROUP_NAME, NULL);
}
;
/* Name for the precedence group. If none is present a new unique one is
generated. */
prec_group_name.opt:
%empty { $$ = new_anonymous_group_name (); }
| variable /* Just a string, maybe there's a better way? */
;
precedence_declarations:
precedence_declaration
| precedence_declarations precedence_declaration
;
precedence_declaration: precedence_declaration:
precedence_declarator tag.opt symbols.prec precedence_declarator tag.opt symbols.prec
{ {
@@ -522,46 +484,6 @@ tag.opt:
| TAG { current_type = $1; tag_seen = true; } | TAG { current_type = $1; tag_seen = true; }
; ;
/* Declaration of a precedence relation between two (lists of) tokens */
precedence_relation_declaration:
"%precr" precedence_relation_symbols
{ prec_braces = default_braces_state; }
prec_rel_comparator
precedence_relation_symbols
{ declare_precedence_relation ($2, $5, $4, @4); }
;
precedence_relation_symbols:
precedence_symbol { $$ = $1; }
| precedence_relation_symbols precedence_symbol
{ $$ = symbol_list_append ($1, $2); }
;
precedence_symbol:
string_or_id
{
if (is_prec_group ($1))
$$ = expand_symbol_group (symgroup_from_uniqstr($1, &@1), @1);
else
$$ = symbol_list_sym_new (symbol_from_uniqstr ($1, @1), @1);
}
| CHAR
{
$$ = symbol_list_sym_new (symbol_from_uniqstr (uniqstr_new (char_name ($1)), @1), @1);
}
;
string_or_id:
STRING { $$ = uniqstr_new (quotearg_style (c_quoting_style, $1)); }
| ID { $$ = $1; }
;
prec_rel_comparator:
">" { $$ = prec_superior; }
| "=" { $$ = prec_equal; }
| ">" ">" { $$ = prec_superior_strict; }
;
/* Just like symbols.1 but accept INT for the sake of POSIX. */ /* Just like symbols.1 but accept INT for the sake of POSIX. */
symbols.prec: symbols.prec:
symbol.prec symbol.prec
+1 -2
View File
@@ -392,8 +392,7 @@ print_grammar (FILE *out, int level)
{ {
char const *tag = symbols[token_translations[i]]->tag; char const *tag = symbols[token_translations[i]]->tag;
int precedence = symbols[token_translations[i]]->content->prec; int precedence = symbols[token_translations[i]]->content->prec;
assoc associativity = symbols[token_translations[i]]->content->prec_node assoc associativity = symbols[token_translations[i]]->content->assoc;
->assoc;
xml_indent (out, level + 2); xml_indent (out, level + 2);
fprintf (out, fprintf (out,
"<terminal symbol-number=\"%d\" token-number=\"%d\"" "<terminal symbol-number=\"%d\" token-number=\"%d\""
+1 -1
View File
@@ -129,7 +129,7 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type)) if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
{ {
unsigned indent = 0; unsigned indent = 0;
complain_indent (&declaration_loc, complaint, &indent, start_complain_indent (&declaration_loc, complaint, &indent,
_("result type clash on merge function %s: " _("result type clash on merge function %s: "
"<%s> != <%s>"), "<%s> != <%s>"),
quote (merge_function->name), type, quote (merge_function->name), type,
+11 -8
View File
@@ -335,7 +335,7 @@ show_sub_message (warnings warning,
const char *at_spec = get_at_spec (var->symbol_index); const char *at_spec = get_at_spec (var->symbol_index);
if (var->err == 0) if (var->err == 0)
complain_indent (&var->loc, warning, &indent, start_complain_indent (&var->loc, warning, &indent,
_("refers to: %c%s at %s"), dollar_or_at, _("refers to: %c%s at %s"), dollar_or_at,
var->id, at_spec); var->id, at_spec);
else else
@@ -372,7 +372,7 @@ show_sub_message (warnings warning,
_(", cannot be accessed from mid-rule action at $%d"), _(", cannot be accessed from mid-rule action at $%d"),
midrule_rhs_index); midrule_rhs_index);
complain_indent (&id_loc, warning, &indent, "%s", start_complain_indent (&id_loc, warning, &indent, "%s",
obstack_finish0 (&msg_buf)); obstack_finish0 (&msg_buf));
obstack_free (&msg_buf, 0); obstack_free (&msg_buf, 0);
} }
@@ -515,7 +515,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
cp_end - cp : ref_tail_fields - cp; cp_end - cp : ref_tail_fields - cp;
unsigned indent = 0; unsigned indent = 0;
complain_indent (&text_loc, complaint, &indent, start_complain_indent (&text_loc, complaint, &indent,
_("invalid reference: %s"), quote (text)); _("invalid reference: %s"), quote (text));
indent += SUB_INDENT; indent += SUB_INDENT;
if (len == 0) if (len == 0)
@@ -523,18 +523,18 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
location sym_loc = text_loc; location sym_loc = text_loc;
sym_loc.start.column += 1; sym_loc.start.column += 1;
sym_loc.end = sym_loc.start; sym_loc.end = sym_loc.start;
complain_indent (&sym_loc, complaint, &indent, start_complain_indent (&sym_loc, complaint, &indent,
_("syntax error after '%c', expecting integer, " _("syntax error after '%c', expecting integer, "
"letter, '_', '[', or '$'"), "letter, '_', '[', or '$'"),
dollar_or_at); dollar_or_at);
} }
else if (midrule_rhs_index) else if (midrule_rhs_index)
complain_indent (&rule->location, complaint, &indent, start_complain_indent (&rule->location, complaint, &indent,
_("symbol not found in production before $%d: " _("symbol not found in production before $%d: "
"%.*s"), "%.*s"),
midrule_rhs_index, len, cp); midrule_rhs_index, len, cp);
else else
complain_indent (&rule->location, complaint, &indent, start_complain_indent (&rule->location, complaint, &indent,
_("symbol not found in production: %.*s"), _("symbol not found in production: %.*s"),
len, cp); len, cp);
@@ -542,6 +542,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
show_sub_messages (complaint, show_sub_messages (complaint,
cp, explicit_bracketing, midrule_rhs_index, cp, explicit_bracketing, midrule_rhs_index,
dollar_or_at, indent); dollar_or_at, indent);
finish_complaint ();
return INVALID_REF; return INVALID_REF;
} }
case 1: case 1:
@@ -549,11 +550,12 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
unsigned indent = 0; unsigned indent = 0;
if (variant_count > 1) if (variant_count > 1)
{ {
complain_indent (&text_loc, Wother, &indent, start_complain_indent (&text_loc, Wother, &indent,
_("misleading reference: %s"), quote (text)); _("misleading reference: %s"), quote (text));
show_sub_messages (Wother, show_sub_messages (Wother,
cp, explicit_bracketing, midrule_rhs_index, cp, explicit_bracketing, midrule_rhs_index,
dollar_or_at, indent + SUB_INDENT); dollar_or_at, indent + SUB_INDENT);
finish_complaint ();
} }
{ {
unsigned symbol_index = unsigned symbol_index =
@@ -565,11 +567,12 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
default: default:
{ {
unsigned indent = 0; unsigned indent = 0;
complain_indent (&text_loc, complaint, &indent, start_complain_indent (&text_loc, complaint, &indent,
_("ambiguous reference: %s"), quote (text)); _("ambiguous reference: %s"), quote (text));
show_sub_messages (complaint, show_sub_messages (complaint,
cp, explicit_bracketing, midrule_rhs_index, cp, explicit_bracketing, midrule_rhs_index,
dollar_or_at, indent + SUB_INDENT); dollar_or_at, indent + SUB_INDENT);
finish_complaint ();
return INVALID_REF; return INVALID_REF;
} }
} }
-17
View File
@@ -223,10 +223,6 @@ eqopt ([[:space:]]*=)?
"%fixed-output-files" return PERCENT_YACC; "%fixed-output-files" return PERCENT_YACC;
"%initial-action" return PERCENT_INITIAL_ACTION; "%initial-action" return PERCENT_INITIAL_ACTION;
"%glr-parser" return PERCENT_GLR_PARSER; "%glr-parser" return PERCENT_GLR_PARSER;
"%gprec" {
prec_braces = gprec_seen;
return PERCENT_GPREC;
}
"%language" return PERCENT_LANGUAGE; "%language" return PERCENT_LANGUAGE;
"%left" return PERCENT_LEFT; "%left" return PERCENT_LEFT;
"%lex-param" RETURN_PERCENT_PARAM(lex); "%lex-param" RETURN_PERCENT_PARAM(lex);
@@ -243,7 +239,6 @@ eqopt ([[:space:]]*=)?
"%parse-param" RETURN_PERCENT_PARAM(parse); "%parse-param" RETURN_PERCENT_PARAM(parse);
"%prec" return PERCENT_PREC; "%prec" return PERCENT_PREC;
"%precedence" return PERCENT_PRECEDENCE; "%precedence" return PERCENT_PRECEDENCE;
"%precr" return PERCENT_PRECR;
"%printer" return PERCENT_PRINTER; "%printer" return PERCENT_PRINTER;
"%pure-parser" RETURN_PERCENT_FLAG("api.pure"); "%pure-parser" RETURN_PERCENT_FLAG("api.pure");
"%require" return PERCENT_REQUIRE; "%require" return PERCENT_REQUIRE;
@@ -278,17 +273,10 @@ eqopt ([[:space:]]*=)?
"=" return EQUAL; "=" return EQUAL;
"|" return PIPE; "|" return PIPE;
";" return SEMICOLON; ";" return SEMICOLON;
"}" return RBRACE;
">" return GT;
{id} { {id} {
val->uniqstr = uniqstr_new (yytext); val->uniqstr = uniqstr_new (yytext);
id_loc = *loc; id_loc = *loc;
if (prec_braces == gprec_seen)
{
prec_braces = group_name_seen;
return ID;
}
bracketed_id_str = NULL; bracketed_id_str = NULL;
BEGIN SC_AFTER_IDENTIFIER; BEGIN SC_AFTER_IDENTIFIER;
} }
@@ -319,11 +307,6 @@ eqopt ([[:space:]]*=)?
/* Code in between braces. */ /* Code in between braces. */
"{" { "{" {
if (prec_braces == gprec_seen || prec_braces == group_name_seen)
{
prec_braces = braces_seen;
return LBRACE;
}
STRING_GROW; STRING_GROW;
nesting = 0; nesting = 0;
code_start = loc->start; code_start = loc->start;
+15 -486
View File
@@ -26,7 +26,6 @@
#include "complain.h" #include "complain.h"
#include "gram.h" #include "gram.h"
#include "symtab.h" #include "symtab.h"
#include "symlist.h"
/*-------------------------------------------------------------------. /*-------------------------------------------------------------------.
| Symbols sorted by tag. Allocated by the first invocation of | | Symbols sorted by tag. Allocated by the first invocation of |
@@ -59,305 +58,6 @@ static symgraph **prec_nodes;
bool *used_assoc = NULL; bool *used_assoc = NULL;
/*-------------------------------------------------------------.
| The current precedence group of symbols. Used by the parser. |
`-------------------------------------------------------------*/
static symgroup *current_group = NULL;
/*-------------------------------------------------------.
| The list of symbols declared in the current statement. |
`-------------------------------------------------------*/
static symbol_list *current_prec_declaration = NULL;
/*-------------------------------------------------.
| A counter to distinguish precedence declarations |
`-------------------------------------------------*/
static int current_prec_level = 0;
/*-----------------------------.
| Constructor for a prec_link. |
`-----------------------------*/
static prec_link *
prec_link_new (prec_node *to, bool transitive)
{
prec_link *res = malloc (sizeof *res);
res->target = to;
res->transitive = transitive;
res->next = NULL;
return res;
}
/*-------------------------------------.
| Destructor for a simple symbol list. |
`-------------------------------------*/
static void
symbol_list_prec_free (symbol_list *l)
{
if (l)
{
symbol_list_prec_free (l->next);
free (l);
}
}
/*------------------------------------------------.
| Check if PARENT has a higher priority than SON. |
`------------------------------------------------*/
bool
is_prec_superior (prec_node *parent, prec_node *son)
{
prec_link *l;
for (l = parent->sons; l; l = l->next)
if (l->target == son)
return true;
return false;
}
/*-----------------------------------------.
| Check if S1 has the same priority as S2. |
`-----------------------------------------*/
bool
is_prec_equal (prec_node *s1, prec_node *s2)
{
prec_link *l;
if (s1 == s2)
return true;
for (l = s1->equals; l; l = l->next)
if (l->target == s2)
return true;
return false;
}
static inline void
complain_contradicting_prec (location *loc, uniqstr s1, uniqstr s2, char c1,
char c2)
{
complain (loc, Wprecedence, _("contradicting declaration: %s %c %s is in "
"conflict with the previous declaration: %s %c %s"), s1, c1, s2,
s1, c2, s2);
}
/*-----------------------------------------------------------------------.
| Compare LINK with TARGET, and return whether they are equal. |
| In case of equality, complain of the duplicate precedence declaration. |
`-----------------------------------------------------------------------*/
static inline bool
is_prec_target (prec_node *l, prec_node *target, uniqstr from, char c,
location loc)
{
if (l == target)
{
complain (&loc, Wprecedence, _("duplicate declaration of the precedence "
"relationship %s %c %s"), from, c,
target->symbol->tag);
return true;
}
return false;
}
/*-----------------------------------------.
| Add a precedence relationship FROM > TO. |
`-----------------------------------------*/
static void
add_prec_link (prec_node *from, prec_node *to, bool transitive, location loc)
{
if (is_prec_superior (to, from))
complain_contradicting_prec(&loc, from->symbol->tag, to->symbol->tag,
'>', '<');
else if (is_prec_equal (from, to))
complain_contradicting_prec(&loc, from->symbol->tag, to->symbol->tag,
'>', '=');
else
{
if (from->sons)
{
if (is_prec_target (from->sons->target, to, from->symbol->tag, '>',
loc))
return;
prec_link *son = from->sons;
for (; son->next; son = son->next)
if (is_prec_target (son->next->target, to, from->symbol->tag, '>',
loc))
return;
son->next = prec_link_new (to, transitive);
}
else
from->sons = prec_link_new (to, transitive);
}
}
/*-------------------------------------------------.
| Add a precedence relationship S1 == S2, one way. |
`-------------------------------------------------*/
static void
create_prec_equal_link (prec_node *s1, prec_node *s2, bool transitive,
location loc)
{
if (s1->equals)
{
if (is_prec_target (s1->equals->target, s2, s1->symbol->tag, '=',
loc))
return;
prec_link *eq = s1->equals;
for (; eq->next; eq = eq->next)
if (is_prec_target (eq->next->target, s2, s1->symbol->tag, '=',
loc))
return;
eq->next = prec_link_new (s2, transitive);
}
else
s1->equals = prec_link_new (s2, transitive);
}
/*---------------------------------------------------.
| Add a precedence relationship S1 == S2, both ways. |
`---------------------------------------------------*/
static void
add_prec_equal_link (prec_node *s1, prec_node *s2, bool transitive,
location loc)
{
if (is_prec_superior (s2, s1))
complain_contradicting_prec(&loc, s1->symbol->tag, s2->symbol->tag,
'=', '>');
else if (is_prec_superior (s1, s2))
complain_contradicting_prec(&loc, s1->symbol->tag, s2->symbol->tag,
'=', '<');
create_prec_equal_link (s1, s2, transitive, loc);
create_prec_equal_link (s2, s1, transitive, loc);
}
/* The function to use to register \a c type relations. */
typedef void (*add_link_t) (prec_node *, prec_node *, bool, location);
static add_link_t
add_link_function (prec_rel_comparator c)
{
switch (c)
{
case prec_superior_strict:
case prec_superior:
return &add_prec_link;
case prec_equal:
return &add_prec_equal_link;
}
abort ();
}
/*---------------------------------------------------------------------.
| Handle the precedence declaration between the elements of S1 and S2. |
`---------------------------------------------------------------------*/
void
declare_precedence_relation (symbol_list *s1, symbol_list *s2,
prec_rel_comparator c, location loc)
{
void (*functionPtr) (prec_node *, prec_node *, bool, location)
= add_link_function (c);
bool transitive = c != prec_superior_strict;
for (symbol_list *l1 = s1; l1; l1 = l1->next)
for (symbol_list *l2 = s2; l2; l2 = l2->next)
(*functionPtr)(l1->content.sym->content->prec_node,
l2->content.sym->content->prec_node, transitive, loc);
symbol_list_free (s1);
symbol_list_free (s2);
}
/*----------------------------------------------.
| Get the list of symbols contained in a group. |
`----------------------------------------------*/
symbol_list *
expand_symbol_group (symgroup *group, location loc)
{
symbol_list *l = NULL;
for (sym_content *s = group->symbol_list; s; s = s->group_next)
l = symbol_list_append (l, symbol_list_sym_new (s->symbol, loc));
return l;
}
/*------------------------------------------------------------------------.
| Add a symbol to the current declaration group, and declare the implicit |
| precedence links. SAME_LINE is true if the symbol was declared in the |
| same statement as the previous one (same precedence level). |
`------------------------------------------------------------------------*/
void
add_to_current_group (sym_content *s, bool same_line)
{
if (!same_line)
for (symbol_list *l = current_prec_declaration; l; l = l->next)
{
sym_content *symb = l->content.sym->content;
if (!current_group->symbol_list)
current_group->symbol_list = symb;
else
{
sym_content *sym = current_group->symbol_list;
while (sym->group_next)
sym = sym->group_next;
sym->group_next = symb;
}
}
if (current_group->symbol_list)
for (sym_content *sym = current_group->symbol_list; sym;
sym = sym->group_next)
add_prec_link (s->prec_node, sym->prec_node, true,
s->prec_node->prec_location);
if (!same_line)
{
symbol_list_prec_free (current_prec_declaration);
current_prec_declaration = malloc (sizeof *current_prec_declaration);
current_prec_declaration->content.sym = s->symbol;
current_prec_declaration->next = NULL;
}
else
{
symbol_list *l = current_prec_declaration;
for (; true; l = l->next)
{
add_prec_equal_link (s->prec_node, l->content.sym->content->prec_node,
true, s->prec_node->prec_location);
if (!l->next)
break;
}
l->next = malloc (sizeof *l->next);
l->next->content.sym = s->symbol;
l->next->next = NULL;
}
}
/*-----------------------------------------.
| Create a new prec_node for the symbol s. |
`-----------------------------------------*/
static prec_node *
prec_node_new (symbol * s)
{
prec_node * res = malloc (sizeof *res);
res->symbol = s;
res->assoc = undef_assoc;
res->sons = NULL;
res-> equals = NULL;
return res;
}
/*--------------------------. /*--------------------------.
| Create a new sym_content. | | Create a new sym_content. |
`--------------------------*/ `--------------------------*/
@@ -378,14 +78,12 @@ sym_content_new (symbol *s)
res->number = NUMBER_UNDEFINED; res->number = NUMBER_UNDEFINED;
res->prec = 0; res->prec = 0;
res->assoc = undef_assoc;
res->user_token_number = USER_NUMBER_UNDEFINED; res->user_token_number = USER_NUMBER_UNDEFINED;
res->class = unknown_sym; res->class = unknown_sym;
res->status = undeclared; res->status = undeclared;
res->group_next = NULL;
res->prec_node = prec_node_new (s);
return res; return res;
} }
@@ -407,7 +105,6 @@ symbol_new (uniqstr tag, location loc)
res->tag = tag; res->tag = tag;
res->location = loc; res->location = loc;
res->alias = NULL; res->alias = NULL;
res->content = sym_content_new (res); res->content = sym_content_new (res);
res->is_alias = false; res->is_alias = false;
@@ -419,28 +116,6 @@ symbol_new (uniqstr tag, location loc)
return res; return res;
} }
void
prec_link_free (prec_link * l)
{
if (l)
{
prec_link_free (l->next);
free (l);
}
}
/*--------------------.
| Free one prec_node. |
`--------------------*/
static void
prec_node_free (prec_node * n)
{
prec_link_free (n->sons);
prec_link_free (n->equals);
free (n);
}
/*--------------------. /*--------------------.
| Free a sym_content. | | Free a sym_content. |
`--------------------*/ `--------------------*/
@@ -448,7 +123,6 @@ prec_node_free (prec_node * n)
static void static void
sym_content_free (sym_content *sym) sym_content_free (sym_content *sym)
{ {
prec_node_free (sym->prec_node);
free (sym); free (sym);
} }
@@ -576,7 +250,7 @@ symbol_redeclaration (symbol *s, const char *what, location first,
location second) location second)
{ {
unsigned i = 0; unsigned i = 0;
complain_indent (&second, complaint, &i, start_complain_indent (&second, complaint, &i,
_("%s redeclaration for %s"), what, s->tag); _("%s redeclaration for %s"), what, s->tag);
i += SUB_INDENT; i += SUB_INDENT;
complain_indent (&first, complaint, &i, complain_indent (&first, complaint, &i,
@@ -588,7 +262,7 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first,
location second) location second)
{ {
unsigned i = 0; unsigned i = 0;
complain_indent (&second, complaint, &i, start_complain_indent (&second, complaint, &i,
_("%s redeclaration for <%s>"), what, s->tag); _("%s redeclaration for <%s>"), what, s->tag);
i += SUB_INDENT; i += SUB_INDENT;
complain_indent (&first, complaint, &i, complain_indent (&first, complaint, &i,
@@ -693,16 +367,14 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
sym_content *s = sym->content; sym_content *s = sym->content;
if (a != undef_assoc) if (a != undef_assoc)
{ {
if (s->prec_node->assoc != undef_assoc) if (s->prec)
symbol_redeclaration (sym, assoc_to_string (a), symbol_redeclaration (sym, assoc_to_string (a),
s->prec_node->prec_location, loc); s->prec_location, loc);
else else
{ {
s->prec = prec; s->prec = prec;
s->prec_node->assoc = a; s->assoc = a;
s->prec_node->prec_location = loc; s->prec_location = loc;
add_to_current_group (s, prec == current_prec_level);
current_prec_level = prec;
} }
} }
@@ -909,7 +581,7 @@ user_token_number_redeclaration (int num, symbol *first, symbol *second)
first = second; first = second;
second = tmp; second = tmp;
} }
complain_indent (&second->location, complaint, &i, start_complain_indent (&second->location, complaint, &i,
_("user token number %d redeclaration for %s"), _("user token number %d redeclaration for %s"),
num, second->tag); num, second->tag);
i += SUB_INDENT; i += SUB_INDENT;
@@ -1012,38 +684,6 @@ hash_semantic_type_hasher (void const *m, size_t tablesize)
return hash_semantic_type (m, tablesize); return hash_semantic_type (m, tablesize);
} }
/*-------------------------------------.
| Symbol precedence group hash table. |
`-------------------------------------*/
static struct hash_table *group_table = NULL;
static inline bool
hash_compare_group (const symgroup *m1, const symgroup *m2)
{
/* Since tags are unique, we can compare the pointers themselves. */
return UNIQSTR_EQ (m1->tag, m2->tag);
}
static bool
hash_group_comparator (void const *m1, void const *m2)
{
return hash_compare_group (m1, m2);
}
static inline size_t
hash_group (const symgroup *m, size_t tablesize)
{
/* Since tags are unique, we can hash the pointer itself. */
return ((uintptr_t) m->tag) % tablesize;
}
static size_t
hash_group_hasher (void const *m, size_t tablesize)
{
return hash_group (m, tablesize);
}
/*-------------------------------. /*-------------------------------.
| Create the symbol hash table. | | Create the symbol hash table. |
`-------------------------------*/ `-------------------------------*/
@@ -1061,12 +701,6 @@ symbols_new (void)
hash_semantic_type_hasher, hash_semantic_type_hasher,
hash_semantic_type_comparator, hash_semantic_type_comparator,
free); free);
group_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_group_hasher,
hash_group_comparator,
free);
set_current_group (DEFAULT_GROUP_NAME, NULL);
} }
@@ -1181,11 +815,9 @@ symbols_free (void)
{ {
hash_free (symbol_table); hash_free (symbol_table);
hash_free (semantic_type_table); hash_free (semantic_type_table);
hash_free (group_table);
free (symbols); free (symbols);
free (symbols_sorted); free (symbols_sorted);
free (semantic_types_sorted); free (semantic_types_sorted);
symbol_list_prec_free (current_prec_declaration);
} }
@@ -1470,8 +1102,8 @@ static inline bool
is_assoc_useless (symbol *s) is_assoc_useless (symbol *s)
{ {
return s return s
&& s->content->prec_node->assoc != undef_assoc && s->content->assoc != undef_assoc
&& s->content->prec_node->assoc != precedence_assoc && s->content->assoc != precedence_assoc
&& !used_assoc[s->content->number]; && !used_assoc[s->content->number];
} }
@@ -1504,124 +1136,21 @@ print_precedence_warnings (void)
{ {
symbol *s = symbols[i]; symbol *s = symbols[i];
if (s if (s
&& s->content->prec != 0
&& !prec_nodes[i]->pred && !prec_nodes[i]->pred
&& !prec_nodes[i]->succ) && !prec_nodes[i]->succ)
{ {
if (is_assoc_useless (s)) if (is_assoc_useless (s))
complain (&s->content->prec_node->prec_location, Wprecedence, complain (&s->content->prec_location, Wprecedence,
_("useless precedence and associativity for %s"), s->tag); _("useless precedence and associativity for %s"), s->tag);
else if (s->content->prec_node->assoc == precedence_assoc) else if (s->content->assoc == precedence_assoc)
complain (&s->content->prec_node->prec_location, Wprecedence, complain (&s->content->prec_location, Wprecedence,
_("useless precedence for %s"), s->tag); _("useless precedence for %s"), s->tag);
} }
else if (is_assoc_useless (s)) else if (is_assoc_useless (s))
complain (&s->content->prec_node->prec_location, Wprecedence, complain (&s->content->prec_location, Wprecedence,
_("useless associativity for %s, use %%precedence"), s->tag); _("useless associativity for %s, use %%precedence"), s->tag);
} }
free (used_assoc); free (used_assoc);
assoc_free (); assoc_free ();
} }
/*------------------------------------------------.
| Counter to create unique anonymous group names. |
`------------------------------------------------*/
static unsigned int anon_group_counter = 0;
/*-------------------------------------------------.
| Return a new unique name for an anonymous group. |
`-------------------------------------------------*/
uniqstr new_anonymous_group_name (void)
{
char buff[20];
snprintf (buff, 20, "__anon%u__", anon_group_counter++);
return uniqstr_new (buff);
}
/*-------------------------------------------.
| Constructor for a symbol precedence group. |
`-------------------------------------------*/
symgroup *
symgroup_new (const uniqstr tag, location loc)
{
symgroup *group = xmalloc (sizeof (*group));
group->tag = tag;
group->symbol_list = NULL;
group->location = loc;
return group;
}
/*----------------------------------------.
| Check if there is a group by that name. |
`----------------------------------------*/
bool
is_prec_group (const uniqstr key)
{
symgroup probe;
symgroup *entry;
probe.tag = key;
entry = hash_lookup (group_table, &probe);
return entry != NULL;
}
/*--------------------------------------------------------------------------.
| Get the symbol precedence group by that name. If not present, a new group |
| is created and inserted in the table, with the location information |
| provided, if any. |
`--------------------------------------------------------------------------*/
symgroup *
symgroup_from_uniqstr (const uniqstr key, location *loc)
{
bool null_loc = loc == NULL;
if (null_loc)
{
loc = malloc (sizeof *loc);
boundary_set (&loc->start, uniqstr_new (""), 1, 1);
boundary_set (&loc->end, uniqstr_new (""), 1, 1);
}
symgroup probe;
symgroup *entry;
probe.tag = key;
entry = hash_lookup (group_table, &probe);
if (!entry)
{
/* First insertion in the hash. */
entry = symgroup_new (key, *loc);
if (!hash_insert (group_table, entry))
xalloc_die ();
}
if (null_loc)
free (loc);
return entry;
}
/*--------------------------------------------------------------------------.
| Change the current group to the one designated by the name, and create it |
| if necessary. The location information is used for creation if available. |
`--------------------------------------------------------------------------*/
void set_current_group (const uniqstr tag, location *loc)
{
for (symbol_list *l = current_prec_declaration; l; l = l->next)
{
sym_content *symb = l->content.sym->content;
if (!current_group->symbol_list)
current_group->symbol_list = symb;
else
{
sym_content *sym = current_group->symbol_list;
for (; sym->group_next; sym = sym->group_next)
{}
sym->group_next = symb;
}
}
symbol_list_prec_free (current_prec_declaration);
current_prec_declaration = NULL;
current_group = symgroup_from_uniqstr (tag, loc);
}
+2 -99
View File
@@ -31,8 +31,6 @@
# include "scan-code.h" # include "scan-code.h"
# include "uniqstr.h" # include "uniqstr.h"
typedef struct symbol_list symbol_list;
/*----------. /*----------.
| Symbols. | | Symbols. |
`----------*/ `----------*/
@@ -64,8 +62,6 @@ typedef struct sym_content sym_content;
When status are checked at the end, "declared" symbols are fine, When status are checked at the end, "declared" symbols are fine,
"used" symbols trigger warnings, otherwise it's an error. */ "used" symbols trigger warnings, otherwise it's an error. */
typedef struct prec_node prec_node;
typedef enum typedef enum
{ {
/** Used in the input file for an unknown reason (error). */ /** Used in the input file for an unknown reason (error). */
@@ -129,21 +125,13 @@ struct sym_content
code_props props[CODE_PROPS_SIZE]; code_props props[CODE_PROPS_SIZE];
symbol_number number; symbol_number number;
location prec_location;
/* Not used anymore, to remove. */
int prec; int prec;
assoc assoc;
int user_token_number; int user_token_number;
symbol_class class; symbol_class class;
status status; status status;
/* The next element in the symbol precedence group. */
sym_content *group_next;
/* The graph node containing all the precedence information for this
symbol. */
prec_node *prec_node;
}; };
/** Undefined user number. */ /** Undefined user number. */
@@ -298,91 +286,6 @@ void print_precedence_warnings (void);
void register_assoc (graphid i, graphid j); void register_assoc (graphid i, graphid j);
/*------------------.
| Groups of symbols |
`------------------*/
#define DEFAULT_GROUP_NAME uniqstr_new ("__default__")
typedef struct symgroup symgroup;
struct symgroup
{
/** The name of the group. */
uniqstr tag;
/** The list of symbols in the group. */
sym_content * symbol_list;
location location;
} ;
/** Get a dummy name for an anonymous group. */
uniqstr new_anonymous_group_name (void);
/** Set the current group in the token precedence declaration to a new group
* with this name */
void set_current_group (const uniqstr name, location *loc);
/** Get or create the group by that name. The location information is used for
* creation when available. */
symgroup *
symgroup_from_uniqstr (const uniqstr key, location *loc);
/** Check if there is a symbol precedence group by that name. */
bool
is_prec_group (const uniqstr key);
/*----------------------------------.
| Graph of precedence relationships |
`----------------------------------*/
typedef struct prec_link prec_link;
struct prec_link
{
prec_node *target;
bool transitive;
prec_link *next;
};
struct prec_node
{
symbol *symbol;
/** Associativity for the symbol. */
assoc assoc;
location prec_location;
prec_link *sons;
prec_link *equals;
};
typedef enum prec_rel_comparator prec_rel_comparator;
enum prec_rel_comparator
{
prec_equal,
prec_superior,
prec_superior_strict,
};
/** Declare a precedence relationship between the symbols of the two lists,
* as defined by the operator. */
void
declare_precedence_relation (symbol_list *l1, symbol_list *l2,
prec_rel_comparator c, location loc);
/** Return the list of symbols contained in the group. */
symbol_list *
expand_symbol_group (symgroup * group, location loc);
/** Check if s1 and s2 have the same precedence level. */
bool is_prec_equal (prec_node * s1, prec_node * s2);
/** Check if from > to . */
bool is_prec_superior (prec_node * from, prec_node * to);
/*-----------------. /*-----------------.
| Semantic types. | | Semantic types. |
`-----------------*/ `-----------------*/
+4 -4
View File
@@ -1385,8 +1385,8 @@ AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y], 0,, AT_BISON_CHECK([-o input.c input.y], 0,,
[[input.y:24.70-72: warning: useless %destructor for type <*> [-Wother] [[input.y:24.70-72: warning: useless %destructor for type <*> [-Wother]
input.y:24.70-72: warning: useless %printer for type <*> [-Wother] input.y:24.70-72: warning: useless %printer for type <*> [-Wother]
input.y:33.3-23: warning: unset value: $$ [-Wother]
input.y:32.3-23: warning: unused value: $3 [-Wother] input.y:32.3-23: warning: unused value: $3 [-Wother]
input.y:33.3-23: warning: unset value: $$ [-Wother]
]]) ]])
AT_BISON_CHECK([-fcaret -o input.c input.y], 0,, AT_BISON_CHECK([-fcaret -o input.c input.y], 0,,
@@ -1396,12 +1396,12 @@ AT_BISON_CHECK([-fcaret -o input.c input.y], 0,,
input.y:24.70-72: warning: useless %printer for type <*> [-Wother] input.y:24.70-72: warning: useless %printer for type <*> [-Wother]
%printer { fprintf (yyoutput, "<*> printer should not be called"); } <*> %printer { fprintf (yyoutput, "<*> printer should not be called"); } <*>
^^^ ^^^
input.y:33.3-23: warning: unset value: $$ [-Wother]
{ @$ = 4; } // Only used.
^^^^^^^^^^^^^^^^^^^^^
input.y:32.3-23: warning: unused value: $3 [-Wother] input.y:32.3-23: warning: unused value: $3 [-Wother]
{ USE ($$); @$ = 3; } // Only set. { USE ($$); @$ = 3; } // Only set.
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
input.y:33.3-23: warning: unset value: $$ [-Wother]
{ @$ = 4; } // Only used.
^^^^^^^^^^^^^^^^^^^^^
]]) ]])
AT_COMPILE([input]) AT_COMPILE([input])
+23 -169
View File
@@ -17,152 +17,6 @@
AT_BANNER([[Conflicts.]]) AT_BANNER([[Conflicts.]])
## ----------------- ##
## Precedence groups ##
## ----------------- ##
# Sample use case of precedence groups and relations, working.
AT_SETUP([Precedence groups])
AT_DATA_GRAMMAR([[input.y]],
[[%token CARET "^"
%token NUM BOOL '^' OR AND
%left '+' '-'
%gprec {
%right CARET
}
%gprec boolean {
%left OR
%left AND
}
%left '*' '/'
%precr boolean >> "^"
%precr CARET > '*' '/' '-' '+'
%%
stmt:
exp
| bool_exp
exp:
NUM
| exp '+' exp
| exp '-' exp
| exp '*' exp
| exp '/' exp
| exp "^" exp
bool_exp:
BOOL
| bool_exp AND bool_exp
| bool_exp OR bool_exp
| bool_exp CARET bool_exp
]])
AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [])
AT_CLEANUP
## -------------------------------- ##
## Conflicting precedence relations ##
## -------------------------------- ##
AT_SETUP([Conflicting precedence relations])
AT_DATA_GRAMMAR([[input.y]],
[[%token TOKEN
%precedence A
%precedence B
%precedence C
%precedence D E
%gprec group {
%precedence F
%precedence G
}
%precr B = C
%precr A > B
%precr C > B
%precr F > G
%precr F > A
%%
exp:
TOKEN
| exp A exp
| exp B exp
| exp C exp
| exp D exp
| exp E exp
| exp F exp
| exp G exp
]])
AT_BISON_CHECK([[-Wall -o input.c input.y]], 0, [],
[[input.y:20.10: warning: contradicting declaration: B = C is in conflict with the previous declaration: B > C [-Wprecedence]
input.y:21.10: warning: contradicting declaration: A > B is in conflict with the previous declaration: A < B [-Wprecedence]
input.y:22.10: warning: contradicting declaration: C > B is in conflict with the previous declaration: C = B [-Wprecedence]
input.y:23.10: warning: contradicting declaration: F > G is in conflict with the previous declaration: F < G [-Wprecedence]
input.y: warning: 27 shift/reduce conflicts [-Wconflicts-sr]
]])
AT_CLEANUP
## ------------------------------ ##
## Duplicate precedence relations ##
## ------------------------------ ##
AT_SETUP([Duplicate precedence relations])
AT_DATA_GRAMMAR([[input.y]],
[[%token TOKEN
%precedence A
%precedence B
%precedence C
%precedence D E
%gprec group {
%precedence F
%precedence G
}
%precr D = E
%precr B > A
%precr C > B
%precr G > F
%precr F > A
%precr C > group
%precr C > F
%%
exp:
TOKEN
| exp A exp
| exp B exp
| exp C exp
| exp D exp
| exp E exp
| exp F exp
| exp G exp
]])
AT_BISON_CHECK([[-Wall -o input.c input.y]], 0, [],
[[input.y:20.10: warning: duplicate declaration of the precedence relationship D = E [-Wprecedence]
input.y:20.10: warning: duplicate declaration of the precedence relationship E = D [-Wprecedence]
input.y:21.10: warning: duplicate declaration of the precedence relationship B > A [-Wprecedence]
input.y:22.10: warning: duplicate declaration of the precedence relationship C > B [-Wprecedence]
input.y:23.10: warning: duplicate declaration of the precedence relationship G > F [-Wprecedence]
input.y:26.10: warning: duplicate declaration of the precedence relationship C > F [-Wprecedence]
input.y: warning: 23 shift/reduce conflicts [-Wconflicts-sr]
]])
AT_CLEANUP
## ------------------------- ## ## ------------------------- ##
## Token declaration order. ## ## Token declaration order. ##
## ------------------------- ## ## ------------------------- ##
@@ -389,18 +243,18 @@ f: B
]]) ]])
AT_BISON_CHECK([-Wprecedence -fcaret -o input.c input.y], 0, [], AT_BISON_CHECK([-Wprecedence -fcaret -o input.c input.y], 0, [],
[[input.y:7.1-9: warning: useless precedence and associativity for U [-Wprecedence] [[input.y:2.1-11: warning: useless precedence for Z [-Wprecedence]
%nonassoc U %precedence Z
^^^^^^^^^ ^^^^^^^^^^^
input.y:6.1-6: warning: useless precedence and associativity for V [-Wprecedence]
%right V
^^^^^^
input.y:5.1-5: warning: useless precedence and associativity for W [-Wprecedence] input.y:5.1-5: warning: useless precedence and associativity for W [-Wprecedence]
%left W %left W
^^^^^ ^^^^^
input.y:2.1-11: warning: useless precedence for Z [-Wprecedence] input.y:6.1-6: warning: useless precedence and associativity for V [-Wprecedence]
%precedence Z %right V
^^^^^^^^^^^ ^^^^^^
input.y:7.1-9: warning: useless precedence and associativity for U [-Wprecedence]
%nonassoc U
^^^^^^^^^
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1152,8 +1006,8 @@ cond:
]]) ]])
AT_BISON_CHECK([-o input.c input.y], 0, [], AT_BISON_CHECK([-o input.c input.y], 0, [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y:12.3-18: warning: rule useless in parser due to conflicts [-Wother]
input.y:12.3-18: warning: rule useless in parser due to conflicts [-Wother] input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1196,8 +1050,8 @@ id : '0';
]]) ]])
AT_BISON_CHECK([-o input.c --report=all input.y], 0, [], AT_BISON_CHECK([-o input.c --report=all input.y], 0, [],
[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] [[input.y:4.6-8: warning: rule useless in parser due to conflicts [-Wother]
input.y:4.6-8: warning: rule useless in parser due to conflicts [-Wother] input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
]]) ]])
# Check the contents of the report. # Check the contents of the report.
@@ -1411,9 +1265,9 @@ e: e '+' e
]]) ]])
AT_BISON_CHECK([-Wall -o input.c input.y], 0, [], AT_BISON_CHECK([-Wall -o input.c input.y], 0, [],
[[input.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr] [[input.y:1.1-5: warning: useless precedence and associativity for '+' [-Wprecedence]
input.y:1.1-5: warning: useless precedence and associativity for '+' [-Wprecedence]
input.y:2.1-5: warning: useless precedence and associativity for '*' [-Wprecedence] input.y:2.1-5: warning: useless precedence and associativity for '*' [-Wprecedence]
input.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr]
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1515,15 +1369,15 @@ reported_conflicts:
]]) ]])
AT_BISON_CHECK([[--report=all input.y]], 0, [], AT_BISON_CHECK([[--report=all input.y]], 0, [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y:12.5-20: warning: rule useless in parser due to conflicts [-Wother]
input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
input.y:12.5-20: warning: rule useless in parser due to conflicts [-Wother]
input.y:20.5-20: warning: rule useless in parser due to conflicts [-Wother] input.y:20.5-20: warning: rule useless in parser due to conflicts [-Wother]
input.y:21.4: warning: rule useless in parser due to conflicts [-Wother] input.y:21.4: warning: rule useless in parser due to conflicts [-Wother]
input.y:25.13: warning: rule useless in parser due to conflicts [-Wother] input.y:25.13: warning: rule useless in parser due to conflicts [-Wother]
input.y:25.16: warning: rule useless in parser due to conflicts [-Wother] input.y:25.16: warning: rule useless in parser due to conflicts [-Wother]
input.y:31.5-7: warning: rule useless in parser due to conflicts [-Wother] input.y:31.5-7: warning: rule useless in parser due to conflicts [-Wother]
input.y:32.4: warning: rule useless in parser due to conflicts [-Wother] input.y:32.4: warning: rule useless in parser due to conflicts [-Wother]
input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
]]) ]])
AT_CHECK([[cat input.output]], 0, AT_CHECK([[cat input.output]], 0,
@@ -1668,12 +1522,12 @@ AT_DATA([[input-keep.y]],
AT_CHECK([[cat input.y >> input-keep.y]]) AT_CHECK([[cat input.y >> input-keep.y]])
AT_BISON_CHECK([[input-keep.y]], 0, [], AT_BISON_CHECK([[input-keep.y]], 0, [],
[[input-keep.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] [[input-keep.y:22.4: warning: rule useless in parser due to conflicts [-Wother]
input-keep.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
input-keep.y:22.4: warning: rule useless in parser due to conflicts [-Wother]
input-keep.y:26.16: warning: rule useless in parser due to conflicts [-Wother] input-keep.y:26.16: warning: rule useless in parser due to conflicts [-Wother]
input-keep.y:32.5-7: warning: rule useless in parser due to conflicts [-Wother] input-keep.y:32.5-7: warning: rule useless in parser due to conflicts [-Wother]
input-keep.y:33.4: warning: rule useless in parser due to conflicts [-Wother] input-keep.y:33.4: warning: rule useless in parser due to conflicts [-Wother]
input-keep.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
input-keep.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1851,9 +1705,9 @@ exp: 'a' | 'a';
]]) ]])
AT_BISON_CHECK([[2.y]], [[0]], [], AT_BISON_CHECK([[2.y]], [[0]], [],
[[2.y: warning: %expect-rr applies only to GLR parsers [-Wother] [[2.y:3.12-14: warning: rule useless in parser due to conflicts [-Wother]
2.y: warning: %expect-rr applies only to GLR parsers [-Wother]
2.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] 2.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
2.y:3.12-14: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
AT_CLEANUP AT_CLEANUP
+88 -88
View File
@@ -426,7 +426,25 @@ dnl don't like even 'print $!4;'.
[[LEX_GETLINE, '$', '!', YNUMBER, '*', YNUMBER, ';']], [[LEX_GETLINE, '$', '!', YNUMBER, '*', YNUMBER, ';']],
dnl BISON-STDERR dnl BISON-STDERR
[[input.y:66.10: warning: empty rule without %empty [-Wempty-rule] [[input.y:33.1-6: warning: useless associativity for ASSIGNOP, use %precedence [-Wprecedence]
input.y:37.1-5: warning: useless precedence and associativity for LEX_GETLINE [-Wprecedence]
input.y:38.1-9: warning: useless associativity for LEX_IN, use %precedence [-Wprecedence]
input.y:39.1-5: warning: useless associativity for FUNC_CALL, use %precedence [-Wprecedence]
input.y:39.1-5: warning: useless associativity for LEX_BUILTIN, use %precedence [-Wprecedence]
input.y:39.1-5: warning: useless associativity for LEX_LENGTH, use %precedence [-Wprecedence]
input.y:40.1-9: warning: useless precedence and associativity for ',' [-Wprecedence]
input.y:42.1-9: warning: useless precedence and associativity for APPEND_OP [-Wprecedence]
input.y:43.1-5: warning: useless associativity for CONCAT_OP, use %precedence [-Wprecedence]
input.y:44.1-5: warning: useless associativity for YNUMBER, use %precedence [-Wprecedence]
input.y:44.1-5: warning: useless associativity for YSTRING, use %precedence [-Wprecedence]
input.y:47.1-6: warning: useless associativity for '!', use %precedence [-Wprecedence]
input.y:47.1-6: warning: useless associativity for UNARY, use %precedence [-Wprecedence]
input.y:49.1-5: warning: useless associativity for INCREMENT, use %precedence [-Wprecedence]
input.y:49.1-5: warning: useless associativity for DECREMENT, use %precedence [-Wprecedence]
input.y:50.1-5: warning: useless associativity for '$', use %precedence [-Wprecedence]
input.y:51.1-5: warning: useless associativity for '(', use %precedence [-Wprecedence]
input.y:51.1-5: warning: useless precedence and associativity for ')' [-Wprecedence]
input.y:66.10: warning: empty rule without %empty [-Wempty-rule]
input.y:169.8: warning: empty rule without %empty [-Wempty-rule] input.y:169.8: warning: empty rule without %empty [-Wempty-rule]
input.y:174.12: warning: empty rule without %empty [-Wempty-rule] input.y:174.12: warning: empty rule without %empty [-Wempty-rule]
input.y:179.13: warning: empty rule without %empty [-Wempty-rule] input.y:179.13: warning: empty rule without %empty [-Wempty-rule]
@@ -439,24 +457,6 @@ input.y:322.9: warning: empty rule without %empty [-Wempty-rule]
]AT_COND_CASE([[canonical LR]], ]AT_COND_CASE([[canonical LR]],
[[input.y: warning: 265 shift/reduce conflicts [-Wconflicts-sr]]], [[input.y: warning: 265 shift/reduce conflicts [-Wconflicts-sr]]],
[[input.y: warning: 65 shift/reduce conflicts [-Wconflicts-sr]]])[ [[input.y: warning: 65 shift/reduce conflicts [-Wconflicts-sr]]])[
input.y:39.1-5: warning: useless associativity for FUNC_CALL, use %precedence [-Wprecedence]
input.y:44.1-5: warning: useless associativity for YNUMBER, use %precedence [-Wprecedence]
input.y:44.1-5: warning: useless associativity for YSTRING, use %precedence [-Wprecedence]
input.y:42.1-9: warning: useless precedence and associativity for APPEND_OP [-Wprecedence]
input.y:33.1-6: warning: useless associativity for ASSIGNOP, use %precedence [-Wprecedence]
input.y:43.1-5: warning: useless associativity for CONCAT_OP, use %precedence [-Wprecedence]
input.y:37.1-5: warning: useless precedence and associativity for LEX_GETLINE [-Wprecedence]
input.y:38.1-9: warning: useless associativity for LEX_IN, use %precedence [-Wprecedence]
input.y:49.1-5: warning: useless associativity for INCREMENT, use %precedence [-Wprecedence]
input.y:49.1-5: warning: useless associativity for DECREMENT, use %precedence [-Wprecedence]
input.y:39.1-5: warning: useless associativity for LEX_BUILTIN, use %precedence [-Wprecedence]
input.y:39.1-5: warning: useless associativity for LEX_LENGTH, use %precedence [-Wprecedence]
input.y:40.1-9: warning: useless precedence and associativity for ',' [-Wprecedence]
input.y:47.1-6: warning: useless associativity for '!', use %precedence [-Wprecedence]
input.y:47.1-6: warning: useless associativity for UNARY, use %precedence [-Wprecedence]
input.y:50.1-5: warning: useless associativity for '$', use %precedence [-Wprecedence]
input.y:51.1-5: warning: useless associativity for '(', use %precedence [-Wprecedence]
input.y:51.1-5: warning: useless precedence and associativity for ')' [-Wprecedence]
]], ]],
dnl LAST-STATE dnl LAST-STATE
@@ -484,7 +484,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
NAME [reduce using rule 152 (opt_variable)] NAME [reduce using rule 152 (opt_variable)]
'$' [reduce using rule 152 (opt_variable)] '$' [reduce using rule 152 (opt_variable)]
@@ -5385,7 +5385,7 @@ @@ -5379,7 +5379,7 @@
156 | . '$' non_post_simp_exp 156 | . '$' non_post_simp_exp
NAME shift, and go to state 9 NAME shift, and go to state 9
@@ -493,7 +493,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
NAME [reduce using rule 152 (opt_variable)] NAME [reduce using rule 152 (opt_variable)]
'$' [reduce using rule 152 (opt_variable)] '$' [reduce using rule 152 (opt_variable)]
@@ -5405,7 +5405,7 @@ @@ -5399,7 +5399,7 @@
156 | . '$' non_post_simp_exp 156 | . '$' non_post_simp_exp
NAME shift, and go to state 9 NAME shift, and go to state 9
@@ -502,7 +502,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
NAME [reduce using rule 152 (opt_variable)] NAME [reduce using rule 152 (opt_variable)]
'$' [reduce using rule 152 (opt_variable)] '$' [reduce using rule 152 (opt_variable)]
@@ -6220,7 +6220,7 @@ @@ -6214,7 +6214,7 @@
156 | . '$' non_post_simp_exp 156 | . '$' non_post_simp_exp
NAME shift, and go to state 9 NAME shift, and go to state 9
@@ -511,7 +511,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%'
NAME [reduce using rule 152 (opt_variable)] NAME [reduce using rule 152 (opt_variable)]
'$' [reduce using rule 152 (opt_variable)] '$' [reduce using rule 152 (opt_variable)]
@@ -11117,3 +11117,274 @@ @@ -11099,3 +11099,274 @@
45 statement: LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement . 45 statement: LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement .
$default reduce using rule 45 (statement) $default reduce using rule 45 (statement)
@@ -1395,7 +1395,13 @@ dnl INPUT
[[]], [[]],
dnl BISON-STDERR dnl BISON-STDERR
[[input.y:128.12: warning: empty rule without %empty [-Wempty-rule] [[input.y:53.1-6: warning: useless associativity for HASSIGN, use %precedence [-Wprecedence]
input.y:54.1-5: warning: useless associativity for HORELSE, use %precedence [-Wprecedence]
input.y:55.1-5: warning: useless associativity for HANDTHEN, use %precedence [-Wprecedence]
input.y:61.1-5: warning: useless associativity for HNOT, use %precedence [-Wprecedence]
input.y:68.1-5: warning: useless associativity for UNEAR, use %precedence [-Wprecedence]
input.y:72.1-5: warning: useless associativity for HQUA, use %precedence [-Wprecedence]
input.y:128.12: warning: empty rule without %empty [-Wempty-rule]
input.y:137.10: warning: empty rule without %empty [-Wempty-rule] input.y:137.10: warning: empty rule without %empty [-Wempty-rule]
input.y:142.8: warning: empty rule without %empty [-Wempty-rule] input.y:142.8: warning: empty rule without %empty [-Wempty-rule]
input.y:161.15: warning: empty rule without %empty [-Wempty-rule] input.y:161.15: warning: empty rule without %empty [-Wempty-rule]
@@ -1422,12 +1428,6 @@ input.y:591.14: warning: empty rule without %empty [-Wempty-rule]
input.y: warning: 144 reduce/reduce conflicts [-Wconflicts-rr]]], input.y: warning: 144 reduce/reduce conflicts [-Wconflicts-rr]]],
[[input.y: warning: 78 shift/reduce conflicts [-Wconflicts-sr] [[input.y: warning: 78 shift/reduce conflicts [-Wconflicts-sr]
input.y: warning: 10 reduce/reduce conflicts [-Wconflicts-rr]]])[ input.y: warning: 10 reduce/reduce conflicts [-Wconflicts-rr]]])[
input.y:72.1-5: warning: useless associativity for HQUA, use %precedence [-Wprecedence]
input.y:53.1-6: warning: useless associativity for HASSIGN, use %precedence [-Wprecedence]
input.y:54.1-5: warning: useless associativity for HORELSE, use %precedence [-Wprecedence]
input.y:55.1-5: warning: useless associativity for HANDTHEN, use %precedence [-Wprecedence]
input.y:61.1-5: warning: useless associativity for HNOT, use %precedence [-Wprecedence]
input.y:68.1-5: warning: useless associativity for UNEAR, use %precedence [-Wprecedence]
]], ]],
dnl LAST-STATE dnl LAST-STATE
@@ -2009,57 +2009,27 @@ dnl without being followed by "of".)
[[VARIABLE, '=', LABEL, LEFT, DOT_X]], [[VARIABLE, '=', LABEL, LEFT, DOT_X]],
dnl BISON-STDERR dnl BISON-STDERR
[[input.y:202.19: warning: empty rule without %empty [-Wempty-rule] [[input.y:137.1-5: warning: useless associativity for '.', use %precedence [-Wprecedence]
input.y:270.6: warning: empty rule without %empty [-Wempty-rule] input.y:140.1-5: warning: useless associativity for PLOT, use %precedence [-Wprecedence]
input.y:292.12: warning: empty rule without %empty [-Wempty-rule]
input.y:309.17: warning: empty rule without %empty [-Wempty-rule]
input.y:382.13: warning: empty rule without %empty [-Wempty-rule]
input.y:471.11-48: warning: rule useless in parser due to conflicts [-Wother]
input.y:154.1-5: warning: useless associativity for LABEL, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for VARIABLE, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for NUMBER, use %precedence [-Wprecedence]
input.y:141.1-5: warning: useless associativity for TEXT, use %precedence [-Wprecedence] input.y:141.1-5: warning: useless associativity for TEXT, use %precedence [-Wprecedence]
input.y:157.1-5: warning: useless associativity for ORDINAL, use %precedence [-Wprecedence] input.y:141.1-5: warning: useless associativity for SPRINTF, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for LAST, use %precedence [-Wprecedence]
input.y:153.1-5: warning: useless associativity for UP, use %precedence [-Wprecedence]
input.y:153.1-5: warning: useless associativity for DOWN, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for BOX, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for CIRCLE, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for ELLIPSE, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for ARC, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for LINE, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for ARROW, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for SPLINE, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for HEIGHT, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for RADIUS, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for WIDTH, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for DIAMETER, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for FROM, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for TO, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for AT, use %precedence [-Wprecedence]
input.y:153.1-5: warning: useless precedence and associativity for SOLID [-Wprecedence]
input.y:153.1-5: warning: useless associativity for DOTTED, use %precedence [-Wprecedence]
input.y:153.1-5: warning: useless associativity for DASHED, use %precedence [-Wprecedence]
input.y:153.1-5: warning: useless associativity for CHOP, use %precedence [-Wprecedence]
input.y:147.1-5: warning: useless precedence and associativity for LJUST [-Wprecedence] input.y:147.1-5: warning: useless precedence and associativity for LJUST [-Wprecedence]
input.y:147.1-5: warning: useless precedence and associativity for RJUST [-Wprecedence] input.y:147.1-5: warning: useless precedence and associativity for RJUST [-Wprecedence]
input.y:147.1-5: warning: useless precedence and associativity for ABOVE [-Wprecedence] input.y:147.1-5: warning: useless precedence and associativity for ABOVE [-Wprecedence]
input.y:147.1-5: warning: useless precedence and associativity for BELOW [-Wprecedence] input.y:147.1-5: warning: useless precedence and associativity for BELOW [-Wprecedence]
input.y:176.1-5: warning: useless associativity for OF, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless associativity for UP, use %precedence [-Wprecedence]
input.y:176.1-5: warning: useless associativity for BETWEEN, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless associativity for DOWN, use %precedence [-Wprecedence]
input.y:177.1-5: warning: useless associativity for AND, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless precedence and associativity for SOLID [-Wprecedence]
input.y:157.1-5: warning: useless associativity for HERE, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless associativity for DOTTED, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_N, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless associativity for DASHED, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_E, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless associativity for CHOP, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_W, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless associativity for FILL, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_S, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless precedence and associativity for COLORED [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_NE, use %precedence [-Wprecedence] input.y:153.1-5: warning: useless precedence and associativity for OUTLINED [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_SE, use %precedence [-Wprecedence] input.y:154.1-5: warning: useless associativity for LABEL, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_NW, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for VARIABLE, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_SW, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for NUMBER, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_C, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for LAST, use %precedence [-Wprecedence]
input.y:167.1-5: warning: useless associativity for DOT_START, use %precedence [-Wprecedence]
input.y:167.1-5: warning: useless associativity for DOT_END, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for SIN, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for SIN, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for COS, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for COS, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for ATAN2, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for ATAN2, use %precedence [-Wprecedence]
@@ -2071,12 +2041,43 @@ input.y:156.1-5: warning: useless associativity for K_MIN, use %precedence [-Wpr
input.y:156.1-5: warning: useless associativity for INT, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for INT, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for RAND, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for RAND, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for SRAND, use %precedence [-Wprecedence] input.y:156.1-5: warning: useless associativity for SRAND, use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for '(', use %precedence [-Wprecedence]
input.y:157.1-5: warning: useless associativity for ORDINAL, use %precedence [-Wprecedence]
input.y:157.1-5: warning: useless associativity for HERE, use %precedence [-Wprecedence]
input.y:157.1-5: warning: useless associativity for '`', use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for BOX, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for CIRCLE, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for ELLIPSE, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for ARC, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for LINE, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for ARROW, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for SPLINE, use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for '@<:@', use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for HEIGHT, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for RADIUS, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for WIDTH, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for DIAMETER, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for FROM, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for TO, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for AT, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for THICKNESS, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_N, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_E, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_W, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_S, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_NE, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_SE, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_NW, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_SW, use %precedence [-Wprecedence]
input.y:166.1-5: warning: useless associativity for DOT_C, use %precedence [-Wprecedence]
input.y:167.1-5: warning: useless associativity for DOT_START, use %precedence [-Wprecedence]
input.y:167.1-5: warning: useless associativity for DOT_END, use %precedence [-Wprecedence]
input.y:167.1-5: warning: useless associativity for TOP, use %precedence [-Wprecedence] input.y:167.1-5: warning: useless associativity for TOP, use %precedence [-Wprecedence]
input.y:167.1-5: warning: useless associativity for BOTTOM, use %precedence [-Wprecedence] input.y:167.1-5: warning: useless associativity for BOTTOM, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for UPPER, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for LOWER, use %precedence [-Wprecedence]
input.y:167.1-5: warning: useless associativity for LEFT_CORNER, use %precedence [-Wprecedence] input.y:167.1-5: warning: useless associativity for LEFT_CORNER, use %precedence [-Wprecedence]
input.y:167.1-5: warning: useless associativity for RIGHT_CORNER, use %precedence [-Wprecedence] input.y:167.1-5: warning: useless associativity for RIGHT_CORNER, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for UPPER, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for LOWER, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for NORTH, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for NORTH, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for SOUTH, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for SOUTH, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for EAST, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for EAST, use %precedence [-Wprecedence]
@@ -2084,18 +2085,17 @@ input.y:168.1-5: warning: useless associativity for WEST, use %precedence [-Wpre
input.y:168.1-5: warning: useless associativity for CENTER, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for CENTER, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for END, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for END, use %precedence [-Wprecedence]
input.y:168.1-5: warning: useless associativity for START, use %precedence [-Wprecedence] input.y:168.1-5: warning: useless associativity for START, use %precedence [-Wprecedence]
input.y:140.1-5: warning: useless associativity for PLOT, use %precedence [-Wprecedence]
input.y:162.1-5: warning: useless associativity for THICKNESS, use %precedence [-Wprecedence]
input.y:153.1-5: warning: useless associativity for FILL, use %precedence [-Wprecedence]
input.y:153.1-5: warning: useless precedence and associativity for COLORED [-Wprecedence]
input.y:153.1-5: warning: useless precedence and associativity for OUTLINED [-Wprecedence]
input.y:141.1-5: warning: useless associativity for SPRINTF, use %precedence [-Wprecedence]
input.y:137.1-5: warning: useless associativity for '.', use %precedence [-Wprecedence]
input.y:156.1-5: warning: useless associativity for '(', use %precedence [-Wprecedence]
input.y:157.1-5: warning: useless associativity for '`', use %precedence [-Wprecedence]
input.y:159.1-5: warning: useless associativity for '@<:@', use %precedence [-Wprecedence]
input.y:170.1-5: warning: useless associativity for ',', use %precedence [-Wprecedence] input.y:170.1-5: warning: useless associativity for ',', use %precedence [-Wprecedence]
input.y:176.1-5: warning: useless associativity for OF, use %precedence [-Wprecedence]
input.y:176.1-5: warning: useless associativity for BETWEEN, use %precedence [-Wprecedence]
input.y:177.1-5: warning: useless associativity for AND, use %precedence [-Wprecedence]
input.y:181.1-6: warning: useless associativity for '!', use %precedence [-Wprecedence] input.y:181.1-6: warning: useless associativity for '!', use %precedence [-Wprecedence]
input.y:202.19: warning: empty rule without %empty [-Wempty-rule]
input.y:270.6: warning: empty rule without %empty [-Wempty-rule]
input.y:292.12: warning: empty rule without %empty [-Wempty-rule]
input.y:309.17: warning: empty rule without %empty [-Wempty-rule]
input.y:382.13: warning: empty rule without %empty [-Wempty-rule]
input.y:471.11-48: warning: rule useless in parser due to conflicts [-Wother]
]], ]],
dnl LAST-STATE dnl LAST-STATE
+55 -54
View File
@@ -64,13 +64,14 @@ AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]])
AT_BISON_CHECK([input.y], [1], [], AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.1-2: error: invalid characters: '\0\001\002\377?' [[input.y:1.1-2: error: invalid characters: '\0\001\002\377?'
input.y:3.1: error: invalid character: '?' input.y:3.1: error: invalid character: '?'
input.y:4.14: error: syntax error, unexpected } input.y:4.14: error: invalid character: '}'
input.y:5.1: error: invalid character: '%' input.y:5.1: error: invalid character: '%'
input.y:5.2: error: invalid character: '&' input.y:5.2: error: invalid character: '&'
input.y:6.1-17: error: invalid directive: '%a-does-not-exist' input.y:6.1-17: error: invalid directive: '%a-does-not-exist'
input.y:7.1: error: invalid character: '%' input.y:7.1: error: invalid character: '%'
input.y:7.2: error: invalid character: '-' input.y:7.2: error: invalid character: '-'
input.y:8.1-9.0: error: missing '%}' at end of file input.y:8.1-9.0: error: missing '%}' at end of file
input.y:8.1-9.0: error: syntax error, unexpected %{...%}
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -141,15 +142,15 @@ exp: foo { $$; } foo { $2; } foo
]]) ]])
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type [[input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
exp: foo { $$; } foo { $2; } foo
^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
exp: foo { $$; } foo { $2; } foo exp: foo { $$; } foo { $2; } foo
^^ ^^
input.y:5.24-25: error: $2 of 'exp' has no declared type input.y:5.24-25: error: $2 of 'exp' has no declared type
exp: foo { $$; } foo { $2; } foo exp: foo { $$; } foo { $2; } foo
^^ ^^
input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
exp: foo { $$; } foo { $2; } foo
^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother] input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother]
| foo | foo
^^^ ^^^
@@ -207,12 +208,12 @@ _AT_UNUSED_VALUES_DECLARATIONS])
AT_BISON_CHECK(m4_ifval($2, [--warnings=midrule-values ])[-fcaret input.y], AT_BISON_CHECK(m4_ifval($2, [--warnings=midrule-values ])[-fcaret input.y],
[0], [], [0], [],
[[input.y:11.10-32: warning: unset value: $][$ [-Wother] [[input.y:11.10-12: warning: unused value: $][1 [-Wother]
a: INT | INT { } INT { } INT { };
^^^^^^^^^^^^^^^^^^^^^^^
input.y:11.10-12: warning: unused value: $][1 [-Wother]
a: INT | INT { } INT { } INT { }; a: INT | INT { } INT { } INT { };
^^^ ^^^
input.y:11.10-32: warning: unset value: $][$ [-Wother]
a: INT | INT { } INT { } INT { };
^^^^^^^^^^^^^^^^^^^^^^^
input.y:11.18-20: warning: unused value: $][3 [-Wother] input.y:11.18-20: warning: unused value: $][3 [-Wother]
a: INT | INT { } INT { } INT { }; a: INT | INT { } INT { } INT { };
^^^ ^^^
@@ -222,28 +223,28 @@ input.y:11.26-28: warning: unused value: $][5 [-Wother]
input.y:12.10-15: warning: empty rule for typed nonterminal, and no action [-Wother] input.y:12.10-15: warning: empty rule for typed nonterminal, and no action [-Wother]
b: INT | %empty; b: INT | %empty;
^^^^^^ ^^^^^^
input.y:13.10-62: warning: unset value: $][$ [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$ [-Wmidrule-values] ]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; }; c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^ ^^^^^^^
input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values] ]]])[[input.y:13.22-24: warning: unused value: $][3 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^
]]])[[input.y:13.10-62: warning: unset value: $][$ [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:13.22-24: warning: unused value: $][3 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; }; c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^ ^^^
input.y:13.43-45: warning: unused value: $][5 [-Wother] ]]m4_ifval($2, [[[input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^
]]])[[input.y:13.43-45: warning: unused value: $][5 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; }; c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^ ^^^
input.y:14.10-49: warning: unset value: $][$ [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$ [-Wmidrule-values] ]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$ [-Wmidrule-values]
d: INT | INT { } INT { $][1; } INT { $<integer>2; }; d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^ ^^^
]]])[[input.y:14.10-49: warning: unset value: $][$ [-Wother] ]]])[[input.y:14.18-20: warning: unused value: $][3 [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:14.18-20: warning: unused value: $][3 [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; }; d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^ ^^^
input.y:14.30-32: warning: unused value: $][5 [-Wother] input.y:14.30-32: warning: unused value: $][5 [-Wother]
@@ -258,12 +259,12 @@ input.y:15.18-20: warning: unused value: $][3 [-Wother]
input.y:15.27-29: warning: unused value: $][5 [-Wother] input.y:15.27-29: warning: unused value: $][5 [-Wother]
e: INT | INT { } INT { } INT { $][1; }; e: INT | INT { } INT { } INT { $][1; };
^^^ ^^^
input.y:17.10-58: warning: unset value: $][$ [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:17.10-12: warning: unused value: $][1 [-Wother] input.y:17.10-12: warning: unused value: $][1 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^ ^^^
input.y:17.10-58: warning: unset value: $][$ [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2 [-Wmidrule-values] ]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2 [-Wmidrule-values]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
@@ -276,12 +277,12 @@ input.y:17.10-12: warning: unused value: $][1 [-Wother]
]]])[[input.y:17.52-54: warning: unused value: $][5 [-Wother] ]]])[[input.y:17.52-54: warning: unused value: $][5 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { }; g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^ ^^^
input.y:18.10-72: warning: unset value: $][$ [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:18.10-12: warning: unused value: $][1 [-Wother] input.y:18.10-12: warning: unused value: $][1 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { }; h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^ ^^^
input.y:18.10-72: warning: unset value: $][$ [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:18.31-33: warning: unused value: $][3 [-Wother] input.y:18.31-33: warning: unused value: $][3 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { }; h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^ ^^^
@@ -294,12 +295,12 @@ input.y:18.31-33: warning: unused value: $][3 [-Wother]
]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3 [-Wmidrule-values] ]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3 [-Wmidrule-values]
j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; }; j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; };
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
]]])[[input.y:21.10-68: warning: unset value: $][$ [-Wother] ]]])[[input.y:21.10-12: warning: unused value: $][1 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:21.10-12: warning: unused value: $][1 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { }; k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^ ^^^
input.y:21.10-68: warning: unset value: $][$ [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:21.14-16: warning: unused value: $][2 [-Wother] input.y:21.14-16: warning: unused value: $][2 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { }; k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^ ^^^
@@ -457,15 +458,15 @@ exp: bar;
]]) ]])
AT_BISON_CHECK([-fcaret input.y], [1], [], AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules [[input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
%destructor {} bar %printer {} foo baz
^^^ ^^^
input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother] input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
%printer {} foo baz %printer {} foo baz
^^^ ^^^
input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother] input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
%printer {} foo baz %destructor {} bar
^^^ ^^^
input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother] input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
%type <foo> qux %type <foo> qux
^^^ ^^^
@@ -1416,9 +1417,9 @@ start: TOK;
AT_BISON_CHECK([[input.yy]], [0], [], AT_BISON_CHECK([[input.yy]], [0], [],
[[input.yy:2.9-25: warning: %define variable 'api.location.type' requires '{...}' values [-Wdeprecated] [[input.yy:2.9-25: warning: %define variable 'api.location.type' requires '{...}' values [-Wdeprecated]
input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
input.yy:4.9-18: warning: %define variable 'api.prefix' requires '{...}' values [-Wdeprecated] input.yy:4.9-18: warning: %define variable 'api.prefix' requires '{...}' values [-Wdeprecated]
input.yy:5.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated] input.yy:5.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated]
input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
]]) ]])
]) ])
@@ -1447,11 +1448,11 @@ exp: %empty
]]) ]])
AT_BISON_CHECK([[input.y]], [0], [], AT_BISON_CHECK([[input.y]], [0], [],
[[input.y:5.9-15: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated] [[input.y:1.9-16: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated]
input.y:2.9-21: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated]
input.y:3.9-28: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated] input.y:3.9-28: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated]
input.y:4.9-33: warning: %define variable 'lr.keep-unreachable-state' requires keyword values [-Wdeprecated] input.y:4.9-33: warning: %define variable 'lr.keep-unreachable-state' requires keyword values [-Wdeprecated]
input.y:2.9-21: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated] input.y:5.9-15: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated]
input.y:1.9-16: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated]
]]) ]])
]) ])
@@ -1716,26 +1717,26 @@ AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
|| exit 77]]) || exit 77]])
AT_BISON_CHECK([input.y], [1], [], AT_BISON_CHECK([input.y], [1], [],
[[input.y:2.9-12: error: invalid number after \-escape: 777 [[input.y:2.8-13: warning: empty character literal [-Wother]
input.y:2.8-13: warning: empty character literal [-Wother] input.y:2.9-12: error: invalid number after \-escape: 777
input.y:2.16-17: error: invalid number after \-escape: 0
input.y:2.15-18: warning: empty character literal [-Wother] input.y:2.15-18: warning: empty character literal [-Wother]
input.y:2.21-25: error: invalid number after \-escape: xfff input.y:2.16-17: error: invalid number after \-escape: 0
input.y:2.20-26: warning: empty character literal [-Wother] input.y:2.20-26: warning: empty character literal [-Wother]
input.y:2.29-31: error: invalid number after \-escape: x0 input.y:2.21-25: error: invalid number after \-escape: xfff
input.y:2.28-32: warning: empty character literal [-Wother] input.y:2.28-32: warning: empty character literal [-Wother]
input.y:3.9-14: error: invalid number after \-escape: uffff input.y:2.29-31: error: invalid number after \-escape: x0
input.y:3.8-15: warning: empty character literal [-Wother] input.y:3.8-15: warning: empty character literal [-Wother]
input.y:3.18-23: error: invalid number after \-escape: u0000 input.y:3.9-14: error: invalid number after \-escape: uffff
input.y:3.17-24: warning: empty character literal [-Wother] input.y:3.17-24: warning: empty character literal [-Wother]
input.y:3.27-36: error: invalid number after \-escape: Uffffffff input.y:3.18-23: error: invalid number after \-escape: u0000
input.y:3.26-37: warning: empty character literal [-Wother] input.y:3.26-37: warning: empty character literal [-Wother]
input.y:3.40-49: error: invalid number after \-escape: U00000000 input.y:3.27-36: error: invalid number after \-escape: Uffffffff
input.y:3.39-50: warning: empty character literal [-Wother] input.y:3.39-50: warning: empty character literal [-Wother]
input.y:4.9-10: error: invalid character after \-escape: ' ' input.y:3.40-49: error: invalid number after \-escape: U00000000
input.y:4.8-11: warning: empty character literal [-Wother] input.y:4.8-11: warning: empty character literal [-Wother]
input.y:4.14-15: error: invalid character after \-escape: A input.y:4.9-10: error: invalid character after \-escape: ' '
input.y:4.13-16: warning: empty character literal [-Wother] input.y:4.13-16: warning: empty character literal [-Wother]
input.y:4.14-15: error: invalid character after \-escape: A
input.y:5.9-16: error: invalid character after \-escape: \t input.y:5.9-16: error: invalid character after \-escape: \t
input.y:5.17: error: invalid character after \-escape: \f input.y:5.17: error: invalid character after \-escape: \f
input.y:5.18: error: invalid character after \-escape: \0 input.y:5.18: error: invalid character after \-escape: \0
@@ -2006,12 +2007,12 @@ AT_BISON_CHECK([[input.y]], [[1]], [[]],
input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:13.11-21: error: %define variable 'parse.error' redefined input.y:13.11-21: error: %define variable 'parse.error' redefined
input.y:13-6: previous definition input.y:13-6: previous definition
input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:14.11-21: error: %define variable 'parse.error' redefined input.y:14.11-21: error: %define variable 'parse.error' redefined
input.y:13.11-21: previous definition input.y:13.11-21: previous definition
input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
]]) ]])
AT_CLEANUP AT_CLEANUP
+41 -41
View File
@@ -88,8 +88,7 @@ exp: useful;
]]) ]])
AT_BISON_CHECK([[input.y]], 0, [], AT_BISON_CHECK([[input.y]], 0, [],
[[input.y: warning: 9 nonterminals useless in grammar [-Wother] [[input.y:4.8-15: warning: nonterminal useless in grammar: useless1 [-Wother]
input.y:4.8-15: warning: nonterminal useless in grammar: useless1 [-Wother]
input.y:5.8-15: warning: nonterminal useless in grammar: useless2 [-Wother] input.y:5.8-15: warning: nonterminal useless in grammar: useless2 [-Wother]
input.y:6.8-15: warning: nonterminal useless in grammar: useless3 [-Wother] input.y:6.8-15: warning: nonterminal useless in grammar: useless3 [-Wother]
input.y:7.8-15: warning: nonterminal useless in grammar: useless4 [-Wother] input.y:7.8-15: warning: nonterminal useless in grammar: useless4 [-Wother]
@@ -98,6 +97,7 @@ input.y:9.8-15: warning: nonterminal useless in grammar: useless6 [-Wother]
input.y:10.8-15: warning: nonterminal useless in grammar: useless7 [-Wother] input.y:10.8-15: warning: nonterminal useless in grammar: useless7 [-Wother]
input.y:11.8-15: warning: nonterminal useless in grammar: useless8 [-Wother] input.y:11.8-15: warning: nonterminal useless in grammar: useless8 [-Wother]
input.y:12.8-15: warning: nonterminal useless in grammar: useless9 [-Wother] input.y:12.8-15: warning: nonterminal useless in grammar: useless9 [-Wother]
input.y: warning: 9 nonterminals useless in grammar [-Wother]
]]) ]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0,
@@ -143,62 +143,62 @@ useless9: '9';
]]) ]])
AT_BISON_CHECK([[-fcaret input.y]], 0, [], AT_BISON_CHECK([[-fcaret input.y]], 0, [],
[[input.y: warning: 9 nonterminals useless in grammar [-Wother] [[input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother]
input.y: warning: 9 rules useless in grammar [-Wother]
input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother]
useless1: '1'; useless1: '1';
^^^^^^^^ ^^^^^^^^
input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother]
useless2: '2';
^^^^^^^^
input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother]
useless3: '3';
^^^^^^^^
input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother]
useless4: '4';
^^^^^^^^
input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother]
useless5: '5';
^^^^^^^^
input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother]
useless6: '6';
^^^^^^^^
input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother]
useless7: '7';
^^^^^^^^
input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother]
useless8: '8';
^^^^^^^^
input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother]
useless9: '9';
^^^^^^^^
input.y:6.11-13: warning: rule useless in grammar [-Wother] input.y:6.11-13: warning: rule useless in grammar [-Wother]
useless1: '1'; useless1: '1';
^^^ ^^^
input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother]
useless2: '2';
^^^^^^^^
input.y:7.11-13: warning: rule useless in grammar [-Wother] input.y:7.11-13: warning: rule useless in grammar [-Wother]
useless2: '2'; useless2: '2';
^^^ ^^^
input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother]
useless3: '3';
^^^^^^^^
input.y:8.11-13: warning: rule useless in grammar [-Wother] input.y:8.11-13: warning: rule useless in grammar [-Wother]
useless3: '3'; useless3: '3';
^^^ ^^^
input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother]
useless4: '4';
^^^^^^^^
input.y:9.11-13: warning: rule useless in grammar [-Wother] input.y:9.11-13: warning: rule useless in grammar [-Wother]
useless4: '4'; useless4: '4';
^^^ ^^^
input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother]
useless5: '5';
^^^^^^^^
input.y:10.11-13: warning: rule useless in grammar [-Wother] input.y:10.11-13: warning: rule useless in grammar [-Wother]
useless5: '5'; useless5: '5';
^^^ ^^^
input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother]
useless6: '6';
^^^^^^^^
input.y:11.11-13: warning: rule useless in grammar [-Wother] input.y:11.11-13: warning: rule useless in grammar [-Wother]
useless6: '6'; useless6: '6';
^^^ ^^^
input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother]
useless7: '7';
^^^^^^^^
input.y:12.11-13: warning: rule useless in grammar [-Wother] input.y:12.11-13: warning: rule useless in grammar [-Wother]
useless7: '7'; useless7: '7';
^^^ ^^^
input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother]
useless8: '8';
^^^^^^^^
input.y:13.11-13: warning: rule useless in grammar [-Wother] input.y:13.11-13: warning: rule useless in grammar [-Wother]
useless8: '8'; useless8: '8';
^^^ ^^^
input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother]
useless9: '9';
^^^^^^^^
input.y:14.11-13: warning: rule useless in grammar [-Wother] input.y:14.11-13: warning: rule useless in grammar [-Wother]
useless9: '9'; useless9: '9';
^^^ ^^^
input.y: warning: 9 nonterminals useless in grammar [-Wother]
input.y: warning: 9 rules useless in grammar [-Wother]
]]) ]])
@@ -276,23 +276,23 @@ non_productive: non_productive useless_token
]]) ]])
AT_BISON_CHECK([[-fcaret not-reduced.y]], 0, [], AT_BISON_CHECK([[-fcaret not-reduced.y]], 0, [],
[[not-reduced.y: warning: 2 nonterminals useless in grammar [-Wother] [[not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive [-Wother]
not-reduced.y: warning: 3 rules useless in grammar [-Wother]
not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother]
not_reachable: useful { /* A not reachable action. */ }
^^^^^^^^^^^^^
not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive [-Wother]
| non_productive { /* A non productive action. */ } | non_productive { /* A non productive action. */ }
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
not-reduced.y:11.6-57: warning: rule useless in grammar [-Wother] not-reduced.y:11.6-57: warning: rule useless in grammar [-Wother]
| non_productive { /* A non productive action. */ } | non_productive { /* A non productive action. */ }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother]
not_reachable: useful { /* A not reachable action. */ }
^^^^^^^^^^^^^
not-reduced.y:14.16-56: warning: rule useless in grammar [-Wother] not-reduced.y:14.16-56: warning: rule useless in grammar [-Wother]
not_reachable: useful { /* A not reachable action. */ } not_reachable: useful { /* A not reachable action. */ }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
not-reduced.y:17.17-18.63: warning: rule useless in grammar [-Wother] not-reduced.y:17.17-18.63: warning: rule useless in grammar [-Wother]
non_productive: non_productive useless_token non_productive: non_productive useless_token
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
not-reduced.y: warning: 2 nonterminals useless in grammar [-Wother]
not-reduced.y: warning: 3 rules useless in grammar [-Wother]
]]) ]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' not-reduced.output]], 0, AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' not-reduced.output]], 0,
@@ -361,13 +361,13 @@ indirection: underivable;
]]) ]])
AT_BISON_CHECK([[input.y]], 0, [], AT_BISON_CHECK([[input.y]], 0, [],
[[input.y: warning: 2 nonterminals useless in grammar [-Wother] [[input.y:5.15-25: warning: nonterminal useless in grammar: underivable [-Wother]
input.y: warning: 3 rules useless in grammar [-Wother]
input.y:5.15-25: warning: nonterminal useless in grammar: underivable [-Wother]
input.y:6.14-24: warning: nonterminal useless in grammar: indirection [-Wother]
input.y:5.15-25: warning: rule useless in grammar [-Wother] input.y:5.15-25: warning: rule useless in grammar [-Wother]
input.y:6.14-24: warning: nonterminal useless in grammar: indirection [-Wother]
input.y:6.14-24: warning: rule useless in grammar [-Wother] input.y:6.14-24: warning: rule useless in grammar [-Wother]
input.y:7.14-24: warning: rule useless in grammar [-Wother] input.y:7.14-24: warning: rule useless in grammar [-Wother]
input.y: warning: 2 nonterminals useless in grammar [-Wother]
input.y: warning: 3 rules useless in grammar [-Wother]
]]) ]])
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0,
@@ -397,9 +397,9 @@ exp: exp;
]]) ]])
AT_BISON_CHECK([[input.y]], 1, [], AT_BISON_CHECK([[input.y]], 1, [],
[[input.y: warning: 2 nonterminals useless in grammar [-Wother] [[input.y:3.1-3: fatal error: start symbol exp does not derive any sentence
input.y: warning: 2 nonterminals useless in grammar [-Wother]
input.y: warning: 2 rules useless in grammar [-Wother] input.y: warning: 2 rules useless in grammar [-Wother]
input.y:3.1-3: fatal error: start symbol exp does not derive any sentence
]]) ]])
AT_CLEANUP AT_CLEANUP
+4 -3
View File
@@ -405,13 +405,14 @@ default: 'a' }
AT_BISON_CHECK([input.y], [1], [], AT_BISON_CHECK([input.y], [1], [],
[[input.y:2.1: error: invalid character: '?' [[input.y:2.1: error: invalid character: '?'
input.y:3.14: error: syntax error, unexpected } input.y:3.14: error: invalid character: '}'
input.y:4.1: error: invalid character: '%' input.y:4.1: error: invalid character: '%'
input.y:4.2: error: invalid character: '&' input.y:4.2: error: invalid character: '&'
input.y:5.1-17: error: invalid directive: '%a-does-not-exist' input.y:5.1-17: error: invalid directive: '%a-does-not-exist'
input.y:6.1: error: invalid character: '%' input.y:6.1: error: invalid character: '%'
input.y:6.2: error: invalid character: '-' input.y:6.2: error: invalid character: '-'
input.y:7.1-8.0: error: missing '%}' at end of file input.y:7.1-8.0: error: missing '%}' at end of file
input.y:7.1-8.0: error: syntax error, unexpected %{...%}
]]) ]])
AT_CLEANUP AT_CLEANUP
@@ -1146,9 +1147,9 @@ sr_conflict:
]]) ]])
AT_BISON_CHECK([[-Wall -o input.c input.y]], [[0]],, AT_BISON_CHECK([[-Wall -o input.c input.y]], [[0]],,
[[input.y:24.5-19: warning: rule useless in parser due to conflicts [-Wother] [[input.y:18.1-5: warning: useless precedence and associativity for TK1 [-Wprecedence]
input.y:24.5-19: warning: rule useless in parser due to conflicts [-Wother]
input.y:28.5-19: warning: rule useless in parser due to conflicts [-Wother] input.y:28.5-19: warning: rule useless in parser due to conflicts [-Wother]
input.y:18.1-5: warning: useless precedence and associativity for TK1 [-Wprecedence]
]]) ]])
AT_COMPILE([[input]]) AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]]) AT_PARSER_CHECK([[./input]])
+4 -4
View File
@@ -186,10 +186,10 @@ start: ;
]]) ]])
AT_BISON_CHECK([[input1.y]], [[1]], [[]], AT_BISON_CHECK([[input1.y]], [[1]], [[]],
[[input1.y: warning: foow fubar [-Wother] [[fooc.y:1.1-10.5: error: foocat fubar
foow.y:2.3-5.3: warning: foowat fubar [-Wother] foow.y:2.3-5.3: warning: foowat fubar [-Wother]
input1.y: warning: foow fubar [-Wother]
input1.y: error: fooc fubar input1.y: error: fooc fubar
fooc.y:1.1-10.5: error: foocat fubar
input1.y: fatal error: foof fubar input1.y: fatal error: foof fubar
]]) ]])
@@ -276,8 +276,8 @@ start: ;
]]) ]])
AT_BISON_CHECK([[input2.y]], [[1]], [[]], AT_BISON_CHECK([[input2.y]], [[1]], [[]],
[[input2.y: warning: morning [-Wother] [[foo.y:1.5-6: fatal error: M4 should exit immediately here
foo.y:1.5-6: fatal error: M4 should exit immediately here input2.y: warning: morning [-Wother]
]]) ]])
AT_CLEANUP AT_CLEANUP