X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ffrontend%2Fscanner.l;h=dd2a86cf5273b4e5e3c450c02306820b282a1a46;hb=3a61ffc8d3d061ee69e7b71d92cf1a036350012c;hp=948b6badf155e848c5182ad1ca38f8004a49eb3f;hpb=ee4601a116d7c8f035d322373f7825d5373e454e;p=sysdb.git diff --git a/src/frontend/scanner.l b/src/frontend/scanner.l index 948b6ba..dd2a86c 100644 --- a/src/frontend/scanner.l +++ b/src/frontend/scanner.l @@ -27,6 +27,10 @@ %{ +#if HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + #include "frontend/connection.h" #include "frontend/parser.h" #include "frontend/grammar.h" @@ -70,6 +74,8 @@ csc_inside ([^*/]+|[^*]\/|\*[^/]) csc_end \*\/ identifier ([A-Za-z_][A-Za-z_0-9$]*) +/* TODO: fully support SQL strings */ +string ('[^']*') %% @@ -85,14 +91,37 @@ identifier ([A-Za-z_][A-Za-z_0-9$]*) } {identifier} { - /* XXX */ - if (! strcasecmp(yytext, "LIST")) + /* XXX: simplify handling of reserved words */ + if (! strcasecmp(yytext, "AND")) + return AND; + else if (! strcasecmp(yytext, "FETCH")) + return FETCH; + else if (! strcasecmp(yytext, "LIST")) 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")) + return WHERE; + + yylval->str = strdup(yytext); return IDENTIFIER; } +{string} { + yytext[yyleng - 1] = '\0'; + yylval->str = strdup(yytext + 1); + return STRING; + } + += { return CMP_EQUAL; } +!= { return CMP_NEQUAL; } +=~ { return CMP_REGEX; } +!~ { return CMP_NREGEX; } -. { /* do nothing for now */ } +. { /* XXX: */ return yytext[0]; } %%