PostgreSQL Source Code  git master
ecpg_keywords.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * ecpg_keywords.c
4  * lexical token lookup for reserved words in postgres embedded SQL
5  *
6  * IDENTIFICATION
7  * src/interfaces/ecpg/preproc/ecpg_keywords.c
8  *
9  *-------------------------------------------------------------------------
10  */
11 
12 #include "postgres_fe.h"
13 
14 #include <ctype.h>
15 
16 /* ScanKeywordList lookup data for ECPG keywords */
17 #include "ecpg_kwlist_d.h"
18 #include "preproc_extern.h"
19 #include "preproc.h"
20 
21 /* Token codes for ECPG keywords */
22 #define PG_KEYWORD(kwname, value) value,
23 
24 static const uint16 ECPGScanKeywordTokens[] = {
25 #include "ecpg_kwlist.h"
26 };
27 
28 #undef PG_KEYWORD
29 
30 
31 /*
32  * ScanECPGKeywordLookup - see if a given word is a keyword
33  *
34  * Returns the token value of the keyword, or -1 if no match.
35  *
36  * Keywords are matched using the same case-folding rules as in the backend.
37  */
38 int
40 {
41  int kwnum;
42 
43  /* First check SQL symbols defined by the backend. */
45  if (kwnum >= 0)
46  return SQLScanKeywordTokens[kwnum];
47 
48  /* Try ECPG-specific keywords. */
49  kwnum = ScanKeywordLookup(text, &ScanECPGKeywords);
50  if (kwnum >= 0)
51  return ECPGScanKeywordTokens[kwnum];
52 
53  return -1;
54 }
unsigned short uint16
Definition: c.h:505
int ScanECPGKeywordLookup(const char *text)
Definition: ecpg_keywords.c:39
static const uint16 ECPGScanKeywordTokens[]
Definition: ecpg_keywords.c:24
const uint16 SQLScanKeywordTokens[]
Definition: keywords.c:34
PGDLLIMPORT const ScanKeywordList ScanKeywords
int ScanKeywordLookup(const char *str, const ScanKeywordList *keywords)
Definition: kwlookup.c:38
Definition: c.h:687