forked from antonmks/Alenka
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfl.l
113 lines (93 loc) · 2.88 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
/*
* 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 <stdarg.h>
#include <string.h>
void yyerror(char *s, ...);
int oldstate;
#define YY_NEVER_INTERACTIVE 1
%}
%option noyywrap nodefault yylineno case-insensitive
%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; }
FROM { return FROM; }
USING { return USING; }
COUNT { return COUNT; }
SUM { return SUM; }
AVG { return AVG; }
MIN { return MIN; }
MAX { return MAX; }
LIMIT { return LIMIT; }
ON { return ON; }
STREAM { return STREAM; }
BINARY { return BINARY; }
[0-9]+ { yylval.intval = atoi(yytext); return INTNUM; }
-?[0-9]+"."[0-9]* |
-?"."[0-9]+ |
-?[0-9]+E[-+]?[0-9]+ |
-?[0-9]+"."[0-9]*E[-+]?[0-9]+ |
-?"."[0-9]+E[-+]?[0-9]+ { yylval.floatval = atof(yytext) ;
return APPROXNUM; }
TRUE { yylval.intval = 1; return BOOL; }
UNKNOWN { yylval.intval = -1; return BOOL; }
FALSE { yylval.intval = 0; return BOOL; }
\"(\\.|\"\"|[^"\n])*\" { yylval.strval = strdup(yytext); return STRING; }
'(\\.|[^'\n])*$ { yyerror("Unterminated string %s", yytext); }
\"(\\.|[^"\n])*$ { yyerror("Unterminated string %s", yytext); }
[-+&~|^/%*(),.;:!{}] { return yytext[0]; }
"&&" { return AND; }
"||" { return OR; }
":=" { return ASSIGN; }
"=" { return EQUAL; }
"==" { 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; }
'[^'\n]*$ { printf("unterminated quoted name %s", yytext); }
[ \t\n]
. { printf("mystery character '%c'", *yytext); }
%%
void PROC_FLUSH_BUF ( FILE * xFile )
{
yy_delete_buffer ( YY_CURRENT_BUFFER );
yy_switch_to_buffer ( yy_create_buffer ( xFile, YY_BUF_SIZE ) );
}