Cite tokens when reporting invalid identifiers.
[pspp] / src / language / data-io / matrix-data.c
index df8647480f9986593ec2351df20dd90c201ea938..4ae4ef70cd7b13ced5138a1d71a549e65e66b94b 100644 (file)
@@ -847,7 +847,10 @@ parse_matrix_data_variables (struct lexer *lexer)
     if (!strcasecmp (names[i], "ROWTYPE_"))
       dict_create_var_assert (dict, "ROWTYPE_", 8);
     else
-      dict_create_var_assert (dict, names[i], 0);
+      {
+        struct variable *var = dict_create_var_assert (dict, names[i], 0);
+        var_set_measure (var, MEASURE_SCALE);
+      }
 
   for (size_t i = 0; i < n_names; ++i)
     free (names[i]);
@@ -891,6 +894,7 @@ parse_matrix_data_subvars (struct lexer *lexer, struct dictionary *dict,
         }
       *tv = true;
 
+      var_set_measure (v, MEASURE_NOMINAL);
       var_set_both_formats (v, &(struct fmt_spec) { .type = FMT_F, .w = 4 });
     }
   return true;
@@ -1007,6 +1011,7 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds)
               mf.svars = xmalloc (sizeof *mf.svars);
               mf.svars[0] = dict_create_var_assert (dict, lex_tokcstr (lexer),
                                                     0);
+              var_set_measure (mf.svars[0], MEASURE_NOMINAL);
               var_set_both_formats (
                 mf.svars[0], &(struct fmt_spec) { .type = FMT_F, .w = 4 });
               mf.n_svars = 1;
@@ -1028,7 +1033,9 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds)
       else if (lex_match_id (lexer, "CELLS"))
        {
           if (mf.input_rowtype)
-            msg (SW, _("CELLS is ignored when VARIABLES includes ROWTYPE_"));
+            lex_next_msg (lexer, SW,
+                          -1, -1, _("CELLS is ignored when VARIABLES "
+                                    "includes ROWTYPE_"));
 
          lex_match (lexer, T_EQUALS);
 
@@ -1053,7 +1060,14 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds)
                   if (open || in_parens || (lex_token (lexer) != T_ENDCMD
                                             && lex_token (lexer) != T_SLASH))
                     {
-                      lex_error (lexer, _("Row type keyword expected."));
+                      const char *rowtypes[] = {
+#define RT(NAME, DIMS) #NAME,
+                        ROWTYPES
+#undef RT
+                        "N_VECTOR", "SD",
+                      };
+                      lex_error_expecting_array (
+                        lexer, rowtypes, sizeof rowtypes / sizeof *rowtypes);
                       goto error;
                     }
                   break;