diff --git a/src/CoolUtils.ml b/src/CoolUtils.ml index 937064c7a3bff02113193643d35af54771503ea3..608526fb42ce3e84324002b5c11e4ed0138f1279 100644 --- a/src/CoolUtils.ml +++ b/src/CoolUtils.ml @@ -50,4 +50,6 @@ let intlist_of_string str = List.map int_of_string (Str.split (Str.regexp "[ \t, let compose f g x = f (g (x)) let flip f y x = f x y +let eval a f = f a +let id a = a diff --git a/src/CoolUtils.mli b/src/CoolUtils.mli index 9e2a54449a7832807f0916ff9414bb8922feef66..fb6fc5cee74d10b0e11a6da5f3c9ae2f502fc24a 100644 --- a/src/CoolUtils.mli +++ b/src/CoolUtils.mli @@ -24,3 +24,5 @@ val intlist_of_string : string -> int list val compose : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c) val flip : ('a -> 'b -> 'c) -> ('b -> 'a -> 'c) +val eval : 'a -> ('a -> 'b) -> 'b +val id : 'a -> 'a diff --git a/src/OWLFunctionalParser.ml b/src/OWLFunctionalParser.ml index 68f882d78ebe40ea0f864779ff026e0d4d3e52a9..bfb6334168ead87e70fedaebc9ea1343f6f6c28e 100644 --- a/src/OWLFunctionalParser.ml +++ b/src/OWLFunctionalParser.ml @@ -1,6 +1,7 @@ module L = List +open CoolUtils open Str open Stream @@ -42,7 +43,7 @@ let line_stream_of_string string = let list_of_stream stream = let cons a b = a::b in - stream_fold cons stream [] + L.rev (stream_fold cons stream []) let tokens_from_string (buf:string) : string annotated list = let lastline = ref 0 in @@ -71,6 +72,9 @@ let tokens_from_string (buf:string) : string annotated list = let string_of_annotation (file,line,col) = file ^ ":" ^ (string_of_int line) ^ ":" ^ (string_of_int col) +let string_of_annotated str_of_a (obj,anno) : string = + string_of_annotation anno ^ " " ^ str_of_a obj + let tree_of_tokens lst : string annotated tree = let stream:string annotated Stream.t = Stream.of_list lst in (* returns the next tree in our forest *) @@ -93,5 +97,11 @@ let tree_of_tokens lst : string annotated tree = let forest = list_of_stream (Stream.from (fun _ -> tree_of_token_stream ())) in Node forest - +let string_of_tree str_of_a atree : string = + let indent str = " "^str in + let rec lines_of_tree t = match t with + | (Leaf a) -> [str_of_a a] + | (Node lst) -> L.map indent (L.concat (L.map lines_of_tree lst)) + in + String.concat "\n" (lines_of_tree atree) diff --git a/src/OWLFunctionalParser.mli b/src/OWLFunctionalParser.mli index b157080b9b382c471aa43c710e4d7b9e074ef9d3..5c742b82b0dae80680414224f8a06ad73b3bd222 100644 --- a/src/OWLFunctionalParser.mli +++ b/src/OWLFunctionalParser.mli @@ -10,9 +10,13 @@ type 'a tree = | Leaf of 'a | Node of (('a tree) list) +val list_of_stream : 'a Stream.t -> 'a list + val string_of_annotation : annotation -> string +val string_of_annotated : ('a -> string) -> 'a annotated -> string val tokens_from_string : string -> string annotated list val tree_of_tokens : string annotated list -> string annotated tree +val string_of_tree : ('a -> string) -> 'a tree -> string (*val parse : string -> OWL.Ontology *) diff --git a/src/coalg.ml b/src/coalg.ml index 745191d9424095fba2525e1e6e5e1d8f437ebe6b..e10e9992e4530418ee5622ee57fe6d2264932a93 100644 --- a/src/coalg.ml +++ b/src/coalg.ml @@ -6,6 +6,9 @@ module CM = CoAlgMisc module CF = CoAlgFormula +module OWLFP = OWLFunctionalParser + +open CoolUtils (* The type of formulae that are accepted. *) (* @@ -37,7 +40,7 @@ let _ = Gc.set { (Gc.get()) with Gc.minor_heap_size = 4194304; major_heap_increm let printUsage () = print_endline "Usage: \"alc <task> <functor> [<flags>]\" where"; - print_endline " <task> in { sat print nnf prov (is »not.(sat ¬f)«) }"; + print_endline " <task> in { sat print nnf prov (is »not.(sat ¬f)«) owlcat }"; print_endline " <functor> in { MultiModalK MultiModalKD CoalitionLogic GML"; print_endline " (or: K) (or: KD) (or: CL) }"; print_endline " <flags> = a list of the following items"; @@ -142,6 +145,18 @@ let choiceNNF () = done with End_of_file -> () +let choiceOWLCat () = + let buf = ref "" in + try + while true do + let input = read_line () in + buf := !buf ^ input ^ "\n" + done + with End_of_file -> () ; + let t = OWLFP.tree_of_tokens (OWLFP.tokens_from_string !buf) in + print_endline (OWLFP.string_of_tree (OWLFP.string_of_annotated id) t) + + let rec parseFlags arr offs : unit = let offs = ref (offs) in let getParam () = @@ -173,6 +188,7 @@ let _ = | "prov" -> choiceProvable () | "print" -> choicePrint () | "nnf" -> choiceNNF () + | "owlcat" -> choiceOWLCat () | _ -> printUsage ()