Commit f8778da5 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Cleanup

parent 9340893b
open Printf
open Types
open Stringify
open Parse
let main () =
let argc = Array.length Sys.argv in
let usage status =
printf "usage: %s command [args]\n" Sys.argv.(0);
printf "command:\n";
printf " help\n";
printf " echo PROGRAM\n";
status
prerr_endline ("usage: " ^ Sys.argv.(0) ^ " command [args]");
prerr_endline "command:";
prerr_endline " help show this help page";
prerr_endline " echo PROGRAM pretty-print a program";
prerr_endline "input program syntax:";
prerr_endline " - omit omega sign after closing parenthesis";
prerr_endline " - write dollar sign ($) instead of pound sign";
exit status
in
if argc = 1 then begin
usage 1
end else
let argc = Array.length Sys.argv in
if argc = 1 then usage 1;
begin
match Sys.argv.(1) with
| "help" ->
usage 0
| "echo" when argc > 2 ->
printf "%s\n" (string_of_program (parse_string Sys.argv.(2)));
0
print_endline (string_of_program (parse_string Sys.argv.(2)))
| _ ->
usage 1
end;
exit 0
let () = exit (main ())
let () = main ()
open Types
let omega = "\207\137"
let string_of_basic ins = ins
let string_of_primitive = function
......@@ -12,5 +14,5 @@ let string_of_primitive = function
let rec string_of_program = function
| Primitive p -> string_of_primitive p
| Concat l -> String.concat ";" (List.map string_of_program l)
| Repeat p -> "(" ^ string_of_program p ^ ")\207\137"
| Repeat p -> "(" ^ string_of_program p ^ ")" ^ omega
| Empty -> ""
Markdown is supported
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