diff options
author | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-11-20 15:42:18 +0100 |
---|---|---|
committer | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-11-22 22:48:00 +0100 |
commit | 57f62f06419972ba799e451d2f56552dc1b2fb63 (patch) | |
tree | 6bd9d8b3f6f8a2f6bd0201ea8ebcc414fa38db6d /grammar | |
parent | ce418aea93a6396412de57aded0ff092bec7596b (diff) |
[plugin] Remove LocalityFixme über hack.
To that extent we introduce a new prototype vernacular extension macro
`VERNAC COMMAND FUNCTIONAL EXTEND` that will take a function with the
proper parameters and attributes.
This of course needs more refinement, in particular we should move
`vernac_command` to its own file and make `Vernacentries` consistent
wrt it.
Diffstat (limited to 'grammar')
-rw-r--r-- | grammar/vernacextend.mlp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/grammar/vernacextend.mlp b/grammar/vernacextend.mlp index ae8fe4da2..5bc8f1504 100644 --- a/grammar/vernacextend.mlp +++ b/grammar/vernacextend.mlp @@ -136,6 +136,10 @@ EXTEND OPT "|"; l = LIST1 rule SEP "|"; "END" -> declare_command loc s c <:expr<None>> l + | "VERNAC"; "COMMAND"; "FUNCTIONAL"; "EXTEND"; s = UIDENT; c = OPT classification; + OPT "|"; l = LIST1 fun_rule SEP "|"; + "END" -> + declare_command loc s c <:expr<None>> l | "VERNAC"; nt = LIDENT ; "EXTEND"; s = UIDENT; c = OPT classification; OPT "|"; l = LIST1 rule SEP "|"; "END" -> @@ -162,13 +166,6 @@ EXTEND (which otherwise could have been another argument) is not passed to the VernacExtend interpreter function to discriminate between the clauses. *) - - (* ejga: Due to the LocalityFixme abomination we cannot eta-expand - [e] as we'd like to, so we need to use the below mess with [fun - st -> st]. - - At some point We should solve the mess and extend - vernacextend.mlp with locality info. *) rule: [ [ "["; s = STRING; l = LIST0 args; "]"; d = OPT deprecation; c = OPT classifier; "->"; "["; e = Pcaml.expr; "]" -> @@ -181,6 +178,18 @@ EXTEND { r_head = None; r_patt = l; r_class = c; r_branch = b; r_depr = d; } ] ] ; + fun_rule: + [ [ "["; s = STRING; l = LIST0 args; "]"; + d = OPT deprecation; c = OPT classifier; "->"; "["; e = Pcaml.expr; "]" -> + let () = if s = "" then failwith "Command name is empty." in + let b = <:expr< $e$ >> in + { r_head = Some s; r_patt = l; r_class = c; r_branch = b; r_depr = d; } + | "[" ; "-" ; l = LIST1 args ; "]" ; + d = OPT deprecation; c = OPT classifier; "->"; "["; e = Pcaml.expr; "]" -> + let b = <:expr< $e$ >> in + { r_head = None; r_patt = l; r_class = c; r_branch = b; r_depr = d; } + ] ] + ; classifier: [ [ "=>"; "["; c = Pcaml.expr; "]" -> <:expr< fun loc -> $c$>> ] ] ; |