Skip to content
Snippets Groups Projects
Commit 4ebb99fc authored by Wanxin Li's avatar Wanxin Li
Browse files

add limit, elim

parent 9f822c80
No related branches found
No related tags found
No related merge requests found
.PHONY: all clean
#CFLAGS = `pkg-config --cflags glib-2.0`
#CFLAGS = `pkg-config --cflags glib-2.0`
#LDLIBS = `pkg-config --libs glib-2.0`
all: SQLPParser Parser
......@@ -7,7 +7,13 @@ SQLPParser: SQLPParser.c SQLPGrammar.y SQLPScanner.l util.o
bison --verbose -d SQLPGrammar.y
flex SQLPScanner.l
gcc -w SQLPParser.c util.o -o SQLPParser
rm -f lex.yy.c SQLPGrammar.tab.c SQLPGrammar.tab.h
rm -f lex.yy.c SQLPGrammar.tab.c SQLPGrammar.tab.h
SQLPParser_new: SQLPParser.c SQLPGrammar_new.y SQLPScanner.l util.o
bison --verbose -d SQLPGrammar_new.y
flex SQLPScanner_new.l
gcc -w SQLPParser.c util.o -o SQLPParser_new
# rm -f lex.yy.c SQLPGrammar.tab.c SQLPGrammar.tab.h
util.o: util.c util.h
gcc -c util.c
......
......@@ -41,13 +41,13 @@ Query
printf("Union Query\n");
$$ = $1;
}
| Union_Query Limit Constant // todo: limit by or limit?
| Union_Query LIMIT Constant
| Select_Query
{
printf("Select Query\n");
$$ = $1;
}
| Select_Query Limit Constant
| Select_Query LIMIT Constant
;
Select_Query
......@@ -59,15 +59,6 @@ Select_Query
| SELECT ELIM Select_List Body
;
Elim
: ELIM
| NO_ELM
;
Limit
: LIMIT
| NO_LIMIT
;
BodyContent // todo: create BodyContent since njoin does not apply to FROM
......@@ -85,7 +76,7 @@ TableList
: TableIdentifier VarIdentifier
{
printf("TableList 1\n");
$$ = create_rename_operator($1, $2);
$$ = create_rename_operator($1, $2);s
}
| TableIdentifier VarIdentifier ',' TableList // keep right-recursive
{
......@@ -197,8 +188,11 @@ CompOperator
Pred
: Conj
| Pred OR Conj
| BasicPred
| Conj AND BasicPred
Conj
: BasicPred
| BasicPred AND Conj
BasicPred
: Term CompOperator Term
......
%{
/*
* Copyright (C) 1989, G. E. Weddell.
*
* This file is part of RDM.
*
* RDM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RDM 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RDM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SQLPGrammar_new.tab.h"
#include <stdio.h>
#include <ctype.h>
int LineNumber = 1;
char LineBuffer[200];
%}
%p 3000
D [0-9]
L [a-zA-Z_]
E [Ee][+-]?{D}+
%%
\%.*\n { LineNumber++; }
\n { LineNumber++; strcpy(LineBuffer, ""); }
"all" { strcat(LineBuffer, yytext); return(ALL); }
"and" { strcat(LineBuffer, yytext); return(AND); }
"array" { strcat(LineBuffer, yytext); return(ARRAY); }
"as" { strcat(LineBuffer, yytext); return(AS); }
"asc" { strcat(LineBuffer, yytext); return(ASC); }
"binary" { strcat(LineBuffer, yytext); return(BINARY); }
"by" { strcat(LineBuffer, yytext); return(BY); }
"change" { strcat(LineBuffer, yytext); return(CHANGE); }
"class" { strcat(LineBuffer, yytext); return(CLASS); }
"constraints" { strcat(LineBuffer, yytext); return(CONSTRAINTS); }
"cover" { strcat(LineBuffer, yytext); return(COVER); }
"declare" { strcat(LineBuffer, yytext); return(DECLARE); }
"delete" { strcat(LineBuffer, yytext); return(DELETE); }
"desc" { strcat(LineBuffer, yytext); return(DESC); }
"union" { strcat(LineBuffer, yytext); return(UNION); }
"determined" { strcat(LineBuffer, yytext); return(DETERMINED); }
"distributed" { strcat(LineBuffer, yytext); return(DISTRIBUTED); }
"dynamic" { strcat(LineBuffer, yytext); return(DYNAMIC); }
"exist" { strcat(LineBuffer, yytext); return(EXIST); }
"elim" { strcat(LineBuffer, yytext); return(ELIM); }
"for" { strcat(LineBuffer, yytext); return(FOR); }
"frequency" { strcat(LineBuffer, yytext); return(FREQUENCY); }
"from" { strcat(LineBuffer, yytext); return(FROM); }
"given" { strcat(LineBuffer, yytext); return(GIVEN); }
"has" { strcat(LineBuffer, yytext); return(HAS); }
"implies" { strcat(LineBuffer, yytext); return(IMPLIES); }
"index" { strcat(LineBuffer, yytext); return(INDEX); }
"insert" { strcat(LineBuffer, yytext); return(INSERT); }
"Integer" { strcat(LineBuffer, yytext); return(INTCLASS); }
"isa" { strcat(LineBuffer, yytext); return(ISA); }
"limit" { strcat(LineBuffer, yytext); return(LIMIT); }
"list" { strcat(LineBuffer, yytext); return(LIST); }
"max" { strcat(LineBuffer, yytext); return(MAX); }
"maxlen" { strcat(LineBuffer, yytext); return(MAXLEN); }
"min" { strcat(LineBuffer, yytext); return(MIN); }
"mod" { strcat(LineBuffer, yytext); return(MOD); }
"not" { strcat(LineBuffer, yytext); return(NOT); }
"of" { strcat(LineBuffer, yytext); return(OF); }
"on" { strcat(LineBuffer, yytext); return(ON); }
"one" { strcat(LineBuffer, yytext); return(ONE); }
"or" { strcat(LineBuffer, yytext); return(OR); }
"order" { strcat(LineBuffer, yytext); return(ORDER); }
"ordered" { strcat(LineBuffer, yytext); return(ORDERED); }
"overlap" { strcat(LineBuffer, yytext); return(OVERLAP); }
"pointer" { strcat(LineBuffer, yytext); return(POINTER); }
"precomputed" { strcat(LineBuffer, yytext); return(PRECOMPUTED); }
"property" { strcat(LineBuffer, yytext); return(PROPERTY); }
"properties" { strcat(LineBuffer, yytext); return(PROPERTIES); }
"query" { strcat(LineBuffer, yytext); return(QUERY); }
"range" { strcat(LineBuffer, yytext); return(RANGE); }
"return" { strcat(LineBuffer, yytext); return(RETURN); }
"schema" { strcat(LineBuffer, yytext); return(SCHEMA); }
"select" { strcat(LineBuffer, yytext); return(SELECT); }
"selectivity" { strcat(LineBuffer, yytext); return(SELECTIVITY); }
"size" { strcat(LineBuffer, yytext); return(SIZE); }
"space" { strcat(LineBuffer, yytext); return(SPACE); }
"static" { strcat(LineBuffer, yytext); return(STATIC); }
"store" { strcat(LineBuffer, yytext); return(STORE); }
"storing" { strcat(LineBuffer, yytext); return(STORING); }
"String" { strcat(LineBuffer, yytext); return(STRCLASS); }
"time" { strcat(LineBuffer, yytext); return(TIME); }
"to" { strcat(LineBuffer, yytext); return(TO); }
"transaction" { strcat(LineBuffer, yytext); return(TRANSACTION); }
"tree" { strcat(LineBuffer, yytext); return(TREE); }
"type" { strcat(LineBuffer, yytext); return(TYPE); }
"unit" { strcat(LineBuffer, yytext); return(UNIT); }
"where" { strcat(LineBuffer, yytext); return(WHERE); }
{L}({L}|{D})* { strcat(LineBuffer, yytext); return(IDENTIFIER); }
{D}+ { strcat(LineBuffer, yytext); return(INTEGER); }
{D}+{E} { strcat(LineBuffer, yytext); return(REAL); }
{D}*"."{D}+({E})? { strcat(LineBuffer, yytext); return(REAL); }
{D}+"."{D}*({E})? { strcat(LineBuffer, yytext); return(REAL); }
\"(\\.|[^\\"])*\" { strcat(LineBuffer, yytext); return(STRING); }
":=" { strcat(LineBuffer, yytext); return(ASSIGN); }
"<=" { strcat(LineBuffer, yytext); return(LE); }
">=" { strcat(LineBuffer, yytext); return(GE); }
"<>" { strcat(LineBuffer, yytext); return(NE); }
";" { strcat(LineBuffer, yytext); return(';'); }
"{" { strcat(LineBuffer, yytext); return('{'); }
"}" { strcat(LineBuffer, yytext); return('}'); }
"," { strcat(LineBuffer, yytext); return(','); }
"=" { strcat(LineBuffer, yytext); return(EQ); }
"(" { strcat(LineBuffer, yytext); return('('); }
")" { strcat(LineBuffer, yytext); return(')'); }
"[" { strcat(LineBuffer, yytext); return('['); }
"]" { strcat(LineBuffer, yytext); return(']'); }
"." { strcat(LineBuffer, yytext); return('.'); }
"-" { strcat(LineBuffer, yytext); return('-'); }
"+" { strcat(LineBuffer, yytext); return('+'); }
"*" { strcat(LineBuffer, yytext); return(STAR); }
"/" { strcat(LineBuffer, yytext); return('/'); }
"<" { strcat(LineBuffer, yytext); return('<'); }
">" { strcat(LineBuffer, yytext); return('>'); }
" " { strcat(LineBuffer, yytext); }
"\r" { strcat(LineBuffer, yytext); }
. { strcat(LineBuffer, yytext);
yyerror("illegal character"); }
%%
yyerror(s)
char *s;
{
int i;
char c;
fprintf( stderr, "\n%s", LineBuffer );
c = input();
while ( c != '\n' && c != 0 ) {
putc(c, stderr);
c = input();
}
putc('\n', stderr);
for (i=1; i <= strlen( LineBuffer ) - strlen( yytext ); i++)
putc(' ', stderr);
for (i=1; i <= strlen( yytext ); i++)
putc('^', stderr);
putc('\n', stderr);
fprintf ( stderr, "** error: %s found in line %d.\n\n", s, LineNumber );
}
yywrap()
{
return(1);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment