Commit 7f2800d0 authored by Thorsten Wißmann's avatar Thorsten Wißmann
Browse files

Add OWL frontend

parent 7b8150bd
......@@ -16,6 +16,7 @@ coalg
coalgcompare
coalg.native
coalgcompare.native
*.native
# oasis build system temp files
setup.ml
......
......@@ -63,5 +63,14 @@ Executable coalg
MainIs: coalg.ml
BuildDepends: libcool
Executable "cool-owl"
CompiledObject: native
Path: src/owl/
BuildTools: ocamlbuild
MainIs: cool-owl.ml
BuildDepends: libcool
# some cabal similar syntax, so steal its syntax highlighting
# vim: ft=cabal
......@@ -52,4 +52,5 @@ 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
let foreach_l a f = List.iter f a
......@@ -26,3 +26,4 @@ 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
val foreach_l : ('a list) -> ('a -> unit) -> unit
open OWL
open CoolUtils
module OWLFP = OWLFunctionalParser
module L = List
let string_of_stdin (): string =
let buf = ref "" in
(try
while true do
let input = read_line () in
buf := !buf ^ input ^ "\n"
done
with End_of_file -> ());
!buf
let owlcat () =
let content = string_of_stdin () in
let t = OWLFP.tree_of_string content in
print_endline (OWLFP.string_of_tree (OWLFP.string_of_annotated id) t)
let rec
printUsage () =
let p = Printf.printf in
p "Usage: %s SUBCMD [ARGS...]\n" (Sys.argv.(0)) ;
p "\n";
p "Where SUBCMD is one of:\n";
foreach_l (tmp_subcmds ()) (fun (name,_,desc) ->
Printf.printf " %-10s %s\n" name desc
);
p "ARGS is subcommand specific.\n"
and
tmp_subcmds () =
let s name func description = (name,func,description) in
[ s "cat" owlcat "Reads a functional style OWL file from stdin and prints it"
; s "-h" printUsage "Prints this help screen"
; s "help" printUsage "Prints this help screen"
]
let subcmds = tmp_subcmds ()
let _ =
if Array.length Sys.argv < 2 then printUsage()
else
let cmd = Sys.argv.(1) in
try (
let (_,f,_) = List.find (fun (n,_,_) -> (n = cmd)) subcmds in
f ()
) with Not_found -> (
Printf.printf "Error: Subcommand %s not found.\n" cmd;
printUsage ()
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment