Files for the next step: run.ml?
authorLucca Hirschi <lucca.hirschi@gmail.com>
Tue, 3 Jul 2012 12:59:46 +0000 (14:59 +0200)
committerLucca Hirschi <lucca.hirschi@gmail.com>
Tue, 3 Jul 2012 12:59:46 +0000 (14:59 +0200)
+ minors

src/asta.ml
src/asta.mli
src/compil.ml
src/run.ml [new file with mode: 0644]
src/run.mli [new file with mode: 0644]
src/test.ml
tests/results/my.result

index 942133c..dc7b88d 100644 (file)
@@ -128,13 +128,13 @@ let print fmt asta =
       if SetT.is_empty z 
       then Format.fprintf fmt "ø"
       else
-       SetT.iter (fun x -> Format.fprintf fmt "|  %a@ "  Transition.print x) z in
+       SetT.iter (fun x -> Format.fprintf fmt "|  %a  @ "  Transition.print x) z in
     let print_box_list fmt trans  =
       Format.fprintf fmt "  @[<hov 0>%a @]" print_list_tr trans in
     Format.fprintf fmt "@[<v 0># Queries transitions:@ %a@ @]"
       print_box_list asta.trans_q;
     Format.fprintf fmt "@[<v 0># Recognizing transitions:@ %a@ @]"
       print_box_list asta.trans_r in
-  Format.fprintf fmt "@[<v 0> ##### ASTA #####@. %a@ @]" print_box 0
+  Format.fprintf fmt "@[<v 1> ##### ASTA #####@, %a@ @]" print_box 0
 
 let to_file out asta = ()
index 3f25edc..76ebdb1 100644 (file)
@@ -72,7 +72,7 @@ val top_states : t -> state list
 (** Give the list of top states of an ASTA *)
 
 val print : Format.formatter -> t -> unit
-(** Describe the automaton as text *)
+(** Pretty printer *)
 
 val to_file : out_channel -> t -> unit
 (** Outputs the description of the automaton on the given out_channel *)
index 99e87b5..f505229 100644 (file)
@@ -75,7 +75,7 @@ let trans query =
     Asta.add_top asta q
       
   and trans_pr  = function             (* either we apply De Morgan rules
-                                          in xPath:parse or here *)
+                                          in xPath.parse or here *)
     | Expr True -> Formula.true_
     | Expr False -> Formula.false_
     | Or (p_1,p_2) -> trans_pr(p_1) +| trans_pr(p_2)
