bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

More locations


From: Akim Demaille
Subject: More locations
Date: 20 Jun 2002 13:05:04 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * src/parse-gram.y (YYPRINT, yyprint): Don't mess with the parser
        internals.
        * src/reader.h, src/reader.c (grammar_current_rule_prec_set):
        Takes a location.
        * src/symtab.h, src/symtab.c (symbol_class_set)
        (symbol_user_token_number_set): Likewise.

Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.13
diff -u -u -r1.13 parse-gram.y
--- src/parse-gram.y 20 Jun 2002 09:08:37 -0000 1.13
+++ src/parse-gram.y 20 Jun 2002 11:03:19 -0000
@@ -69,12 +69,9 @@
 #define yyerror(Msg) \
         gram_error (yycontrol, &yylloc, Msg)
 
-/* When debugging our pure parser, we want to see values and locations
-   of the tokens.  */
 #define YYPRINT(File, Type, Value) \
-        yyprint (File, &yylloc, Type, &Value)
-static void yyprint (FILE *file, const location_t *loc,
-                     int type, const yystype *value);
+        yyprint (File, Type, &Value)
+static void yyprint (FILE *file, int type, const yystype *value);
 
 symbol_class current_class = unknown_sym;
 char *current_type = 0;
@@ -289,26 +286,26 @@
      }
 | ID
      {
-       symbol_class_set ($1, current_class);
+       symbol_class_set ($1, current_class, @1);
        symbol_type_set ($1, @1, current_type);
      }
 | ID INT
     {
-      symbol_class_set ($1, current_class);
+      symbol_class_set ($1, current_class, @1);
       symbol_type_set ($1, @1, current_type);
-      symbol_user_token_number_set ($1, $2);
+      symbol_user_token_number_set ($1, $2, @2);
     }
 | ID string_as_id
     {
-      symbol_class_set ($1, current_class);
+      symbol_class_set ($1, current_class, @1);
       symbol_type_set ($1, @1, current_type);
       symbol_make_alias ($1, $2);
     }
 | ID INT string_as_id
     {
-      symbol_class_set ($1, current_class);
+      symbol_class_set ($1, current_class, @1);
       symbol_type_set ($1, @1, current_type);
-      symbol_user_token_number_set ($1, $2);
+      symbol_user_token_number_set ($1, $2, @2);
       symbol_make_alias ($1, $3);
     }
 ;
@@ -357,7 +354,7 @@
 | rhs action
     { grammar_current_rule_action_append ($2, @2); }
 | rhs "%prec" symbol
-    { grammar_current_rule_prec_set ($3); }
+    { grammar_current_rule_prec_set ($3, @3); }
 ;
 
 symbol:
@@ -376,7 +373,7 @@
   STRING
     {
       $$ = getsym ($1, @1);
-      symbol_class_set ($$, token_sym);
+      symbol_class_set ($$, token_sym, @1);
     }
 ;
 
