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
31f67726
Commit
31f67726
authored
6 years ago
by
expan
Browse files
Options
Downloads
Patches
Plain Diff
small fix
parent
f8b4b938
No related branches found
No related tags found
1 merge request
!1
SQLP parser with cons cells
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
SQLPGrammar.output
+177
-149
177 additions, 149 deletions
SQLPGrammar.output
SQLPGrammar.y
+44
-82
44 additions, 82 deletions
SQLPGrammar.y
SQLPParser
+0
-0
0 additions, 0 deletions
SQLPParser
SQLPParser.c
+2
-2
2 additions, 2 deletions
SQLPParser.c
old
+205
-0
205 additions, 0 deletions
old
util.o
+0
-0
0 additions, 0 deletions
util.o
with
428 additions
and
233 deletions
SQLPGrammar.output
+
177
−
149
View file @
31f67726
...
...
@@ -93,44 +93,46 @@ Grammar
11 | Union_Query UNION Select_Query
12 Select_List: STAR
13 |
AttrPath
14 |
AttrPath
',' Select_List
13 |
Col
14 |
Col
',' Select_List
15 AttrPath: Identifier
16 | Identifier '.' AttrPath
15 Col: Identifier '.' AttrPath
17 Operator: EQ
18 | NE
19 | LE
20 | GE
21 | LT
22 | GT
16 AttrPath: Identifier
17 | Identifier '.' AttrPath
23 Bool: AttrPath Operator AttrPath
24 | AttrPath Operator CONSTANT
18 Operator: EQ
19 | NE
20 | LE
21 | GE
22 | LT
23 | GT
25 Pred: Bool AND Pred
26 | NOT Pred
27 | EXIST '(' Query ')'
24 Bool: Col Operator Col
25 | Col Operator CONSTANT
26 Pred: Bool AND Pred
27 | NOT Pred
28 | EXIST '(' Query ')'
Terminals, with rules where they appear
$end (0) 0
'(' (40) 2
7
')' (41) 2
7
'(' (40) 2
8
')' (41) 2
8
',' (44) 9 14
'.' (46) 1
6
'.' (46) 1
5 17
error (256)
IMPLIES (258)
OR (259)
AND (260) 2
5
NOT (261) 2
6
LE (262)
19
GE (263) 2
0
LT (264) 2
1
GT (265) 2
2
NE (266) 1
8
AND (260) 2
6
NOT (261) 2
7
LE (262)
20
GE (263) 2
1
LT (264) 2
2
GT (265) 2
3
NE (266) 1
9
HAS (267)
MAX (268)
MIN (269)
...
...
@@ -139,7 +141,7 @@ ASC (271)
DESC (272)
MOD (273)
ASSIGN (274)
EQ (275) 1
7
EQ (275) 1
8
STAR (276) 12
COMMA (277)
DOT (278)
...
...
@@ -151,7 +153,7 @@ UNIT (283)
TIME (284)
SPACE (285)
IDENTIFIER (286) 2
CONSTANT (287) 2
4
CONSTANT (287) 2
5
STRING_LITERAL (288)
SIZEOF (289)
STORE (290)
...
...
@@ -186,7 +188,7 @@ WHERE (318) 6 7
ORDER (319)
PRECOMPUTED (320)
ONE (321)
EXIST (322) 2
7
EXIST (322) 2
8
FOR (323)
ALL (324)
TRANSACTION (325)
...
...
@@ -215,9 +217,9 @@ $accept (91)
SQLPProgram (92)
on left: 1, on right: 0
Identifier (93)
on left: 2, on right: 8 9 15 16
on left: 2, on right: 8 9 15 16
17
Query (94)
on left: 3, on right: 1 2
7
on left: 3, on right: 1 2
8
Select_Query (95)
on left: 4, on right: 10 11
Body (96)
...
...
@@ -228,14 +230,16 @@ Union_Query (98)
on left: 10 11, on right: 3 11
Select_List (99)
on left: 12 13 14, on right: 4 14
AttrPath (100)
on left: 15 16, on right: 13 14 16 23 24
Operator (101)
on left: 17 18 19 20 21 22, on right: 23 24
Bool (102)
on left: 23 24, on right: 6 25
Pred (103)
on left: 25 26 27, on right: 7 25 26
Col (100)
on left: 15, on right: 13 14 24 25
AttrPath (101)
on left: 16 17, on right: 15 17
Operator (102)
on left: 18 19 20 21 22 23, on right: 24 25
Bool (103)
on left: 24 25, on right: 6 26
Pred (104)
on left: 26 27 28, on right: 7 26 27
State 0
...
...
@@ -259,7 +263,7 @@ State 1
Identifier go to state 8
Select_List go to state 9
AttrPath
go to state 10
Col
go to state 10
State 2
...
...
@@ -309,13 +313,10 @@ State 7
State 8
15 AttrPath: Identifier .
16 | Identifier . '.' AttrPath
15 Col: Identifier . '.' AttrPath
'.' shift, and go to state 13
$default reduce using rule 15 (AttrPath)
State 9
...
...
@@ -328,8 +329,8 @@ State 9
State 10
13 Select_List:
AttrPath
.
14 |
AttrPath
. ',' Select_List
13 Select_List:
Col
.
14 |
Col
. ',' Select_List
',' shift, and go to state 16
...
...
@@ -354,12 +355,12 @@ State 12
State 13
1
6 AttrPath
: Identifier '.' . AttrPath
1
5 Col
: Identifier '.' . AttrPath
IDENTIFIER shift, and go to state 7
Identifier go to state 8
AttrPath go to state 1
8
Identifier go to state
1
8
AttrPath go to state 1
9
State 14
...
...
@@ -370,8 +371,8 @@ State 14
IDENTIFIER shift, and go to state 7
Identifier go to state
19
TablePath go to state 2
0
Identifier go to state
20
TablePath go to state 2
1
State 15
...
...
@@ -383,14 +384,14 @@ State 15
State 16
14 Select_List:
AttrPath
',' . Select_List
14 Select_List:
Col
',' . Select_List
STAR shift, and go to state 6
IDENTIFIER shift, and go to state 7
Identifier go to state 8
Select_List go to state 2
1
AttrPath
go to state 10
Select_List go to state 2
2
Col
go to state 10
State 17
...
...
@@ -402,257 +403,284 @@ State 17
State 18
16 AttrPath: Identifier '.' AttrPath .
16 AttrPath: Identifier .
17 | Identifier . '.' AttrPath
'.' shift, and go to state 23
$default reduce using rule 16 (AttrPath)
State 19
15 Col: Identifier '.' AttrPath .
$default reduce using rule 15 (Col)
State 20
8 TablePath: Identifier . Identifier
9 | Identifier . Identifier ',' TablePath
IDENTIFIER shift, and go to state 7
Identifier go to state 2
2
Identifier go to state 2
4
State 2
0
State 2
1
5 Body: FROM TablePath .
6 | FROM TablePath . WHERE Bool
7 | FROM TablePath . WHERE Pred
WHERE shift, and go to state 2
3
WHERE shift, and go to state 2
5
$default reduce using rule 5 (Body)
State 2
1
State 2
2
14 Select_List:
AttrPath
',' Select_List .
14 Select_List:
Col
',' Select_List .
$default reduce using rule 14 (Select_List)
State 22
State 23
17 AttrPath: Identifier '.' . AttrPath
IDENTIFIER shift, and go to state 7
Identifier go to state 18
AttrPath go to state 26
State 24
8 TablePath: Identifier Identifier .
9 | Identifier Identifier . ',' TablePath
',' shift, and go to state 2
4
',' shift, and go to state 2
7
$default reduce using rule 8 (TablePath)
State 2
3
State 2
5
6 Body: FROM TablePath WHERE . Bool
7 | FROM TablePath WHERE . Pred
NOT shift, and go to state 2
5
NOT shift, and go to state 2
8
IDENTIFIER shift, and go to state 7
EXIST shift, and go to state 2
6
EXIST shift, and go to state 2
9
Identifier go to state 8
AttrPath
go to state
27
Bool go to state
28
Pred go to state 2
9
Col
go to state
30
Bool go to state
31
Pred go to state
3
2
State 24
State 26
17 AttrPath: Identifier '.' AttrPath .
$default reduce using rule 17 (AttrPath)
State 27
9 TablePath: Identifier Identifier ',' . TablePath
IDENTIFIER shift, and go to state 7
Identifier go to state
19
TablePath go to state 3
0
Identifier go to state
20
TablePath go to state 3
3
State 2
5
State 2
8
2
6
Pred: NOT . Pred
2
7
Pred: NOT . Pred
NOT shift, and go to state 2
5
NOT shift, and go to state 2
8
IDENTIFIER shift, and go to state 7
EXIST shift, and go to state 2
6
EXIST shift, and go to state 2
9
Identifier go to state 8
AttrPath
go to state
27
Bool go to state 3
1
Pred go to state 3
2
Col
go to state
30
Bool go to state 3
4
Pred go to state 3
5
State 2
6
State 2
9
2
7
Pred: EXIST . '(' Query ')'
2
8
Pred: EXIST . '(' Query ')'
'(' shift, and go to state 3
3
'(' shift, and go to state 3
6
State
27
State
30
2
3
Bool:
AttrPath
. Operator
AttrPath
2
4
|
AttrPath
. Operator CONSTANT
2
4
Bool:
Col
. Operator
Col
2
5
|
Col
. Operator CONSTANT
LE shift, and go to state 3
4
GE shift, and go to state 3
5
LT shift, and go to state 3
6
GT shift, and go to state
37
NE shift, and go to state
38
EQ shift, and go to state
39
LE shift, and go to state 3
7
GE shift, and go to state 3
8
LT shift, and go to state 3
9
GT shift, and go to state
40
NE shift, and go to state
41
EQ shift, and go to state
42
Operator go to state 4
0
Operator go to state 4
3
State
28
State
31
6 Body: FROM TablePath WHERE Bool .
2
5
Pred: Bool . AND Pred
2
6
Pred: Bool . AND Pred
AND shift, and go to state 4
1
AND shift, and go to state 4
4
$default reduce using rule 6 (Body)
State 2
9
State
3
2
7 Body: FROM TablePath WHERE Pred .
$default reduce using rule 7 (Body)
State 3
0
State 3
3
9 TablePath: Identifier Identifier ',' TablePath .
$default reduce using rule 9 (TablePath)
State 3
1
State 3
4
2
5
Pred: Bool . AND Pred
2
6
Pred: Bool . AND Pred
AND shift, and go to state 4
1
AND shift, and go to state 4
4
State 3
2
State 3
5
2
6
Pred: NOT Pred .
2
7
Pred: NOT Pred .
$default reduce using rule 2
6
(Pred)
$default reduce using rule 2
7
(Pred)
State 3
3
State 3
6
2
7
Pred: EXIST '(' . Query ')'
2
8
Pred: EXIST '(' . Query ')'
SELECT shift, and go to state 1
Query go to state 4
2
Query go to state 4
5
Select_Query go to state 4
Union_Query go to state 5
State 3
4
State 3
7
19
Operator: LE .
20
Operator: LE .
$default reduce using rule
19
(Operator)
$default reduce using rule
20
(Operator)
State 3
5
State 3
8
2
0
Operator: GE .
2
1
Operator: GE .
$default reduce using rule 2
0
(Operator)
$default reduce using rule 2
1
(Operator)
State 3
6
State 3
9
2
1
Operator: LT .
2
2
Operator: LT .
$default reduce using rule 2
1
(Operator)
$default reduce using rule 2
2
(Operator)
State
37
State
40
2
2
Operator: GT .
2
3
Operator: GT .
$default reduce using rule 2
2
(Operator)
$default reduce using rule 2
3
(Operator)
State
38
State
41
1
8
Operator: NE .
1
9
Operator: NE .
$default reduce using rule 1
8
(Operator)
$default reduce using rule 1
9
(Operator)
State
39
State
42
1
7
Operator: EQ .
1
8
Operator: EQ .
$default reduce using rule 1
7
(Operator)
$default reduce using rule 1
8
(Operator)
State 4
0
State 4
3
2
3
Bool:
AttrPath
Operator .
AttrPath
2
4
|
AttrPath
Operator . CONSTANT
2
4
Bool:
Col
Operator .
Col
2
5
|
Col
Operator . CONSTANT
IDENTIFIER shift, and go to state 7
CONSTANT shift, and go to state 4
3
CONSTANT shift, and go to state 4
6
Identifier go to state 8
AttrPath
go to state 4
4
Col
go to state 4
7
State 4
1
State 4
4
2
5
Pred: Bool AND . Pred
2
6
Pred: Bool AND . Pred
NOT shift, and go to state 2
5
NOT shift, and go to state 2
8
IDENTIFIER shift, and go to state 7
EXIST shift, and go to state 2
6
EXIST shift, and go to state 2
9
Identifier go to state 8
AttrPath
go to state
27
Bool go to state 3
1
Pred go to state 4
5
Col
go to state
30
Bool go to state 3
4
Pred go to state 4
8
State 4
2
State 4
5
2
7
Pred: EXIST '(' Query . ')'
2
8
Pred: EXIST '(' Query . ')'
')' shift, and go to state 4
6
')' shift, and go to state 4
9
State 4
3
State 4
6
2
4
Bool:
AttrPath
Operator CONSTANT .
2
5
Bool:
Col
Operator CONSTANT .
$default reduce using rule 2
4
(Bool)
$default reduce using rule 2
5
(Bool)
State 4
4
State 4
7
2
3
Bool:
AttrPath
Operator
AttrPath
.
2
4
Bool:
Col
Operator
Col
.
$default reduce using rule 2
3
(Bool)
$default reduce using rule 2
4
(Bool)
State 4
5
State 4
8
2
5
Pred: Bool AND Pred .
2
6
Pred: Bool AND Pred .
$default reduce using rule 2
5
(Pred)
$default reduce using rule 2
6
(Pred)
State 4
6
State 4
9
2
7
Pred: EXIST '(' Query ')' .
2
8
Pred: EXIST '(' Query ')' .
$default reduce using rule 2
7
(Pred)
$default reduce using rule 2
8
(Pred)
This diff is collapsed.
Click to expand it.
SQLPGrammar.y
+
44
−
82
View file @
31f67726
...
...
@@ -28,95 +28,68 @@
SQLPProgram
: Query
{ printf("Input Query\n");
struct node *n = new_node(1, SQLPProgram);
n->children[0] = $1;
cons_cell *n = $1;
printf("Printing Tree\n");
print_tree(n, 0);
struct linked_node *linked_tree = malloc(sizeof(struct linked_node));
translate(linked_tree, n);
print_linked_tree(linked_tree, 0);
print_cons_tree(n, 0);
}
;
Identifier
: IDENTIFIER
{ printf("|%s| ", yytext);
$$ = new_node(1, Identifier);
$$->children[0] = new_node(0, IDENTIFIER);
$$ = yytext;
}
;
Query
: Union_Query
{ printf("Union Query\n");
$$ = new_node(1, Query);
$$->children[0] = $1;
$$ = $1;
}
;
Select_Query
: SELECT Select_List Body
{ printf("SQLP Query\n");
$$ = new_node(3, Select_Query);
$$->children[0] = new_node(0, SELECT);
$$->children[1] = $2;
$$->children[2] = $3;
$$ = create_proj_operator($1, $2);
}
;
Body
: FROM TablePath
{ printf("Body 1\n");
$$ = new_node(2, Body);
$$->children[0] = new_node(0, FROM);
$$->children[1] = $2;}
$$ = $2;
}
| FROM TablePath WHERE Bool
{ printf("Body 2\n");
$$ = new_node(4, Body);
$$->children[0] = new_node(0, FROM);
$$->children[1] = $2;
$$->children[2] = new_node(0, WHERE);
$$->children[3] = $4;
$$ = create_eval_operator($4, $2);
}
| FROM TablePath WHERE Pred
{ printf("Body 3\n");
$$ = new_node(4, Body);
$$->children[0] = new_node(0, FROM);
$$->children[1] = $2;
$$->children[2] = new_node(0, WHERE);
$$->children[3] = $4;
$$ = create_eval_operator($4, $2);
}
;
TablePath
: Identifier Identifier
{ printf("table path1\n");
$$ = new_node(2, TablePath);
$$->children[0] = $1;
$$->children[1] = $2;
}
{ printf("last table path\n");
$$ = create_atom_operator($1, $2);
}
| Identifier Identifier ',' TablePath
{ printf("table path2\n");
$$ = new_node(4, TablePath);
$$->children[0] = $1;
$$->children[1] = $2;
$$->children[2] = new_node(0, COMMA);
$$->children[3] = $4;
$$ = create_cross_operator(create_atom_operator($1, $2), $4);
}
;
Union_Query
: Select_Query
{ printf("union query 1\n");
$$ = new_node(1, Union_Query);
$$->children[0] = $1;
$$ = $1;
}
| Union_Query UNION Select_Query
{ printf("union query 2\n");
$$ = new_node(3, Union_Query);
$$->children[0] = $1;
$$->children[1] = new_node(0, UNION);
$$->children[2] = $3;
$$ = create_union_all_operator($1, $3);
}
;
...
...
@@ -126,34 +99,34 @@ Select_List
$$ = new_node(1, Select_List);
$$->children[0] = new_node(0, STAR);
}
|
AttrPath
|
Col
{ printf("select list attr path\n");
$$ = new_node(1, Select_List);
$$->children[0] = $1;
$$ = create_assign_operator($1, $1, NULL);
}
|
AttrPath
',' Select_List
|
Col
',' Select_List
{ printf("Select list\n");
$$ = new_node(3, Select_List);
$$->children[0] = $1;
$$->children[1] = new_node(0, COMMA);
$$->children[2] = $3;
$$ = create_assign_operator($1, $1, $2);
}
;
Col
: Identifier '.' AttrPath
{
printf("col\n");
$$ = create_spcol($1, $3);
}
AttrPath
: Identifier
{ printf("path id\n");
$$ = new_node(1, AttrPath);
$$->children[0] = $1;
$$ = create_pf(create_attr($1), NULL);
}
| Identifier '.' AttrPath
{ printf("Path Function\n");
$$ = new_node(3, AttrPath);
$$->children[0] = $1;
$$->children[1] = new_node(0, DOT);
$$->children[2] = $3;
$$ = create_pf(create_attr($1), $3);
}
;
Operator
: EQ
| NE
...
...
@@ -164,42 +137,31 @@ Operator
;
Bool
: AttrPath Operator AttrPath
{ printf("AttrPath op AttrPath\n");
$$ = new_node(3, Bool);
$$->children[0] = $1;
$$->children[1] = $2;
$$->children[2] = $3;
: Col Operator Col
{ printf("Col op Col\n");
$$ = create_comp_operator($2, $1, $3, NULL);
}
| AttrPath Operator CONSTANT
{ printf("AttrPath op Constant\n");
$$ = new_node(3, Bool);
$$->children[0] = $1;
$$->children[1] = $2;
$$->children[2] = new_node(0, CONSTANT);
| Col Operator CONSTANT
{ printf("Col op Constant\n");
cons_cell* a = create_cons_cell_w_atom(CONSTANT, NULL);
$$ = create_comp_operator($2, $1, a, NULL);
}
;
Pred
: Bool AND Pred
{ printf("pred and pred\n");
$$ = new_node(3, Pred);
$$->children[0] = $1;
$$->children[1] = new_node(0, AND);
$$->children[2] = $3;
$$ = $1;
$$->cdr->cdr->cdr->cdr->car = $3;
}
| NOT Pred
{ printf("Not Pred\n");
$$ = new_node(2, Pred);
$$->children[0] = new_node(0, NOT);
$$->children[1] = $2;
$$ = create_not_operator($1, NULL);
}
| EXIST '(' Query ')'
{ printf("Exist query\n");
$$ =
new_node(2, Pred
);
$$->children[0] = new_node(0, EXIST);
$$->children[1] = $3;
$$ =
create_atom("INPROG"
);
//
$$->children[0] = new_node(0, EXIST);
//
$$->children[1] = $3;
}
;
\ No newline at end of file
;
This diff is collapsed.
Click to expand it.
SQLPParser
deleted
100755 → 0
+
0
−
0
View file @
f8b4b938
File deleted
This diff is collapsed.
Click to expand it.
SQLPParser.c
+
2
−
2
View file @
31f67726
...
...
@@ -18,7 +18,7 @@
*/
#include
<stdio.h>
#include
<
util.h
>
#include
"
util.h
"
#include
"lex.yy.c"
#include
"SQLPGrammar.tab.c"
...
...
@@ -34,4 +34,4 @@ int main()
fprintf
(
stderr
,
"checking semantics.
\n
"
);
printf
(
")
\n
"
);
return
(
Result
);
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
SQLPGrammer2.y
→
old
+
205
−
0
View file @
31f67726
...
...
@@ -28,67 +28,95 @@
SQLPProgram
: Query
{ printf("Input Query\n");
cons_cell *n = $1;
struct node *n = new_node(1, SQLPProgram);
n->children[0] = $1;
printf("Printing Tree\n");
print_cons_tree(n, 0);
print_tree(n, 0);
struct linked_node *linked_tree = malloc(sizeof(struct linked_node));
translate(linked_tree, n);
print_linked_tree(linked_tree, 0);
}
;
Identifier
: IDENTIFIER
{ printf("|%s| ", yytext);
$$ = yytext;
$$ = new_node(1, Identifier);
$$->children[0] = new_node(0, IDENTIFIER);
}
;
Query
: Union_Query
{ printf("Union Query\n");
$$ = $1;
$$ = new_node(1, Query);
$$->children[0] = $1;
}
;
Select_Query
: SELECT Select_List Body
{ printf("SQLP Query\n");
$$ = create_proj_operator($1, $2);
$$ = new_node(3, Select_Query);
$$->children[0] = new_node(0, SELECT);
$$->children[1] = $2;
$$->children[2] = $3;
}
;
Body
: FROM TablePath
{ printf("Body 1\n");
$$ = create_cons_cell($2,NULL);
$$ = new_node(2, Body);
$$->children[0] = new_node(0, FROM);
$$->children[1] = $2;}
| FROM TablePath WHERE Bool
{ printf("Body 2\n");
$$ = create_eval_operator($4, $2);
$$ = new_node(4, Body);
$$->children[0] = new_node(0, FROM);
$$->children[1] = $2;
$$->children[2] = new_node(0, WHERE);
$$->children[3] = $4;
}
| FROM TablePath WHERE Pred
{ printf("Body 3\n");
$$ = create_eval_operator($4, $2);
$$ = new_node(4, Body);
$$->children[0] = new_node(0, FROM);
$$->children[1] = $2;
$$->children[2] = new_node(0, WHERE);
$$->children[3] = $4;
}
;
TablePath
: Identifier Identifier
{ printf("last table path\n");
$$ = create_atom_operator($1, $2);
}
{ printf("table path1\n");
$$ = new_node(2, TablePath);
$$->children[0] = $1;
$$->children[1] = $2;
}
| Identifier Identifier ',' TablePath
{ printf("table path2\n");
$$ = create_cross_operator(create_atom_operator($1, $2), $4);
$$ = new_node(4, TablePath);
$$->children[0] = $1;
$$->children[1] = $2;
$$->children[2] = new_node(0, COMMA);
$$->children[3] = $4;
}
;
Union_Query
: Select_Query
{ printf("union query 1\n");
$$ = $1;
$$ = new_node(1, Union_Query);
$$->children[0] = $1;
}
| Union_Query UNION Select_Query
{ printf("union query 2\n");
$$ = create_union_all_operator($1, $3);
$$ = new_node(3, Union_Query);
$$->children[0] = $1;
$$->children[1] = new_node(0, UNION);
$$->children[2] = $3;
}
;
...
...
@@ -98,34 +126,34 @@ Select_List
$$ = new_node(1, Select_List);
$$->children[0] = new_node(0, STAR);
}
|
Col
|
AttrPath
{ printf("select list attr path\n");
$$ = create_assign_operator($1, $1, NULL);
$$ = new_node(1, Select_List);
$$->children[0] = $1;
}
|
Col
',' Select_List
|
AttrPath
',' Select_List
{ printf("Select list\n");
$$ = create_assign_operator($1, $1, $2);
$$ = new_node(3, Select_List);
$$->children[0] = $1;
$$->children[1] = new_node(0, COMMA);
$$->children[2] = $3;
}
;
Col
: Identifier '.' AttrPath
{
printf("col\n");
$$ = create_spcol($1, $3);
}
AttrPath
: Identifier
{ printf("path id\n");
$$ = create_pf(create_attr($1), NULL);
$$ = new_node(1, AttrPath);
$$->children[0] = $1;
}
| Identifier '.' AttrPath
{ printf("Path Function\n");
$$ = create_pf(create_attr($1), $3);
$$ = new_node(3, AttrPath);
$$->children[0] = $1;
$$->children[1] = new_node(0, DOT);
$$->children[2] = $3;
}
;
Operator
: EQ
| NE
...
...
@@ -136,26 +164,37 @@ Operator
;
Bool
: Col Operator Col
{ printf("Col op Col\n");
$$ = create_comp_operator($2, $1, $3, NULL);
: AttrPath Operator AttrPath
{ printf("AttrPath op AttrPath\n");
$$ = new_node(3, Bool);
$$->children[0] = $1;
$$->children[1] = $2;
$$->children[2] = $3;
}
| Col Operator CONSTANT
{ printf("Col op Constant\n");
cons_cell* a = create_cons_cell_w_atom(CONSTANT, NULL);
$$ = create_comp_operator($2, $1, a, NULL);
| AttrPath Operator CONSTANT
{ printf("AttrPath op Constant\n");
$$ = new_node(3, Bool);
$$->children[0] = $1;
$$->children[1] = $2;
$$->children[2] = new_node(0, CONSTANT);
}
;
Pred
: Bool AND Pred
{ printf("pred and pred\n");
$$ = $1;
$$->cdr->cdr->cdr->cdr->car = $3;
$$ = new_node(3, Pred);
$$->children[0] = $1;
$$->children[1] = new_node(0, AND);
$$->children[2] = $3;
}
| NOT Pred
{ printf("Not Pred\n");
$$ = create_not_operator($1, NULL);
$$ = new_node(2, Pred);
$$->children[0] = new_node(0, NOT);
$$->children[1] = $2;
}
| EXIST '(' Query ')'
{ printf("Exist query\n");
...
...
@@ -163,4 +202,4 @@ Pred
$$->children[0] = new_node(0, EXIST);
$$->children[1] = $3;
}
;
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
util.o
+
0
−
0
View file @
31f67726
No preview for this file type
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