X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ffrontend%2Fscanner.l;h=9eec4de6c455e3dadd99fe586c2d4e68ba324395;hb=495dfe8178398c64d78f1476fe505fb0e36eefdc;hp=a0c05d8ab495fdd7ed4da9e215f0caa280f1b36c;hpb=bf39a85b7764641b4a4f0c452331c8be8cb34a01;p=sysdb.git diff --git a/src/frontend/scanner.l b/src/frontend/scanner.l index a0c05d8..9eec4de 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 ('[^']*') %% @@ -80,19 +86,38 @@ identifier ([A-Za-z_][A-Za-z_0-9$]*) {csc_inside} { /* ignore */ } {csc_end} { BEGIN(INITIAL); } <> { - sdb_fe_yyerror(yylval, yyscanner, "unterminated C-style comment"); + sdb_fe_yyerror(yylloc, yyscanner, "unterminated C-style comment"); return SCANNER_ERROR; } {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, "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_REGEX; } -. { /* do nothing for now */ } +. { /* XXX: */ return yytext[0]; } %%