-
Notifications
You must be signed in to change notification settings - Fork 120
/
fl.l
147 lines (126 loc) · 3.85 KB
/
fl.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
%{
#include "bison.tab.h"
#include "atof.h"
#ifdef _WIN64
#define atoll(S) _atoi64(S)
#else
#include <unistd.h>
#endif
void yyerror(char *s, ...);
#define YY_NEVER_INTERACTIVE 1
#define YY_NO_UNISTD_H
%}
%option noyywrap nodefault yylineno case-insensitive never-interactive
%x COMMENT
%s BTWMODE
%%
AND {return AND; }
OR {return OR; }
LOAD { return LOAD; }
FILTER { return FILTER; }
DESC { return DESC; }
ASC { return ASC; }
ORDER { return ORDER; }
BY { return BY; }
JOIN { return JOIN; }
STORE { return STORE; }
INTO { return INTO; }
GROUP { return GROUP; }
AS { return AS; }
SELECT { return SELECT; }
USING { return USING; }
COUNT { return COUNT; }
SUM { return SUM; }
AVG { return AVG; }
MIN { return MIN; }
MAX { return MAX; }
LIMIT { return LIMIT; }
ON { return ON; }
BINARY { return BINARY; }
DISTINCT { return DISTINCT; }
LEFT { return LEFT; }
RIGHT { return RIGHT; }
OUTER { return OUTER; }
SEMI { return SEMI; }
ANTI { return ANTI; }
SORT {return SORT; }
SEGMENTS {return SEGMENTS; }
PRESORTED {return PRESORTED; }
INSERT {return INSERT; }
WHERE {return WHERE; }
DISPLAY {return DISPLAY; }
CASE {return CASE; }
WHEN {return WHEN; }
THEN {return THEN; }
ELSE {return ELSE; }
END {return END; }
SHOW {return SHOW; }
TABLES {return TABLES; }
TABLE {return TABLE; }
DESCRIBE {return DESCRIBE; }
DROP {return DROP; }
DELETE {return DELETE; }
FROM {return FROM; }
LIKE {return LIKE; }
CREATE {return CREATE; }
INDEX {return INDEX; }
YEAR {return YEAR; }
MONTH {return MONTH; }
DAY {return DAY; }
CAST_TO_INT {return CAST_TO_INT; }
APPEND {return APPEND; }
NO {return NO; }
ENCODING {return ENCODING; }
-?[0-9]+ { yylval.intval = atoll(yytext); return INTNUM; }
-?[0-9]+"."[0-9]* |
-?[0-9]+"."[0-9]* |
-?"."[0-9]+ { yylval.strval = strdup(yytext); return DECIMAL1; }
-?[0-9]+E[-+]?[0-9]+ |
-?[0-9]+"."[0-9]*E[-+]?[0-9]+ |
-?"."[0-9]+E[-+]?[0-9]+ { yylval.floatval = atoff(yytext) ;return APPROXNUM; }
[0-9]+(HOUR|MINUTE|SECOND|MSECOND|DAY|MONTH|YEAR) { yylval.strval = strdup(yytext); return STRING; }
date\(\) { yylval.strval = strdup(yytext); return STRING;}
TRUE { yylval.intval = 1; return BOOL1; }
UNKNOWN { yylval.intval = -1; return BOOL1; }
FALSE { yylval.intval = 0; return BOOL1; }
\"(\\.|\"\"|[^"\n])*\" { yylval.strval = strdup(yytext); return STRING; }
'(\\.|[^'\n])*$ { yyerror("Unterminated string %s", yytext); break;}
\"(\\.|[^"\n])*$ { yyerror("Unterminated string %s", yytext); break;}
[-+&~|^/%*(),.;:!{}] { return yytext[0]; }
"&&" { return AND; }
"||" { return OR; }
":=" { return ASSIGN; }
"=" { return EQUAL; }
"<>" { return NONEQUAL; }
"==" { yylval.subtok = 4; return COMPARISON; }
"<=>" { yylval.subtok = 12; return COMPARISON; }
">=" { yylval.subtok = 6; return COMPARISON; }
">" { yylval.subtok = 2; return COMPARISON; }
"<=" { yylval.subtok = 5; return COMPARISON; }
"<" { yylval.subtok = 1; return COMPARISON; }
"!=" { yylval.subtok = 3; return COMPARISON; }
'[A-Za-z0-9_:\\\.|;]*' { yylval.strval = strdup(yytext+1);
yylval.strval[yyleng-2] = 0; return FILENAME; }
[A-Za-z][A-Za-z0-9_]* { yylval.strval = strdup(yytext);return NAME; }
'[^'/\\.\n]+' { yylval.strval = strdup(yytext+1);yylval.strval[yyleng-2] = 0; return FILENAME; }
[ \t\n]
. { }
%%
void PROC_FLUSH_BUF ( FILE * xFile )
{
yy_delete_buffer ( YY_CURRENT_BUFFER );
yy_switch_to_buffer ( yy_create_buffer ( xFile, YY_BUF_SIZE ) );
}