Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LDI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grant Weddell
LDI
Commits
71c7f977
Commit
71c7f977
authored
5 years ago
by
w328li
Browse files
Options
Downloads
Patches
Plain Diff
changed grammar rules according to June 12 discussion
todo: build parse tree
parent
1a732a2c
No related branches found
No related tags found
1 merge request
!5
Dev Merge into Master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SQLPGrammar_new.y
+37
-73
37 additions, 73 deletions
SQLPGrammar_new.y
with
37 additions
and
73 deletions
SQLPGrammar_new.y
+
37
−
73
View file @
71c7f977
...
...
@@ -30,8 +30,8 @@ SQLPProgram
{
printf("Input Query\n");
cons_cell *n = $1;
printf("Printing Tree\n");
print_cons_tree(n);
printf("Printing Tree\n");
print_cons_tree(n);
}
;
...
...
@@ -41,11 +41,13 @@ Query
printf("Union Query\n");
$$ = $1;
}
| Union_Query Limit Constant // todo: limit by or limit?
| Select_Query
{
printf("Select Query\n");
$$ = $1;
}
| Select_Query Limit Constant
;
Select_Query
...
...
@@ -54,6 +56,7 @@ Select_Query
printf("SQLP Query\n");
$$ = create_proj_operator($2, $3);
}
| SELECT ELIM Select_List Body
;
Elim
...
...
@@ -67,46 +70,44 @@ Limit
;
Body
: FROM Table
Path
: FROM Table
List
{
printf("Body 1\n");
$$ = $2;
}
| FROM Table
Path
WHERE Pred
| FROM Table
List
WHERE Pred
{
printf("Body 2\n");
$$ = create_eval_operator($4, $2);
}
;
Table
Path
Table
List
: TableIdentifier VarIdentifier
{
printf("Table
path
1\n");
printf("Table
List
1\n");
$$ = create_rename_operator($1, $2);
}
| TableIdentifier VarIdentifier ',' Table
Path
| TableIdentifier VarIdentifier ',' Table
List // keep right-recursive
{
printf("Table
path
2\n");
printf("Table
List
2\n");
$$ = create_cross_operator(create_rename_operator($1, $2), $4);
}
;
Union_Query
:
Union
_Query UNION
Select
_Query
:
'(' Select
_Query
')'
UNION
Union
_Query
{
printf("Union query\n");
$$ = create_union_all_operator($1, $3);
$$ = create_union_all_operator($1, $3);
// todo: create_union_operator
}
| '(' Select_Query ')' UNIONALL Union_Query
: Select_Query
;
Select_List
: STAR
{
printf("Select_List 1\n");
$$ = create_atom("STAR");
}
| Col
: Col
{
printf("Select_List 2\n");
$$ = create_rename_operator($1, NULL);
...
...
@@ -161,7 +162,7 @@ AttrIdentifier
$$ = create_var(yytext);
}
Operator
Comp
Operator
: EQ
{
printf("Operator EQ\n");
...
...
@@ -195,62 +196,23 @@ Operator
;
Pred
: Col Operator Col
{
printf("Pred 1\n");
cons_cell* first_term = create_term($1);
cons_cell* second_term = create_term($3);
$$ = create_comp_operator($2, first_term, second_term, NULL);
}
| Col Operator Constant
{
printf("Pred 2\n");
cons_cell* first_term = create_term($1);
$$ = create_comp_operator($2, first_term, $3, NULL);
}
| Pred AND Col Operator Col
{
printf("Pred 3\n");
cons_cell* first_term = create_term($1);
cons_cell* second_term = create_term($3);
comp_cons = create_comp_operator($2, first_term, second_term, NULL);
$$ = create_and_operator($1, comp_cons);
}
| Pred AND Col Operator Constant
{
printf("Pred 4\n");
cons_cell* first_term = create_term($1);
cons_cell* second_term = create_term($3);
comp_cons = create_comp_operator($2, first_term, $3, NULL);
$$ = create_and_operator($1, comp_cons);
}
| Pred OR Col Operator Col
{
printf("Pred 5\n");
cons_cell* first_term = create_term($1);
cons_cell* second_term = create_term($3);
comp_cons = create_comp_operator($2, first_term, second_term, NULL);
$$ = create_or_operator($1, comp_cons);
}
| Pred OR Col Operator Constant
{
printf("Pred 6\n");
cons_cell* first_term = create_term($1);
cons_cell* second_term = create_term($3);
comp_cons = create_comp_operator($2, first_term, $3, NULL);
$$ = create_or_operator($1, comp_cons);
}
| NOT Pred
{
printf("Pred 7\n");
$$ = create_not_operator($1, NULL);
}
| EXIST '(' SELECT STAR Body ')'
{
printf("Pred 8\n")
// todo: create exist operator?
}
;
: Conj
| Pred OR Conj
| BasicPred
| Conj AND BasicPred
BasicPred
: Term CompOperator Term
| EXIST '(' Body ')'
| NOT BasicPred
| '(' Pred ')'
Term
: Constant
| TableList
Constant
: INTEGER
...
...
@@ -268,3 +230,5 @@ Constant
printf("STRING is |%s|", yytext);
$$ = create_constant(yytext);
}
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment