58{
59 int cur_token;
63 char *cur_yytext;
64
65 /* Get next token --- we might already have it */
67 {
73 }
74 else
76
77 /*
78 * If this token isn't one that requires lookahead, just return it.
79 */
80 switch (cur_token)
81 {
82 case FORMAT:
83 case NOT:
84 case NULLS_P:
85 case WITH:
86 case WITHOUT:
87 case UIDENT:
88 case USCONST:
89 break;
90 default:
91 return cur_token;
92 }
93
94 /* Save and restore lexer output variables around the call */
96 cur_yylloc = base_yylloc;
98
99 /* Get next token, saving outputs into lookahead variables */
101
106
108 base_yylloc = cur_yylloc;
110
112
113 /* Replace cur_token if needed, based on lookahead */
114 switch (cur_token)
115 {
116 case FORMAT:
117 /* Replace FORMAT by FORMAT_LA if it's followed by JSON */
119 {
120 case JSON:
121 cur_token = FORMAT_LA;
122 break;
123 }
124 break;
125
126 case NOT:
127 /* Replace NOT by NOT_LA if it's followed by BETWEEN, IN, etc */
129 {
130 case BETWEEN:
131 case IN_P:
132 case LIKE:
133 case ILIKE:
134 case SIMILAR:
135 cur_token = NOT_LA;
136 break;
137 }
138 break;
139
140 case NULLS_P:
141 /* Replace NULLS_P by NULLS_LA if it's followed by FIRST or LAST */
143 {
144 case FIRST_P:
145 case LAST_P:
146 cur_token = NULLS_LA;
147 break;
148 }
149 break;
150
151 case WITH:
152 /* Replace WITH by WITH_LA if it's followed by TIME or ORDINALITY */
154 {
155 case TIME:
156 case ORDINALITY:
157 cur_token = WITH_LA;
158 break;
159 }
160 break;
161
162 case WITHOUT:
163 /* Replace WITHOUT by WITHOUT_LA if it's followed by TIME */
165 {
166 case TIME:
167 cur_token = WITHOUT_LA;
168 break;
169 }
170 break;
171 case UIDENT:
172 case USCONST:
173 /* Look ahead for UESCAPE */
175 {
176 /* Yup, so get third token, which had better be SCONST */
177 const char *escstr;
178
179 /*
180 * Again save and restore lexer output variables around the
181 * call
182 */
184 cur_yylloc = base_yylloc;
186
187 /* Get third token */
189
192
193 /*
194 * Save and check escape string, which the scanner returns
195 * with quotes
196 */
200
202 base_yylloc = cur_yylloc;
204
205 /* Combine 3 tokens into 1 */
207 " UESCAPE ",
208 escstr);
210
211 /* Clear have_lookahead, thereby consuming all three tokens */
213 }
214
215 if (cur_token == UIDENT)
216 cur_token = IDENT;
217 else if (cur_token == USCONST)
218 cur_token = SCONST;
219 break;
220 }
221
222 return cur_token;
223}
static bool next_token(char **lineptr, StringInfo buf, bool *initial_quote, bool *terminating_comma)
static YYLTYPE lookahead_yylloc
static int base_yylex_location(void)
static bool have_lookahead
static int lookahead_token
static YYSTYPE lookahead_yylval
static char * lookahead_yytext
static bool check_uescapechar(unsigned char escape)
void mmerror(int error_code, enum errortype type, const char *error,...) pg_attribute_printf(3
char * make3_str(const char *str1, const char *str2, const char *str3)