-
Notifications
You must be signed in to change notification settings - Fork 87
Migrate from CIL's Pretty to OCaml's Format #213
Copy link
Copy link
Open
Labels
cleanupRefactoring, clean-upRefactoring, clean-up
Description
In #210 it came up multiple times that OCaml's standard Format module could replace Pretty from CIL with additional benefits:
- It's maintained in OCaml's standard library while
Prettyisn't properly maintained (maybe we should do this migration even in our CIL fork eventually). - It has much more features for producing pretty output.
- It's supposed to be faster by not constructing
Pretty.docstructures but writing to a formatter directly (a la howPrintable.printXmlcurrently works). - It's supposed to be faster by using GADTs for internal implementation instead of
Obj(Possibly excessive functions inPrintable.S#210 (comment)). ppx_deriving.stdhasderiving showthat also derives a pretty-printer in addition to a simpleshow(Possibly excessive functions inPrintable.S#210 (comment)).- It allows custom semantic tags, e.g. for colors, and their behavior can depend on where the output is going (to the terminal or to a string).
TODO
- Replace
Printable.prettywithval pp: Format.formatter -> t -> unit. This is the de facto standard naming for these pretty printer andderiving showalso derives this signature. - Rewrite every implementation of
prettyaspp. - Rewrite every
Pretty.printfwithFormat.printfby usingppinstead ofpretty. - Rewrite tracing system to use
Formatinstead ofPretty. - Rewrite every
traceby usingppinstead ofpretty. - Implement
ppfor CIL types, e.g.pp_expto replaced_exp. CIL has a lot ofPretty-based code to pretty-print everything (including entire programs). We don't need all of it though unless we also decide to migrate CIL itself.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
cleanupRefactoring, clean-upRefactoring, clean-up