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

fix term

parent 34bd0871
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,8 @@
%token ON DETERMINED COVER QUERY GIVEN FROM SELECT WHERE ORDER
%token PRECOMPUTED ONE EXIST FOR ALL TRANSACTION INTCLASS STRCLASS
%token INTEGER REAL DOUBLEREAL STRING MAXLEN RANGE TO
%token INSERT END CHANGE DELETE DECLARE RETURN UNION
%token INSERT END CHANGE DELETE DECLARE RETURN UNION UNIONALL
%token ELIM LIMIT NJOIN
%start SQLPProgram
%%
......@@ -74,7 +75,7 @@ BodyContent // create BodyContent since njoin does not apply to FROM
: TableList
{
printf("BodyContent 1\n");
$$ = $1
$$ = $1;
}
| TableList WHERE Pred
{
......@@ -84,20 +85,20 @@ BodyContent // create BodyContent since njoin does not apply to FROM
| '(' TableList ')' NJOIN BodyContent
{
printf("BodyContent 3\n");
$$ = create_njoin_operator($1, $3)
$$ = create_njoin_operator($1, $3);
}
| '(' TableList WHERE Pred ')' NJOIN BodyContent
{
printf("BodyContent 3\n");
$$ = create_njoin_operator(create_eval_operator($4, $2), $6)
$$ = create_njoin_operator(create_eval_operator($4, $2), $6);
}
Body
: FROM BodyContent
{
printf("Body \n")
$$ = $2
printf("Body \n");
$$ = $2;
}
;
......@@ -105,7 +106,7 @@ TableList
: TableIdentifier VarIdentifier
{
printf("TableList 1\n");
$$ = create_rename_operator($1, $2);s
$$ = create_rename_operator($1, $2);
}
| TableIdentifier VarIdentifier ',' TableList // keep right-recursive
{
......@@ -126,10 +127,10 @@ UnionQuery
printf("UnionQuery 2\n");
$$ = create_union_all_operator($2, $5);
}
: SelectQuery
| SelectQuery
{
printf("UnionQuery 3\n");
$$ = $1
$$ = $1;
}
;
......@@ -139,13 +140,13 @@ SelectList
printf("SelectList 2\n");
$$ = create_rename_operator($1, NULL);
}
| Col as AttrIdentifier // todo: create_as_operator
| Col AS AttrIdentifier // todo: create_as_operator
| Col ',' SelectList
{
printf("SelectList 4\n");
$$ = create_rename_operator($1, $2);
}
| Col as AttrIdentifier ',' SelectList
| Col AS AttrIdentifier ',' SelectList
;
Col
......@@ -226,12 +227,12 @@ Pred
: Conj
{
printf("Pred 1\n");
$$ = $1
$$ = $1;
}
| Pred OR Conj
{
printf("Pred 2 \n");
$$ = create_or_operator($1, $3)
$$ = create_or_operator($1, $3);
}
......@@ -239,7 +240,7 @@ Conj
: BasicPred
{
printf("Conj 1 \n");
$$ = $1
$$ = $1;
}
| BasicPred AND Conj
{
......@@ -263,24 +264,24 @@ BasicPred
| NOT BasicPred
{
printf("BasicPred 3 \n");
$$ = create_not_operator($2);
$$ = create_not_operator($2, NULL);
}
| '(' Pred ')'
{
printf("BasicPred 4\n");
$$ = $1
$$ = $1;
}
Term
: Constant
{
printf("Term 1\n");
$$ = create_constant($1)
$$ = $1;
}
| Col
{
printf("Term 2\n");
$$ = create_col($1)
$$ = $1;
}
......
/*
* 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 <stdio.h>
#include "util.h"
#include "lex.yy.c"
#include "SQLPGrammar_new.tab.c"
int main()
{
int Result;
strcpy(LineBuffer, "");
printf("(\n");
Result = yyparse();
if (Result)
printf("**error**");
else
fprintf(stderr, "checking semantics.\n");
printf(")\n");
return (Result);
}
......@@ -51,6 +51,7 @@ E [Ee][+-]?{D}+
"delete" { strcat(LineBuffer, yytext); return(DELETE); }
"desc" { strcat(LineBuffer, yytext); return(DESC); }
"union" { strcat(LineBuffer, yytext); return(UNION); }
"unionall" { strcat(LineBuffer, yytext); return(UNIONALL); }
"determined" { strcat(LineBuffer, yytext); return(DETERMINED); }
"distributed" { strcat(LineBuffer, yytext); return(DISTRIBUTED); }
"dynamic" { strcat(LineBuffer, yytext); return(DYNAMIC); }
......@@ -61,6 +62,7 @@ E [Ee][+-]?{D}+
"from" { strcat(LineBuffer, yytext); return(FROM); }
"given" { strcat(LineBuffer, yytext); return(GIVEN); }
"has" { strcat(LineBuffer, yytext); return(HAS); }
"njoin" { strcat(LineBuffer, yytext); return(NJOIN); }
"implies" { strcat(LineBuffer, yytext); return(IMPLIES); }
"index" { strcat(LineBuffer, yytext); return(INDEX); }
"insert" { strcat(LineBuffer, yytext); return(INSERT); }
......
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