-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql.l
34 lines (34 loc) · 923 Bytes
/
sql.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
%{
#include "y.tab.h"
#include <cstring>
%}
%option noyywrap
%%
"create" { return CREATE; }
"table" { return TABLE; }
"select" { return SELECT; }
"insert" { return INSERT; }
"into" { return INTO; }
"from" { return FROM; }
"values" { return VALUES; }
"drop" { return DROP; }
"varchar" { return CHAR; }
"number" { return NUMBER; }
"count" {return COUNT; }
"where" {return WHERE;}
";" { return SCOLON; }
"(" { return OBR; }
")" { return CBR; }
"*" { return ALL; }
"," { return COMMA;}
"'" { return QUOTE; }
"=" {return EQUALS; }
\n { return EOL;}
[0-9]+ { yylval.sval = (char *)malloc(strlen(yytext)+1);
strcpy(yylval.sval, yytext);
return INTEGER; }
[A-Za-z]+ { yylval.sval = (char *) malloc(strlen(yytext)+1);
strcpy(yylval.sval, yytext);
return STRING; }
. ;
%%