This commit is contained in:
brianb 2001-04-16 01:05:23 +00:00
parent ee6df7d015
commit c4039d997e
3 changed files with 0 additions and 491 deletions

View File

@ -1,30 +0,0 @@
SHELL = /bin/sh
LEX = flex -i
YACC = yacc -d
CC = gcc
CPPFLAGS =
CFLAGS = $(CPPFLAG) -g -O2 -DHW_LITTLE_ENDIAN
LDFLAGS =
LIBS = -L ../libmdb -lmdb -ll `glib-config --libs` -lreadline -lncurses
INC = -I ../include `glib-config --cflags` -I/usr/include/readline
OBJS = y.tab.o lex.yy.o mdbsql.o main.o
all: mdb-sql
libmdb: $(OBJS)
rm -f libmdb.a
ar cq libmdb.a $(OBJS)
clean:
rm -f core *.o *.a y.tab.* lex.yy.c mdb-sql
lex.yy.c: sql.l
$(LEX) $<
y.tab.c: sql.y
$(YACC) $<
.c.o:
$(CC) $(CFLAGS) -g -c $< $(INC)
sql: $(OBJS)
$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)

View File

@ -1,443 +0,0 @@
#ifndef lint
static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define yyclearin (yychar=(-1))
#define yyerrok (yyerrflag=0)
#define YYRECOVERING (yyerrflag!=0)
#define YYPREFIX "yy"
#line 2 "parser.y"
#include "mdbsql.h"
MdbSQL *g_sql;
#line 7 "parser.y"
typedef union {
char *name;
double dval;
int ival;
} YYSTYPE;
#line 22 "y.tab.c"
#define NAME 257
#define PATH 258
#define NUMBER 259
#define STRING 260
#define SELECT 261
#define FROM 262
#define WHERE 263
#define CONNECT 264
#define TO 265
#define LIST 266
#define TABLES 267
#define AND 268
#define YYERRCODE 256
short yylhs[] = { -1,
0, 0, 0, 3, 3, 5, 5, 6, 6, 7,
7, 7, 8, 8, 4, 4, 2, 1, 1, 1,
9,
};
short yylen[] = { 2,
5, 3, 2, 0, 2, 1, 3, 3, 3, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1,
};
short yydefred[] = { 0,
0, 0, 0, 0, 21, 18, 0, 0, 0, 3,
0, 0, 16, 15, 2, 17, 0, 20, 0, 1,
0, 13, 14, 5, 0, 0, 10, 11, 12, 0,
0, 0, 8, 7, 9,
};
short yydgoto[] = { 4,
7, 17, 20, 15, 24, 25, 30, 26, 8,
};
short yysindex[] = { -260,
-42, -251, -250, 0, 0, 0, -246, -29, -255, 0,
-239, -42, 0, 0, 0, 0, -244, 0, -252, 0,
-51, 0, 0, 0, -248, -51, 0, 0, 0, -247,
-252, -236, 0, 0, 0,
};
short yyrindex[] = { 0,
0, 0, 0, 0, 0, 0, 0, -240, 0, 0,
0, 0, 0, 0, 0, 0, 23, 0, 0, 0,
0, 0, 0, 0, 24, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
};
short yygindex[] = { 0,
13, 0, 0, 0, -5, 0, 1, -2, 0,
};
#define YYTABLESIZE 215
short yytable[] = { 6,
1, 13, 14, 2, 21, 3, 22, 23, 29, 27,
28, 22, 23, 9, 12, 11, 10, 16, 19, 31,
35, 19, 4, 6, 18, 34, 32, 33, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 5,
};
short yycheck[] = { 42,
261, 257, 258, 264, 257, 266, 259, 260, 60, 61,
62, 259, 260, 265, 44, 262, 267, 257, 263, 268,
257, 262, 0, 0, 12, 31, 26, 30, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 257,
};
#define YYFINAL 4
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 268
#if YYDEBUG
char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,"'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'<'","'='","'>'",0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NAME","PATH",
"NUMBER","STRING","SELECT","FROM","WHERE","CONNECT","TO","LIST","TABLES","AND",
};
char *yyrule[] = {
"$accept : query",
"query : SELECT column_list FROM table where_clause",
"query : CONNECT TO database",
"query : LIST TABLES",
"where_clause :",
"where_clause : WHERE sarg_list",
"sarg_list : sarg",
"sarg_list : sarg AND sarg_list",
"sarg : NAME operator constant",
"sarg : constant operator NAME",
"operator : '='",
"operator : '>'",
"operator : '<'",
"constant : NUMBER",
"constant : STRING",
"database : PATH",
"database : NAME",
"table : NAME",
"column_list : '*'",
"column_list : column",
"column_list : column ',' column_list",
"column : NAME",
};
#endif
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
short *yyssp;
YYSTYPE *yyvsp;
YYSTYPE yyval;
YYSTYPE yylval;
short yyss[YYSTACKSIZE];
YYSTYPE yyvs[YYSTACKSIZE];
#define yystacksize YYSTACKSIZE
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
yyparse()
{
register int yym, yyn, yystate;
#if YYDEBUG
register char *yys;
extern char *getenv();
if (yys = getenv("YYDEBUG"))
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = (-1);
yyssp = yyss;
yyvsp = yyvs;
*yyssp = yystate = 0;
yyloop:
if (yyn = yydefred[yystate]) goto yyreduce;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
yychar = (-1);
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
#ifdef lint
goto yynewerror;
#endif
yynewerror:
yyerror("syntax error");
#ifdef lint
goto yyerrlab;
#endif
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yyssp);
#endif
if (yyssp <= yyss) goto yyabort;
--yyssp;
--yyvsp;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = (-1);
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
yyval = yyvsp[1-yym];
switch (yyn)
{
case 1:
#line 19 "parser.y"
{
mdb_sql_select(g_sql);
}
break;
case 2:
#line 22 "parser.y"
{
mdb_sql_open(g_sql, yyvsp[0].name); free(yyvsp[0].name);
}
break;
case 3:
#line 25 "parser.y"
{
mdb_sql_listtables(g_sql);
}
break;
case 8:
#line 41 "parser.y"
{
mdb_sql_add_sarg(g_sql, yyvsp[-2].name, yyvsp[-1].ival, yyvsp[0].name);
free(yyvsp[-2].name);
free(yyvsp[0].name);
}
break;
case 9:
#line 46 "parser.y"
{
mdb_sql_add_sarg(g_sql, yyvsp[0].name, yyvsp[-1].ival, yyvsp[-2].name);
free(yyvsp[-2].name);
free(yyvsp[0].name);
}
break;
case 10:
#line 54 "parser.y"
{ yyval.ival = MDB_EQUAL; }
break;
case 11:
#line 55 "parser.y"
{ yyval.ival = MDB_GT; }
break;
case 12:
#line 56 "parser.y"
{ yyval.ival = MDB_LT; }
break;
case 13:
#line 59 "parser.y"
{ yyval.name = yyvsp[0].name; }
break;
case 14:
#line 60 "parser.y"
{ yyval.name = yyvsp[0].name; }
break;
case 17:
#line 68 "parser.y"
{ mdb_sql_add_table(g_sql, yyvsp[0].name); free(yyvsp[0].name); }
break;
case 18:
#line 72 "parser.y"
{ mdb_sql_all_columns(g_sql); }
break;
case 21:
#line 78 "parser.y"
{ mdb_sql_add_column(g_sql, yyvsp[0].name); free(yyvsp[0].name); }
break;
#line 388 "y.tab.c"
}
yyssp -= yym;
yystate = *yyssp;
yyvsp -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yyssp = YYFINAL;
*++yyvsp = yyval;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yyssp, yystate);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate;
*++yyvsp = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
return (1);
yyaccept:
return (0);
}

View File

@ -1,18 +0,0 @@
#define NAME 257
#define PATH 258
#define NUMBER 259
#define STRING 260
#define SELECT 261
#define FROM 262
#define WHERE 263
#define CONNECT 264
#define TO 265
#define LIST 266
#define TABLES 267
#define AND 268
typedef union {
char *name;
double dval;
int ival;
} YYSTYPE;
extern YYSTYPE yylval;