Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Question about writing plugins/vercular commands extension

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Question about writing plugins/vercular commands extension


Chronological Thread 
  • From: Talia Ringer <tringer AT cs.washington.edu>
  • To: Coq-Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Question about writing plugins/vercular commands extension
  • Date: Thu, 30 Jan 2020 23:53:46 -0800
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=tringer AT cs.washington.edu; spf=None smtp.mailfrom=tringer AT cs.washington.edu; spf=None smtp.helo=postmaster AT mail-io1-f44.google.com
  • Ironport-phdr: 9a23:iZ1LxBFcJpJrUe9b/EMEVp1GYnF86YWxBRYc798ds5kLTJ7zpsmwAkXT6L1XgUPTWs2DsrQY0raQ6PGrADRcqdbZ6TZeKccKD0dEwewt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9FYHdldm42P6v8JPPfQpImCC9YbRvJxmqsAndrMYbjZZtJ6orxBbEpnREd/lKyW5nOFmfmwrw6tqq8JNs7ihdtegt+9JcXan/Yq81UaFWADM6Pm4v+cblrwPDTQyB5nsdVmUZjB9FCBXb4R/5Q5n8rDL0uvJy1yeGM8L2S6s0WSm54KdwVBDokiYHOCUn/2zRl8d9kbhUoBOlpxx43o7UfISYP+dwc6/BYd8XQ3dKU8BMXCJDH4y8dZMCAOUPPelar4fzqVgAowagCwawH+7g0CNEi2Xs0KEmz+gsEwfL1xEgEdIUt3TUqc34OrkIXuCxzanH1yjIYe9X2Tf754jHbAohquyLULJsa8rRyE8vFwzbgVWKsoHqIyiV2v4DsmeB9OpgVeOvi2goqwFtpTivwN0ghZfUiYII013J8zhyzogyJd29UkF7YNikHYNftyGbK4t2Qt4iTHpytCkmzb0GvJi2dzUJxpQ/3xPTdeCLfoyS7h/gVOudOyp0iXNkdb6liBu//k6twfDmWMauylZFtC9Fn8HMtn8T0xzT7dCKSv5n8Ueg3TaDzgHT6uZZLUwtm6rWJJEszqQ/lpoUtkTDESv2l1vsgKCKcUUk//Ck6+XhYrr4up+RL5F4hh36P6g0mcGyAf40PhUPUmWa4+ix27Lu8VX8QLpQj/02lqfZsIrdJcQevqO5HxVV0ocl6xawETimys8VkmUcLF5fdhOIlZPpO1HPIPD+Ave/n1OskDFxy//YI7LhH43BLmLfn7f5YbZ990lcxRIvwtBY/pJYE60OIPbuWkDqr9HYFR84Mwmsw+n9Etl914UeWXiOAqCDKq/Sv0WItaoTJLynY5ZQkzLgIbBx7Pn3yHQ9hFU1fK+z3JJRZmruTdp8JEDMXXPog95JK2YMsQckBLj2klyEXjNJT32pGb01/TE6Do26CoGFS4yw1u/SlBynF4FbMzgVQmuHFm3lIt3dBqU8LRmKK8okqQQqELisT4h7iEOrvQ7+jrtgd6/apnFeupXk29x4oebUkENqrGAmP4Gmy2iIClpMsCYQXTZvjfJ0ugpiw0yD0K53n/teU9Ff+qERC1ZoBdvn1+V/TuvKdEfEd9aNRkyhR4z3UzoqCM042N8PZUlhHNPkgxzejXKn

Maybe a silly question, but does it work if you use { } instead of [ ]? I don't know if you just copied over the code incorrectly. The error messages for .mlg files are always bewildering. Apologies if it's not that. I haven't used VERNAC ARGUMENT EXTEND before.

Whenever you do figure this out, I'd like to add an example to one of the plugin tutorials in the Coq repo. Please let me know if you are willing to share a minimal example for that.

Talia

On Thu, Jan 30, 2020, 11:38 PM Zoe Paraskevopoulou <zoe.paraskevopoulou AT princeton.edu> wrote:
Hi Coq Club,

I’ve been trying to write a vernacular command that parses some optional arguments, but I’m facing some issue and I’d appreciate some help.

The result I’m trying to achieve is: 

CertiCoq Compile [options] <global_identifier>

where [options] is zero or more compilation flags like -debug.

For this I wrote the following code: 

type command_args =
 | ANF
 | TIME
 | OPT of int
 | DEBUG
 | ARGS of int

VERNAC ARGUMENT EXTEND cargs 
| [ "-anf" ] -> [ ANF ]
| [ "-time" ] -> [ TIME ]
| [ "-o1" ] -> [ OPT(1) ]
| [ "-debug" ] -> [ DEBUG ]
| [ "-args" int(n) ] -> [ ARGS(n) ]
END.

However, when I compile I get the following error: 

File "g_certicoq.ml4", line 1, characters 0-0:
Error: This _expression_ has type int -> Pp.t
       but an _expression_ was expected of type
         'a Extend.entry = 'a Grammar.GMake(CLexer).Entry.e

This happens whenever I try to parse a non-terminal symbols (e.g. string()) in VERNAC ARGUMENT EXTEND, not just with int().

If I drop the last case of cargs and parse this option at the VERNAC COMMAND instead, everything works:

VERNAC COMMAND EXTEND CertiCoq_Compile CLASSIFIED AS QUERY
| [ "CertiCoq" "Compile" cargs_list(l) “-args” int(x) global(gr) ] -> [ ... do stuff ...  ]
END

Any idea about what is going on? I’m suspecting that I’m missing an import because I’ve seen this type of parsing in VERNAC ARGUMENT EXTEND before. For example here: https://github.com/coq/coq/blob/master/plugins/ltac/g_ltac.mlg. I tried to use the same imports but that didn’t help.

I am using Coq 8.9.1 and OCaml 4.07.0.

Cheers,
Zoe



Archive powered by MHonArc 2.6.18.

Top of Page