Code

frontend: Let LIST not include details.
[sysdb.git] / src / frontend / scanner.l
index a0c05d8ab495fdd7ed4da9e215f0caa280f1b36c..61f1743fa60560c69f2cf5835f9c49827e760b17 100644 (file)
 
 %{
 
+#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,17 +86,29 @@ identifier  ([A-Za-z_][A-Za-z_0-9$]*)
 <CSC>{csc_inside}      { /* ignore */ }
 <CSC>{csc_end}         { BEGIN(INITIAL); }
 <CSC><<EOF>> {
-               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, "FETCH"))
+                       return FETCH;
+               else if (! strcasecmp(yytext, "LIST"))
                        return LIST;
+               else if (! strcasecmp(yytext, "LOOKUP"))
+                       return LOOKUP;
+               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;
+       }
 
 .      { /* do nothing for now */ }