Changeset: 86cde4d0479c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=86cde4d0479c
Added Files:
        sql/server/sql_parser.output
Modified Files:
        sql/server/rel_graph.c
        sql/server/sql_parser.y
Branch: graph1
Log Message:

WIP: disambiguate the parser


diffs (truncated from 120609 to 300 lines):

diff --git a/sql/server/rel_graph.c b/sql/server/rel_graph.c
--- a/sql/server/rel_graph.c
+++ b/sql/server/rel_graph.c
@@ -122,36 +122,46 @@ static sql_exp* bindg_ret(mvc *sql, sql_
        }
 }
 
-static sql_exp* bindg_exp(mvc *sql, sql_exp *exp, symbol *sym){
-       graph_join *g;
-       sql_exp* e;
+static sql_exp* bindg_exp(mvc *sql, sql_exp *exp, dlist *parse_tree){
+       graph_join *g =NULL;
+       sql_exp* e =NULL;
        exp_kind exp_kind_value = {type_value, card_column, TRUE};
+       const char* table_ref = NULL; // the table referred (optional)
+       symbol* expr_weight = NULL; // the expression inside CHEAPEST SUM ( ... 
);
 
        assert(exp && "Expected an expression");
+       assert(parse_tree && "The input argument parse_tree is NULL");
+       assert(parse_tree->cnt == 2 && "Expected two nodes in the root of the 
parse tree");
 
        if(exp->type != e_cmp || get_cmp(exp) != cmp_filter_graph){
                // this is not a graph join, move along
                return NULL;
        }
 
-       g = exp->f;
+       table_ref = parse_tree->h->data.sval;
+       expr_weight = parse_tree->h->next->data.lval;
 
-       // try to bind the expression
-       e = rel_value_exp(sql, &(g->edges), sym, sql_sel, exp_kind_value);
-       if(!e){ return NULL; }
 
-       // an expression has already been bound
-       if(g->cost){
-               return sql_error(sql, 02, "TODO: At the moment you cannot bind 
multiple CHEAPEST SUM expression against the same join");
-       }
+       return NULL;
 
-       // found it!
-       g->cost = exp_label(sql->sa, e, ++sql->label);
-       return g->cost;
+//     g = exp->f;
+//
+//     // try to bind the expression
+//     e = rel_value_exp(sql, &(g->edges), sym, sql_sel, exp_kind_value);
+//     if(!e){ return NULL; }
+//
+//     // an expression has already been bound
+//     if(g->cost){
+//             return sql_error(sql, 02, "TODO: At the moment you cannot bind 
multiple CHEAPEST SUM expression against the same join");
+//     }
+//
+//     // found it!
+//     g->cost = exp_label(sql->sa, e, ++sql->label);
+//     return g->cost;
 }
 
 
-static sql_exp* bindg_exps(mvc *sql, list *exps, symbol *sym){
+static sql_exp* bindg_exps(mvc *sql, list *exps, dlist *sym){
        sql_exp *result = NULL;
 
        // edge case
@@ -166,7 +176,7 @@ static sql_exp* bindg_exps(mvc *sql, lis
        return result;
 }
 
-static sql_exp* bindg_rel(mvc *sql, sql_rel* relation, symbol *sym){
+static sql_exp* bindg_rel(mvc *sql, sql_rel* relation, dlist *sym){
        // edge case
        if(!relation || error_reported(sql)) return NULL;
 
@@ -213,15 +223,16 @@ sql_exp* rel_graph_cheapest_sum(mvc *sql
        }
 
        // Check whether an argument has been specified
-       if(!sym->data.sym){
-               // TODO this should be already handled by the parser (i.e. it's 
not part of the language)
+       if(!sym->data.lval){
+               // TODO: actually this case is not part of the parser language, 
i.e. it never occurs
+               // perhaps it should be implicitly treated as CHEAPEST SUM (1) ?
                sql_error(sql, 02, "Empty argument for CHEAPEST SUM");
                return NULL;
        }
 
        // Find the relation where the sub the expression binds to
        assert(is_project((*rel)->op) && "Unexpected relation type");
-       exp_bound = bindg_rel(sql, (*rel)->l, sym->data.sym);
+       exp_bound = bindg_rel(sql, (*rel)->l, sym->data.lval);
        if(!exp_bound){ return NULL; }
 
        // Create the new column
diff --git a/sql/server/sql_parser.output b/sql/server/sql_parser.output
new file mode 100644
--- /dev/null
+++ b/sql/server/sql_parser.output
@@ -0,0 +1,120446 @@
+State 5 conflicts: 1 shift/reduce
+State 164 conflicts: 1 shift/reduce
+State 283 conflicts: 9 shift/reduce
+State 302 conflicts: 1 reduce/reduce
+State 303 conflicts: 1 reduce/reduce
+State 348 conflicts: 1 shift/reduce, 1 reduce/reduce
+State 349 conflicts: 1 shift/reduce, 1 reduce/reduce
+State 350 conflicts: 2 shift/reduce
+State 385 conflicts: 1 shift/reduce
+State 389 conflicts: 1 reduce/reduce
+State 466 conflicts: 1 shift/reduce
+State 491 conflicts: 2 shift/reduce
+State 531 conflicts: 1 shift/reduce
+State 542 conflicts: 1 shift/reduce
+State 609 conflicts: 1 reduce/reduce
+State 615 conflicts: 1 shift/reduce
+State 617 conflicts: 1 shift/reduce
+State 621 conflicts: 1 shift/reduce
+State 766 conflicts: 2 shift/reduce
+State 768 conflicts: 1 shift/reduce
+State 769 conflicts: 2 shift/reduce
+State 909 conflicts: 1 shift/reduce
+State 945 conflicts: 1 shift/reduce
+State 947 conflicts: 1 shift/reduce
+State 948 conflicts: 1 shift/reduce
+State 949 conflicts: 1 shift/reduce
+State 950 conflicts: 1 reduce/reduce
+State 977 conflicts: 24 shift/reduce
+State 978 conflicts: 1 shift/reduce
+State 979 conflicts: 1 shift/reduce
+State 980 conflicts: 1 shift/reduce
+State 981 conflicts: 1 shift/reduce
+State 982 conflicts: 1 shift/reduce
+State 983 conflicts: 1 shift/reduce
+State 984 conflicts: 1 shift/reduce
+State 985 conflicts: 1 shift/reduce
+State 986 conflicts: 1 shift/reduce
+State 987 conflicts: 1 shift/reduce
+State 988 conflicts: 1 shift/reduce
+State 989 conflicts: 1 shift/reduce
+State 990 conflicts: 1 shift/reduce
+State 991 conflicts: 1 shift/reduce
+State 992 conflicts: 1 shift/reduce
+State 993 conflicts: 1 shift/reduce
+State 994 conflicts: 1 shift/reduce
+State 995 conflicts: 1 shift/reduce
+State 996 conflicts: 1 shift/reduce
+State 997 conflicts: 1 shift/reduce
+State 998 conflicts: 1 shift/reduce
+State 999 conflicts: 1 shift/reduce
+State 1000 conflicts: 1 shift/reduce
+State 1011 conflicts: 5 shift/reduce
+State 1016 conflicts: 1 reduce/reduce
+State 1017 conflicts: 1 reduce/reduce
+State 1019 conflicts: 1 reduce/reduce
+State 1102 conflicts: 5 shift/reduce
+State 1202 conflicts: 8 reduce/reduce
+State 1234 conflicts: 1 shift/reduce
+State 1249 conflicts: 1 shift/reduce
+State 1339 conflicts: 5 shift/reduce
+State 1459 conflicts: 1 reduce/reduce
+State 1504 conflicts: 1 shift/reduce
+State 1609 conflicts: 1 shift/reduce
+State 1634 conflicts: 1 reduce/reduce
+State 1641 conflicts: 1 shift/reduce
+State 1677 conflicts: 1 shift/reduce
+State 1758 conflicts: 1 reduce/reduce
+State 1827 conflicts: 2 shift/reduce
+State 1828 conflicts: 2 shift/reduce
+State 1852 conflicts: 1 shift/reduce
+State 1911 conflicts: 1 shift/reduce
+State 1913 conflicts: 1 shift/reduce
+State 1914 conflicts: 1 shift/reduce
+State 1915 conflicts: 1 shift/reduce
+
+
+Grammar
+
+    0 $accept: sqlstmt $end
+
+    1 sqlstmt: sql SCOLON
+
+    2 $@1: %empty
+
+    3 sqlstmt: PREPARE $@1 sql SCOLON
+
+    4 $@2: %empty
+
+    5 sqlstmt: SQL_PLAN $@2 sql SCOLON
+
+    6 $@3: %empty
+
+    7 sqlstmt: SQL_EXPLAIN $@3 sql SCOLON
+
+    8 $@4: %empty
+
+    9 sqlstmt: SQL_DEBUG $@4 sqlstmt
+
+   10 $@5: %empty
+
+   11 sqlstmt: SQL_TRACE $@5 sqlstmt
+   12        | exec SCOLON
+   13        | %empty
+   14        | SCOLON
+   15        | error SCOLON
+   16        | LEX_ERROR
+
+   17 create: CREATE
+
+   18 drop: DROP
+
+   19 set: SET
+
+   20 declare: DECLARE
+
+   21 sql: schema
+   22    | grant
+   23    | revoke
+   24    | create_statement
+   25    | drop_statement
+   26    | alter_statement
+   27    | declare_statement
+   28    | set_statement
+   29    | ANALYZE qname opt_column_list opt_sample opt_minmax
+   30    | call_procedure_statement
+
+   31 opt_minmax: %empty
+   32           | MINMAX
+
+   33 declare_statement: declare variable_list
+   34                  | declare table_def
+
+   35 variable_list: ident_commalist data_type
+   36              | variable_list ',' ident_commalist data_type
+
+   37 set_statement: set ident '=' simple_atom
+   38              | set sqlSESSION AUTHORIZATION ident
+   39              | set SCHEMA ident
+   40              | set user '=' ident
+   41              | set ROLE ident
+   42              | set TIME ZONE LOCAL
+   43              | set TIME ZONE interval_expression
+
+   44 schema: create SCHEMA schema_name_clause opt_schema_default_char_set 
opt_path_specification opt_schema_element_list
+   45       | drop SCHEMA qname drop_action
+
+   46 schema_name_clause: ident
+   47                   | AUTHORIZATION authorization_identifier
+   48                   | ident AUTHORIZATION authorization_identifier
+
+   49 authorization_identifier: ident
+
+   50 opt_schema_default_char_set: %empty
+   51                            | DEFAULT CHARACTER SET ident
+
+   52 opt_schema_element_list: %empty
+   53                        | schema_element_list
+
+   54 schema_element_list: schema_element
+   55                    | schema_element_list schema_element
+
+   56 schema_element: grant
+   57               | revoke
+   58               | create_statement
+   59               | drop_statement
+   60               | alter_statement
+
+   61 opt_grantor: %empty
+   62            | WITH ADMIN grantor
+
+   63 grantor: CURRENT_USER
+   64        | CURRENT_ROLE
+
+   65 grant: GRANT privileges TO grantee_commalist opt_with_grant 
opt_from_grantor
+   66      | GRANT authid_list TO grantee_commalist opt_with_admin 
opt_from_grantor
+
+   67 authid_list: authid
+   68            | authid_list ',' authid
+
+   69 opt_with_grant: %empty
+   70               | WITH GRANT OPTION
+
+   71 opt_with_admin: %empty
+   72               | WITH ADMIN OPTION
+
+   73 opt_from_grantor: %empty
+   74                 | FROM grantor
+
+   75 revoke: REVOKE opt_grant_for privileges FROM grantee_commalist 
opt_from_grantor
+   76       | REVOKE opt_admin_for authid_list FROM grantee_commalist 
opt_from_grantor
+
+   77 opt_grant_for: %empty
+   78              | GRANT OPTION FOR
+
+   79 opt_admin_for: %empty
+   80              | ADMIN OPTION FOR
+
+   81 privileges: global_privileges
+   82           | object_privileges ON object_name
+
+   83 global_privileges: global_privilege
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to