Code

frontend: Let LIST not include details.
[sysdb.git] / src / frontend / scanner.l
index 6c2bfa148fd802ff4365187015d7636895af86bf..61f1743fa60560c69f2cf5835f9c49827e760b17 100644 (file)
@@ -74,6 +74,8 @@ csc_inside    ([^*/]+|[^*]\/|\*[^/])
 csc_end                \*\/
 
 identifier     ([A-Za-z_][A-Za-z_0-9$]*)
+/* TODO: fully support SQL strings */
+string         ('[^']*')
 
 %%
 
@@ -89,12 +91,24 @@ identifier  ([A-Za-z_][A-Za-z_0-9$]*)
        }
 
 {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 */ }