From: Lucca Hirschi Date: Tue, 3 Jul 2012 12:59:46 +0000 (+0200) Subject: Files for the next step: run.ml? X-Git-Tag: Core~13 X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=commitdiff_plain;h=6b4b9309e0f49f9a87d97ea87829aa74614dedb7 Files for the next step: run.ml? + minors --- diff --git a/src/asta.ml b/src/asta.ml index 942133c..dc7b88d 100644 --- a/src/asta.ml +++ b/src/asta.ml @@ -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 " @[%a @]" print_list_tr trans in Format.fprintf fmt "@[# Queries transitions:@ %a@ @]" print_box_list asta.trans_q; Format.fprintf fmt "@[# Recognizing transitions:@ %a@ @]" print_box_list asta.trans_r in - Format.fprintf fmt "@[ ##### ASTA #####@. %a@ @]" print_box 0 + Format.fprintf fmt "@[ ##### ASTA #####@, %a@ @]" print_box 0 let to_file out asta = () diff --git a/src/asta.mli b/src/asta.mli index 3f25edc..76ebdb1 100644 --- a/src/asta.mli +++ b/src/asta.mli @@ -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 *) diff --git a/src/compil.ml b/src/compil.ml index 99e87b5..f505229 100644 --- a/src/compil.ml +++ b/src/compil.ml @@ -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 index 0000000..e24462f --- /dev/null +++ b/src/run.ml @@ -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 index 0000000..38bedd1 --- /dev/null +++ b/src/run.mli @@ -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 *) diff --git a/src/test.ml b/src/test.ml index 7d6bf58..16c96e5 100644 --- a/src/test.ml +++ b/src/test.ml @@ -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 "@[ ##### Query #####@. %a@]@ " + let run = compute_run doc asta in + fprintf err_formatter "@[##### 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 "@[ ##### Run #####@. %a@]@ " + Run.print run; exit 0 - diff --git a/tests/results/my.result b/tests/results/my.result index 25e0974..227e738 100644 --- a/tests/results/my.result +++ b/tests/results/my.result @@ -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> @@ -33,3 +12,29 @@ Parse query OK ! Parse Tree OK ! Compil OK ! + + ##### 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 #####