Skip to content

Commit badf2e9

Browse files
committed
refactor(parser): hoist SMT option types to EcParsetree
Moves the polymorphic variant types used by the SMT option grammar rules (`prover`, `pi`, `smt`) out of the parser's `%{ ... %}` header into `EcParsetree` (renamed to `psmtprover`, `psmt_prover_info`, `psmt` for consistency with the other `p*` parsetree types). Also enables menhir's `--inspection` flag on the parser so the generated `MenhirInterpreter` module exposes nonterminal symbols for external inspection. The flag requires nonterminal action types to be accessible from outside the parser module, which is why the types have to leave the `%{ ... %}` header. Prep for a subsequent feature commit that relies on `--inspection`. No semantic change to SMT parsing.
1 parent e74c002 commit badf2e9

3 files changed

Lines changed: 31 additions & 31 deletions

File tree

src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
(menhir
3232
(modules ecParser)
3333
(explain true)
34-
(flags --table --unused-token COMMENT))
34+
(flags --table --unused-token COMMENT --inspection))

src/ecParser.mly

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -141,35 +141,9 @@
141141
(Some "cannot mark with 'declare' this kind of objects ")
142142

143143
(* ------------------------------------------------------------------ *)
144-
type prover =
145-
[ `Exclude | `Include | `Only] * psymbol
146-
147-
type pi = [
148-
| `DBHINT of pdbhint
149-
| `INT of int
150-
| `PROVER of prover list
151-
]
152-
153-
type smt = [
154-
| `ALL
155-
| `ITERATE
156-
| `QUORUM of int
157-
| `MAXLEMMAS of int option
158-
| `MAXPROVERS of int
159-
| `PROVER of prover list
160-
| `TIMEOUT of int
161-
| `UNWANTEDLEMMAS of EcParsetree.pdbhint
162-
| `WANTEDLEMMAS of EcParsetree.pdbhint
163-
| `VERBOSE of int option
164-
| `VERSION of [ `Full | `Lazy ]
165-
| `DUMPIN of string located
166-
| `SELECTED
167-
| `DEBUG
168-
]
169-
170144
module SMT : sig
171-
val mk_pi_option : psymbol -> pi option -> smt
172-
val mk_smt_option : smt list -> pprover_infos
145+
val mk_pi_option : psymbol -> psmt_prover_info option -> psmt
146+
val mk_smt_option : psmt list -> pprover_infos
173147
val simple_smt_option : pprover_infos
174148
end = struct
175149
let option_matching tomatch =
@@ -243,7 +217,7 @@
243217
let msg = Printf.sprintf "`%s`: no option expected" (unloc s) in
244218
parse_error s.pl_loc (Some msg)
245219

246-
let mk_pi_option (s : psymbol) (o : pi option) : smt =
220+
let mk_pi_option (s : psymbol) (o : psmt_prover_info option) : psmt =
247221
let s = option_matching s in
248222

249223
match unloc s with
@@ -263,7 +237,7 @@
263237
| "debug" -> get_as_none s o; (`DEBUG)
264238
| _ -> assert false
265239

266-
let mk_smt_option (os : smt list) =
240+
let mk_smt_option (os : psmt list) =
267241
let mprovers = ref None in
268242
let timeout = ref None in
269243
let pnames = ref None in

src/ecParsetree.ml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,32 @@ type pdbmap1 = {
869869

870870
and pdbhint = pdbmap1 list
871871

872+
type psmtprover =
873+
[include_exclude | `Only] * psymbol
874+
875+
type psmt_prover_info = [
876+
| `DBHINT of pdbhint
877+
| `INT of int
878+
| `PROVER of psmtprover list
879+
]
880+
881+
type psmt = [
882+
| `ALL
883+
| `ITERATE
884+
| `QUORUM of int
885+
| `MAXLEMMAS of int option
886+
| `MAXPROVERS of int
887+
| `PROVER of psmtprover list
888+
| `TIMEOUT of int
889+
| `UNWANTEDLEMMAS of pdbhint
890+
| `WANTEDLEMMAS of pdbhint
891+
| `VERBOSE of int option
892+
| `VERSION of [ `Full | `Lazy ]
893+
| `DUMPIN of string located
894+
| `SELECTED
895+
| `DEBUG
896+
]
897+
872898
(* -------------------------------------------------------------------- *)
873899
type pprover_list = {
874900
pp_use_only : string located list;

0 commit comments

Comments
 (0)