Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lean: omit type abbreviations and leave a comment instead #983

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/sail_lean_backend/pretty_print_lean.ml
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,7 @@ let doc_typdef ctx (TD_aux (td, tannot) as full_typdef) =
| _ -> [string "structure"; string id; separate space rectyp; string "where"]
in
doc_typ_quant_in_comment ctx tq ^^ hardline ^^ nest 2 (flow (break 1) decl_start ^^ hardline ^^ fields_doc)
| TD_abbrev (Id_aux (Id id, _), tq, A_aux (A_typ t, _)) ->
nest 2 (flow (break 1) [string "abbrev"; string id; coloneq; doc_typ ctx t])
| TD_abbrev (id, tq, A_aux (A_typ t, _)) -> string "/- Type abbreviation omitted: " ^^ doc_id_ctor id ^^ string " -/"
| TD_abbrev (Id_aux (Id id, _), tq, A_aux (A_nexp ne, _)) ->
nest 2 (flow (break 1) [string "abbrev"; string id; colon; string "Int"; coloneq; doc_nexp ctx ne])
| TD_variant (Id_aux (Id id, _), tq, ar, _) ->
Expand Down
2 changes: 1 addition & 1 deletion test/lean/bitfield.expected.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Out.Sail.Sail

open Sail

abbrev cr_type := (BitVec 8)
/- Type abbreviation omitted: cr_type -/

inductive Register : Type where
| R
Expand Down
2 changes: 1 addition & 1 deletion test/lean/register_vector.expected.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Out.Sail.Sail

open Sail

abbrev reg_index := Nat
/- Type abbreviation omitted: reg_index -/

inductive Register : Type where
| R0
Expand Down
4 changes: 3 additions & 1 deletion test/lean/typedef.expected.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ abbrev xlen : Int := 64

abbrev xlen_bytes : Int := 8

abbrev xlenbits := (BitVec 64)
/- Type abbreviation omitted: xlenbits -/

/- Type abbreviation omitted: bits2 -/

abbrev SailM := PreSailM PEmpty.elim trivialChoiceSource

Expand Down
2 changes: 2 additions & 0 deletions test/lean/typedef.sail
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ function EXTZ(m, v) = sail_zero_extend(v, m)
val EXTS : forall 'n 'm, 'm >= 'n. (implicit('m), bits('n)) -> bits('m)
function EXTS(m, v) = sail_sign_extend(v, m)

type bits2('n) = bitvector('n)

Loading