/[bison]/bison/src/parse-gram.y
ViewVC logotype

Diff of /bison/src/parse-gram.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by akim, Sat Jun 15 18:26:45 2002 UTC revision 1.9 by akim, Mon Jun 17 07:04:24 2002 UTC
# Line 88  int current_prec = 0; Line 88  int current_prec = 0;
88  %union  %union
89  {  {
90    symbol_t *symbol;    symbol_t *symbol;
91      symbol_list *list;
92    int integer;    int integer;
93    char *string;    char *string;
94    associativity assoc;    associativity assoc;
# Line 144  int current_prec = 0; Line 145  int current_prec = 0;
145  %type <integer> INT  %type <integer> INT
146  %type <symbol> ID symbol string_as_id  %type <symbol> ID symbol string_as_id
147  %type <assoc> precedence_declarator  %type <assoc> precedence_declarator
148    %type <list>  symbols.1
149  %%  %%
150    
151  input:  input:
# Line 211  symbol_declaration: Line 212  symbol_declaration:
212        current_class = unknown_sym;        current_class = unknown_sym;
213        current_type = NULL;        current_type = NULL;
214      }      }
215  | "%type" TYPE {current_type = $2; } nterms_to_type.1  | "%type" TYPE symbols.1
216      {      {
217        current_type = NULL;        symbol_list *list;
218          for (list = $3; list; list = list->next)
219            symbol_type_set (list->sym, list->location, $2);
220          LIST_FREE (symbol_list, $3);
221      }      }
222  ;  ;
223    
224  precedence_declaration:  precedence_declaration:
225    precedence_declarator type.opt    precedence_declarator type.opt symbols.1
226      { current_assoc = $1; ++current_prec; }      {
227    terms_to_prec.1        symbol_list *list;
228      { current_assoc = non_assoc; current_type = NULL; }        ++current_prec;
229          for (list = $3; list; list = list->next)
230            {
231              symbol_type_set (list->sym, list->location, current_type);
232              symbol_precedence_set (list->sym, list->location, current_prec, $1);
233            }
234          LIST_FREE (symbol_list, $3);
235          current_type = NULL;
236        }
237  ;  ;
238    
239  precedence_declarator:  precedence_declarator:
# Line 236  type.opt: Line 248  type.opt:
248  ;  ;
249    
250  /* One or more nonterminals to be %typed. */  /* One or more nonterminals to be %typed. */
 nterms_to_type.1:  
   ID                   { symbol_type_set ($1, current_type); }  
 | nterms_to_type.1 ID  { symbol_type_set ($2, current_type); }  
 ;  
251    
252  /* One or more symbols to be given a precedence/associativity.  */  symbols.1:
253  terms_to_prec.1:    symbol            { $$ = symbol_list_new ($1, @1); }
254    symbol  | symbols.1 symbol  { $$ = symbol_list_prepend ($1, $2, @2); }
     {  
       symbol_type_set ($1, current_type);  
       symbol_precedence_set ($1, current_prec, current_assoc);  
     }  
 | terms_to_prec.1 symbol  
     {  
       symbol_type_set ($2, current_type);  
       symbol_precedence_set ($2, current_prec, current_assoc);  
     }  
255  ;  ;
256    
257  /* One token definition.  */  /* One token definition.  */
# Line 264  symbol_def: Line 263  symbol_def:
263  | ID  | ID
264       {       {
265         symbol_class_set ($1, current_class);         symbol_class_set ($1, current_class);
266         symbol_type_set ($1, current_type);         symbol_type_set ($1, @1, current_type);
267       }       }
268  | ID INT  | ID INT
269      {      {
270        symbol_class_set ($1, current_class);        symbol_class_set ($1, current_class);
271        symbol_type_set ($1, current_type);        symbol_type_set ($1, @1, current_type);
272        symbol_user_token_number_set ($1, $2);        symbol_user_token_number_set ($1, $2);
273      }      }
274  | ID string_as_id  | ID string_as_id
275      {      {
276        symbol_class_set ($1, current_class);        symbol_class_set ($1, current_class);
277        symbol_type_set ($1, current_type);        symbol_type_set ($1, @1, current_type);
278        symbol_make_alias ($1, $2);        symbol_make_alias ($1, $2);
279      }      }
280  | ID INT string_as_id  | ID INT string_as_id
281      {      {
282        symbol_class_set ($1, current_class);        symbol_class_set ($1, current_class);
283        symbol_type_set ($1, current_type);        symbol_type_set ($1, @1, current_type);
284        symbol_user_token_number_set ($1, $2);        symbol_user_token_number_set ($1, $2);
285        symbol_make_alias ($1, $3);        symbol_make_alias ($1, $3);
286      }      }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26