diff --git a/src/run.ml b/src/run.ml
new file mode 100644 (file)
index 0000000..e24462f
--- /dev/null
@@ -0,0 +1,18 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                  Lucca Hirschi, ?   *)
+(*                  ?   *)
+(*                                                                     *)
+(*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
+(*  Recherche Scientifique. All rights reserved.  This file is         *)
+(*  distributed under the terms of the GNU Lesser General Public       *)
+(*  License, with the special exception on linking described in file   *)
+(*  ../LICENSE.                                                        *)
+(*                                                                     *)
+(***********************************************************************)
+
+type t = int
+
+let compute tree asta = 0
+
+let print fmt run = ()
diff --git a/src/run.mli b/src/run.mli
new file mode 100644 (file)
index 0000000..38bedd1
--- /dev/null
@@ -0,0 +1,23 @@
+(***********************************************************************)
+(*                                                                     *)
+(*                  Lucca Hirschi, ?   *)
+(*                  ?   *)
+(*                                                                     *)
+(*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
+(*  Recherche Scientifique. All rights reserved.  This file is         *)
+(*  distributed under the terms of the GNU Lesser General Public       *)
+(*  License, with the special exception on linking described in file   *)
+(*  ../LICENSE.                                                        *)
+(*                                                                     *)
+(***********************************************************************)
+
+(** Implementation of runs in ASTA and algorithms for computing them *)
+
+type t
+(** The type of runs in ASTA *)
+
+val compute : Tree.t -> Asta.t -> t
+(** Gives the maximal run of an ASTA on a tree *)
+
+val print : Format.formatter -> t -> unit
+(** Pretty printer *)
index 7d6bf58..16c96e5 100644 (file)
@@ -43,18 +43,25 @@ let query () =
 
 let build_asta query =
   let asta = Compil.trans query in
-  fprintf err_formatter "Compil OK !\n";
+  fprintf err_formatter "Compil OK ! ";
   asta
 
+let compute_run doc query = 
+  let run = Run.compute doc query in
+  fprintf err_formatter "Run OK ! \n";
+  run
+
 let () =
   let query = query () in
   let doc = doc () in
   let asta = build_asta query in
-  fprintf err_formatter "@[<v 0> ##### Query #####@.      %a@]@ "
+  let run = compute_run doc asta in
+  fprintf err_formatter "@[<v 0>##### Query #####@.  %a@]@ "
     XPath.Ast.print query;
-  Asta.print err_formatter asta;
   output_string stderr "\n##### Doc #####\n";
   Tree.print_xml stderr doc (Tree.root doc);
   output_string stderr "\n";
+  Asta.print err_formatter asta;
+  fprintf err_formatter "@[<v 0> ##### Run #####@.  %a@]@ "
+    Run.print run;
   exit 0
-
index 25e0974..227e738 100644 (file)
@@ -1,27 +1,6 @@
-Parse query OK ! Parse Tree OK ! Compil OK !
- ##### Query #####
-      /descendant::a[descendant::c[child::e and not descendant::f[not descendant::e]/descendant::g]]/descendant::b[child::g]
- ##### ASTA #####
- # Query states: { q₁ q₂ q₈ q₉ }
- # Recognizing states: { q₀ q₃ q₄ q₅ q₆ q₇ }
- # Selecting states: { q₁ }
- # Bottom states: { q₁ q₂ q₈ }
- # Tom states: { q₉ }
- # Queries transitions:
-   |  q₁ ----F(b)---> ↓₁q₀
-   |  q₂ ----Cof(ø)---> ↓₁q₂ ∨ ↓₂q₂ ∨ ↓₁q₁ ∨ ↓₂q₁
-   |  q₈ ----F(a)---> (↓₁q₂ ∨ ↓₁q₁) ∧ ↓₁q₇
-   |  q₈ ----Cof(ø)---> ↓₁q₈ ∨ ↓₂q₈
-   |  q₉ ----Cof(ø)---> ↓₁q₈  
- # Recognizing transitions:
-   |  q₀ ----F(g)---> ⊤ |  q₀ ----Cof(ø)---> ↓₂q₀
-   |  q₃ ----F(g)---> ⊤ |  q₃ ----Cof(ø)---> ↓₁q₃ ∨ ↓₂q₃
-   |  q₄ ----F(e)---> ⊤ |  q₄ ----Cof(ø)---> ↓₁q₄ ∨ ↓₂q₄
-   |  q₅ ----F(f)---> ̅↓̅₁̅q̅₄ ∧ ↓₁q₃
-   |  q₅ ----Cof(ø)---> ↓₁q₅ ∨ ↓₂q₅ |  q₆ ----F(e)---> ⊤
-   |  q₆ ----Cof(ø)---> ↓₂q₆
-   |  q₇ ----F(c)---> ↓₁q₆ ∧ ̅↓̅₁̅q̅₅
-   |  q₇ ----Cof(ø)---> ↓₁q₇ ∨ ↓₂q₇
+Parse query OK ! Parse Tree OK ! Compil OK ! Run OK ! 
+##### Query #####
+  /descendant::a[descendant::c[child::e and not descendant::f[not descendant::e]/descendant::g]]/descendant::b[child::g]
 ##### Doc #####
 <#document><a>
   <b/>
@@ -33,3 +12,29 @@ Parse query OK ! Parse Tree OK ! Compil OK !
   </e>
   <j> <k/> <l/> <m/> </j>
 </a></#document>
+
+ ##### ASTA #####
+  # Query states: { q₁ q₂ q₈ q₉ }
+  # Recognizing states: { q₀ q₃ q₄ q₅ q₆ q₇ }
+  # Selecting states: { q₁ }
+  # Bottom states: { q₁ q₂ q₈ }
+  # Tom states: { q₉ }
+  # Queries transitions:
+    |  q₁ ----F(b)---> ↓₁q₀  
+    |  q₂ ----Cof(ø)---> ↓₁q₂ ∨ ↓₂q₂ ∨ ↓₁q₁ ∨ ↓₂q₁  
+    |  q₈ ----F(a)---> (↓₁q₂ ∨ ↓₁q₁) ∧ ↓₁q₇  
+    |  q₈ ----Cof(ø)---> ↓₁q₈ ∨ ↓₂q₈  
+    |  q₉ ----Cof(ø)---> ↓₁q₈    
+  # Recognizing transitions:
+    |  q₀ ----F(g)---> ⊤   |  q₀ ----Cof(ø)---> ↓₂q₀  
+    |  q₃ ----F(g)---> ⊤  
+    |  q₃ ----Cof(ø)---> ↓₁q₃ ∨ ↓₂q₃  
+    |  q₄ ----F(e)---> ⊤  
+    |  q₄ ----Cof(ø)---> ↓₁q₄ ∨ ↓₂q₄  
+    |  q₅ ----F(f)---> ̅↓̅₁̅q̅₄ ∧ ↓₁q₃  
+    |  q₅ ----Cof(ø)---> ↓₁q₅ ∨ ↓₂q₅  
+    |  q₆ ----F(e)---> ⊤   |  q₆ ----Cof(ø)---> ↓₂q₆  
+    |  q₇ ----F(c)---> ↓₁q₆ ∧ ̅↓̅₁̅q̅₅  
+    |  q₇ ----Cof(ø)---> ↓₁q₇ ∨ ↓₂q₇    
+  
+  ##### Run #####