From 5a9c2accf1b54294cd71b90ca5cca5f69ac8e76e Mon Sep 17 00:00:00 2001 From: Lucca Hirschi Date: Mon, 2 Jul 2012 11:13:15 +0200 Subject: [PATCH] Files compil.ml? for compilation XPath -> ASTA + test.ml call this function and print the result --- src/asta.ml | 12 +++++++++--- src/asta.mli | 5 ++++- src/compil.ml | 16 ++++++++++++++++ src/compil.mli | 19 +++++++++++++++++++ src/test.ml | 8 +++----- 5 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 src/compil.ml create mode 100644 src/compil.mli diff --git a/src/asta.ml b/src/asta.ml index cb4521e..670bb35 100644 --- a/src/asta.ml +++ b/src/asta.ml @@ -13,8 +13,6 @@ (* *) (***********************************************************************) -open Format - type state = State.t type label = QNameSet.t @@ -73,6 +71,14 @@ let transitions asta st = | (a,s,l) :: tl -> (s,l) :: (remove_states tl) in remove_states (SetT.elements (SetT.filter filter asta.trans)) +let dummy = { + reco = StateSet.empty; + selec = StateSet.empty; + bottom = StateSet.empty; + top = StateSet.empty; + trans = SetT.empty; +} + let print fmt asta = let pp = Format.fprintf fmt in @@ -85,7 +91,7 @@ let print fmt asta = pp "\nTop states: "; StateSet.print fmt asta.top; pp "\nTransitions: \n"; - Format.fprintf fmt "{@[ %a @]}" (* todo: check boxes *) + Format.fprintf fmt "{@[ %a @]}" (* todo: check boxes *) (Pretty.print_list ~sep:"@, " (Transition.print)) (SetT.elements (asta.trans)) diff --git a/src/asta.mli b/src/asta.mli index 0dd1994..dff376f 100644 --- a/src/asta.mli +++ b/src/asta.mli @@ -2,7 +2,7 @@ (* *) (* TAToo *) (* *) -(* ? *) +(* Lucca Hirschi, ? *) (* ? *) (* *) (* Copyright 2010-2012 Université Paris-Sud and Centre National de la *) @@ -34,6 +34,9 @@ val transition : t -> state -> label -> formula val transitions : t -> state -> (label*formula) list (** Give the list of labels and formulae from transitions for a given state *) +val dummy : t +(** The empty automaton *) + val print : Format.formatter -> t -> unit (** Describe the automaton as text *) diff --git a/src/compil.ml b/src/compil.ml new file mode 100644 index 0000000..30440f3 --- /dev/null +++ b/src/compil.ml @@ -0,0 +1,16 @@ +(***********************************************************************) +(* *) +(* TAToo *) +(* *) +(* 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. *) +(* *) +(***********************************************************************) + +let trad qu = Asta.dummy diff --git a/src/compil.mli b/src/compil.mli new file mode 100644 index 0000000..e21975d --- /dev/null +++ b/src/compil.mli @@ -0,0 +1,19 @@ +(***********************************************************************) +(* *) +(* TAToo *) +(* *) +(* 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 compilation from XPath queries into ASTA *) + +val trad : XPath.Ast.path -> Asta.t +(** Compilation function *) diff --git a/src/test.ml b/src/test.ml index df5b112..8b69fd8 100644 --- a/src/test.ml +++ b/src/test.ml @@ -19,11 +19,6 @@ only the first line of XPath_querie_file is read *) -module F = Formula -module G = Asta - -(* to force ocaml build to add Formula to the dependency chain even if - we don't use it yet*) let doc = let fd = open_in Sys.argv.(1) in @@ -42,8 +37,11 @@ let query = open Format +let asta = Compil.trad query + let () = fprintf err_formatter "Query: %a\n%!" XPath.Ast.print query; + fprintf err_formatter "Asta: %a\n%!" Asta.print asta; fprintf err_formatter "Document:\n%!"; Tree.print_xml stderr doc (Tree.root doc); exit 0 -- 2.17.1