From 30bc0bb1291426e5e26eb2dee1ffc41e4c246349 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Thu, 7 Feb 2013 10:36:30 +0100 Subject: [PATCH] Refactor module organisation and build process. --- Makefile | 4 +- _tags | 5 +- myocamlbuild.ml | 175 ++---------------- myocamlbuild_config.ml | 34 ---- scripts/gen_mlpack.sh | 29 +++ src/auto.mlpack | 4 + src/{ => auto}/ata.ml | 4 +- src/{ => auto}/formula.ml | 4 +- src/{ => auto}/formula.mli | 14 +- src/{ => auto}/state.ml | 3 +- src/{ => auto}/state.mli | 0 src/{ => auto}/stateSet.ml | 3 +- src/{ => auto}/stateSet.mli | 4 +- src/test.ml | 14 +- src/tree.mlpack | 1 + src/{tree.ml => tree/naive.ml} | 3 +- src/{tree.mli => tree/naive.mli} | 4 +- src/utils.mlpack | 9 + src/{ => utils}/finiteCofinite.ml | 0 src/{ => utils}/finiteCofinite.mli | 0 src/{ => utils}/hcons.ml | 4 +- src/{ => utils}/hcons.mli | 0 src/{utils.ml => utils/misc.ml} | 0 src/{ => utils}/pretty.ml | 0 src/{ => utils}/pretty.mli | 0 src/{ => utils}/ptset.ml | 0 src/{ => utils}/ptset.mli | 0 src/{ => utils}/qName.ml | 0 src/{ => utils}/qName.mli | 0 src/{ => utils}/qNameSet.ml | 0 src/{ => utils}/qNameSet.mli | 0 src/{ => utils}/sigs.ml | 0 src/{ => utils}/uid.ml | 0 src/{ => utils}/uid.mli | 0 src/xPath.mlpack | 4 - src/xpath.mlpack | 4 + src/{XPath => xpath}/ast.ml | 3 +- src/{XPath => xpath}/ast.mli | 12 +- src/{XPath => xpath}/parser.ml | 4 +- src/{XPath => xpath}/ulexer.ml | 0 .../xpath_internal_parser.mly | 14 +- 41 files changed, 113 insertions(+), 246 deletions(-) delete mode 100644 myocamlbuild_config.ml create mode 100755 scripts/gen_mlpack.sh create mode 100644 src/auto.mlpack rename src/{ => auto}/ata.ml (98%) rename src/{ => auto}/formula.ml (98%) rename src/{ => auto}/formula.mli (92%) rename src/{ => auto}/state.ml (94%) rename src/{ => auto}/state.mli (100%) rename src/{ => auto}/stateSet.ml (94%) rename src/{ => auto}/stateSet.mli (91%) create mode 100644 src/tree.mlpack rename src/{tree.ml => tree/naive.ml} (98%) rename src/{tree.mli => tree/naive.mli} (96%) create mode 100644 src/utils.mlpack rename src/{ => utils}/finiteCofinite.ml (100%) rename src/{ => utils}/finiteCofinite.mli (100%) rename src/{ => utils}/hcons.ml (95%) rename src/{ => utils}/hcons.mli (100%) rename src/{utils.ml => utils/misc.ml} (100%) rename src/{ => utils}/pretty.ml (100%) rename src/{ => utils}/pretty.mli (100%) rename src/{ => utils}/ptset.ml (100%) rename src/{ => utils}/ptset.mli (100%) rename src/{ => utils}/qName.ml (100%) rename src/{ => utils}/qName.mli (100%) rename src/{ => utils}/qNameSet.ml (100%) rename src/{ => utils}/qNameSet.mli (100%) rename src/{ => utils}/sigs.ml (100%) rename src/{ => utils}/uid.ml (100%) rename src/{ => utils}/uid.mli (100%) delete mode 100644 src/xPath.mlpack create mode 100644 src/xpath.mlpack rename src/{XPath => xpath}/ast.ml (98%) rename src/{XPath => xpath}/ast.mli (90%) rename src/{XPath => xpath}/parser.ml (89%) rename src/{XPath => xpath}/ulexer.ml (100%) rename src/{XPath => xpath}/xpath_internal_parser.mly (91%) diff --git a/Makefile b/Makefile index 83aeb8f..5e3c1ad 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,8 @@ -SOURCE_DIR=src,src/XPath +SOURCE_DIR=src,src/xpath,src/utils,src/tree,src/auto TARGET=main.otarget - all: ocamlbuild -Is $(SOURCE_DIR) $(TARGET) - clean: ocamlbuild -clean diff --git a/_tags b/_tags index cf9b611..11dbbef 100644 --- a/_tags +++ b/_tags @@ -1 +1,4 @@ -: for-pack(XPath) +: for-pack(Xpath) +: for-pack(Utils) +: for-pack(Tree) +: for-pack(Auto) diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 1bb2410..2d9913e 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,177 +1,28 @@ -(***********************************************************************) -(* *) -(* TAToo *) -(* *) -(* Kim Nguyen, LRI UMR8623 *) -(* Université Paris-Sud & CNRS *) -(* *) -(* Copyright 2010-2013 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. *) -(* *) -(***********************************************************************) - -(* - Time-stamp: -*) - open Ocamlbuild_plugin open Command -open Myocamlbuild_config -open Format - -let print_list l = - eprintf "%![%s]%!\n" (String.concat ", " l) - -let _A x = A x -let _S ?(extra=N) l = S (List.map (fun e -> (S [extra; _A e] )) l) -;; -let cxx_flags_for_ml = [ _S ~extra:(_A "-ccopt") cxx_flags ] -let cxx_flags = ref [ _S cxx_flags ] -let project_dirs = [ src_path; include_path ] -let cxx_include_flags = _S cxx_includes -let cxx_link_flags = ref [ _S cxx_lpaths; _S cxx_libs] -let native_link_flags = ref (List.map (fun s -> s ^ ".cmxa") ocaml_link) -let byte_link_flags = ref ("-custom" :: (List.map (fun s -> s ^ ".cma") ocaml_link)) -let link_flags = [ A"-linkpkg" ] -let libs_files = List.map (fun s -> "file:" ^ s) cxx_libs_objects - - -let native_compile_flags = ref [A"-fno-PIC"] -let compile_flags = ref [] - -let dwsize = sprintf "-DWORDSIZE%i" Sys.word_size - -(* Utils *) -let ( @= ) r l = r := !r @ l -let ( =:: ) r e = r := e :: !r - -(* Pre-processed files *) -let pp_macro_options = ref - [ A dwsize; A "-I"; P include_path ] - -let include_full_path = Pathname.pwd / include_path -module Depends = -struct -open Scanf -let scan_include ml = - let ic = open_in ml and includes = ref [] in - begin - try - while true do - let s = input_line ic in - if String.length s > 0 then - try - sscanf s " INCLUDE \"%s@\"" (fun s -> includes =:: include_path /s) - with Scan_failure _ -> () - done - with End_of_file -> close_in ic - end; - !includes - -let ocaml ml = - let rec loop file = - let includes = scan_include file in - List.fold_left (fun a i -> (loop i) @ a) includes includes - in - let includes = loop ml in - dep [ "file:" ^ ml ] includes -let parse_depends depfile = - let ichan = open_in depfile in - let iscan = Scanning.from_channel ichan in - let includes = ref [] in - bscanf iscan " %_s@: %s " ignore; - try - while true do - bscanf iscan " %s " ( - function "" -> raise End_of_file - | "\\" -> () - | s -> includes =::s) - done; [] - with - _ -> close_in ichan;!includes +let ocamlfind_packages = "unix,ulex,expat,camlp4,camlp4.lib,camlp4.macro" -let cxx cpp = - let depfile = !Options.build_dir /" __cxx_depends.tmp" in - let cmd = Cmd (S[ A cxx_cmd ; S !cxx_flags; cxx_include_flags ; A"-MM"; - A "-MF"; P depfile; P cpp]) - in - let () = Command.execute ~quiet:true ~pretend:false cmd in - let includes = parse_depends depfile in - let includes' = (List.filter (Pathname.is_relative) includes) in - dep [ "compile"; "file:" ^ cpp ] includes' -end - -let cxx_compile env _build = - let cpp = env "%.cpp" and obj = env "%.o" in - let tags = (tags_of_pathname cpp) ++ "compile" ++ "c++" in - Cmd(S[T tags; A cxx_cmd; A "-o" ; P obj; A "-c"; S !cxx_flags; cxx_include_flags; P cpp]) - -(* Native compile and link action *) - -let ocamlfind x = S[ T (Tags.singleton "ocamlfind"); A"ocamlfind"; x ; A "-package"; A ocamlfind_packages; A "-syntax"; A "camlp4o" ] - -let ppopt l = List.map (fun e -> S[ A"-ppopt"; e ]) l +let ocamlfind x = S[ T (Tags.singleton "ocamlfind"); + A "ocamlfind"; x ; + A "-package"; + A ocamlfind_packages; + A "-syntax"; + A "camlp4o"; + A "-ppopt"; A "-I"; A"-ppopt"; A"include" + ] let () = dispatch begin function | Before_rules -> - Options.ocamlc := ocamlfind (A"ocamlc"); Options.ocamlopt := ocamlfind (A"ocamlopt"); Options.ocamldep := ocamlfind (A"ocamldep"); Options.ocamldoc := ocamlfind (A"ocamldoc"); Options.ocamlmktop := ocamlfind (A"ocamlmktop"); - - if not (List.mem "log" !Options.tags) then begin - pp_macro_options @= [ A "-DNLOG" ]; - end; - if (List.mem "profile" !Options.tags) then begin - pp_macro_options @= [ A "-DPROFILE" ]; - native_compile_flags @= [A "-p" ]; - native_link_flags @= [ "-p" ]; - cxx_flags @= [ A "-pg" ]; - cxx_link_flags @= [ A "-pg" ]; - end; - - if (List.mem "debug" !Options.tags) then begin - pp_macro_options @= [ A "-DDEBUG" ]; - cxx_flags @= [ A "-O0"; A "-g" ]; - cxx_link_flags @= [ A "-g" ]; - end - else begin - compile_flags @= [A "-noassert"]; - pp_macro_options @= [ A "-unsafe" ]; - native_compile_flags @= [ A "-inline"; A ocaml_inline ]; - cxx_flags @= [ A "-O3" ] - end; - - let dir_path = Pathname.pwd / src_path in - let dir = Pathname.readdir dir_path in - - Array.iter (fun entry -> - if Pathname.check_extension entry "ml" then - Depends.ocaml (src_path / entry) - else if Pathname.check_extension entry "cpp" then - Depends.cxx (src_path / entry) - ) dir; - - | After_rules -> - dep [ "link" ] cstub_lib; - rule "c++: cpp & depends -> o" ~prod:"%.o" ~deps:[ "%.cpp" ] cxx_compile; - let syntax_flags = S[ S (ppopt !pp_macro_options) ] - in - flag [ "ocaml"; "ocamldep"] syntax_flags; - flag [ "ocaml"; "compile" ] (S[ A "-cc"; A cxx_cmd; S cxx_flags_for_ml ; syntax_flags; S !compile_flags ]); - flag [ "ocaml"; "native"; "compile" ] (S !native_compile_flags); - flag [ "ocaml"; "link" ] - (S [ S link_flags ; A "-cc"; A cxx_cmd; S cxx_flags_for_ml; A "-cclib" ; - Quote (S [ _S cstub_lib; S !cxx_link_flags]) ]); - flag [ "ocaml"; "byte"; "link" ] (_S !byte_link_flags); - flag [ "ocaml"; "native"; "link" ] (_S !native_link_flags); - flag [ "c"; "ocamlmklib"] (A "-custom") + dep [ "extension:ml" ] + (List.map (fun s -> "include/" ^ s ) + (Array.to_list (Pathname.readdir "include"))); + flag [ "ocaml"; "link" ] (A"-linkpkg") | _ -> () end diff --git a/myocamlbuild_config.ml b/myocamlbuild_config.ml deleted file mode 100644 index ef9d2e6..0000000 --- a/myocamlbuild_config.ml +++ /dev/null @@ -1,34 +0,0 @@ -(***********************************************************************) -(* *) -(* TAToo *) -(* *) -(* Kim Nguyen, LRI UMR8623 *) -(* Université Paris-Sud & CNRS *) -(* *) -(* Copyright 2010-2013 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. *) -(* *) -(***********************************************************************) - -(* - Time-stamp: -*) - -let ocaml_inline = "1000";; -let include_path = "include";; -let src_path = "src";; -let ocaml_link = [ ];; -let ocamlfind_packages = "unix,ulex,expat,camlp4,camlp4.lib,camlp4.macro";; -let cxx_flags = [ "-fno-PIC"; "-std=c++0x"; "-O3" ];; -let main_targets = [ "native","src/main.native"; - "byte", "src/main.byte" ];; -let cstub_lib = [ ];; - -let cxx_cmd = "g++";; -let cxx_includes = [ ] -let cxx_lpaths = [ ] -let cxx_libs = [ ];; -let cxx_libs_objects = [];; diff --git a/scripts/gen_mlpack.sh b/scripts/gen_mlpack.sh new file mode 100755 index 0000000..95f78ec --- /dev/null +++ b/scripts/gen_mlpack.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +cd src +echo `pwd` +for dir in * +do + if [ -d "$dir" ] + then + echo "$dir" + rm -f "$dir".mlpack + cd "$dir" + for i in *.ml *.mly *.mll + do + if [ ! -f "$i" ] + then + continue + fi + echo "$i" + f=`echo "$i" | cut -b1` + l=`basename "$i" .mll` + l=`basename "$l" .mly` + l=`basename "$l" .ml | cut -b2-` + o=`echo "$f" | tr a-z A-Z` + echo "$dir"/"$o""$l" >> ../"$dir".mlpack + done + cd .. + fi +done +cd .. \ No newline at end of file diff --git a/src/auto.mlpack b/src/auto.mlpack new file mode 100644 index 0000000..af2dae6 --- /dev/null +++ b/src/auto.mlpack @@ -0,0 +1,4 @@ +auto/Ata +auto/Formula +auto/State +auto/StateSet diff --git a/src/ata.ml b/src/auto/ata.ml similarity index 98% rename from src/ata.ml rename to src/auto/ata.ml index 6ec859c..5001ebc 100644 --- a/src/ata.ml +++ b/src/auto/ata.ml @@ -14,10 +14,12 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) open Format +open Utils + type move = [ `Left | `Right | `Up1 | `Up2 | `Epsilon ] type state_ctx = { left : StateSet.t; right : StateSet.t; diff --git a/src/formula.ml b/src/auto/formula.ml similarity index 98% rename from src/formula.ml rename to src/auto/formula.ml index ad774ea..70407cf 100644 --- a/src/formula.ml +++ b/src/auto/formula.ml @@ -14,13 +14,13 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) INCLUDE "utils.ml" open Format - +open Utils (* diff --git a/src/formula.mli b/src/auto/formula.mli similarity index 92% rename from src/formula.mli rename to src/auto/formula.mli index e83bca1..3cf240d 100644 --- a/src/formula.mli +++ b/src/auto/formula.mli @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) module type PREDICATE = @@ -23,8 +23,8 @@ sig type ctx val eval : ctx -> t -> bool val neg : t -> t - include Hcons.Abstract with type t := t - include Sigs.AUX.Printable with type t := t + include Utils.Hcons.Abstract with type t := t + include Utils.Sigs.AUX.Printable with type t := t end type ('formula,'pred) expr = @@ -46,7 +46,7 @@ sig val hash : t -> int (** Hash function for formulae *) - val uid : t -> Uid.t + val uid : t -> Utils.Uid.t (** Returns a unique ID for formulae *) val equal : t -> t -> bool @@ -77,15 +77,15 @@ sig (** [atom_ dir b q] creates a down_left or down_right atom for state [q]. The atom is positive if [b == true]. *) - + val not_ : t -> t val or_ : t -> t -> t val and_ : t -> t -> t (** Boolean connective *) - + val of_bool : bool -> t (** Convert an ocaml Boolean value to a formula *) - + val eval : P.ctx -> t -> bool (** Evaluate a formula given a context for atomic predicates *) end diff --git a/src/state.ml b/src/auto/state.ml similarity index 94% rename from src/state.ml rename to src/auto/state.ml index bd1c72c..83ad4b4 100644 --- a/src/state.ml +++ b/src/auto/state.ml @@ -14,10 +14,11 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) open Format +open Utils type t = int let make = diff --git a/src/state.mli b/src/auto/state.mli similarity index 100% rename from src/state.mli rename to src/auto/state.mli diff --git a/src/stateSet.ml b/src/auto/stateSet.ml similarity index 94% rename from src/stateSet.ml rename to src/auto/stateSet.ml index 5871c7e..e99cd5e 100644 --- a/src/stateSet.ml +++ b/src/auto/stateSet.ml @@ -14,10 +14,11 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) open Format +open Utils include Ptset.Make (Hcons.PosInt) diff --git a/src/stateSet.mli b/src/auto/stateSet.mli similarity index 91% rename from src/stateSet.mli rename to src/auto/stateSet.mli index 1de4dee..96b5b6d 100644 --- a/src/stateSet.mli +++ b/src/auto/stateSet.mli @@ -14,11 +14,11 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) (** Implementation of sets of states *) -include Ptset.S with type elt = int +include Utils.Ptset.S with type elt = int val print : Format.formatter -> t -> unit (** Pretty printer *) diff --git a/src/test.ml b/src/test.ml index dec8918..e854f44 100644 --- a/src/test.ml +++ b/src/test.ml @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) (** use: xml_file "XPath querie" @@ -22,26 +22,26 @@ only the first line of XPath_querie_file is read *) -module F = Formula -module A = Ata +module F = Auto.Formula +module A = Auto.Ata (* 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 - let d = Tree.load_xml_file fd in + let d = Tree.Naive.load_xml_file fd in close_in fd; d let query = let arg2 = Sys.argv.(2) in - XPath.Parser.parse (Ulexing.from_latin1_string arg2) + Xpath.Parser.parse (Ulexing.from_latin1_string arg2) open Format let () = - fprintf err_formatter "Query: %a\n%!" XPath.Ast.print_path query; + fprintf err_formatter "Query: %a\n%!" Xpath.Ast.print_path query; fprintf err_formatter "Document:\n%!"; - Tree.print_xml stderr doc (Tree.root doc); + Tree.Naive.print_xml stderr doc (Tree.Naive.root doc); exit 0 diff --git a/src/tree.mlpack b/src/tree.mlpack new file mode 100644 index 0000000..933b481 --- /dev/null +++ b/src/tree.mlpack @@ -0,0 +1 @@ +tree/Naive diff --git a/src/tree.ml b/src/tree/naive.ml similarity index 98% rename from src/tree.ml rename to src/tree/naive.ml index 71f9a98..1086b1e 100644 --- a/src/tree.ml +++ b/src/tree/naive.ml @@ -14,8 +14,9 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) +open Utils type node = { tag : QName.t; diff --git a/src/tree.mli b/src/tree/naive.mli similarity index 96% rename from src/tree.mli rename to src/tree/naive.mli index 72cd077..60d1258 100644 --- a/src/tree.mli +++ b/src/tree/naive.mli @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) (** Implementation of documents as binary trees *) @@ -65,7 +65,7 @@ val parent : t -> node -> node Returns [nil] if [n == nil]. *) -val tag : t -> node -> QName.t +val tag : t -> node -> Utils.QName.t (** Returns the label of a given node *) val data : t -> node -> string diff --git a/src/utils.mlpack b/src/utils.mlpack new file mode 100644 index 0000000..27622d0 --- /dev/null +++ b/src/utils.mlpack @@ -0,0 +1,9 @@ +utils/FiniteCofinite +utils/Hcons +utils/Misc +utils/Pretty +utils/Ptset +utils/QName +utils/QNameSet +utils/Sigs +utils/Uid diff --git a/src/finiteCofinite.ml b/src/utils/finiteCofinite.ml similarity index 100% rename from src/finiteCofinite.ml rename to src/utils/finiteCofinite.ml diff --git a/src/finiteCofinite.mli b/src/utils/finiteCofinite.mli similarity index 100% rename from src/finiteCofinite.mli rename to src/utils/finiteCofinite.mli diff --git a/src/hcons.ml b/src/utils/hcons.ml similarity index 95% rename from src/hcons.ml rename to src/utils/hcons.ml index 1fc059c..eba8bac 100644 --- a/src/hcons.ml +++ b/src/utils/hcons.ml @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) include Sigs.HCONS @@ -61,7 +61,7 @@ struct cell end -module Make = Builder (Utils.HashSet) +module Make = Builder (Misc.HashSet) module Weak = Builder (Weak.Make) module PosInt = diff --git a/src/hcons.mli b/src/utils/hcons.mli similarity index 100% rename from src/hcons.mli rename to src/utils/hcons.mli diff --git a/src/utils.ml b/src/utils/misc.ml similarity index 100% rename from src/utils.ml rename to src/utils/misc.ml diff --git a/src/pretty.ml b/src/utils/pretty.ml similarity index 100% rename from src/pretty.ml rename to src/utils/pretty.ml diff --git a/src/pretty.mli b/src/utils/pretty.mli similarity index 100% rename from src/pretty.mli rename to src/utils/pretty.mli diff --git a/src/ptset.ml b/src/utils/ptset.ml similarity index 100% rename from src/ptset.ml rename to src/utils/ptset.ml diff --git a/src/ptset.mli b/src/utils/ptset.mli similarity index 100% rename from src/ptset.mli rename to src/utils/ptset.mli diff --git a/src/qName.ml b/src/utils/qName.ml similarity index 100% rename from src/qName.ml rename to src/utils/qName.ml diff --git a/src/qName.mli b/src/utils/qName.mli similarity index 100% rename from src/qName.mli rename to src/utils/qName.mli diff --git a/src/qNameSet.ml b/src/utils/qNameSet.ml similarity index 100% rename from src/qNameSet.ml rename to src/utils/qNameSet.ml diff --git a/src/qNameSet.mli b/src/utils/qNameSet.mli similarity index 100% rename from src/qNameSet.mli rename to src/utils/qNameSet.mli diff --git a/src/sigs.ml b/src/utils/sigs.ml similarity index 100% rename from src/sigs.ml rename to src/utils/sigs.ml diff --git a/src/uid.ml b/src/utils/uid.ml similarity index 100% rename from src/uid.ml rename to src/utils/uid.ml diff --git a/src/uid.mli b/src/utils/uid.mli similarity index 100% rename from src/uid.mli rename to src/utils/uid.mli diff --git a/src/xPath.mlpack b/src/xPath.mlpack deleted file mode 100644 index e062c25..0000000 --- a/src/xPath.mlpack +++ /dev/null @@ -1,4 +0,0 @@ -Ast -Parser -Ulexer -Xpath_internal_parser diff --git a/src/xpath.mlpack b/src/xpath.mlpack new file mode 100644 index 0000000..7619c15 --- /dev/null +++ b/src/xpath.mlpack @@ -0,0 +1,4 @@ +xpath/Ast +xpath/Parser +xpath/Ulexer +xpath/Xpath_internal_parser diff --git a/src/XPath/ast.ml b/src/xpath/ast.ml similarity index 98% rename from src/XPath/ast.ml rename to src/xpath/ast.ml index a097024..c3c00d9 100644 --- a/src/XPath/ast.ml +++ b/src/xpath/ast.ml @@ -14,9 +14,10 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) +open Utils type path = single_path list and single_path = Absolute of step list | Relative of step list diff --git a/src/XPath/ast.mli b/src/xpath/ast.mli similarity index 90% rename from src/XPath/ast.mli rename to src/xpath/ast.mli index a2b0579..f2a4df7 100644 --- a/src/XPath/ast.mli +++ b/src/xpath/ast.mli @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) type path = single_path list @@ -23,21 +23,21 @@ and step = axis * test * expr list and axis = Self | Attribute | Child | Descendant | DescendantOrSelf | FollowingSibling | Parent | Ancestor | AncestorOrSelf | PrecedingSibling | Preceding | Following -and test = QNameSet.t +and test = Utils.QNameSet.t and binop = Eq | Neq | Lt | Gt | Lte | Gte | Or | And | Add | Sub | Mult | Div | Mod and unop = Neg and expr = | Number of [ `Int of int | `Float of float ] | String of string - | Fun_call of QName.t * expr list + | Fun_call of Utils.QName.t * expr list | Path of path | Binop of expr * binop * expr | Unop of unop * expr type t = path -val text : QNameSet.t -val node : QNameSet.t -val star : QNameSet.t +val text : Utils.QNameSet.t +val node : Utils.QNameSet.t +val star : Utils.QNameSet.t val print_binop : Format.formatter -> binop -> unit val print_unop : Format.formatter -> unop -> unit val print_path : Format.formatter -> path -> unit diff --git a/src/XPath/parser.ml b/src/xpath/parser.ml similarity index 89% rename from src/XPath/parser.ml rename to src/xpath/parser.ml index 69e76e1..ed5283e 100644 --- a/src/XPath/parser.ml +++ b/src/xpath/parser.ml @@ -14,11 +14,11 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) include Xpath_internal_parser let parse (l : Ulexing.lexbuf) = - xpath (fun _ -> Ulexer.token l) (Lexing.from_string "!!dummy!!") + xpath_query (fun _ -> Ulexer.token l) (Lexing.from_string "!!dummy!!") diff --git a/src/XPath/ulexer.ml b/src/xpath/ulexer.ml similarity index 100% rename from src/XPath/ulexer.ml rename to src/xpath/ulexer.ml diff --git a/src/XPath/xpath_internal_parser.mly b/src/xpath/xpath_internal_parser.mly similarity index 91% rename from src/XPath/xpath_internal_parser.mly rename to src/xpath/xpath_internal_parser.mly index cd32ebb..04ecf36 100644 --- a/src/XPath/xpath_internal_parser.mly +++ b/src/xpath/xpath_internal_parser.mly @@ -15,7 +15,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) open Ast @@ -42,12 +42,12 @@ %left MOD DIV STAR %nonassoc uminus -%start xpath -%type xpath +%start xpath_query +%type xpath_query %% -xpath: +xpath_query: path EOF { $1 } ; @@ -90,7 +90,7 @@ axis_test: let _ = Format.flush_str_formatter () in let () = Format.fprintf Format.str_formatter "%a" Ast.print_axis $1 in let a = Format.flush_str_formatter () in - Child, QNameSet.singleton (QName.of_string a) + Child, Utils.QNameSet.singleton (Utils.QName.of_string a) } ; @@ -98,7 +98,7 @@ test: NODE { node } | TEXT { text } | STAR { star } -| TAG { QNameSet.singleton(QName.of_string $1) } +| TAG { Utils.QNameSet.singleton(Utils.QName.of_string $1) } ; pred_list: @@ -128,7 +128,7 @@ expr: | expr LTE expr { Binop($1, Lte, $3) } | expr GT expr { Binop($1, Gt, $3) } | expr GTE expr { Binop($1, Gte, $3) } -| TAG LP arg_list RP { Fun_call(QName.of_string $1, $3) } +| TAG LP arg_list RP { Fun_call(Utils.QName.of_string $1, $3) } | LP expr RP { $2 } | path { Path $1 } ; -- 2.17.1