}
else
{
- char *s = xasprintf ("`%s'", token_type_to_string (type));
- lex_error_expecting (lexer, s, NULL_SENTINEL);
- free (s);
+ const char *type_string = token_type_to_string (type);
+ if (type_string)
+ {
+ char *s = xasprintf ("`%s'", type_string);
+ lex_error_expecting (lexer, s, NULL_SENTINEL);
+ free (s);
+ }
+ else
+ lex_error_expecting (lexer, token_type_to_name (type), NULL_SENTINEL);
+
return false;
}
}
bool
lex_force_string_or_id (struct lexer *lexer)
{
- return lex_is_integer (lexer) || lex_force_string (lexer);
+ return lex_token (lexer) == T_ID || lex_force_string (lexer);
}
/* If the current token is an integer, does nothing and returns true.