Remove AbsoluteDOS from the XPath AST.
authorKim Nguyễn <kn@lri.fr>
Fri, 21 Dec 2012 13:16:39 +0000 (14:16 +0100)
committerKim Nguyễn <kn@lri.fr>
Mon, 4 Feb 2013 14:57:33 +0000 (15:57 +0100)
src/formula.ml
src/formula.mli
src/test.ml
src/xPath.ml
src/xPath.mli

index 4c58e3c..14fd76f 100644 (file)
@@ -21,8 +21,7 @@ type 'formula expr =
   | True
   | Or of 'formula * 'formula
   | And of 'formula * 'formula
   | True
   | Or of 'formula * 'formula
   | And of 'formula * 'formula
-  | Move of (move * bool * State.t)
-  | Label of QNameSet.t
+  | Move of move * bool * State.t
 
 type 'hcons node = {
   pos : 'hcons expr;
 
 type 'hcons node = {
   pos : 'hcons expr;
@@ -43,7 +42,6 @@ module rec Node : Hcons.S
       | Or(xf1, xf2), Or(yf1, yf2)
       | And(xf1, xf2), And(yf1,yf2)  -> (xf1 == yf1) && (xf2 == yf2)
       | Move(d1, p1, s1), Move(d2 ,p2 ,s2) -> d1 == d2 && p1 == p2 && s1 == s2
       | Or(xf1, xf2), Or(yf1, yf2)
       | And(xf1, xf2), And(yf1,yf2)  -> (xf1 == yf1) && (xf2 == yf2)
       | Move(d1, p1, s1), Move(d2 ,p2 ,s2) -> d1 == d2 && p1 == p2 && s1 == s2
-      | Label s1, Label s2 -> s1 == s2
       | _ -> false
 
     let hash f =
       | _ -> false
 
     let hash f =
@@ -56,7 +54,6 @@ module rec Node : Hcons.S
         HASHINT3(PRIME3, Uid.to_int f1.Node.id, Uid.to_int f2.Node.id)
 
       | Move(d, p, s) -> HASHINT4(PRIME5, hash_const_variant d,vb p,s)
         HASHINT3(PRIME3, Uid.to_int f1.Node.id, Uid.to_int f2.Node.id)
 
       | Move(d, p, s) -> HASHINT4(PRIME5, hash_const_variant d,vb p,s)
-      | Label s -> HASHINT2(PRIME7, Uid.to_int s.QNameSet.id)
   end
 
 type t = Node.t
   end
 
 type t = Node.t
@@ -64,14 +61,12 @@ let hash x = x.Node.hash
 let uid x = x.Node.id
 let equal = Node.equal
 let expr f = f.Node.node.pos
 let uid x = x.Node.id
 let equal = Node.equal
 let expr f = f.Node.node.pos
-(*let st f = f.Node.node.st*)
-(*let size f = f.Node.node.size*)
+
 let compare f1 f2 = compare f1.Node.id  f2.Node.id
 let prio f =
   match expr f with
     | True | False -> 10
     | Move _ -> 8
 let compare f1 f2 = compare f1.Node.id  f2.Node.id
 let prio f =
   match expr f with
     | True | False -> 10
     | Move _ -> 8
-    | Label _ -> 7
     | And _ -> 6
     | Or _ -> 1
 
     | And _ -> 6
     | Or _ -> 1
 
@@ -88,7 +83,6 @@ let rec print ?(parent=false) ppf f =
       (print ppf f1);
       fprintf ppf " %s " Pretty.vee;
       (print ppf f2);
       (print ppf f1);
       fprintf ppf " %s " Pretty.vee;
       (print ppf f2);
-    | Label s -> fprintf ppf "%a" QNameSet.print s
     | Move(dir, b, s) ->
       let _ = flush_str_formatter() in
       let fmt = str_formatter in
     | Move(dir, b, s) ->
       let _ = flush_str_formatter() in
       let fmt = str_formatter in
@@ -155,12 +149,3 @@ let and_ f1 f2 =
 
 let of_bool = function true -> true_ | false -> false_
 
 
 let of_bool = function true -> true_ | false -> false_
 
-
-module Infix = struct
-  let ( +| ) f1 f2 = or_ f1 f2
-
-  let ( *& ) f1 f2 = and_ f1 f2
-
-  let ( *+ ) d s = atom_ d true s
-  let ( *- ) d s = atom_ d false s
-end
index 78edcfc..04b3662 100644 (file)
@@ -24,8 +24,7 @@ type 'formula expr =
   | True
   | Or of 'formula * 'formula
   | And of 'formula * 'formula
   | True
   | Or of 'formula * 'formula
   | And of 'formula * 'formula
