X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ffrontend%2Fscanner.l;h=0396db53e0d742f17ca12de0fcec788da4c24045;hb=033aa984a8b4be78ced113a3715422841a48d9a8;hp=9eec4de6c455e3dadd99fe586c2d4e68ba324395;hpb=a2c999f4a7c1368c8cdaf554219fb4123068a3f7;p=sysdb.git diff --git a/src/frontend/scanner.l b/src/frontend/scanner.l index 9eec4de..0396db5 100644 --- a/src/frontend/scanner.l +++ b/src/frontend/scanner.l @@ -31,6 +31,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include "core/data.h" #include "frontend/connection.h" #include "frontend/parser.h" #include "frontend/grammar.h" @@ -39,6 +40,7 @@ #include #include +#include #define YY_EXTRA_TYPE sdb_fe_yyextra_t * @@ -77,6 +79,16 @@ identifier ([A-Za-z_][A-Za-z_0-9$]*) /* TODO: fully support SQL strings */ string ('[^']*') +dec ([\+\-]?[0-9]+) +exp ([\+\-]?[0-9]+[Ee]\+?[0-9]+) +integer ({dec}|{exp}) +float1 ([\+\-]?[0-9]+\.[0-9]*([Ee][\+\-]?[0-9]+)?) +float2 ([\+\-]?[0-9]*\.[0-9]+([Ee][\+\-]?[0-9]+)?) +float3 ([\+\-]?[0-9]+[Ee]\-[0-9]+) +float4 ([\+\-]?[Ii][Nn][Ff]([Ii][Nn][Ii][Tt][Yy])?) +float5 ([Nn][Aa][Nn]) +float ({float1}|{float2}|{float3}|{float4}|{float5}) + %% {whitespace} | @@ -100,6 +112,8 @@ string ('[^']*') return LIST; else if (! strcasecmp(yytext, "LOOKUP")) return LOOKUP; + else if (! strcasecmp(yytext, "NOT")) + return NOT; else if (! strcasecmp(yytext, "OR")) return OR; else if (! strcasecmp(yytext, "WHERE")) @@ -113,9 +127,25 @@ string ('[^']*') yylval->str = strdup(yytext + 1); return STRING; } +{integer} { + yylval->data.data.integer = (int64_t)strtoll(yytext, NULL, 10); + yylval->data.type = SDB_TYPE_INTEGER; + return INTEGER; + } +{float} { + yylval->data.data.decimal = strtod(yytext, NULL); + yylval->data.type = SDB_TYPE_DECIMAL; + return FLOAT; + } = { return CMP_EQUAL; } +!= { return CMP_NEQUAL; } =~ { return CMP_REGEX; } +!~ { return CMP_NREGEX; } +\< { return CMP_LT; } +\<= { return CMP_LE; } +\>= { return CMP_GE; } +\> { return CMP_GT; } . { /* XXX: */ return yytext[0]; }