Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ehfeng/LDI
  • w328li/LDI
  • gweddell/LDI
3 results
Show changes
Commits on Source (44)
Showing
with 516 additions and 941 deletions
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
.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
all: SQLPSchema SQLPParser SQLPRefExp
SQLPParser: SQLPParser.c SQLPGrammar.y SQLPScanner.l util.o
bison --verbose -d SQLPGrammar.y
flex SQLPScanner.l
flex -D SQLPGrammar 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
SQLPSchema: SQLPSchema_main.c SQLPSchema.y SQLPScanner.l util.o
bison -d SQLPSchema.y
flex -D SQLPSchema SQLPScanner.l
gcc -g -w SQLPSchema_main.c util.o -o SQLPSchema
rm -f lex.yy.c SQLPSchema.tab.c SQLPSchema.tab.h
SQLPRefExp: SQLPRefExp_main.c SQLPRefExp.y SQLPScanner.l util.o
bison -d SQLPRefExp.y
flex -D SQLPRefExp SQLPScanner.l
gcc -g -w SQLPRefExp_main.c util.o -o SQLPRefExp
rm -f lex.yy.c SQLPRefExp.tab.c SQLPRefExp.tab.h
util.o: util.c util.h
gcc -c util.c
# gcc `pkg-config --cflags --libs glib-2.0` util.c
#gcc -c util.c
gcc -g -c util.c
Parser: parser.c util.o
gcc -w parser.c util.o -o Parser
gcc -g -w parser.c util.o -o Parser
clean:
rm -f lex.yy.c *.tab.c *.tab.h *.fasl Parser util.o
......
File deleted
......@@ -44,6 +44,9 @@ test input is
`select s.name from student s where s.name = "John" and s.num = 10;`.
The files added in Spring 2019 are appended with `_new`. To run the new
executable, the command is `./SQLPParser_new`.
Currently a syntax error will be reported when the semi-colon is read, but the
parse tree that is output is correct.
......@@ -77,4 +80,50 @@ valid.
Also the Makefile only has two commands, `make` and `make clean`. `make` will
create both the SQLPParser and Parser programs to do what was described above.
Maybe this should be changed in the future to be separate but we'll leave that
discussion for the future.
\ No newline at end of file
discussion for the future.
Added in Spring 2019:
Entity descriptions for algebra in lisp form. There are two sorts of operators:
(1) operators producing normal tables with an ordered finite sequence of attribute
names, and (2) operators producing “column tables”, where tuples are a possibly
infinite set of “SQLP column name”/“constant” pairs.
`<query> (1)
( select <set-or-bag> <limit> (as-list <as> … ) <body> )
( union <set-or-bag> <limit> (query-list <query> … ) )`
`<set-or-bag>
distinct
all`
`<limit>
( limit <integer-constant> )
( no-limit )`
`<as>
( as <column> <attribute-name> )`
`<body> (2)
<pred>
( atom <table-name> <var> )
( natural-join-list <body> … )
( sub-query <query> <var> )`
`<pred>
( equal <term> <term> )
( less-than <term> <term> )
( less-than-or-equal <term> <term> )
( exists <body> )
( not <pred> )
( and-list <pred> … )
( or-list <pred> … )`
`<term>
<column>
( integer <integer-constant> )
( string <string-constant> )`
`<column>
( column <var> ( attribute-name-list <attribute-name> … ) )`
\ No newline at end of file
Terminals unused in grammar
IMPLIES
OR
HAS
MAX
MIN
AS
ASC
DESC
MOD
ASSIGN
COMMA
DOT
SIZE
SELECTIVITY
OVERLAP
FREQUENCY
UNIT
TIME
SPACE
CONSTANT
STRING_LITERAL
SIZEOF
STORE
STORING
DYNAMIC
STATIC
OF
TYPE
ORDERED
BY
INDEX
LIST
ARRAY
BINARY
TREE
DISTRIBUTED
POINTER
SCHEMA
CLASS
ISA
PROPERTIES
CONSTRAINTS
PROPERTY
ON
DETERMINED
COVER
QUERY
GIVEN
ORDER
PRECOMPUTED
ONE
FOR
ALL
TRANSACTION
INTCLASS
STRCLASS
DOUBLEREAL
MAXLEN
RANGE
TO
INSERT
END
CHANGE
DELETE
DECLARE
RETURN
State 31 conflicts: 3 reduce/reduce
Grammar
0 $accept: SQLPProgram $end
1 SQLPProgram: Query
2 Query: Union_Query
3 Select_Query: SELECT Select_List Body
4 Body: FROM TablePath
5 | FROM TablePath WHERE Bool
6 | FROM TablePath WHERE Pred
7 TablePath: TableIdentifier VarIdentifier
8 | TableIdentifier VarIdentifier ',' TablePath
9 Union_Query: Select_Query
10 | Union_Query UNION Select_Query
11 Select_List: STAR
12 | Col
13 | Col ',' Select_List
14 Col: VarIdentifier '.' AttrPath
15 AttrPath: AttrIdentifier
16 | AttrIdentifier '.' AttrPath
17 VarIdentifier: IDENTIFIER
18 TableIdentifier: IDENTIFIER
19 AttrIdentifier: IDENTIFIER
20 Operator: EQ
21 | NE
22 | LE
23 | GE
24 | LT
25 | GT
26 Bool: Col Operator Col
27 | Col Operator Constant
28 Pred: Bool AND Pred
29 | NOT Pred
30 | EXIST '(' Query ')'
31 | Bool
32 Constant: INTEGER
33 | REAL
34 | STRING
Terminals, with rules where they appear
$end (0) 0
'(' (40) 30
')' (41) 30
',' (44) 8 13
'.' (46) 14 16
error (256)
IMPLIES (258)
OR (259)
AND (260) 28
NOT (261) 29
LE (262) 22
GE (263) 23
LT (264) 24
GT (265) 25
NE (266) 21
HAS (267)
MAX (268)
MIN (269)
AS (270)
ASC (271)
DESC (272)
MOD (273)
ASSIGN (274)
EQ (275) 20
STAR (276) 11
COMMA (277)
DOT (278)
SIZE (279)
SELECTIVITY (280)
OVERLAP (281)
FREQUENCY (282)
UNIT (283)
TIME (284)
SPACE (285)
IDENTIFIER (286) 17 18 19
CONSTANT (287)
STRING_LITERAL (288)
SIZEOF (289)
STORE (290)
STORING (291)
DYNAMIC (292)
STATIC (293)
OF (294)
TYPE (295)
ORDERED (296)
BY (297)
INDEX (298)
LIST (299)
ARRAY (300)
BINARY (301)
TREE (302)
DISTRIBUTED (303)
POINTER (304)
SCHEMA (305)
CLASS (306)
ISA (307)
PROPERTIES (308)
CONSTRAINTS (309)
PROPERTY (310)
ON (311)
DETERMINED (312)
COVER (313)
QUERY (314)
GIVEN (315)
FROM (316) 4 5 6
SELECT (317) 3
WHERE (318) 5 6
ORDER (319)
PRECOMPUTED (320)
ONE (321)
EXIST (322) 30
FOR (323)
ALL (324)
TRANSACTION (325)
INTCLASS (326)
STRCLASS (327)
INTEGER (328) 32
REAL (329) 33
DOUBLEREAL (330)
STRING (331) 34
MAXLEN (332)
RANGE (333)
TO (334)
INSERT (335)
END (336)
CHANGE (337)
DELETE (338)
DECLARE (339)
RETURN (340)
UNION (341) 10
Nonterminals, with rules where they appear
$accept (91)
on left: 0
SQLPProgram (92)
on left: 1, on right: 0
Query (93)
on left: 2, on right: 1 30
Select_Query (94)
on left: 3, on right: 9 10
Body (95)
on left: 4 5 6, on right: 3
TablePath (96)
on left: 7 8, on right: 4 5 6 8
Union_Query (97)
on left: 9 10, on right: 2 10
Select_List (98)
on left: 11 12 13, on right: 3 13
Col (99)
on left: 14, on right: 12 13 26 27
AttrPath (100)
on left: 15 16, on right: 14 16
VarIdentifier (101)
on left: 17, on right: 7 8 14
TableIdentifier (102)
on left: 18, on right: 7 8
AttrIdentifier (103)
on left: 19, on right: 15 16
Operator (104)
on left: 20 21 22 23 24 25, on right: 26 27
Bool (105)
on left: 26 27, on right: 5 28 31
Pred (106)
on left: 28 29 30 31, on right: 6 28 29
Constant (107)
on left: 32 33 34, on right: 27
State 0
0 $accept: . SQLPProgram $end
SELECT shift, and go to state 1
SQLPProgram go to state 2
Query go to state 3
Select_Query go to state 4
Union_Query go to state 5
State 1
3 Select_Query: SELECT . Select_List Body
STAR shift, and go to state 6
IDENTIFIER shift, and go to state 7
Select_List go to state 8
Col go to state 9
VarIdentifier go to state 10
State 2
0 $accept: SQLPProgram . $end
$end shift, and go to state 11
State 3
1 SQLPProgram: Query .
$default reduce using rule 1 (SQLPProgram)
State 4
9 Union_Query: Select_Query .
$default reduce using rule 9 (Union_Query)
State 5
2 Query: Union_Query .
10 Union_Query: Union_Query . UNION Select_Query
UNION shift, and go to state 12
$default reduce using rule 2 (Query)
State 6
11 Select_List: STAR .
$default reduce using rule 11 (Select_List)
State 7
17 VarIdentifier: IDENTIFIER .
$default reduce using rule 17 (VarIdentifier)
State 8
3 Select_Query: SELECT Select_List . Body
FROM shift, and go to state 13
Body go to state 14
State 9
12 Select_List: Col .
13 | Col . ',' Select_List
',' shift, and go to state 15
$default reduce using rule 12 (Select_List)
State 10
14 Col: VarIdentifier . '.' AttrPath
'.' shift, and go to state 16
State 11
0 $accept: SQLPProgram $end .
$default accept
State 12
10 Union_Query: Union_Query UNION . Select_Query
SELECT shift, and go to state 1
Select_Query go to state 17
State 13
4 Body: FROM . TablePath
5 | FROM . TablePath WHERE Bool
6 | FROM . TablePath WHERE Pred
IDENTIFIER shift, and go to state 18
TablePath go to state 19
TableIdentifier go to state 20
State 14
3 Select_Query: SELECT Select_List Body .
$default reduce using rule 3 (Select_Query)
State 15
13 Select_List: Col ',' . Select_List
STAR shift, and go to state 6
IDENTIFIER shift, and go to state 7
Select_List go to state 21
Col go to state 9
VarIdentifier go to state 10
State 16
14 Col: VarIdentifier '.' . AttrPath
IDENTIFIER shift, and go to state 22
AttrPath go to state 23
AttrIdentifier go to state 24
State 17
10 Union_Query: Union_Query UNION Select_Query .
$default reduce using rule 10 (Union_Query)
State 18
18 TableIdentifier: IDENTIFIER .
$default reduce using rule 18 (TableIdentifier)
State 19
4 Body: FROM TablePath .
5 | FROM TablePath . WHERE Bool
6 | FROM TablePath . WHERE Pred
WHERE shift, and go to state 25
$default reduce using rule 4 (Body)
State 20
7 TablePath: TableIdentifier . VarIdentifier
8 | TableIdentifier . VarIdentifier ',' TablePath
IDENTIFIER shift, and go to state 7
VarIdentifier go to state 26
State 21
13 Select_List: Col ',' Select_List .
$default reduce using rule 13 (Select_List)
State 22
19 AttrIdentifier: IDENTIFIER .
$default reduce using rule 19 (AttrIdentifier)
State 23
14 Col: VarIdentifier '.' AttrPath .
$default reduce using rule 14 (Col)
State 24
15 AttrPath: AttrIdentifier .
16 | AttrIdentifier . '.' AttrPath
'.' shift, and go to state 27
$default reduce using rule 15 (AttrPath)
State 25
5 Body: FROM TablePath WHERE . Bool
6 | FROM TablePath WHERE . Pred
NOT shift, and go to state 28
IDENTIFIER shift, and go to state 7
EXIST shift, and go to state 29
Col go to state 30
VarIdentifier go to state 10
Bool go to state 31
Pred go to state 32
State 26
7 TablePath: TableIdentifier VarIdentifier .
8 | TableIdentifier VarIdentifier . ',' TablePath
',' shift, and go to state 33
$default reduce using rule 7 (TablePath)
State 27
16 AttrPath: AttrIdentifier '.' . AttrPath
IDENTIFIER shift, and go to state 22
AttrPath go to state 34
AttrIdentifier go to state 24
State 28
29 Pred: NOT . Pred
NOT shift, and go to state 28
IDENTIFIER shift, and go to state 7
EXIST shift, and go to state 29
Col go to state 30
VarIdentifier go to state 10
Bool go to state 35
Pred go to state 36
State 29
30 Pred: EXIST . '(' Query ')'
'(' shift, and go to state 37
State 30
26 Bool: Col . Operator Col
27 | Col . Operator Constant
LE shift, and go to state 38
GE shift, and go to state 39
LT shift, and go to state 40
GT shift, and go to state 41
NE shift, and go to state 42
EQ shift, and go to state 43
Operator go to state 44
State 31
5 Body: FROM TablePath WHERE Bool .
28 Pred: Bool . AND Pred
31 | Bool .
AND shift, and go to state 45
$end reduce using rule 5 (Body)
$end [reduce using rule 31 (Pred)]
UNION reduce using rule 5 (Body)
UNION [reduce using rule 31 (Pred)]
')' reduce using rule 5 (Body)
')' [reduce using rule 31 (Pred)]
$default reduce using rule 5 (Body)
State 32
6 Body: FROM TablePath WHERE Pred .
$default reduce using rule 6 (Body)
State 33
8 TablePath: TableIdentifier VarIdentifier ',' . TablePath
IDENTIFIER shift, and go to state 18
TablePath go to state 46
TableIdentifier go to state 20
State 34
16 AttrPath: AttrIdentifier '.' AttrPath .
$default reduce using rule 16 (AttrPath)
State 35
28 Pred: Bool . AND Pred
31 | Bool .
AND shift, and go to state 45
$default reduce using rule 31 (Pred)
State 36
29 Pred: NOT Pred .
$default reduce using rule 29 (Pred)
State 37
30 Pred: EXIST '(' . Query ')'
SELECT shift, and go to state 1
Query go to state 47
Select_Query go to state 4
Union_Query go to state 5
State 38
22 Operator: LE .
$default reduce using rule 22 (Operator)
State 39
23 Operator: GE .
$default reduce using rule 23 (Operator)
State 40
24 Operator: LT .
$default reduce using rule 24 (Operator)
State 41
25 Operator: GT .
$default reduce using rule 25 (Operator)
State 42
21 Operator: NE .
$default reduce using rule 21 (Operator)
State 43
20 Operator: EQ .
$default reduce using rule 20 (Operator)
State 44
26 Bool: Col Operator . Col
27 | Col Operator . Constant
IDENTIFIER shift, and go to state 7
INTEGER shift, and go to state 48
REAL shift, and go to state 49
STRING shift, and go to state 50
Col go to state 51
VarIdentifier go to state 10
Constant go to state 52
State 45
28 Pred: Bool AND . Pred
NOT shift, and go to state 28
IDENTIFIER shift, and go to state 7
EXIST shift, and go to state 29
Col go to state 30
VarIdentifier go to state 10
Bool go to state 35
Pred go to state 53
State 46
8 TablePath: TableIdentifier VarIdentifier ',' TablePath .
$default reduce using rule 8 (TablePath)
State 47
30 Pred: EXIST '(' Query . ')'
')' shift, and go to state 54
State 48
32 Constant: INTEGER .
$default reduce using rule 32 (Constant)
State 49
33 Constant: REAL .
$default reduce using rule 33 (Constant)
State 50
34 Constant: STRING .
$default reduce using rule 34 (Constant)
State 51
26 Bool: Col Operator Col .
$default reduce using rule 26 (Bool)
State 52
27 Bool: Col Operator Constant .
$default reduce using rule 27 (Bool)
State 53
28 Pred: Bool AND Pred .
$default reduce using rule 28 (Pred)
State 54
30 Pred: EXIST '(' Query ')' .
$default reduce using rule 30 (Pred)
......@@ -13,207 +13,330 @@
%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 SCHEMA CLASS ISA PROPERTIES CONSTRAINTS PROPERTY DISJOINT
%token FOREIGN KEY REFERENCES WITH
%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 PRECOMPUTED ONE EXIST FOR ALL TRANSACTION INTCLASS STRCLASS OID
%token INTEGER REAL DOUBLEREAL STRING MAXLEN RANGE TO SELF
%token INSERT END CHANGE DELETE DECLARE RETURN UNION UNIONALL
%token LIMIT DISTINCT REF
%start SQLPProgram
%%
SQLPProgram
: Query
{ printf("Input Query\n");
cons_cell *n = $1;
printf("Printing Tree\n");
print_cons_tree(n);
}
{
printf("Input Query\n");
cons_cell *n = $1;
printf("Printing Tree\n");
print_cons_tree(n);
}
;
Query
: Union_Query
{ printf("Union Query\n");
$$ = $1;
}
: UnionQuery
{
printf("Query 1\n");
$$ = $1;
}
| SelectQuery
{
printf("Query 3\n");
$$ = $1;
}
| SelectQuery LIMIT Integer
{
printf("Query 4\n");
$$ = create_limit_operator($1, $3);
}
;
Select_Query
: SELECT Select_List Body
{ printf("SQLP Query\n");
$$ = create_proj_operator($2, $3);
}
SelectQuery
: SELECT
{
printf("SelectQuery 1 \n");
}
| SELECT SelectList
{
printf("SelectQuery 2 \n");
$$ = create_rename_operator($2, NULL);
}
| SELECT Body
{
printf("SelectQuery 3 \n");
$$ = create_rename_operator($2, NULL);
}
| SELECT SelectList Body
{
printf("SelectQuery 4 \n");
$$ = create_proj_operator($2, $3);
}
| SELECT DISTINCT Body
{
printf("SelectList 5 \n");
$$ = create_rename_operator($3, NULL);
}
| SELECT DISTINCT SelectList Body
{
printf("SelectList 6 \n");
$$ = create_proj_operator($2, $3);
}
;
Body
: FROM TablePath
{ printf("Body 1\n");
$$ = $2;
}
| FROM TablePath WHERE Bool
{ printf("Body 2\n");
$$ = create_eval_operator($4, $2);
}
| FROM TablePath WHERE Pred
{ printf("Body 3\n");
$$ = create_eval_operator($4, $2);
}
: FROM TableList
{
printf("Body 1 \n");
$$ = create_rename_operator($2, NULL);
}
| FROM WHERE Pred
{
printf("Body 2 \n");
$$ = create_rename_operator($3, NULL);
}
| FROM TableList WHERE Pred
{
printf("Body 3 \n");
$$ = create_eval_operator($4, $2);
}
;
TablePath
: TableIdentifier VarIdentifier
{ printf("last table path\n");
$$ = create_rename_operator($1, $2);
}
| TableIdentifier VarIdentifier ',' TablePath
{ printf("table path2\n");
$$ = create_cross_operator(create_rename_operator($1, $2), $4);
}
;
TableList
: TableIdentifier VarIdentifier
{
printf("TableList 1\n");
$$ = create_rename_operator($1, $2);
}
| TableIdentifier VarIdentifier ',' TableList
{
printf("TableList 2\n");
$$ = create_cross_operator(create_rename_operator($1, $2), $4);
}
;
Union_Query
: Select_Query
{ printf("union query 1\n");
$$ = $1;
}
| Union_Query UNION Select_Query
{ printf("union query 2\n");
$$ = create_union_all_operator($1, $3);
}
;
Select_List
: STAR
{ printf("star\n");
//$$ = new_node(1, Select_List);
//$$->children[0] = new_node(0, STAR);
}
| Col
{ printf("select list attr path\n");
$$ = create_rename_operator($1, NULL);
}
| Col ',' Select_List
{ printf("Select list\n");
$$ = create_rename_operator($1, $2);
}
UnionQuery
: '(' SelectQuery ')' UNION UnionQuery
{
printf("UnionQuery 1\n");
$$ = create_union_all_operator($2, $5);
}
| '(' SelectQuery ')' UNIONALL UnionQuery
{
printf("UnionQuery 2\n");
$$ = create_union_all_operator($2, $5);
}
| '(' SelectQuery ')'
{
printf("UnionQuery 3\n");
$$ = create_rename_operator($1, NULL);
}
;
SelectList
: Col
{
printf("SelectList 1\n");
$$ = create_rename_operator($1, NULL);
}
| Col AS AttrIdentifier
{
printf("SelectList 2\n");
$$ = create_as_operator($1, $3);
}
| Col ',' SelectList
{
printf("SelectList 3\n");
$$ = create_rename_operator($1, $2);
}
| Col AS AttrIdentifier ',' SelectList
{
printf("SelectList 4\n");
$$ = create_rename_operator($1, create_as_operator($3, $5));
}
| AttrIdentifier
{
printf("SelectList 1\n");
$$ = create_rename_operator($1, NULL);
}
| AttrIdentifier AS AttrIdentifier
{
printf("SelectList 2\n");
$$ = create_as_operator($1, $3);
}
| AttrIdentifier ',' SelectList
{
printf("SelectList 3\n");
$$ = create_rename_operator($1, $2);
}
| AttrIdentifier AS AttrIdentifier ',' SelectList
{
printf("SelectList 4\n");
$$ = create_rename_operator($1, create_as_operator($3, $5));
}
;
Col
: VarIdentifier '.' AttrPath
{
printf("col\n");
$$ = create_spcol($1, $3);
}
Col
: VarIdentifier '.' AttrPath
{
printf("col\n");
$$ = create_spcol($1, $3);
}
;
AttrPath
AttrPath
: AttrIdentifier
{ printf("path id\n");
$$ = create_pf($1, NULL);
}
{
printf("AttrPath 1\n");
$$ = create_pf($1, NULL);
}
| AttrIdentifier '.' AttrPath
{ printf("Path Function\n");
$$ = create_pf($1, $3);
}
;
{
printf("AttrPath 2\n");
$$ = create_pf($1, $3);
}
VarIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_var(yytext);
}
: IDENTIFIER
{
printf("VarIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
}
TableIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_table(yytext);
}
: IDENTIFIER
{
printf("TableIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
}
AttrIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_attr(yytext);
}
: IDENTIFIER
{
printf("AttrIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
}
Operator
CompOperator
: EQ
{
$$ = create_op(yytext);
}
{
printf("CompOperator EQ\n");
$$ = create_op(yytext);
}
| NE
{
$$ = create_op(yytext);
}
{
printf("CompOperator NE\n");
$$ = create_op(yytext);
}
| LE
{
$$ = create_op(yytext);
}
{
printf("CompOperator LE\n");
$$ = create_op(yytext);
}
| GE
{
$$ = create_op(yytext);
}
{
printf("CompOperator GE\n");
$$ = create_op(yytext);
}
| LT
{
$$ = create_op(yytext);
}
{
printf("CompOperator LT\n");
$$ = create_op(yytext);
}
| GT
{
$$ = create_op(yytext);
}
;
Bool
: Col Operator Col
{ printf("Col op Col\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("Col op Constant\n");
cons_cell* first_term = create_term($1);
$$ = create_comp_operator($2, first_term, $3, NULL);
}
{
printf("CompOperator GT\n");
$$ = create_op(yytext);
}
;
Pred
: Bool AND Pred
{ printf("pred and pred\n");
// $$ = $1;
// $$->cdr->cdr->cdr->cdr->car = $3;
$$ = create_and_operator($1, $3);
}
| NOT Pred
{ printf("Not Pred\n");
$$ = create_not_operator($1, NULL);
}
| EXIST '(' Query ')'
{ printf("Exist query\n");
$$ = create_atom("INPROG");
//$$->children[0] = new_node(0, EXIST);
//$$->children[1] = $3;
}
| Bool
{
printf("Bool\n");
$$ = $1;
}
;
: Conj
{
printf("Pred 1\n");
$$ = $1;
}
| Conj OR Pred
{
printf("Pred 2 \n");
$$ = create_or_operator($1, $3);
}
Conj
: BasicPred
{
printf("Conj 1 \n");
$$ = $1;
}
| BasicPred AND Conj
{
printf("Conj 2 \n");
$$ = create_and_operator($1, $3);
}
BasicPred
: Term CompOperator Term
{
printf("BasicPred 1\n");
cons_cell* first_term = create_term($1);
cons_cell* second_term = create_term($3);
$$ = create_comp_operator($2, first_term, second_term);
}
| EXIST '(' Body ')'
{
printf("BasicPred 2\n");
$$ = create_exist_operator($2);
}
| NOT BasicPred
{
printf("BasicPred 3 \n");
$$ = create_not_operator($2);
}
| '(' Pred ')'
{
printf("BasicPred 4\n");
$$ = $1;
}
Term
: Constant
{
printf("Term 1\n");
$$ = $1;
}
| Col
{
printf("Term 2\n");
$$ = $1;
}
Integer
: INTEGER
{
printf("INTEGER is |%s|", yytext);
$$ = create_constant(yytext);
}
Constant
: INTEGER
{ printf("|%s|", yytext);
$$ = create_constant(yytext);
}
{
printf("INTEGER is |%s|", yytext);
$$ = create_constant(yytext);
}
| REAL
{ printf("|%s|", yytext);
$$ = create_constant(yytext);
}
| STRING
{ printf("|%s|", yytext);
$$ = create_constant(yytext);
}
{
printf("REAL is |%s|", yytext);
$$ = create_constant(yytext);
}
| STRING
{
printf("STRING is |%s|", yytext);
$$ = create_constant(yytext);
}
;
File deleted
......@@ -24,7 +24,7 @@
int main()
{
int Result;
int Result;
strcpy(LineBuffer, "");
printf("(\n");
Result = yyparse();
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.SQLPParser</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
File deleted
select x.ssn_num from Person x where x.std_info.name = "A"
\ No newline at end of file
File added
%{
#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 DISJOINT
%token FOREIGN KEY REFERENCES WITH
%token ON DETERMINED COVER QUERY GIVEN FROM SELECT WHERE ORDER
%token PRECOMPUTED ONE EXIST FOR ALL TRANSACTION INTCLASS STRCLASS OID
%token INTEGER REAL DOUBLEREAL STRING MAXLEN RANGE TO SELF
%token INSERT END CHANGE DELETE DECLARE RETURN UNION UNIONALL
%token LIMIT DISTINCT REF
%start SQLPRefExp
%%
SQLPRefExp
: OidExpLst
{
printf("Input RefExp\n");
cons_cell *n = $1;
printf("Printing RefExp Tree\n");
print_cons_tree(n);
}
;
OidExpLst
: OidExpLst ';' OidExp
{
printf("OidExpLst\n");
$$ = create_oidexplst_operator($1, $3);
}
| OidExp
{
printf("OidExp\n");
$$ = create_oidexplst_operator($1, NULL);
}
;
OidExp
: TableIdentifier REF '(' RefExp ')'
{
printf("OidExp\n");
$$ = create_oidexp_operator($1, $4);
}
;
RefExp
: Col
{
printf("RefExp\n");
$$ = create_refexp_operator($1, NULL);
}
| RefExp ',' Col
{
printf("RefExp\n");
$$ = create_refexp_operator($1, $3);
}
| VarIdentifier
{
printf("RefExp\n");
$$ = create_refexp_operator($1, NULL);
}
| RefExp ',' VarIdentifier
{
printf("RefExp\n");
$$ = create_refexp_operator($1, $3);
}
;
Col
: VarIdentifier '.' AttrPath
{
printf("col\n");
$$ = create_spcol($1, $3);
}
AttrPath
: AttrIdentifier
{
printf("path id\n");
$$ = create_pf($1, NULL);
}
| AttrIdentifier '.' AttrPath
{
printf("Path Function\n");
$$ = create_pf($1, $3);
}
;
VarIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_var(yytext);
}
TableIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_table(yytext);
}
AttrIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_attr(yytext);
}
Person -> (name, age, gender);
House -> (owner.name, address);
Address -> (planet, country, province, city, district)
/*
* 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 "SQLPRefExp.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);
}