-  | Move of (move * bool * State.t)
-  | Label of QNameSet.t
+  | Move of move * bool * State.t
 
 (** View of the internal representation of a formula,
     used for pattern matching *)
 
 (** View of the internal representation of a formula,
     used for pattern matching *)
@@ -80,14 +79,3 @@ val and_ : t -> t -> t
 
 val of_bool : bool -> t
 (** Convert an ocaml Boolean value to a formula *)
 
 val of_bool : bool -> t
 (** Convert an ocaml Boolean value to a formula *)
-
-module Infix : sig
-  val ( +| ) : t -> t -> t
-  val ( *& ) : t -> t -> t
-  val ( *+ ) : move -> StateSet.elt -> t
-  val ( *- ) : move -> StateSet.elt -> t
-end
-(** Module to facilitate infix notations of formulae.
-    Just [open Formla.Infix] and write:
-    [let f = `Left *+ q1 +| `Right *+ q2 in ...]
-*)
index 465e409..b8f2be8 100644 (file)
@@ -20,6 +20,7 @@
 *)
 
 module F = Formula
 *)
 
 module F = Formula
+module A = Ata
 (* to force ocaml build to add Formula to the dependency chain even if
    we don't use it yet*)
 
 (* to force ocaml build to add Formula to the dependency chain even if
    we don't use it yet*)
 
index 7ebc135..5258b67 100644 (file)
@@ -17,7 +17,7 @@
 module Ast =
 struct
 
 module Ast =
 struct
 
-  type path = Absolute of step list | AbsoluteDoS of step list| Relative of step list
+  type path = Absolute of step list | Relative of step list
   and step = axis * test *predicate
   and axis = Self | Attribute | Child | Descendant | DescendantOrSelf | FollowingSibling
              | Parent | Ancestor | AncestorOrSelf | PrecedingSibling | Preceding | Following
   and step = axis * test *predicate
   and axis = Self | Attribute | Child | Descendant | DescendantOrSelf | FollowingSibling
              | Parent | Ancestor | AncestorOrSelf | PrecedingSibling | Preceding | Following
@@ -62,9 +62,6 @@ struct
   let rec print fmt p =
     let l = match p with
       | Absolute l -> pp fmt "/"; l
   let rec print fmt p =
     let l = match p with
       | Absolute l -> pp fmt "/"; l
-      | AbsoluteDoS l -> pp fmt "/";
-        print_step fmt (DescendantOrSelf,Simple QNameSet.any,Expr True);
-        pp fmt "/"; l
       | Relative l -> l
     in
       Pretty.print_list ~sep:"/" print_step fmt l
       | Relative l -> l
     in
       Pretty.print_list ~sep:"/" print_step fmt l
@@ -139,8 +136,6 @@ struct
     print_axis r a; Format.flush_str_formatter()
 
 
     print_axis r a; Format.flush_str_formatter()
 
 
-
-
 EXTEND Gram
 
 GLOBAL: query;
 EXTEND Gram
 
 GLOBAL: query;
@@ -149,8 +144,7 @@ GLOBAL: query;
 ;
 
  path : [
 ;
 
  path : [
-   [ "//" ; l = slist -> AbsoluteDoS (List.rev l) ]
- | [ "/" ; l = slist -> Absolute (List.rev l) ]
+ [ "/" ; l = slist -> Absolute (List.rev l) ]
  | [ l = slist  -> Relative (List.rev l) ]
  ]
 ;
  | [ l = slist  -> Relative (List.rev l) ]
  ]
 ;
@@ -174,8 +168,8 @@ step : [
       | Some(t) ->  (axis,t,p)
       | None -> (Child,Simple (QNameSet.singleton (QName.of_string (axis_to_string axis))),p)
     in match a with
       | Some(t) ->  (axis,t,p)
       | None -> (Child,Simple (QNameSet.singleton (QName.of_string (axis_to_string axis))),p)
     in match a with
-      | Following -> [ (DescendantOrSelf,t,p);
-               (FollowingSibling, t_star,Expr(True));
+      | Following -> [ (DescendantOrSelf,t,p); 
+              (FollowingSibling, t_star,Expr(True));
                (Ancestor, t_star ,Expr(True)) ]
 
       | Preceding -> [ (DescendantOrSelf,t,p);
                (Ancestor, t_star ,Expr(True)) ]
 
       | Preceding -> [ (DescendantOrSelf,t,p);
index afb4c39..de89955 100644 (file)
@@ -18,8 +18,7 @@
 
 module Ast :
 sig
 
 module Ast :
 sig
-  type path = Absolute of step list | AbsoluteDoS of step list
-              | Relative of step list
+  type path = Absolute of step list | Relative of step list
 
   and step = axis * test * predicate
   and axis = Self | Attribute | Child | Descendant | DescendantOrSelf
 
   and step = axis * test * predicate
   and axis = Self | Attribute | Child | Descendant | DescendantOrSelf