2001-04-08 01:32:43 +00:00
|
|
|
%{
|
2001-05-16 00:21:17 +00:00
|
|
|
/* MDB Tools - A library for reading MS Access database file
|
|
|
|
|
* Copyright (C) 2000 Brian Bruns
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
2001-04-08 01:32:43 +00:00
|
|
|
#include "mdbsql.h"
|
|
|
|
|
|
|
|
|
|
MdbSQL *g_sql;
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
%union {
|
|
|
|
|
char *name;
|
|
|
|
|
double dval;
|
|
|
|
|
int ival;
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-16 00:21:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
%token <name> NAME PATH STRING NUMBER
|
2001-04-20 21:06:46 +00:00
|
|
|
%token SELECT FROM WHERE CONNECT DISCONNECT TO LIST TABLES WHERE AND
|
|
|
|
|
%token DESCRIBE TABLE
|
|
|
|
|
%token LTEQ GTEQ LIKE
|
2001-04-08 01:32:43 +00:00
|
|
|
|
2001-05-16 00:21:17 +00:00
|
|
|
%type <name> database
|
|
|
|
|
%type <name> constant
|
|
|
|
|
%type <ival> operator
|
|
|
|
|
|
2001-04-08 01:32:43 +00:00
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
query:
|
|
|
|
|
SELECT column_list FROM table where_clause {
|
|
|
|
|
mdb_sql_select(g_sql);
|
|
|
|
|
}
|
|
|
|
|
| CONNECT TO database {
|
2001-05-16 00:21:17 +00:00
|
|
|
mdb_sql_open(g_sql, $3); free($3);
|
2001-04-08 01:32:43 +00:00
|
|
|
}
|
2001-04-20 21:06:46 +00:00
|
|
|
| DISCONNECT {
|
|
|
|
|
mdb_sql_close(g_sql);
|
|
|
|
|
}
|
|
|
|
|
| DESCRIBE TABLE table {
|
|
|
|
|
mdb_sql_describe_table(g_sql);
|
|
|
|
|
}
|
2001-04-08 01:32:43 +00:00
|
|
|
| LIST TABLES {
|
|
|
|
|
mdb_sql_listtables(g_sql);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
where_clause:
|
|
|
|
|
/* empty */
|
|
|
|
|
| WHERE sarg_list
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
sarg_list:
|
|
|
|
|
sarg
|
|
|
|
|
| sarg AND sarg_list
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
sarg:
|
|
|
|
|
NAME operator constant {
|
2001-05-16 00:21:17 +00:00
|
|
|
mdb_sql_add_sarg(g_sql, $1, $2, $3);
|
|
|
|
|
free($1);
|
|
|
|
|
free($3);
|
2001-04-08 01:32:43 +00:00
|
|
|
}
|
|
|
|
|
| constant operator NAME {
|
2001-05-16 00:21:17 +00:00
|
|
|
mdb_sql_add_sarg(g_sql, $3, $2, $1);
|
|
|
|
|
free($1);
|
|
|
|
|
free($3);
|
2001-04-08 01:32:43 +00:00
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
operator:
|
2001-05-16 00:21:17 +00:00
|
|
|
'=' { $$ = MDB_EQUAL; }
|
|
|
|
|
| '>' { $$ = MDB_GT; }
|
|
|
|
|
| '<' { $$ = MDB_LT; }
|
|
|
|
|
| LTEQ { $$ = MDB_LTEQ; }
|
|
|
|
|
| GTEQ { $$ = MDB_GTEQ; }
|
|
|
|
|
| LIKE { $$ = MDB_LIKE; }
|
2001-04-08 01:32:43 +00:00
|
|
|
;
|
|
|
|
|
constant:
|
2001-05-16 00:21:17 +00:00
|
|
|
NUMBER { $$ = $1; }
|
|
|
|
|
| STRING { $$ = $1; }
|
2001-04-08 01:32:43 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
database:
|
|
|
|
|
PATH
|
|
|
|
|
| NAME
|
|
|
|
|
|
|
|
|
|
table:
|
2001-05-16 00:21:17 +00:00
|
|
|
NAME { mdb_sql_add_table(g_sql, $1); free($1); }
|
2001-04-08 01:32:43 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
column_list:
|
|
|
|
|
'*' { mdb_sql_all_columns(g_sql); }
|
|
|
|
|
| column
|
|
|
|
|
| column ',' column_list
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
column:
|
2001-05-16 00:21:17 +00:00
|
|
|
NAME { mdb_sql_add_column(g_sql, $1); free($1); }
|
2001-04-08 01:32:43 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
%%
|