2001-04-08 09:32:43 +08:00
|
|
|
%{
|
|
|
|
#include <string.h>
|
|
|
|
#include "mdbsql.h"
|
2001-04-12 07:33:19 +08:00
|
|
|
#include "parser.h"
|
2001-04-08 09:32:43 +08:00
|
|
|
|
|
|
|
extern MdbSQL *g_sql;
|
|
|
|
%}
|
|
|
|
|
|
|
|
%%
|
|
|
|
select { return SELECT; }
|
|
|
|
from { return FROM; }
|
|
|
|
connect { return CONNECT; }
|
2001-04-21 05:06:46 +08:00
|
|
|
disconnect { return DISCONNECT; }
|
2001-04-08 09:32:43 +08:00
|
|
|
to { return TO; }
|
|
|
|
list { return LIST; }
|
|
|
|
where { return WHERE; }
|
|
|
|
and { return AND; }
|
|
|
|
tables { return TABLES; }
|
2001-04-21 05:06:46 +08:00
|
|
|
table { return TABLE; }
|
|
|
|
describe { return DESCRIBE; }
|
|
|
|
(<=) { return LTEQ; }
|
|
|
|
(>=) { return GTEQ; }
|
|
|
|
like { return LIKE; }
|
2001-04-08 09:32:43 +08:00
|
|
|
[ \t\r] ;
|
|
|
|
[A-z][A-z0-9]* { yylval.name = strdup(yytext); return NAME; }
|
|
|
|
'.*' { yylval.name = strdup(yytext); return STRING; }
|
|
|
|
([0-9]+|([0-9]*\.[0-9+)([eE][-+]?[0-9]+)?) {
|
|
|
|
yylval.name = strdup(yytext); return NUMBER;
|
|
|
|
}
|
2001-04-21 05:06:46 +08:00
|
|
|
~?(\/?[A-z0-9\.]+)+ { yylval.name = strdup(yytext); return PATH; }
|
2001-04-08 09:32:43 +08:00
|
|
|
. { return yytext[0]; }
|
|
|
|
%%
|
|
|
|
|
|
|
|
void yyerror(char *s)
|
|
|
|
{
|
|
|
|
fprintf(stderr,"Error at Line : %s near %s\n", s, yytext);
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
g_sql = mdb_sql_init();
|
|
|
|
yyin = stdin;
|
|
|
|
if (yyparse()) {
|
|
|
|
fprintf(stderr, "Couldn't parse SQL\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
mdb_sql_dump(g_sql);
|
|
|
|
mdb_sql_exit(g_sql);
|
|
|
|
}
|
|
|
|
#endif
|