mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 08:13:02 +00:00
* 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.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
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>
|
2002-07-09 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* doc/bison.texinfo: Properly set the ``header'' part.
|
* doc/bison.texinfo: Properly set the ``header'' part.
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ bin_PROGRAMS = bison
|
|||||||
|
|
||||||
bison_SOURCES = \
|
bison_SOURCES = \
|
||||||
LR0.c LR0.h \
|
LR0.c LR0.h \
|
||||||
|
assoc.c assoc.h \
|
||||||
closure.c closure.h \
|
closure.c closure.h \
|
||||||
complain.c complain.h \
|
complain.c complain.h \
|
||||||
conflicts.c conflicts.h \
|
conflicts.c conflicts.h \
|
||||||
|
|||||||
43
src/assoc.c
Normal file
43
src/assoc.c
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
||||||
35
src/assoc.h
Normal file
35
src/assoc.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/* 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_ */
|
||||||
@@ -105,7 +105,7 @@ symbol_class current_class = unknown_sym;
|
|||||||
char *current_type = 0;
|
char *current_type = 0;
|
||||||
symbol_t *current_lhs;
|
symbol_t *current_lhs;
|
||||||
location_t current_lhs_location;
|
location_t current_lhs_location;
|
||||||
associativity current_assoc;
|
assoc_t current_assoc;
|
||||||
int current_prec = 0;
|
int current_prec = 0;
|
||||||
braced_code_t current_braced_code = action_braced_code;
|
braced_code_t current_braced_code = action_braced_code;
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ typedef union {
|
|||||||
symbol_list_t *list;
|
symbol_list_t *list;
|
||||||
int integer;
|
int integer;
|
||||||
char *string;
|
char *string;
|
||||||
associativity assoc;
|
assoc_t assoc;
|
||||||
} yystype;
|
} yystype;
|
||||||
/* Line 187 of /usr/local/share/bison/yacc.c. */
|
/* Line 187 of /usr/local/share/bison/yacc.c. */
|
||||||
#line 238 "parse-gram.c"
|
#line 238 "parse-gram.c"
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ typedef union {
|
|||||||
symbol_list_t *list;
|
symbol_list_t *list;
|
||||||
int integer;
|
int integer;
|
||||||
char *string;
|
char *string;
|
||||||
associativity assoc;
|
assoc_t assoc;
|
||||||
} yystype;
|
} yystype;
|
||||||
/* Line 1271 of /usr/local/share/bison/yacc.c. */
|
/* Line 1271 of /usr/local/share/bison/yacc.c. */
|
||||||
#line 141 "y.tab.h"
|
#line 141 "y.tab.h"
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ symbol_class current_class = unknown_sym;
|
|||||||
char *current_type = 0;
|
char *current_type = 0;
|
||||||
symbol_t *current_lhs;
|
symbol_t *current_lhs;
|
||||||
location_t current_lhs_location;
|
location_t current_lhs_location;
|
||||||
associativity current_assoc;
|
assoc_t current_assoc;
|
||||||
int current_prec = 0;
|
int current_prec = 0;
|
||||||
braced_code_t current_braced_code = action_braced_code;
|
braced_code_t current_braced_code = action_braced_code;
|
||||||
%}
|
%}
|
||||||
@@ -91,7 +91,7 @@ braced_code_t current_braced_code = action_braced_code;
|
|||||||
symbol_list_t *list;
|
symbol_list_t *list;
|
||||||
int integer;
|
int integer;
|
||||||
char *string;
|
char *string;
|
||||||
associativity assoc;
|
assoc_t assoc;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Define the tokens together with there human representation. */
|
/* Define the tokens together with there human representation. */
|
||||||
|
|||||||
17
src/symtab.c
17
src/symtab.c
@@ -55,7 +55,7 @@ symbol_new (const char *tag, location_t location)
|
|||||||
|
|
||||||
res->number = NUMBER_UNDEFINED;
|
res->number = NUMBER_UNDEFINED;
|
||||||
res->prec = 0;
|
res->prec = 0;
|
||||||
res->assoc = right_assoc;
|
res->assoc = undef_assoc;
|
||||||
res->user_token_number = USER_NUMBER_UNDEFINED;
|
res->user_token_number = USER_NUMBER_UNDEFINED;
|
||||||
|
|
||||||
res->alias = NULL;
|
res->alias = NULL;
|
||||||
@@ -129,7 +129,7 @@ symbol_printer_set (symbol_t *symbol, char *printer, location_t location)
|
|||||||
|
|
||||||
void
|
void
|
||||||
symbol_precedence_set (symbol_t *symbol,
|
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 (assoc != undef_assoc)
|
||||||
{
|
{
|
||||||
@@ -288,15 +288,12 @@ symbol_check_alias_consistence (symbol_t *this)
|
|||||||
|
|
||||||
if (this->assoc != this->alias->assoc)
|
if (this->assoc != this->alias->assoc)
|
||||||
{
|
{
|
||||||
/* FIXME: For some reason (probably the S/R => keep the S),
|
if (this->assoc != undef_assoc && this->alias->assoc != undef_assoc)
|
||||||
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)
|
|
||||||
complain_at (this->alias->location,
|
complain_at (this->alias->location,
|
||||||
_("conflicting associativities for %s and %s"),
|
_("conflicting associativities for %s (%s) and %s (%s)"),
|
||||||
this->tag, this->alias->tag);
|
this->tag, assoc_to_string (this->assoc),
|
||||||
if (this->assoc != 0)
|
this->alias->tag, assoc_to_string (this->alias->assoc));
|
||||||
|
if (this->assoc != undef_assoc)
|
||||||
this->alias->assoc = this->assoc;
|
this->alias->assoc = this->assoc;
|
||||||
else
|
else
|
||||||
this->assoc = this->alias->assoc;
|
this->assoc = this->alias->assoc;
|
||||||
|
|||||||
15
src/symtab.h
15
src/symtab.h
@@ -23,21 +23,12 @@
|
|||||||
# define SYMTAB_H_
|
# define SYMTAB_H_
|
||||||
|
|
||||||
# include "location.h"
|
# include "location.h"
|
||||||
|
# include "assoc.h"
|
||||||
|
|
||||||
/*----------.
|
/*----------.
|
||||||
| Symbols. |
|
| Symbols. |
|
||||||
`----------*/
|
`----------*/
|
||||||
|
|
||||||
/* Associativity values for tokens and rules. */
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
undef_assoc,
|
|
||||||
right_assoc,
|
|
||||||
left_assoc,
|
|
||||||
non_assoc
|
|
||||||
} associativity;
|
|
||||||
|
|
||||||
|
|
||||||
/* Symbol classes. */
|
/* Symbol classes. */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -68,7 +59,7 @@ struct symbol_s
|
|||||||
|
|
||||||
symbol_number_t number;
|
symbol_number_t number;
|
||||||
short prec;
|
short prec;
|
||||||
associativity assoc;
|
assoc_t assoc;
|
||||||
int user_token_number;
|
int user_token_number;
|
||||||
|
|
||||||
/* Points to the other in the identifier-symbol pair for an alias.
|
/* Points to the other in the identifier-symbol pair for an alias.
|
||||||
@@ -118,7 +109,7 @@ void symbol_printer_set PARAMS ((symbol_t *symbol,
|
|||||||
/* Set the PRECEDENCE associated to SYMBOL. Ensures that SYMBOL is a
|
/* Set the PRECEDENCE associated to SYMBOL. Ensures that SYMBOL is a
|
||||||
terminal. Does nothing if invoked with UNDEF_ASSOC as ASSOC. */
|
terminal. Does nothing if invoked with UNDEF_ASSOC as ASSOC. */
|
||||||
void symbol_precedence_set PARAMS ((symbol_t *symbol,
|
void symbol_precedence_set PARAMS ((symbol_t *symbol,
|
||||||
int prec, associativity assoc,
|
int prec, assoc_t assoc,
|
||||||
location_t location));
|
location_t location));
|
||||||
|
|
||||||
/* Set the CLASS associated to SYMBOL. */
|
/* Set the CLASS associated to SYMBOL. */
|
||||||
|
|||||||
Reference in New Issue
Block a user