Revert "work toward better error reporting"
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 22 Nov 2021 03:39:31 +0000 (19:39 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 22 Nov 2021 03:39:31 +0000 (19:39 -0800)
This reverts commit 73d1c7eda1b9ea351bb37c55a9be592a4884a516.

src/language/lexer/lexer.h
src/language/stats/matrix.c
src/libpspp/message.c
src/libpspp/message.h

index d82470ffdd456d52a2efe37f9037f7441a4c2686..1282b6946b732e451ca080cd3b1cf50e621557a1 100644 (file)
@@ -160,7 +160,6 @@ int lex_get_last_column (const struct lexer *, int n);
 const char *lex_get_file_name (const struct lexer *);
 struct msg_location *lex_get_location (const struct lexer *, int n0, int n1);
 struct msg_location *lex_get_lines (const struct lexer *, int n0, int n1);
-void lex_extend_location (const struct lexer *, int n, struct msg_location *);
 const char *lex_get_encoding (const struct lexer *);
 
 /* Issuing errors. */
index 2e7bb83dfb1c1d21d09bcc78533b1a21718b5d73..473cec585a29c77bb27f7d0b1f782774407ef7bd 100644 (file)
@@ -501,8 +501,6 @@ struct matrix_expr
         struct matrix_var *variable;
         struct read_file *eof;
       };
-
-    struct msg_location *location;
   };
 
 static void
@@ -554,7 +552,6 @@ MATRIX_FUNCTIONS
     case MOP_EOF:
       break;
     }
-  msg_location_destroy (e->location);
   free (e);
 }
 
@@ -568,9 +565,6 @@ matrix_expr_create_subs (enum matrix_op op, struct matrix_expr **subs,
     .subs = xmemdup (subs, n_subs * sizeof *subs),
     .n_subs = n_subs
   };
-
-  for (size_t i = 0; i < n_subs; i++)
-    msg_location_merge (&e->location, subs[i]->location);
   return e;
 }
 
