Update of /cvsroot/monetdb/pathfinder/compiler/semantics
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14694/compiler/semantics
Modified Files:
Tag: M5XQ
typecheck.brg
Log Message:
propagated changes of Thursday Nov 05 2009 - Monday Nov 09 2009
from the development trunk to the M5XQ branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/11/05 - singhan: compiler/semantics/typecheck.brg,1.83
XQuery full-text search support initial version!
This initial version provides support to
-ftcontains keyword,
e.g., for $f in doc("menu.xml")//food[./name ftcontains "Belgian Waffles"]
return $f
The above query will return all the food nodes that has some relevancy over
"Belgian Waffles"
-initial score variable support
e.g., for $f score $s in doc("menu.xml")//food[./name ftcontains "Belgian
Waffles"]
return $s
The above query will return the relevancy score of all the matched food
nodes, however since its an initial version, the support to this score variable
is very limited.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: typecheck.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/typecheck.brg,v
retrieving revision 1.79.2.3
retrieving revision 1.79.2.4
diff -u -d -r1.79.2.3 -r1.79.2.4
--- typecheck.brg 15 Oct 2009 14:02:48 -0000 1.79.2.3
+++ typecheck.brg 9 Nov 2009 00:04:52 -0000 1.79.2.4
@@ -176,6 +176,9 @@
/* Pathfinder extension: XRPC */
%term xrpc = 76 /**< XRPC calls: "execute at" */
+ /* Associated For variable holders */
+%term vars = 77 /**< variable pair (position. var + score. var)
of a for */
+
%%
Query: main (FunctionDecls, CoreExpr) = 1 (10);
@@ -302,6 +305,25 @@
/* Pathfinder extension: XRPC */
CoreExpr: xrpc (CoreExpr, CoreExpr) = 88 (10);
+/*full-text support*/
+OptBindExpr: for_ (forbind (forvars (var,
+
vars (nil, nil)),
+ CoreExpr),
+ OptBindExpr) = 89 (10);
+OptBindExpr: for_ (forbind (forvars (var,
+
vars (var, nil)),
+ CoreExpr),
+ OptBindExpr) = 90 (10);
+
+OptBindExpr: for_ (forbind (forvars (var,
+
vars (nil, var)),
+ CoreExpr),
+ OptBindExpr) = 91 (10);
+OptBindExpr: for_ (forbind (forvars (var,
+
vars (var, var)),
+ CoreExpr),
+ OptBindExpr) = 92 (10);
+
%%
/** Type of a core tree node */
@@ -449,7 +471,7 @@
case 5:
TY(p) = *PFty_simplify (L(p)->sem.flwr.quantifier (TY(R(p))));
break;
-
+
/* OptBindExpr: for_ (forbind (forvars (var, nil),
CoreExpr),
OptBindExpr) */
@@ -1282,6 +1304,289 @@
TY(p) = TY(R(p));
break;
+
+ /* OptBindExpr: for_ (forbind (forvars (var,
+
vars (nil, nil)),
+ CoreExpr),
+ OptBindExpr) */
+ case 89:
+ { /* TOPDOWN */
+
+ /* W3C XQuery, 5.8.2
+ *
+ * E |- CoreExpr : t1 E[Var : prime (t1)] |- CoreExpr : t2
+ * -------------------------------------------------------------
+ * for_ (Var, nil, nil, CoreExpr, OptBindExpr) : t2 . quantifier
(t1)
+ */
+ PFty_t t1;
+
+ /* nil : none */
+ TY(LLRL(p)) = PFty_none ();
+ TY(LLRR(p)) = PFty_none ();
+
+ /* E |- CoreExpr : t1 */
+ reduce (kids[0], nts[0]);
+ t1 = TY(LR(p));
+
+ /*
+ * The specs prohibit the (statically typed) empty sequence
+ * in many places. (see XQuery FS, beginning of Section 4)
+ */
+ if (PFty_subtype (t1, PFty_empty ()))
+ PFoops (OOPS_TYPECHECK,
+ "binding sequence in a for clause has static "
+ "type `empty'");
+
+ /*
+ * XQuery Update Facility disallows updates in the `for'
+ * part.
+ */
+ if (!PFty_disjoint (PFty_stmt (),
+ PFty_prime (PFty_defn (t1))))
+ PFoops (OOPS_TYPECHECK,
+ "err:XUST0101: binding sequence may not contain "
+ "an updating expression (has type `%s')",
+ PFty_str (t1));
+
+ /* sanity check */
+ if (!PFty_subtype (t1, PFty_star (PFty_item ())))
+ PFoops (OOPS_TYPECHECK,
+ "illegal binding in for clause, cannot iterate over "
+ "type `%s'",
+ PFty_str (t1));
+
+ /* Var : prime (t1) */
+ TY(LLL(p)) = *PFty_simplify (PFty_prime (PFty_defn (t1)));
+
+ /* Var1 should now have a sensible type (not `none') */
+ assert (PFty_subtype (TY(LLL(p)), PFty_star (PFty_item ())));
+
+ /* E[Var : prime (t1)] |- CoreExpr : t2 */
+ assert (LLL(p)->sem.var);
+ TY( LLL(p)->sem.var ) = TY(LLL(p));
+ reduce (kids[1], nts[1]);
+
+ p->sem.flwr.quantifier = PFty_quantifier
+ (R(p)->sem.flwr.quantifier (
+ PFty_defn (t1)));
+
+ } break;
+
+ /* OptBindExpr: for_ (forbind (forvars (var,
+
vars (var, nil)),
+ CoreExpr),
+ OptBindExpr) */
+ case 90:
+ { /* TOPDOWN */
+
+ /* W3C XQuery, 5.8.2
+ *
+ * E |- CoreExpr : t1
+ * E[Var1:prime (t1), Var2:xs:integer] |- OptBindExpr : t2
+ * --------------------------------------------------------------
+ * for_ (Var1, Var2, nil, CoreExpr, CoreExpr) : t2 . quantifier
(t1)
+ */
+ PFty_t t1;
+
+ /* E |- CoreExpr : t1 */
+ reduce (kids[0], nts[0]);
+ t1 = TY(LR(p));
+
+ /*
+ * The specs prohibit the (statically typed) empty sequence
+ * in many places. (see XQuery FS, beginning of Section 4)
+ */
+ if (PFty_subtype (t1, PFty_empty ()))
+ PFoops (OOPS_TYPECHECK,
+ "binding sequence in a for clause has static "
+ "type `empty'");
+
+ /*
+ * XQuery Update Facility disallows updates in the `for'
+ * part.
+ */
+ if (!PFty_disjoint (PFty_stmt (),
+ PFty_prime (PFty_defn (t1))))
+ PFoops (OOPS_TYPECHECK,
+ "err:XUST0101: binding sequence may not contain "
+ "an updating expression (has type `%s')",
+ PFty_str (t1));
+
+ /* sanity check */
+ if (!PFty_subtype (t1, PFty_star (PFty_item ())))
+ PFoops (OOPS_TYPECHECK,
+ "illegal binding in for clause, cannot iterate over "
+ "type `%s'",
+ PFty_str (t1));
+
+ /* Var2 : xs:integer */
+ TY(LLRL(p)) = PFty_xs_integer ();
+ assert (LLRL(p)->sem.var);
+ TY( LLRL(p)->sem.var ) = TY(LLRL(p));
+
+ /* Var3 : nil */
+ TY(LLRR(p)) = PFty_none ();;
+
+ /* Var1 : prime (t1) */
+ TY(LLL(p)) = *PFty_simplify (PFty_prime (PFty_defn (t1)));
+
+ /* Var1 should now have a sensible type (not `none') */
+ assert (PFty_subtype (TY(LLL(p)), PFty_star (PFty_item ())));
+
+ /* E[Var1 : prime (t1), Var2 : xs:integer] |- CoreExpr : t2 */
+ assert (LLL(p)->sem.var);
+ TY( LLL(p)->sem.var ) = TY(LLL(p));
+ reduce (kids[1], nts[1]);
+
+ p->sem.flwr.quantifier = PFty_quantifier
+ (R(p)->sem.flwr.quantifier (PFty_defn (t1)));
+
+ } break;
+
+ /* OptBindExpr: for_ (forbind (forvars (var,
+
vars (nil, var)),
+ CoreExpr),
+ OptBindExpr) */
+ case 91:
+ { /* TOPDOWN */
+
+ /* W3C XQuery, 5.8.2
+ *
+ * E |- CoreExpr : t1 E[Var : prime (t1)] |- CoreExpr : t2
+ * -------------------------------------------------------------
+ * for_ (Var, nil, Var3, CoreExpr, OptBindExpr) : t2 . quantifier
(t1)
+ */
+ PFty_t t1;
+
+ /* nil : none */
+ TY(LLRL(p)) = PFty_none ();
+
+ /* E |- CoreExpr : t1 */
+ reduce (kids[0], nts[0]);
+ t1 = TY(LR(p));
+
+ /*
+ * The specs prohibit the (statically typed) empty sequence
+ * in many places. (see XQuery FS, beginning of Section 4)
+ */
+ if (PFty_subtype (t1, PFty_empty ()))
+ PFoops (OOPS_TYPECHECK,
+ "binding sequence in a for clause has static "
+ "type `empty'");
+
+ /*
+ * XQuery Update Facility disallows updates in the `for'
+ * part.
+ */
+ if (!PFty_disjoint (PFty_stmt (),
+ PFty_prime (PFty_defn (t1))))
+ PFoops (OOPS_TYPECHECK,
+ "err:XUST0101: binding sequence may not contain "
+ "an updating expression (has type `%s')",
+ PFty_str (t1));
+
+ /* sanity check */
+ if (!PFty_subtype (t1, PFty_star (PFty_item ())))
+ PFoops (OOPS_TYPECHECK,
+ "illegal binding in for clause, cannot iterate over "
+ "type `%s'",
+ PFty_str (t1));
+
+ /* Var3 : xs:double */
+ TY(LLRR(p)) = PFty_xs_double ();
+ assert (LLRR(p)->sem.var);
+ TY( LLRR(p)->sem.var ) = TY(LLRR(p));
+
+ /* Var : prime (t1) */
+ TY(LLL(p)) = *PFty_simplify (PFty_prime (PFty_defn (t1)));
+
+ /* Var1 should now have a sensible type (not `none') */
+ assert (PFty_subtype (TY(LLL(p)), PFty_star (PFty_item ())));
+
+ /* E[Var : prime (t1)] |- CoreExpr : t2 */
+ assert (LLL(p)->sem.var);
+ TY( LLL(p)->sem.var ) = TY(LLL(p));
+ reduce (kids[1], nts[1]);
+
+ p->sem.flwr.quantifier = PFty_quantifier
+ (R(p)->sem.flwr.quantifier (
+ PFty_defn (t1)));
+
+ } break;
+
+ /* OptBindExpr: for_ (forbind (forvars (var,
+
vars (var, var)),
+ CoreExpr),
+ OptBindExpr) */
+ case 92:
+ { /* TOPDOWN */
+
+ /* W3C XQuery, 5.8.2
+ *
+ * E |- CoreExpr : t1
+ * E[Var1:prime (t1), Var2:xs:integer] |- OptBindExpr : t2
+ * --------------------------------------------------------------
+ * for_ (Var1, Var2, Var3, CoreExpr, CoreExpr) : t2 . quantifier
(t1)
+ */
+ PFty_t t1;
+
+ /* E |- CoreExpr : t1 */
+ reduce (kids[0], nts[0]);
+ t1 = TY(LR(p));
+
+ /*
+ * The specs prohibit the (statically typed) empty sequence
+ * in many places. (see XQuery FS, beginning of Section 4)
+ */
+ if (PFty_subtype (t1, PFty_empty ()))
+ PFoops (OOPS_TYPECHECK,
+ "binding sequence in a for clause has static "
+ "type `empty'");
+
+ /*
+ * XQuery Update Facility disallows updates in the `for'
+ * part.
+ */
+ if (!PFty_disjoint (PFty_stmt (),
+ PFty_prime (PFty_defn (t1))))
+ PFoops (OOPS_TYPECHECK,
+ "err:XUST0101: binding sequence may not contain "
+ "an updating expression (has type `%s')",
+ PFty_str (t1));
+
+ /* sanity check */
+ if (!PFty_subtype (t1, PFty_star (PFty_item ())))
+ PFoops (OOPS_TYPECHECK,
+ "illegal binding in for clause, cannot iterate over "
+ "type `%s'",
+ PFty_str (t1));
+
+ /* Var2 : xs:integer */
+ TY(LLRL(p)) = PFty_xs_integer ();
+ assert (LLRL(p)->sem.var);
+ TY( LLRL(p)->sem.var ) = TY(LLRL(p));
+
+ /* Var3 : xs:double */
+ TY(LLRR(p)) = PFty_xs_double ();
+ assert (LLRR(p)->sem.var);
+ TY( LLRR(p)->sem.var ) = TY(LLRR(p));
+
+ /* Var1 : prime (t1) */
+ TY(LLL(p)) = *PFty_simplify (PFty_prime (PFty_defn (t1)));
+
+ /* Var1 should now have a sensible type (not `none') */
+ assert (PFty_subtype (TY(LLL(p)), PFty_star (PFty_item ())));
+
+ /* E[Var1 : prime (t1), Var2 : xs:integer] |- CoreExpr : t2 */
+ assert (LLL(p)->sem.var);
+ TY( LLL(p)->sem.var ) = TY(LLL(p));
+ reduce (kids[1], nts[1]);
+
+ p->sem.flwr.quantifier = PFty_quantifier
+ (R(p)->sem.flwr.quantifier (PFty_defn (t1)));
+
+ } break;
+
default:
PFoops (OOPS_FATAL, "untranslated expression '%s'",
PFtypecheck_string[rule]);
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins