Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 560591e

Browse files
committedMar 27, 2022
refactor
1 parent f0c1815 commit 560591e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed
 

‎analysis/src/Xform.ml

+12-8
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)
Please sign in to comment.