Skip to content

Commit 44688c5

Browse files
committed
refactor
1 parent 23a728b commit 44688c5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

analysis/src/Xform.ml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,21 @@ module IfThenElse = struct
101101
if !changed then Some newStructure else None
102102
end
103103

104+
let parse ~filename =
105+
let {Res_driver.parsetree = structure; comments} =
106+
Res_driver.parsingEngine.parseImplementation ~forPrinter:false ~filename
107+
in
108+
let print ~structure =
109+
Res_printer.printImplementation ~width:!Res_cli.ResClflags.width ~comments
110+
structure
111+
in
112+
(structure, print)
113+
104114
let command ~path ~pos =
105115
if Filename.check_suffix path ".res" then
106-
let parser =
107-
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
108-
in
109-
let {Res_driver.parsetree = structure; comments} = parser ~filename:path in
110-
let printer =
111-
Res_printer.printImplementation ~width:!Res_cli.ResClflags.width ~comments
112-
in
116+
let structure, print = parse ~filename:path in
113117
match IfThenElse.xform ~pos structure with
114118
| None -> ()
115119
| Some newStructure ->
116-
let formatted = printer newStructure in
120+
let formatted = print newStructure in
117121
Printf.printf "Hit IfThenElse. Formatted:\n%s" formatted

0 commit comments

Comments
 (0)