Adjust all former `associativity' dependencies.
* src/symtab.c (symbol_new): Default associativity is `undef', not
`right'.
(symbol_check_alias_consistence): Adjust.
+2002-07-16 Akim Demaille <akim@epita.fr>
+
+ * src/assoc.c, src/asssoc.h (assoc_t, assoc_to_string): New.
+ Adjust all former `associativity' dependencies.
+ * src/symtab.c (symbol_new): Default associativity is `undef', not
+ `right'.
+ (symbol_check_alias_consistence): Adjust.
+
2002-07-09 Akim Demaille <akim@epita.fr>
* doc/bison.texinfo: Properly set the ``header'' part.
bison_SOURCES = \
LR0.c LR0.h \
+ assoc.c assoc.h \
closure.c closure.h \
complain.c complain.h \
conflicts.c conflicts.h \
--- /dev/null
+/* Associativity information.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+ This file is part of Bison, the GNU Compiler Compiler.
+
+ Bison is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bison is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bison; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "system.h"
+#include "assoc.h"
+
+
+const char *
+assoc_to_string (assoc_t assoc)
+{
+ switch (assoc)
+ {
+ case undef_assoc:
+ return "undefined associativity";
+
+ case right_assoc:
+ return "%right";
+
+ case left_assoc:
+ return "%left";
+
+ case non_assoc:
+ return "%nonassoc";
+ }
+ return NULL;
+}
--- /dev/null
+/* Associativity information.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+ This file is part of Bison, the GNU Compiler Compiler.
+
+ Bison is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bison is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bison; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef ASSOC_H_
+# define ASSOC_H_
+
+/* Associativity values for tokens and rules. */
+typedef enum
+{
+ undef_assoc,
+ right_assoc,
+ left_assoc,
+ non_assoc
+} assoc_t;
+
+const char *assoc_to_string PARAMS ((assoc_t assoc));
+
+#endif /* !ASSOC_H_ */
char *current_type = 0;
symbol_t *current_lhs;
location_t current_lhs_location;
-associativity current_assoc;
+assoc_t current_assoc;
int current_prec = 0;
braced_code_t current_braced_code = action_braced_code;
symbol_list_t *list;
int integer;
char *string;
- associativity assoc;
+ assoc_t assoc;
} yystype;
/* Line 187 of /usr/local/share/bison/yacc.c. */
#line 238 "parse-gram.c"
symbol_list_t *list;
int integer;
char *string;
- associativity assoc;
+ assoc_t assoc;
} yystype;
/* Line 1271 of /usr/local/share/bison/yacc.c. */
#line 141 "y.tab.h"
char *current_type = 0;
symbol_t *current_lhs;
location_t current_lhs_location;
-associativity current_assoc;
+assoc_t current_assoc;
int current_prec = 0;
braced_code_t current_braced_code = action_braced_code;
%}
symbol_list_t *list;
int integer;
char *string;
- associativity assoc;
+ assoc_t assoc;
};
/* Define the tokens together with there human representation. */
res->number = NUMBER_UNDEFINED;
res->prec = 0;
- res->assoc = right_assoc;
+ res->assoc = undef_assoc;
res->user_token_number = USER_NUMBER_UNDEFINED;
res->alias = NULL;
void
symbol_precedence_set (symbol_t *symbol,
- int prec, associativity assoc, location_t location)
+ int prec, assoc_t assoc, location_t location)
{
if (assoc != undef_assoc)
{
if (this->assoc != this->alias->assoc)
{
- /* FIXME: For some reason (probably the S/R => keep the S),
- the right assoc is chosen has the ``not set''. This is
- not nice, fix this! */
- if (this->assoc != right_assoc
- && this->alias->assoc != right_assoc)
+ if (this->assoc != undef_assoc && this->alias->assoc != undef_assoc)
complain_at (this->alias->location,
- _("conflicting associativities for %s and %s"),
- this->tag, this->alias->tag);
- if (this->assoc != 0)
+ _("conflicting associativities for %s (%s) and %s (%s)"),
+ this->tag, assoc_to_string (this->assoc),
+ this->alias->tag, assoc_to_string (this->alias->assoc));
+ if (this->assoc != undef_assoc)
this->alias->assoc = this->assoc;
else
this->assoc = this->alias->assoc;
# define SYMTAB_H_
# include "location.h"
+# include "assoc.h"
/*----------.
| Symbols. |
`----------*/
-/* Associativity values for tokens and rules. */
-typedef enum
-{
- undef_assoc,
- right_assoc,
- left_assoc,
- non_assoc
-} associativity;
-
-
/* Symbol classes. */
typedef enum
{
symbol_number_t number;
short prec;
- associativity assoc;
+ assoc_t assoc;
int user_token_number;
/* Points to the other in the identifier-symbol pair for an alias.
/* Set the PRECEDENCE associated to SYMBOL. Ensures that SYMBOL is a
terminal. Does nothing if invoked with UNDEF_ASSOC as ASSOC. */
void symbol_precedence_set PARAMS ((symbol_t *symbol,
- int prec, associativity assoc,
+ int prec, assoc_t assoc,
location_t location));
/* Set the CLASS associated to SYMBOL. */