1/*-------------------------------------------------------------------------
4 * lexical token lookup for reserved words in postgres embedded SQL
6 * src/interfaces/ecpg/preproc/c_keywords.c
8 *-------------------------------------------------------------------------
12/* ScanKeywordList lookup data for C keywords */
13#include "c_kwlist_d.h"
17/* Token codes for C keywords */
18 #define PG_KEYWORD(kwname, value) value,
28 * ScanCKeywordLookup - see if a given word is a keyword
30 * Returns the token value of the keyword, or -1 if no match.
32 * Do a hash search using plain strcmp() comparison. This is much like
33 * ScanKeywordLookup(), except we want case-sensitive matching.
43 * Reject immediately if too long to be any keyword. This saves useless
44 * hashing work on long strings.
47 if (
len > ScanCKeywords.max_kw_len)
51 * Compute the hash function. Since it's a perfect hash, we need only
52 * match to the specific keyword it identifies.
54 h = ScanCKeywords_hash_func(
text,
len);
56 /* An out-of-range result implies no match */
57 if (h < 0 || h >= ScanCKeywords.num_keywords)
62 if (strcmp(kw,
text) == 0)
int ScanCKeywordLookup(const char *text)
static const uint16 ScanCKeywordTokens[]
static const char * GetScanKeyword(int n, const ScanKeywordList *keywords)