lexer: Add support for macro identifiers (that begin with '!').
[pspp] / src / language / lexer / token.c
index 80c6615c5a5015048ed7e4767ada3e135c26262f..f6bc6a1d22166a8f7dfc118f400bcdbd5f8ac88d 100644 (file)
@@ -135,8 +135,6 @@ string_representation (struct substring ss)
 char *
 token_to_string (const struct token *token)
 {
-  const char *name;
-
   switch (token->type)
     {
     case T_POS_NUM:
@@ -144,14 +142,14 @@ token_to_string (const struct token *token)
       return number_token_to_string (token);
 
     case T_ID:
+    case T_MACRO_ID:
       return ss_xstrdup (token->string);
 
     case T_STRING:
       return string_representation (token->string);
 
     default:
-      name = token_type_to_name (token->type);
-      return name != NULL ? xstrdup (name) : NULL;
+      return xstrdup_if_nonnull (token_type_to_name (token->type));
     }
 }