lexer: New function lex_force_match_phrase().
[pspp] / src / language / dictionary / attributes.c
index 88832fd501f641ebcc041c1558fa3d214047c454..e646af3847ed45e8cc4ec58d98c583838e850562 100644 (file)
@@ -59,8 +59,7 @@ cmd_variable_attribute (struct lexer *lexer, struct dataset *ds)
       size_t n_vars, i;
       bool ok;
 
-      if (!lex_force_match_id (lexer, "VARIABLES")
-          || !lex_force_match (lexer, T_EQUALS)
+      if (!lex_force_match_phrase (lexer, "VARIABLES=")
           || !parse_variables (lexer, dict, &vars, &n_vars, PV_NONE))
         return CMD_FAILURE;
 
@@ -87,12 +86,16 @@ static char *
 parse_attribute_name (struct lexer *lexer, const char *dict_encoding,
                       size_t *index)
 {
-  char *name;
-
-  if (!lex_force_id (lexer)
-      || !id_is_valid (lex_tokcstr (lexer), dict_encoding, true))
+  if (!lex_force_id (lexer))
     return NULL;
-  name = xstrdup (lex_tokcstr (lexer));
+  char *error = id_is_valid__ (lex_tokcstr (lexer), dict_encoding);
+  if (error)
+    {
+      lex_error (lexer, "%s", error);
+      free (error);
+      return NULL;
+    }
+  char *name = xstrdup (lex_tokcstr (lexer));
   lex_get (lexer);
 
   if (lex_match (lexer, T_LBRACK))