Skip to content

Commit cc48c2c

Browse files
committed
Add command to convert smtml scripts to smt-lib scripts
1 parent 479e300 commit cc48c2c

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

bin/main.ml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let prove_mode_conv =
3333
[ ("batch", Batch); ("cached", Cached); ("incremental", Incremental) ]
3434

3535
let parse_cmdline =
36-
let aux files solver prover_mode debug print_statistics =
36+
let run debug files solver prover_mode print_statistics =
3737
let module Mappings =
3838
(val mappings_of_solver solver : Mappings_intf.S_with_fresh)
3939
in
@@ -72,24 +72,53 @@ let parse_cmdline =
7272
Solver.pp_statistics state.solver
7373
end
7474
in
75+
76+
let to_smt2 debug solver file =
77+
let module Mappings =
78+
(val mappings_of_solver solver : Mappings_intf.S_with_fresh)
79+
in
80+
Mappings.set_debug debug;
81+
let ast = Parse.from_file ~filename:file in
82+
let assertions =
83+
List.filter_map (function Ast.Assert e -> Some e | _ -> None) ast
84+
in
85+
Format.printf "%a@." (Mappings.pp_smt ?status:None) assertions
86+
in
87+
7588
let open Cmdliner in
89+
let file0 =
90+
Arg.(
91+
required
92+
& pos 0 (some string) None
93+
& info [] ~docv:"files" ~doc:"files to read" )
94+
in
7695
let files =
7796
Arg.(value & pos_all string [] & info [] ~docv:"files" ~doc:"files to read")
78-
and prover =
97+
in
98+
let solver =
7999
Arg.(
80100
value & opt solver_conv Z3_solver
81101
& info [ "s"; "solver" ] ~doc:"SMT solver to use" )
82-
and prover_mode =
102+
in
103+
let solver_mode =
83104
Arg.(
84105
value & opt prove_mode_conv Batch & info [ "mode" ] ~doc:"SMT solver mode" )
85-
and debug =
106+
in
107+
let debug =
86108
Arg.(value & flag & info [ "debug" ] ~doc:"Print debugging messages")
87-
and print_statistics =
109+
in
110+
let print_statistics =
88111
Arg.(value & flag & info [ "st" ] ~doc:"Print statistics")
89112
in
90-
Cmd.v
91-
(Cmd.info "smtml" ~version:"%%VERSION%%")
92-
Term.(const aux $ files $ prover $ prover_mode $ debug $ print_statistics)
113+
114+
let run_cmd =
115+
Cmd.v (Cmd.info "run")
116+
Term.(const run $ debug $ files $ solver $ solver_mode $ print_statistics)
117+
in
118+
let to_smt2 =
119+
Cmd.v (Cmd.info "to-smt2") Term.(const to_smt2 $ debug $ solver $ file0)
120+
in
121+
Cmd.group (Cmd.info "smtml" ~version:"%%VERSION%%") [ run_cmd; to_smt2 ]
93122

94123
let () =
95124
match Cmdliner.Cmd.eval_value parse_cmdline with

test/parser/test_core.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Test boolean parsing:
2-
$ dune exec -- smtml test_core.smtml
2+
$ smtml run test_core.smtml
33
sat
44
sat
55
(model

test/parser/test_lia.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Test int parsing:
2-
$ dune exec -- smtml test_lia.smtml
2+
$ smtml run test_lia.smtml
33
sat
44
sat

test/parser/test_lra.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Test real parsing:
2-
$ dune exec -- smtml test_lra.smtml
2+
$ smtml run test_lra.smtml
33
sat
44
(model
55
(x -2.)

test/parser/test_qf_fp.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Test fp parsing:
2-
$ dune exec -- smtml test_qf_fp.smtml
2+
$ smtml run test_qf_fp.smtml
33
unsat
44
sat
55
sat

test/parser/test_qf_s.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Test parsing string:
2-
$ dune exec -- smtml test_qf_s.smtml
2+
$ smtml run test_qf_s.smtml
33
sat
44
(model
55
(x "abcd"))

test/regression/test_pr_71.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Test float parsing:
2-
$ smtml test_pr_71.smtml
2+
$ smtml run test_pr_71.smtml
33
sat

0 commit comments

Comments
 (0)