Skip to content

Commit

Permalink
Updates to miaou7
Browse files Browse the repository at this point in the history
  • Loading branch information
artkhyzha committed Oct 29, 2024
1 parent 2b5ffc5 commit 8b4f1bc
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions tools/miaou.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module Make
| 1 -> 3
| n -> n+1

let pp_evt k = sprintf "E%d" k
let pp_evt k = sprintf "E\\textsubscript{%d}" k

(* Pretty print elements for n-ary operators *)

Expand All @@ -164,8 +164,8 @@ module Make

let sep op =
match op with
| Union -> ",",", or"
| Inter|Seq|Cartesian -> ";","; and"
| Union -> ".","."
| Inter|Seq|Cartesian -> ".","."
| _ -> assert false

(***********)
Expand Down Expand Up @@ -258,7 +258,7 @@ module Make
let pp_rel_id e1 e2 id =
Item
(sprintf
"\\expandafter\\MakeUppercase%s"
"\\expandafter{\\MakeUppercase%s}"
(do_pp_rel_id e1 e2 id))

let tr_rel_id e1 e2 loc id = pp_rel_id e1 e2 (pp_id loc id)
Expand Down Expand Up @@ -440,8 +440,14 @@ module Make
| Item txt ->
Some
(Item
(sprintf "\\expandafter\\MakeUppercase\\notthecase{%s}" txt))
| List _|DiffPair _|IfCond _ ->
(sprintf "\\expandafter{\\MakeUppercase\\notthecase{%s}}" txt))
| List (op,intro_txt,sep_txt,es) ->
(* eprintf "~~~~~~~~~~~~~~~~~~~~\n"; *)
(* eprintf "%s\n" (sprintf "\\expandafter{\\MakeUppercase\\notthecase{%s}}" intro_txt); *)
(* eprintf "%s\n" (List.fold_left (fun acc e -> acc ^ "," ^ (pp_txt e)) " " es) ; *)
(* eprintf "~~~~~~~~~~~~~~~~~~~~\n"; *)
Some (List (op,(sprintf "\\expandafter{\\MakeUppercase\\notthecase{%s}}" intro_txt),sep_txt,es))
| DiffPair _|IfCond _ ->
None

and tr_evts e1 = function
Expand All @@ -451,7 +457,7 @@ module Make
tr_evts_id e1 loc "anyevent"
| Var (loc,id) ->
tr_evts_id e1 loc id
| Op1 (loc,Comp,e) ->
| Op1 (loc,Comp,e) | App (loc,Var (_,"exempt"),e) ->
begin
match tr_evts_not e1 e with
| None -> tr_fail loc
Expand Down Expand Up @@ -488,13 +494,7 @@ module Make
[Op1 (_,ToId,Var (_,"A"));
Var (_,"amo");
Op1 (_,ToId,Var (_,"L"));]))
->
mk_list Inter
[pp_evts_id e1 "ExpW";
pp_evts_id e1 "A";
pp_evts_id e1 "REL";
pp_evts_id e1 "byamo";]
(* pp_evts_id e1 "rangeAamoL" *)
-> pp_evts_id e1 "rangeAamoL"
| App (_,Var (_,"range"),Var (_,"lxsx")) ->
pp_evts_id e1 "rangelxsx"
| App (_,
Expand Down Expand Up @@ -537,9 +537,9 @@ module Make
| _,_ -> false

let rec flatten_out = function
| List ((Inter|Union|Seq as op),_,_,ts)
| List ((Inter|Union|Seq as op),intro_txt,sep_txt,ts)
->
mk_list op (flatten_op op ts)
List (op,intro_txt,sep_txt,(flatten_op op ts))
| List (op,txt,s,ts) ->
List (op,txt,s,List.map flatten_out ts)
| DiffPair (e1,e2) ->
Expand Down Expand Up @@ -590,9 +590,11 @@ module Make
and pp_txt indent s = function
| Item txt
| List (_,_,_,[Item txt]) ->
(* eprintf "%s\\item %s%s:\n" indent txt s ; *)
printf "%s\\item %s%s\n" indent txt s
| List (_,txt,(s1,s2),txts) ->
printf "%s\\item %s:\n" indent (Misc.capitalize txt) ;
(* eprintf "123%s\\item %s:\n" indent txt ; *)
let indent = next_indent indent in
printf "%s\\begin{itemize}\n" indent ;
pp_txts indent s1 s2 s txts ;
Expand Down Expand Up @@ -668,12 +670,14 @@ module Make
let pref =
match ty with
| Some RLN|None ->
(* assumes /<name>emph macro *)
let def_txt = (pp_id loc id) ^ "emph" in
sprintf
"\\expandafter\\MakeUppercase\\%s{an Effect %s}{an Effect %s} if and only if"
(pp_id loc id) (pp_evt 1) (pp_evt 2)
"\\expandafter{\\MakeUppercase\\%s{an Effect %s}{an Effect %s}} if"
def_txt (pp_evt 1) (pp_evt 2)
| Some SET ->
sprintf
"\\expandafter\\MakeUppercase\\%s{an Effect %s} if and only if"
"\\expandafter{\\MakeUppercase\\%s{an Effect %s}} if"
(pp_id loc id) (pp_evt 1) in
let d =
if O.flatten then
Expand Down

0 comments on commit 8b4f1bc

Please sign in to comment.