(lex_match_id): Reimplement in terms of lex_match_id_n.
* identifier.c (lex_id_match_n): New function.
(lex_id_match): Reimplement in terms of lex_id_match_n.
+2007-12-04 Ben Pfaff <blp@gnu.org>
+
+ * identifier.c (lex_id_match_n): New function.
+ (lex_id_match): Reimplement in terms of lex_id_match_n.
+
2007-11-24 Ben Pfaff <blp@gnu.org>
* automake.mk (src_data_libdata_a_SOURCES): Add val-type.h, to fix
and those characters are identical to KEYWORD. */
bool
lex_id_match (struct substring keyword, struct substring token)
+{
+ return lex_id_match_n (keyword, token, 3);
+}
+
+/* Returns true if TOKEN is a case-insensitive match for at least
+ the first N characters of KEYWORD. */
+bool
+lex_id_match_n (struct substring keyword, struct substring token, size_t n)
{
size_t token_len = ss_length (token);
size_t keyword_len = ss_length (keyword);
- if (token_len >= 3 && token_len < keyword_len)
+ if (token_len >= n && token_len < keyword_len)
return ss_equals_case (ss_head (keyword, token_len), token);
else
return ss_equals_case (keyword, token);
/* Comparing identifiers. */
bool lex_id_match (struct substring keyword, struct substring token);
+bool lex_id_match_n (struct substring keyword, struct substring token,
+ size_t n);
int lex_id_to_token (struct substring);
/* Identifier names. */
+2007-12-04 Ben Pfaff <blp@gnu.org>
+
+ * lexer.c (lex_match_id_n): New function.
+ (lex_match_id): Reimplement in terms of lex_match_id_n.
+
2007-08-16 Ben Pfaff <blp@gnu.org>
Implement journaling. Bug #17240.
Otherwise, returns false. */
bool
lex_match_id (struct lexer *lexer, const char *s)
+{
+ return lex_match_id_n (lexer, s, 3);
+}
+
+/* If the current token is the identifier S, skips it and returns
+ true. The identifier may be abbreviated to its first N
+ letters.
+ Otherwise, returns false. */
+bool
+lex_match_id_n (struct lexer *lexer, const char *s, size_t n)
{
if (lexer->token == T_ID
- && lex_id_match (ss_cstr (s), ss_cstr (lexer->tokid)))
+ && lex_id_match_n (ss_cstr (s), ss_cstr (lexer->tokid), n))
{
lex_get (lexer);
return true;
/* Token matching functions. */
bool lex_match (struct lexer *, int);
bool lex_match_id (struct lexer *, const char *);
+bool lex_match_id_n (struct lexer *, const char *, size_t n);
bool lex_match_int (struct lexer *, int);
/* Forcible matching functions. */