-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscanner.l
executable file
·43 lines (33 loc) · 990 Bytes
/
scanner.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
%{
#include "common.h"
#include "parser.tab.h"
%}
/* Definições */
STRING ([a-zA-Z][a-z0-9]*)|\*
WHITESPACE [ \n\r\t]+
FLOAT [0-9]+\.[0-9]+
INTEGER [0-9]+
IGNORE (UNIQUE|CHECK|DEFAULT)
ANY_CHAR .
%% /* Regras */
{WHITESPACE} /* Ignore */ ;
"NOT NULL" { return T_NOT_NULL;}
"CREATE" { return T_CREATE;}
"TABLE" { return T_TABLE; }
"VARCHAR" { yylval.strval = strdup(yytext); return T_VARCHAR; }
"INT" {yylval.strval = strdup(yytext); return T_INT; }
"FLOAT" { yylval.strval = strdup(yytext); return T_FLOAT; }
"SELECT" { return T_SELECT;}
"FROM" { return T_FROM;}
"PRIMARY KEY" {return T_PRIMARY_KEY;}
"FOREIGN KEY" {return T_FOREIGN_KEY;}
"REFERENCES" {return T_REFERENCES;}
[\(\)\{\}:;=,] {return yytext[0];}
{IGNORE} {return T_IGNORE;}
{STRING} {yylval.strval = strdup(yytext);return D_STRING;}
{INTEGER} { return D_INTEGER; }
{FLOAT} { return D_FLOAT; }
{ANY_CHAR} {
printf("Unexpected character in input: '%c' (ASCII=%d)\n", yytext[0], yytext[0]);
}
%% /* Código C */