Skip to content

Commit

Permalink
Pp matches with or-patterns (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
toku-sa-n committed Aug 12, 2023
1 parent ae65e54 commit f0f0aa5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/ppast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,14 @@ and pp_local_binder_expr printer = function
| _ -> raise (NotImplemented (contents printer))

and pp_branch_expr printer = function
| CAst.{ v = [ patterns ], expr; loc = _ } ->
| CAst.{ v = patterns, expr; loc = _ } ->
write printer "| ";
commad printer (pp_cases_pattern_expr printer) patterns;
with_seps
~sep:(fun () -> write printer " | ")
(commad printer (pp_cases_pattern_expr printer))
patterns;
write printer " => ";
pp_constr_expr printer expr
| _ -> raise (NotImplemented (contents printer))

let pp_definition_expr printer = function
| Vernacexpr.ProveBody ([], expr) ->
Expand Down
3 changes: 3 additions & 0 deletions test/coq_files/match/or-pattern/in.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Inductive foo:Type:=A|B|C|D|E|F.

Definition bar(x:foo):nat:=match x with A=>1|B|C=>2|D|E|F=>3 end.
14 changes: 14 additions & 0 deletions test/coq_files/match/or-pattern/out.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Inductive foo : Type :=
| A
| B
| C
| D
| E
| F.

Definition bar (x : foo) : nat :=
match x with
| A => 1
| B | C => 2
| D | E | F => 3
end.

0 comments on commit f0f0aa5

Please sign in to comment.