@@ -411,11 +408,9 @@
 
 static void
 yyprint (FILE *file,
-         const location_t *loc, int type, const yystype *value)
+         int type, const yystype *value)
 {
-  fputs (" (", file);
-  LOCATION_PRINT (file, *loc);
-  fputs (")", file);
+  fputc (' ', file);
   switch (type)
     {
     case CHARACTER:
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.197
diff -u -u -r1.197 reader.c
--- src/reader.c 17 Jun 2002 07:04:49 -0000 1.197
+++ src/reader.c 20 Jun 2002 11:03:19 -0000
@@ -50,7 +50,7 @@
 grammar_start_symbol_set (symbol_t *s, location_t l)
 {
   if (start_flag)
-    complain (_("multiple %s declarations"), "%start");
+    complain_at (l, _("multiple %s declarations"), "%start");
   else
     {
       start_flag = 1;
@@ -200,7 +200,7 @@
       ++nvars;
     }
   else if (lhs->class == token_sym)
-    complain (_("rule given for %s, which is a token"), lhs->tag);
+    complain_at (location, _("rule given for %s, which is a token"), lhs->tag);
 }
 
 /* Check that the last rule (CURRENT_RULE) is properly defined.  For
@@ -224,14 +224,16 @@
       const char *lhs_type = lhs->type_name       ? lhs->type_name       : "";
       const char *rhs_type = first_rhs->type_name ? first_rhs->type_name : "";
       if (strcmp (lhs_type, rhs_type))
-       complain (_("type clash (`%s' `%s') on default action"),
-                 lhs_type, rhs_type);
+       complain_at (current_rule->location,
+                    _("type clash (`%s' `%s') on default action"),
+                    lhs_type, rhs_type);
     }
   /* Warn if there is no default for $$ but we need one.  */
   else
     {
       if (lhs->type_name)
-       complain (_("empty rule for typed nonterminal, and no action"));
+       complain_at (current_rule->location,
+                    _("empty rule for typed nonterminal, and no action"));
     }
 }
 
@@ -299,10 +301,10 @@
 /* Set the precedence symbol of the current rule to PRECSYM. */
 
 void
-grammar_current_rule_prec_set (symbol_t *precsym)
+grammar_current_rule_prec_set (symbol_t *precsym, location_t location)
 {
   if (current_rule->ruleprec)
-    complain (_("two @prec's in a row"));
+    complain_at (location, _("two @prec's in a row"));
   current_rule->ruleprec = precsym;
 }
 
Index: src/reader.h
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.h,v
retrieving revision 1.23
diff -u -u -r1.23 reader.h
--- src/reader.h 20 Jun 2002 09:08:37 -0000 1.23
+++ src/reader.h 20 Jun 2002 11:03:19 -0000
@@ -68,7 +68,8 @@
 void grammar_rule_begin PARAMS ((symbol_t *lhs, location_t l));
 void grammar_rule_end PARAMS ((location_t l));
 void grammar_midrule_action PARAMS ((void));
-void grammar_current_rule_prec_set PARAMS ((symbol_t *precsym));
+void grammar_current_rule_prec_set PARAMS ((symbol_t *precsym,
+                                           location_t l));
 void grammar_current_rule_symbol_append PARAMS ((symbol_t *symbol,
                                                 location_t l));
 void grammar_current_rule_action_append PARAMS ((const char *action,
Index: src/scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.14
diff -u -u -r1.14 scan-gram.l
--- src/scan-gram.l 20 Jun 2002 09:08:37 -0000 1.14
+++ src/scan-gram.l 20 Jun 2002 11:03:19 -0000
@@ -290,8 +290,8 @@
     {
       YY_OBS_FINISH;
       yylval->symbol = getsym (last_string, *yylloc);
-      symbol_class_set (yylval->symbol, token_sym);
-      symbol_user_token_number_set (yylval->symbol, last_string[1]);
+      symbol_class_set (yylval->symbol, token_sym, *yylloc);
+      symbol_user_token_number_set (yylval->symbol, last_string[1], *yylloc);
       YY_OBS_FREE;
       yy_pop_state ();
       return ID;
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.37
diff -u -u -r1.37 symtab.c
--- src/symtab.c 20 Jun 2002 09:08:37 -0000 1.37
+++ src/symtab.c 20 Jun 2002 11:03:19 -0000
@@ -175,7 +175,7 @@
     }
 
   /* Only terminals have a precedence. */
-  symbol_class_set (symbol, token_sym);
+  symbol_class_set (symbol, token_sym, location);
 }
 
 
@@ -184,10 +184,10 @@
 `-------------------------------------*/
 
 void
-symbol_class_set (symbol_t *symbol, symbol_class class)
+symbol_class_set (symbol_t *symbol, symbol_class class, location_t location)
 {
   if (symbol->class != unknown_sym && symbol->class != class)
-    complain (_("symbol %s redefined"), symbol_tag_get (symbol));
+    complain_at (location, _("symbol %s redefined"), symbol_tag_get (symbol));
 
   if (class == nterm_sym && symbol->class != nterm_sym)
     symbol->number = nvars++;
@@ -203,14 +203,15 @@
 `-------------------------------------------------*/
 
 void
-symbol_user_token_number_set (symbol_t *symbol, int user_token_number)
+symbol_user_token_number_set (symbol_t *symbol,
+                             int user_token_number, location_t location)
 {
   assert (symbol->class == token_sym);
 
   if (symbol->user_token_number != USER_NUMBER_UNDEFINED
       && symbol->user_token_number != user_token_number)
-    complain (_("redefining user token number of %s"),
-             symbol_tag_get (symbol));
+    complain_at (location, _("redefining user token number of %s"),
+                symbol_tag_get (symbol));
 
   symbol->user_token_number = user_token_number;
   /* User defined EOF token? */
Index: src/symtab.h
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.h,v
retrieving revision 1.37
diff -u -u -r1.37 symtab.h
--- src/symtab.h 20 Jun 2002 09:08:37 -0000 1.37
+++ src/symtab.h 20 Jun 2002 11:03:19 -0000
@@ -127,10 +127,13 @@
                                    int prec, associativity assoc));
 
 /* Set the CLASS associated to SYMBOL.  */
-void symbol_class_set PARAMS ((symbol_t *symbol, symbol_class class));
+void symbol_class_set PARAMS ((symbol_t *symbol,
+                              symbol_class class, location_t location));
 
 /* Set the USER_TOKEN_NUMBER associated to SYMBOL.  */
-void symbol_user_token_number_set PARAMS ((symbol_t *symbol, int user_number));
+void symbol_user_token_number_set PARAMS ((symbol_t *symbol,
+                                          int user_number,
+                                          location_t location));
 
 
 /* Distinguished symbols.  AXIOM is the real start symbol, that used
Index: tests/actions.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/actions.at,v
retrieving revision 1.9
diff -u -u -r1.9 actions.at
--- tests/actions.at 20 Jun 2002 09:47:44 -0000 1.9
+++ tests/actions.at 20 Jun 2002 11:03:19 -0000
@@ -153,11 +153,11 @@
 
 
 
-## ------------- ##
-## Destructors.  ##
-## ------------- ##
+## -------------------------- ##
+## Printers and Destructors.  ##
+## -------------------------- ##
 
-AT_SETUP([Destructors])
+AT_SETUP([Printers and Destructors])
 
 # Make sure complex $n work.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]