1
/*****************************************************************************
3
Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/******************************************************
20
SQL parser lexical analyzer: input file for the GNU Flex lexer generator
22
Created 12/14/1997 Heikki Tuuri
23
*******************************************************/
29
%option never-interactive
34
%option noyy_scan_buffer
35
%option noyy_scan_bytes
36
%option noyy_scan_string
39
#define YYSTYPE que_node_t*
42
#include "pars0pars.h"
43
#include "pars0grm.hh"
48
#define malloc(A) ut_malloc(A)
49
#define free(A) ut_free(A)
50
#define realloc(P, A) ut_realloc(P, A)
51
#define exit(A) ut_error
53
#define YY_INPUT(buf, result, max_size) pars_get_lex_chars(buf, &result, max_size)
55
/* String buffer for removing quotes */
56
static ulint stringbuf_len_alloc = 0; /* Allocated length */
57
static ulint stringbuf_len = 0; /* Current length */
58
static char* stringbuf; /* Start of buffer */
59
/** Appends a string to the buffer. */
64
const char* str, /*!< in: string to be appended */
65
ulint len) /*!< in: length of the string */
67
if (stringbuf == NULL) {
68
stringbuf = malloc(1);
69
stringbuf_len_alloc = 1;
72
if (stringbuf_len + len > stringbuf_len_alloc) {
73
while (stringbuf_len + len > stringbuf_len_alloc) {
74
stringbuf_len_alloc <<= 1;
76
stringbuf = realloc(stringbuf, stringbuf_len_alloc);
79
memcpy(stringbuf + stringbuf_len, str, len);
86
ID [a-z_A-Z][a-z_A-Z0-9]*
87
BOUND_LIT \:[a-z_A-Z0-9]+
88
BOUND_ID \$[a-z_A-Z0-9]+
96
yylval = sym_tab_add_int_lit(pars_sym_tab_global,
101
{DIGIT}+"."{DIGIT}* {
102
ut_error; /* not implemented */
104
return(PARS_FLOAT_LIT);
110
yylval = sym_tab_add_bound_lit(pars_sym_tab_global,
117
yylval = sym_tab_add_bound_id(pars_sym_tab_global,
120
return(PARS_ID_TOKEN);
124
/* Quoted character string literals are handled in an explicit
125
start state 'quoted'. This state is entered and the buffer for
126
the scanned string is emptied upon encountering a starting quote.
128
In the state 'quoted', only two actions are possible (defined below). */
133
/* Got a sequence of characters other than "'":
134
append to string buffer */
135
string_append(yytext, yyleng);
138
/* Got a sequence of "'" characters:
139
append half of them to string buffer,
140
as "''" represents a single "'".
141
We apply truncating division,
142
so that "'''" will result in "'". */
144
string_append(yytext, yyleng / 2);
146
/* If we got an odd number of quotes, then the
147
last quote we got is the terminating quote.
148
At the end of the string, we return to the
149
initial start state and report the scanned
154
yylval = sym_tab_add_str_lit(
156
(byte*) stringbuf, stringbuf_len);
157
return(PARS_STR_LIT);
162
/* Quoted identifiers are handled in an explicit start state 'id'.
163
This state is entered and the buffer for the scanned string is emptied
164
upon encountering a starting quote.
166
In the state 'id', only two actions are possible (defined below). */
171
/* Got a sequence of characters other than '"':
172
append to string buffer */
173
string_append(yytext, yyleng);
176
/* Got a sequence of '"' characters:
177
append half of them to string buffer,
178
as '""' represents a single '"'.
179
We apply truncating division,
180
so that '"""' will result in '"'. */
182
string_append(yytext, yyleng / 2);
184
/* If we got an odd number of quotes, then the
185
last quote we got is the terminating quote.
186
At the end of the string, we return to the
187
initial start state and report the scanned
192
yylval = sym_tab_add_id(
194
(byte*) stringbuf, stringbuf_len);
196
return(PARS_ID_TOKEN);
201
yylval = sym_tab_add_null_lit(pars_sym_tab_global);
203
return(PARS_NULL_LIT);
207
/* Implicit cursor name */
208
yylval = sym_tab_add_str_lit(pars_sym_tab_global,
209
(byte*) yytext, yyleng);
210
return(PARS_SQL_TOKEN);
214
return(PARS_AND_TOKEN);
218
return(PARS_OR_TOKEN);
222
return(PARS_NOT_TOKEN);
226
return(PARS_PROCEDURE_TOKEN);
230
return(PARS_IN_TOKEN);
234
return(PARS_OUT_TOKEN);
238
return(PARS_BINARY_TOKEN);
242
return(PARS_BLOB_TOKEN);
246
return(PARS_INT_TOKEN);
250
return(PARS_INT_TOKEN);
254
return(PARS_FLOAT_TOKEN);
258
return(PARS_CHAR_TOKEN);
262
return(PARS_IS_TOKEN);
266
return(PARS_BEGIN_TOKEN);
270
return(PARS_END_TOKEN);
274
return(PARS_IF_TOKEN);
278
return(PARS_THEN_TOKEN);
282
return(PARS_ELSE_TOKEN);
286
return(PARS_ELSIF_TOKEN);
290
return(PARS_LOOP_TOKEN);
294
return(PARS_WHILE_TOKEN);
298
return(PARS_RETURN_TOKEN);
302
return(PARS_SELECT_TOKEN);
306
return(PARS_SUM_TOKEN);
310
return(PARS_COUNT_TOKEN);
314
return(PARS_DISTINCT_TOKEN);
318
return(PARS_FROM_TOKEN);
322
return(PARS_WHERE_TOKEN);
326
return(PARS_FOR_TOKEN);
330
return(PARS_READ_TOKEN);
334
return(PARS_ORDER_TOKEN);
338
return(PARS_BY_TOKEN);
342
return(PARS_ASC_TOKEN);
346
return(PARS_DESC_TOKEN);
350
return(PARS_INSERT_TOKEN);
354
return(PARS_INTO_TOKEN);
358
return(PARS_VALUES_TOKEN);
362
return(PARS_UPDATE_TOKEN);
366
return(PARS_SET_TOKEN);
370
return(PARS_DELETE_TOKEN);
374
return(PARS_CURRENT_TOKEN);
378
return(PARS_OF_TOKEN);
382
return(PARS_CREATE_TOKEN);
386
return(PARS_TABLE_TOKEN);
390
return(PARS_INDEX_TOKEN);
394
return(PARS_UNIQUE_TOKEN);
398
return(PARS_CLUSTERED_TOKEN);
401
"DOES_NOT_FIT_IN_MEMORY" {
402
return(PARS_DOES_NOT_FIT_IN_MEM_TOKEN);
406
return(PARS_ON_TOKEN);
410
return(PARS_DECLARE_TOKEN);
414
return(PARS_CURSOR_TOKEN);
418
return(PARS_OPEN_TOKEN);
422
return(PARS_FETCH_TOKEN);
426
return(PARS_CLOSE_TOKEN);
430
return(PARS_NOTFOUND_TOKEN);
434
return(PARS_TO_CHAR_TOKEN);
438
return(PARS_TO_NUMBER_TOKEN);
442
return(PARS_TO_BINARY_TOKEN);
446
return(PARS_BINARY_TO_NUMBER_TOKEN);
450
return(PARS_SUBSTR_TOKEN);
454
return(PARS_REPLSTR_TOKEN);
458
return(PARS_CONCAT_TOKEN);
462
return(PARS_INSTR_TOKEN);
466
return(PARS_LENGTH_TOKEN);
470
return(PARS_SYSDATE_TOKEN);
474
return(PARS_PRINTF_TOKEN);
478
return(PARS_ASSERT_TOKEN);
482
return(PARS_RND_TOKEN);
486
return(PARS_RND_STR_TOKEN);
490
return(PARS_ROW_PRINTF_TOKEN);
494
return(PARS_COMMIT_TOKEN);
498
return(PARS_ROLLBACK_TOKEN);
502
return(PARS_WORK_TOKEN);
506
return(PARS_UNSIGNED_TOKEN);
510
return(PARS_EXIT_TOKEN);
514
return(PARS_FUNCTION_TOKEN);
518
return(PARS_LOCK_TOKEN);
522
return(PARS_SHARE_TOKEN);
526
return(PARS_MODE_TOKEN);
530
yylval = sym_tab_add_id(pars_sym_tab_global,
533
return(PARS_ID_TOKEN);
537
return(PARS_DDOT_TOKEN);
541
return(PARS_ASSIGN_TOKEN);
545
return(PARS_LE_TOKEN);
549
return(PARS_GE_TOKEN);
553
return(PARS_NE_TOKEN);
558
return((int)(*yytext));
563
return((int)(*yytext));
568
return((int)(*yytext));
573
return((int)(*yytext));
578
return((int)(*yytext));
583
return((int)(*yytext));
588
return((int)(*yytext));
593
return((int)(*yytext));
598
return((int)(*yytext));
603
return((int)(*yytext));
608
return((int)(*yytext));
613
return((int)(*yytext));
618
return((int)(*yytext));
623
return((int)(*yytext));
628
return((int)(*yytext));
631
"/*" BEGIN(comment); /* eat up comment */
635
<comment>"*"+"/" BEGIN(INITIAL);
637
[ \t\n]+ /* eat up whitespace */
641
fprintf(stderr,"Unrecognized character: %02x\n",
651
/* yylex_destroy() is not defined before Flex 2.5.9
652
so we attempt to define something that should be good enough
653
for old Flex - such as that found on CentOS 5
655
#if !defined(YY_FLEX_MAJOR_VERSION) || YY_FLEX_MAJOR_VERSION < 2 \
656
|| (YY_FLEX_MAJOR_VERSION == 2 \
657
&& (!defined(YY_FLEX_MINOR_VERSION) || YY_FLEX_MINOR_VERSION < 5 \
658
|| (YY_FLEX_MINOR_VERSION == 5 \
659
&& (!defined(YY_FLEX_SUBMINOR_VERSION) \
660
|| YY_FLEX_SUBMINOR_VERSION < 9))))
661
# define yylex_destroy() yy_delete_buffer(YY_CURRENT_BUFFER)
664
/**********************************************************************
665
Release any resources used by the lexer. */
668
pars_lexer_close(void)
669
/*==================*/
674
stringbuf_len_alloc = stringbuf_len = 0;