X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fidentifier.c;h=498f5ea966987e38f75eba3dd105f6e112ed69f5;hb=53d725a9a75cf1644a4cbc9a7d08855ac02b65e4;hp=fa9e320846c542bd380e36bb4f56fcb75f5c973f;hpb=325168fb62e51d5154e932abec91ba40dd081f3f;p=pspp-builds.git diff --git a/src/data/identifier.c b/src/data/identifier.c index fa9e3208..498f5ea9 100644 --- a/src/data/identifier.c +++ b/src/data/identifier.c @@ -31,6 +31,22 @@ #include "gl/c-ctype.h" +/* Tokens. */ + +const char * +token_type_to_string (enum token_type type) +{ + switch (type) + { +#define TOKEN_TYPE(TYPE) case T_##TYPE: return #TYPE; + TOKEN_TYPES +#undef TOKEN_TYPE + case TOKEN_N_TYPES: + default: + return "unknown token type"; + } +} + /* Recognizing identifiers. */ static bool @@ -173,7 +189,7 @@ static const size_t keyword_cnt = sizeof keywords / sizeof *keywords; /* Returns true if TOKEN is representable as a keyword. */ bool -lex_is_keyword (int token) +lex_is_keyword (enum token_type token) { const struct keyword *kw; for (kw = keywords; kw < &keywords[keyword_cnt]; kw++) @@ -200,7 +216,7 @@ lex_id_to_token (struct substring id) /* Returns the name for the given keyword token type. */ const char * -lex_id_name (int token) +lex_id_name (enum token_type token) { const struct keyword *kw;