@@ -2651,32 +2645,19 @@ matrix_parse_function (struct matrix_state *s, const char *token,
   if (!f)
     return false;
 
+  lex_get_n (s->lexer, 2);
+
   struct matrix_expr *e = xmalloc (sizeof *e);
-  *e = (struct matrix_expr) {
-    .op = f->op,
-    .location = lex_get_location (s->lexer, 0, 0)
-  };
+  *e = (struct matrix_expr) { .op = f->op, .subs = NULL };
 
-  lex_get_n (s->lexer, 2);
   if (lex_token (s->lexer) != T_RPAREN)
     {
       size_t allocated_subs = 0;
       do
         {
-          struct msg_location *arg_location = lex_get_location (s->lexer, 0, 0);
           struct matrix_expr *sub = matrix_parse_expr (s);
           if (!sub)
-            {
-              msg_location_destroy (arg_location);
-              goto error;
-            }
-          if (!sub->location)
-            {
-              lex_extend_location (s->lexer, 0, arg_location);
-              sub->location = arg_location;
-            }
-          else
-            msg_location_destroy (arg_location);
+            goto error;
 
           if (e->n_subs >= allocated_subs)
             e->subs = x2nrealloc (e->subs, &allocated_subs, sizeof *e->subs);
@@ -4347,7 +4328,6 @@ matrix_expr_evaluate_integer (const struct matrix_expr *e, const char *context,
 struct matrix_lvalue
   {
     struct matrix_var *var;
-    struct msg_location *var_location;
     struct matrix_expr *indexes[2];
     size_t n_indexes;
   };
@@ -4369,7 +4349,6 @@ matrix_lvalue_parse (struct matrix_state *s)
   struct matrix_lvalue *lvalue = xzalloc (sizeof *lvalue);
   if (!lex_force_id (s->lexer))
     goto error;
-  lvalue->var_location = lex_get_location (s->lexer, 0, 0);
   lvalue->var = matrix_var_lookup (s, lex_tokss (s->lexer));
   if (lex_next_token (s->lexer, 1) == T_LPAREN)
     {
@@ -4530,23 +4509,21 @@ matrix_lvalue_evaluate (struct matrix_lvalue *lvalue,
   gsl_matrix *dm = lvalue->var->value;
   if (!dm)
     {
-      msg_at (SE, lvalue->var_location,
-              _("Undefined variable %s."), lvalue->var->name);
+      msg (SE, _("Undefined variable %s."), lvalue->var->name);
       return false;
     }
   else if (dm->size1 == 0 || dm->size2 == 0)
     {
-      msg_at (SE, lvalue->var_location,
-              _("Cannot index %zu×%zu matrix."), dm->size1, dm->size2);
+      msg (SE, _("Cannot index %zu×%zu matrix."),
+           dm->size1, dm->size2);
       return false;
     }
   else if (lvalue->n_indexes == 1)
     {
       if (!is_vector (dm))
         {
-          msg_at (SE, lvalue->var_location,
-                  _("Can't use vector indexing on %zu×%zu matrix %s."),
-                  dm->size1, dm->size2, lvalue->var->name);
+          msg (SE, _("Can't use vector indexing on %zu×%zu matrix %s."),
+               dm->size1, dm->size2, lvalue->var->name);
           return false;
         }
       return matrix_lvalue_evaluate_vector (lvalue->indexes[0],
index e3d301efd7ae8ae76a09a83360e1b09ed8f5c671..41a1da17502ea5e18386cdecb5c0d99df2c3afae 100644 (file)
@@ -51,14 +51,12 @@ static int messages_disabled;
 
 
 void
-vmsg (enum msg_class class, const struct msg_location *location,
-      const char *format, va_list args)
+vmsg (enum msg_class class, const char *format, va_list args)
 {
   struct msg *m = xmalloc (sizeof *m);
   *m = (struct msg) {
     .category = msg_class_to_category (class),
     .severity = msg_class_to_severity (class),
-    .location = msg_location_dup (location),
     .text = xvasprintf (format, args),
   };
   msg_emit (m);
@@ -71,21 +69,11 @@ msg (enum msg_class class, const char *format, ...)
 {
   va_list args;
   va_start (args, format);
-  vmsg (class, NULL, format, args);
+  vmsg (class, format, args);
   va_end (args);
 }
 
-/* Outputs error message in CLASS, with text FORMAT, formatted with printf.
-   LOCATION is the reported location for the message. */
-void
-msg_at (enum msg_class class, const struct msg_location *location,
-        const char *format, ...)
-{
-  va_list args;
-  va_start (args, format);
-  vmsg (class, location, format, args);
-  va_end (args);
-}
+
 
 void
 msg_error (int errnum, const char *format, ...)
index fdb5a535600cbed7f9a1f111072363dd9d1708bd..6cfbde7c5019ba2740a01c80bde5266edc7b06fc 100644 (file)
@@ -85,8 +85,6 @@ void msg_location_uninit (struct msg_location *);
 void msg_location_destroy (struct msg_location *);
 struct msg_location *msg_location_dup (const struct msg_location *);
 
-void msg_location_merge (struct msg_location **, const struct msg_location *);
-
 bool msg_location_is_empty (const struct msg_location *);
 void msg_location_format (const struct msg_location *, struct string *);
 
@@ -121,14 +119,10 @@ void msg_destroy(struct msg *);
 char *msg_to_string (const struct msg *);
 
 /* Emitting messages. */
-void vmsg (enum msg_class, const struct msg_location *,
-           const char *format, va_list args)
-     PRINTF_FORMAT (3, 0);
+void vmsg (enum msg_class class, const char *format, va_list args)
+     PRINTF_FORMAT (2, 0);
 void msg (enum msg_class, const char *format, ...)
      PRINTF_FORMAT (2, 3);
-void msg_at (enum msg_class, const struct msg_location *,
-             const char *format, ...)
-     PRINTF_FORMAT (3, 4);
 void msg_emit (struct msg *);
 
 void msg_error (int errnum, const char *format, ...)