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

Adapt to Coq PR #19301 which unifies the syntax of Theorem, Definition and Fixpoint #703

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 17 additions & 4 deletions src/coq_elpi_arg_syntax.mlg
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ let pr_attributes _ _ _ atts =

let wit_elpi_ftactic_arg = EA.Tac.wit

let binders = Pcoq.Constr.binders

let def_body = G_vernac.def_body

let of_coq_inductive_declaration ~atts kind id =
Expand All @@ -195,12 +197,23 @@ let of_coq_record_declaration ~atts kind id =
| Inductive _ -> assert false
| Record r -> r

let of_coq_definition ~loc ~atts name udecl def =
[%%if coq = "8.20"]
let of_coq_definition ~loc ~atts name udecl bl def =
match def with
| Vernacexpr.DefineBody(bl',red,c,ty) ->
(* For compatibility with Coq PR #19301, binders have been parsed in advance *)
assert (CList.is_empty bl');
EA.Cmd.(ConstantDecl { name = snd name; atts; udecl; typ = (bl,ty); red; body = Some c })
| Vernacexpr.ProveBody _ ->
CErrors.user_err ~loc Pp.(str"syntax error: missing Definition body")
[%%else]
let of_coq_definition ~loc ~atts name udecl bl def =
match def with
| Vernacexpr.DefineBody(bl,red,c,ty) ->
| Vernacexpr.DefineBody(red,c,ty) ->
EA.Cmd.(ConstantDecl { name = snd name; atts; udecl; typ = (bl,ty); red; body = Some c })
| Vernacexpr.ProveBody _ ->
CErrors.user_err ~loc Pp.(str"syntax error: missing Definition body")
[%%endif]

}

Expand Down Expand Up @@ -285,8 +298,8 @@ GLOB_PRINTED BY { fun _ _ _ -> EA.Cmd.pp_glob env sigma }
| [ "Structure" inductive_or_record_definition(id) ] -> { EA.Cmd.RecordDecl (of_coq_record_declaration ~atts:[] Vernacexpr.Structure id) }
| [ "#[" attributes(atts) "]" "Structure" inductive_or_record_definition(id) ] -> { EA.Cmd.RecordDecl (of_coq_record_declaration ~atts Vernacexpr.Structure id) }

| [ "Definition" qualified_name(name) univ_decl_opt(udecl) def_body(def) ] -> { of_coq_definition ~loc ~atts:[] name udecl def }
| [ "#[" attributes(atts) "]" "Definition" qualified_name(name) univ_decl_opt(udecl) def_body(def) ] -> { of_coq_definition ~loc ~atts name udecl def }
| [ "Definition" qualified_name(name) univ_decl_opt(udecl) binders(bl) def_body(def) ] -> { of_coq_definition ~loc ~atts:[] name udecl bl def }
| [ "#[" attributes(atts) "]" "Definition" qualified_name(name) univ_decl_opt(udecl) binders(bl) def_body(def) ] -> { of_coq_definition ~loc ~atts name udecl bl def }

| [ "Axiom" qualified_name(name) univ_decl_opt(udecl) telescope(typ) colon_constr(t) ] -> {
EA.Cmd.(ConstantDecl { name = snd name; atts = []; udecl; typ = (typ,Some t); red = None; body = None }) }
Expand Down
Loading