Skip to content
Snippets Groups Projects
Commit d00a16cc authored by w328li's avatar w328li
Browse files

add create_operator

parent 5689dc78
No related branches found
No related tags found
No related merge requests found
......@@ -513,11 +513,11 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 26, 26, 36, 41, 46, 51, 59, 60, 61,
62, 66, 67, 68, 72, 77, 86, 91, 96, 104,
109, 110, 115, 119, 126, 131, 138, 146, 153, 160,
165, 170, 175, 180, 185, 193, 198, 206, 211, 218,
225, 230, 235, 242, 247, 257, 262, 267
0, 26, 26, 36, 41, 46, 51, 59, 64, 69,
74, 82, 87, 92, 100, 105, 114, 119, 124, 132,
137, 138, 143, 147, 154, 159, 166, 174, 181, 188,
193, 198, 203, 208, 213, 221, 226, 234, 239, 246,
253, 258, 263, 270, 275, 285, 290, 295
};
#endif
......@@ -1399,298 +1399,361 @@ yyreduce:
#line 1400 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 7:
#line 60 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("SelectQuery 1 \n");
(yyval) = (yyvsp[0]);
}
#line 1409 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 8:
#line 65 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("SelectQuery 2 \n");
(yyval) = create_proj_operator((yyvsp[-1]), (yyvsp[0]));
}
#line 1418 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 9:
#line 70 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("SelectList 3 \n");
(yyval) = (yyvsp[0]);
}
#line 1427 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 10:
#line 75 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("SelectList 4 \n");
(yyval) = create_proj_operator((yyvsp[-2]), (yyvsp[-1]));
}
#line 1436 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 11:
#line 83 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Body 1 \n");
(yyval) = (yyvsp[0]);
}
#line 1445 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 12:
#line 88 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Body 2 \n");
// todo
}
#line 1454 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 13:
#line 93 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Body 3 \n");
(yyval) = create_eval_operator((yyvsp[0]), (yyvsp[-2]));
}
#line 1463 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 14:
#line 73 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 101 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("TableList 1\n");
(yyval) = create_rename_operator((yyvsp[-1]), (yyvsp[0]));
}
#line 1409 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1472 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 15:
#line 78 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 106 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("TableList 2\n");
(yyval) = create_cross_operator(create_rename_operator((yyvsp[-3]), (yyvsp[-2])), (yyvsp[0]));
}
#line 1418 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1481 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 16:
#line 87 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 115 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("UnionQuery 1\n");
(yyval) = create_union_all_operator((yyvsp[-3]), (yyvsp[0]));
}
#line 1427 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1490 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 17:
#line 92 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 120 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("UnionQuery 2\n");
(yyval) = create_union_all_operator((yyvsp[-3]), (yyvsp[0]));
}
#line 1436 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1499 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 18:
#line 97 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 125 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("UnionQuery 3\n");
(yyval) = (yyvsp[-2]);
}
#line 1445 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1508 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 19:
#line 105 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 133 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("SelectList 2\n");
(yyval) = create_rename_operator((yyvsp[0]), NULL);
}
#line 1454 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1517 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 21:
#line 111 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 139 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("SelectList 4\n");
(yyval) = create_rename_operator((yyvsp[-2]), (yyvsp[-1]));
}
#line 1463 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1526 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 23:
#line 120 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 148 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("col\n");
(yyval) = create_spcol((yyvsp[-2]), (yyvsp[0]));
}
#line 1472 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1535 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 24:
#line 127 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 155 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("AttrPath 1\n");
(yyval) = create_pf((yyvsp[0]), NULL);
}
#line 1481 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1544 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 25:
#line 132 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 160 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("AttrPath 2\n");
(yyval) = create_pf((yyvsp[-2]), (yyvsp[0]));
}
#line 1490 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1553 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 26:
#line 139 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 167 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("VarIdentifier is |%s| ", yytext);
(yyval) = create_var(yytext);
}
#line 1499 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1562 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 27:
#line 147 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 175 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("TableIdentifier is |%s| ", yytext);
(yyval) = create_var(yytext);
}
#line 1508 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1571 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 28:
#line 154 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 182 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("AttrIdentifier is |%s| ", yytext);
(yyval) = create_var(yytext);
}
#line 1517 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1580 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 29:
#line 161 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 189 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("CompOperator EQ\n");
(yyval) = create_op(yytext);
}
#line 1526 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1589 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 30:
#line 166 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 194 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("CompOperator NE\n");
(yyval) = create_op(yytext);
}
#line 1535 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1598 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 31:
#line 171 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 199 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("CompOperator LE\n");
(yyval) = create_op(yytext);
}
#line 1544 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1607 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 32:
#line 176 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 204 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("CompOperator GE\n");
(yyval) = create_op(yytext);
}
#line 1553 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1616 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 33:
#line 181 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 209 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("CompOperator LT\n");
(yyval) = create_op(yytext);
}
#line 1562 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1625 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 34:
#line 186 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 214 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("CompOperator GT\n");
(yyval) = create_op(yytext);
}
#line 1571 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1634 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 35:
#line 194 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 222 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Pred 1\n");
(yyval) = (yyvsp[0]);
}
#line 1580 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1643 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 36:
#line 199 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 227 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Pred 2 \n");
(yyval) = create_or_operator((yyvsp[-2]), (yyvsp[0]));
}
#line 1589 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1652 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 37:
#line 207 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 235 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Conj 1 \n");
(yyval) = (yyvsp[0]);
}
#line 1598 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1661 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 38:
#line 212 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 240 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Conj 2 \n");
(yyval) = create_and_operator((yyvsp[-2]), (yyvsp[0]));
}
#line 1607 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1670 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 39:
#line 219 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 247 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("BasicPred 1\n");
cons_cell* first_term = create_term((yyvsp[-2]));
cons_cell* second_term = create_term((yyvsp[0]));
(yyval) = create_comp_operator((yyvsp[-1]), first_term, second_term, NULL);
}
#line 1618 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1681 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 40:
#line 226 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 254 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("BasicPred 2\n");
(yyval) = create_exist_operator((yyvsp[-2]));
}
#line 1627 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1690 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 41:
#line 231 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 259 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("BasicPred 3 \n");
(yyval) = create_not_operator((yyvsp[0]));
}
#line 1636 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1699 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 42:
#line 236 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 264 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("BasicPred 4\n");
(yyval) = (yyvsp[-2]);
}
#line 1645 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1708 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 43:
#line 243 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 271 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Term 1\n");
(yyval) = (yyvsp[0]);
}
#line 1654 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1717 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 44:
#line 248 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 276 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("Term 2\n");
(yyval) = (yyvsp[0]);
}
#line 1663 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1726 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 45:
#line 258 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 286 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("INTEGER is |%s|", yytext);
(yyval) = create_constant(yytext);
}
#line 1672 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1735 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 46:
#line 263 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 291 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("REAL is |%s|", yytext);
(yyval) = create_constant(yytext);
}
#line 1681 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1744 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
case 47:
#line 268 "SQLPGrammar_new.y" /* yacc.c:1646 */
#line 296 "SQLPGrammar_new.y" /* yacc.c:1646 */
{
printf("STRING is |%s|", yytext);
(yyval) = create_constant(yytext);
}
#line 1690 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1753 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
break;
#line 1694 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
#line 1757 "SQLPGrammar_new.tab.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
......
......@@ -57,15 +57,43 @@ Query
SelectQuery
: SELECT Body
{
printf("SelectQuery 1 \n");
$$ = $2;
}
| SELECT SelectList Body
{
printf("SelectQuery 2 \n");
$$ = create_proj_operator($2, $3);
}
| SELECT DISTINCT Body
{
printf("SelectList 3 \n");
$$ = $3;
}
| SELECT DISTINCT SelectList Body
{
printf("SelectList 4 \n");
$$ = create_proj_operator($2, $3);
}
;
Body
: FROM TableList
{
printf("Body 1 \n");
$$ = $2;
}
| FROM WHERE Pred
{
printf("Body 2 \n");
// todo
}
| FROM TableList WHERE Pred
{
printf("Body 3 \n");
$$ = create_eval_operator($4, $2);
}
;
TableList
......
No preview for this file type
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