Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Roseseed
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
Wanxin Li
Roseseed
Commits
d2e0a366
Commit
d2e0a366
authored
5 years ago
by
Wanxin Li
Browse files
Options
Downloads
Patches
Plain Diff
changed grammar rules after June12 discussion
parent
32e1c17b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.DS_Store
+0
-0
0 additions, 0 deletions
.DS_Store
SQLPGrammar_new.y
+233
-0
233 additions, 0 deletions
SQLPGrammar_new.y
with
233 additions
and
0 deletions
.DS_Store
0 → 100644
+
0
−
0
View file @
d2e0a366
File added
This diff is collapsed.
Click to expand it.
SQLPGrammar_new.y
0 → 100644
+
233
−
0
View file @
d2e0a366
%{
#include "util.h"
%}
%define api.value.type {cons_cell *}
%token IMPLIES OR AND NOT LE GE LT GT NE HAS MAX MIN AS ASC DESC MOD ASSIGN EQ STAR COMMA DOT
%token SIZE SELECTIVITY OVERLAP
%token FREQUENCY UNIT TIME SPACE
%token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
%token STORE STORING DYNAMIC STATIC OF TYPE ORDERED BY
%token INDEX LIST ARRAY BINARY TREE DISTRIBUTED POINTER
%token SCHEMA CLASS ISA PROPERTIES CONSTRAINTS PROPERTY
%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
%start SQLPProgram
%%
/*
todo: add ELIM, LIMIT
todo: check recursive token is on the left
*/
SQLPProgram
: Query
{
printf("Input Query\n");
cons_cell *n = $1;
printf("Printing Tree\n");
print_cons_tree(n);
}
;
Query
: Union_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 // 4 possibilities
: SELECT Select_List Body
{
printf("SQLP Query\n");
$$ = create_proj_operator($2, $3);
}
;
Elim
: ELIM
| NO_ELM
;
Limit
: LIMIT
| NO_LIMIT
;
Body
: FROM TableList
{
printf("Body 1\n");
$$ = $2;
}
| FROM TableList WHERE Pred
{
printf("Body 2\n");
$$ = create_eval_operator($4, $2);
}
;
TableList
: TableIdentifier VarIdentifier
{
printf("TableList 1\n");
$$ = create_rename_operator($1, $2);
}
| TableIdentifier VarIdentifier ',' TableList // keep right-recursive
{
printf("TableList 2\n");
$$ = create_cross_operator(create_rename_operator($1, $2), $4); //
}
;
Union_Query
: '(' Select_Query ')' UNION Union_Query
{
printf("Union query\n");
$$ = create_union_all_operator($1, $3); // todo: create_union_operator
}
| '(' Select_Query ')' UNIONALL Union_Query
: Select_Query
;
Select_List
: Col
{
printf("Select_List 2\n");
$$ = create_rename_operator($1, NULL);
}
| Col as AttrIdentifier
| Col ',' Select_List
{
printf("Select_List 4\n");
$$ = create_rename_operator($1, $2);
}
| Col as AttrIdentifier ',' Select_List
; // todo: left_recursive
Col
: VarIdentifier '.' AttrPath
{
printf("col\n");
$$ = create_spcol($1, $3);
}
AttrPath
: AttrIdentifier
{
printf("AttrPath 1\n");
$$ = create_pf($1, NULL);
}
| AttrIdentifier '.' AttrPath
{
printf("AttrPath 2\n");
$$ = create_pf($1, $3);
}
VarIdentifier
: IDENTIFIER
{
printf("VarIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
}
TableIdentifier
: IDENTIFIER
{
printf("TableIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
}
AttrIdentifier
: IDENTIFIER
{
printf("AttrIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
}
CompOperator
: EQ
{
printf("Operator EQ\n");
$$ = create_op(yytext);
}
| NE
{
printf("Operator NE\n");
$$ = create_op(yytext);
}
| LE
{
printf("Operator LE\n");
$$ = create_op(yytext);
}
| GE
{
printf("Operator GE\n");
$$ = create_op(yytext);
}
| LT
{
printf("Operator LT\n");
$$ = create_op(yytext);
}
| GT
{
printf("Operator GT\n");
$$ = create_op(yytext);
}
;
Pred
: Conj
| Pred OR Conj
| BasicPred
| Conj AND BasicPred
BasicPred
: Term CompOperator Term
| EXIST '(' Body ')'
| NOT BasicPred
| '(' Pred ')'
Term
: Constant
| TableList
Constant
: INTEGER
{
printf("INTEGER is |%s|", yytext);
$$ = create_constant(yytext);
}
| REAL
{
printf("REAL is |%s|", yytext);
$$ = create_constant(yytext);
}
| STRING
{
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