You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The _CoqProject file supports a syntax -arg which is not documented in the Coq reference manual but which we fortunately found documented in ProofGeneral. We realized that there are however some ambiguities with this syntax, in particular regarding options which span over several "tokens" of the command line, as e.g. for -arg "-w -notation-overriden", vs -arg -w -notation-overriden, vs one line -arg -w and the next line -arg notation-overriden, etc.
That would be good to be able to document more precisely this syntax and that PG, CoqIDE and coq_makefile parse it consistently. For instance, is -arg intended to take a space-free argument, or, if non space-free, a double-quote surrounded argument? Are single-quote surrounded argument allowed? How to pass an argument which contains quotes, as, if, e.g., I would like to pass -arg '-Q "" Foo'? Etc. In the case of coq_makefile the parsing rules are here. What are the parsing rules for PG?
PS: "Remark" is written using the French spelling here.
The core of the difficulty, I think, is this statement in the help of coq_makefile (I think it was removed since 8.4; this is what it said in 8.4): [-f file]: take the contents of file as arguments. The problem here is that normally it's the shell that splits input strings, passing the program a list or individual arguments; with -f, coq_makefile has to take responsibility for splitting the input string. Additionally, -arg requires further splitting, since coqc needs to receive each argument separately.
Hi, just an extra question about the use of double quotes. Maybe it is too late and users already use the syntax but I was wondering whether -arg "-w -notation-overriden" should not be interpreted like in CoqIDE, i.e. as if -w -notation-overriden was a single argument (and thus being invalid for coqtop). Additionally, the latter would be consistent with PG feeling which itself qualifies coq_makefile convention as weird. This would also be consistent with PG manual which says "-arg must be followed by one and only one option to pass to coqtop/coqc, use several -arg to issue several options".
I mean, in the case of -arg "-w -notation-overriden", it is obvious for a human that we mean two arguments. But if I want to give a name with spaces, like, say, /Program Files/coq/foo.v, shall it be clear that I need to write "\"/Program Files/coq\"" rather than simply "/Program Files/coq/foo.v", knowing that make and thus coq_makefile are anyway unable to deal with spaces in filename (but, maybe coq_makefile will move to dune and that may become different).
PS: In PG manual, I found another typo: "intial" instead of "initial".
I'm asking to eventually decide what to exactly document in the Coq reference manual.
@herbelin@cpitclaudel is there some news about this? I don't have strong opinion either. But it is very important that coqide, pg and coq_makefile behave all the same (and any other ide).
Note ongoing discussions about the format of _CoqProject. See item "Format of _CoqProject file" at https://github.com/coq/coq/wiki/Next-Coq-Working-Group (the page shall move though) where @charguer is advocating for supporting any Coq option without -arg in _CoqProject.
Note also ongoing discussions on possibly replacing coq_makefile with dune.
I agree with @herbelin, this should pass a single argument -w -notation-overriden (which then gets rejected by Coq). If PG/coq_makefile do space splitting of -arg flags, they also need to provide a way to escape spaces, and then complexity quickly spirals upwards.
Would be nice to fix PG to accept what is apparently standard syntax (a) as it's very confusing when make works but PG fails with inscrutable error messages and (b) the first form is more readable and hence easier to maintain.
The current situation is unfortunate: #113 led to some patches, then @anton-trunov improved -arg parsing in 9b3d7e5, then @Columbus240 further added a layer of unquoting in 774cb5f, but we haven't converged yet. And I still don't think that coq_makefile documents which shell syntax it expects. Happy to fix this thing if someone can point at the exact semantics that we want.
So my interpretation of the syntax is that on the string within ", we do '-aware whitespace splitting: we split at each whitespace, except text within ' is taken verbatim and not split.
What is not clear to me is whether there are any escape sequences, i.e., what do I do if I wand to pass ' or " itself as argument? Lucky enough that's not something I ever had to do.
Nice find. This text is "new" from rocq-prover/rocq#14558 . I am not sure that the changes that were made there are consistent with the changes that were made here. I will take a look.
Activity
cpitclaudel commentedon Sep 27, 2018
Hi @herbelin!
The parsing code in PG is here:
PG/coq/coq-system.el
Lines 471 to 537 in 733cd24
Note in particular the implementation
coq--extract-prog-args, which further splits the arguments passed to-arg.You can use the following to test how it behaves:
And you can use the following to see what we pass to Coq:
For example:
Concretely:
-arg "-w -notation-overriden"is supported and yields-arg -w -notation-overridenis not supported-arg -w -arg notation-overridenis supported-arg "-Q \"\" Foo"yields("-emacs" "-Q" "" "Foo")The core of the difficulty, I think, is this statement in the help of
coq_makefile(I think it was removed since 8.4; this is what it said in 8.4):[-f file]: take the contents of file as arguments. The problem here is that normally it's the shell that splits input strings, passing the program a list or individual arguments; with-f,coq_makefilehas to take responsibility for splitting the input string. Additionally,-argrequires further splitting, sincecoqcneeds to receive each argument separately.anton-trunov commentedon Sep 27, 2018
I think it's not supported though, because I tried that and it didn't work with PG (but it works with CoqIDE).
I might be wrong, but it seems the order is reversed and the leading hyphen got cut off from
-notation-overriden.cpitclaudel commentedon Sep 27, 2018
Ah, good point, that's a bug
Hmm, but you didn't include it in the input to
coq--read-options-from-project-file, so I think that's normalanton-trunov commentedon Sep 27, 2018
oops, you are right :) I re-checked and the hyphen survives :)
Fix parsing of -arg in _CoqProject file
anton-trunov commentedon Sep 27, 2018
@cpitclaudel #393 fixes the problem, I think; I tested it on on a real Coq project
herbelin commentedon Oct 11, 2018
Hi, just an extra question about the use of double quotes. Maybe it is too late and users already use the syntax but I was wondering whether
-arg "-w -notation-overriden"should not be interpreted like in CoqIDE, i.e. as if-w -notation-overridenwas a single argument (and thus being invalid forcoqtop). Additionally, the latter would be consistent with PG feeling which itself qualifiescoq_makefileconvention as weird. This would also be consistent with PG manual which says "-arg must be followed by one and only one option to pass to coqtop/coqc, use several -arg to issue several options".I mean, in the case of
-arg "-w -notation-overriden", it is obvious for a human that we mean two arguments. But if I want to give a name with spaces, like, say,/Program Files/coq/foo.v, shall it be clear that I need to write"\"/Program Files/coq\""rather than simply"/Program Files/coq/foo.v", knowing thatmakeand thuscoq_makefileare anyway unable to deal with spaces in filename (but, maybecoq_makefilewill move toduneand that may become different).PS: In PG manual, I found another typo: "intial" instead of "initial".
I'm asking to eventually decide what to exactly document in the Coq reference manual.
cpitclaudel commentedon Oct 11, 2018
No strong opinion :) When I wrote the new arg parsing code in PG I added this comment (ignore the
\escapes; they were needed for ELisp docstrings:PG/coq/coq-system.el
Lines 504 to 510 in 5b7b84b
I'm fine with deprecating this approach. I hope we can soon get a better configuration format.
Matafou commentedon Dec 20, 2018
@herbelin @cpitclaudel is there some news about this? I don't have strong opinion either. But it is very important that coqide, pg and coq_makefile behave all the same (and any other ide).
herbelin commentedon Dec 21, 2018
@Matafou: I finally made rocq-prover/rocq#8714 which documents what works with both PG, CoqIDE and
coq_makeflle.Note ongoing discussions about the format of
_CoqProject. See item "Format of _CoqProject file" at https://github.com/coq/coq/wiki/Next-Coq-Working-Group (the page shall move though) where @charguer is advocating for supporting any Coq option without-argin_CoqProject.Note also ongoing discussions on possibly replacing
coq_makefilewithdune.RalfJung commentedon Oct 3, 2024
I agree with @herbelin, this should pass a single argument
-w -notation-overriden(which then gets rejected by Coq). If PG/coq_makefile do space splitting of-argflags, they also need to provide a way to escape spaces, and then complexity quickly spirals upwards.Matafou commentedon Oct 3, 2024
I tend to agree.
Any news of a better project file format?
herbelin commentedon Oct 3, 2024
Were there remaining problems across PG, coq_makefile, CoqIDE, ... when writing things such as:
and, either
or
Conversely, how realistic would it be to change the format (if in incompatible ways)?
Matafou commentedon Oct 6, 2024
I don't think there are problems if each arg is on its own line. @cpitclaudel do you agree?
RalfJung commentedon Jul 29, 2026
I just ran into this problem: this is a valid part of a _RocqProject file according to the makefile gnerator...
... however, PG chokes when I have that in the project file. I have to instead write this as follows:
Would be nice to fix PG to accept what is apparently standard syntax (a) as it's very confusing when
makeworks but PG fails with inscrutable error messages and (b) the first form is more readable and hence easier to maintain.cpitclaudel commentedon Jul 30, 2026
The current situation is unfortunate: #113 led to some patches, then @anton-trunov improved
-argparsing in 9b3d7e5, then @Columbus240 further added a layer of unquoting in 774cb5f, but we haven't converged yet. And I still don't think that coq_makefile documents which shell syntax it expects. Happy to fix this thing if someone can point at the exact semantics that we want.RalfJung commentedon Jul 30, 2026
It doesn't document the full syntax but it does document that
-arg "-set 'Default Proof Using=Type'"should work and should pass two arguments,-setandDefault Proof Using=Type:https://github.com/rocq-prover/rocq/blob/master/doc/sphinx/practical-tools/utilities.rst#quoting-arguments-to-rocq-c
So my interpretation of the syntax is that on the string within
", we do'-aware whitespace splitting: we split at each whitespace, except text within'is taken verbatim and not split.What is not clear to me is whether there are any escape sequences, i.e., what do I do if I wand to pass
'or"itself as argument? Lucky enough that's not something I ever had to do.cpitclaudel commentedon Jul 30, 2026
Nice find. This text is "new" from rocq-prover/rocq#14558 . I am not sure that the changes that were made there are consistent with the changes that were made here. I will take a look.
Adjust _RocqProject parsing to `rocq makefile` changes
Adjust _RocqProject parsing to `rocq makefile` changes
cpitclaudel commentedon Jul 31, 2026
@RalfJung can you try #880?
Adjust _RocqProject parsing to `rocq makefile` changes