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
Handle single-quotes in arguments to -arg
#590
Conversation
A solution sketch to issue ProofGeneral#589. coq_makefile parses _CoqProject files in a slightly weird way. If we write `-arg "a b"` in _CoqProject then it passes the arguments `a` and `b` to coqc, but if we write `-arg "'a b'"` it passes `a b` to coqc, as a single argument. This commit tries to adapt to this behavior.
Somehow this seems to work in the cases I want to use. But I expect it doesn’t mirror the behaviour of coq_makefile & make in all cases. |
Hi, this seems like a good patch, my main concern is about already written _CoqProject files that would break... |
I will merge this soon if no one objects. |
But we need to add something to the CHANGES file, since it may break a few use case relying on the old (and wrong) behaviour. |
Hi. Since I recently changed how coq_makefile interprets the _CoqProject, we might adapt the algorithm, so it precisely mirrors the behavior of coq. |
Hi @Columbus240 can you be more precise please? What is the new behaviour? In what versions of coq(_makefile) can we expect it to be available? |
Pinging @Columbus240 you said you had changed the behaviour of |
Yes, exactly. To this aim, I'd just suggest browsing the repositories of Coq libraries that are part of Coq's CI (but there are many of them 😅) And among these libraries, a number of them have some
I didn't take a close look but I believe you're right; if the fix is "conservative" w.r.t. most libraries I suggested above, +1 for merging indeed. |
I am still waiting for @Columbus240 to clarify these sentence:
If coq_makefile changed its behaviour we should try to understand how it works now before merging this I guess. |
Sorry for letting you wait. The parsing algorithm is implemented in lib/coqProject_file.ml if you've got the time to decipher code. Regarding availability: the PR with the new behaviour has been merged in July but there has not been a release since then. It is thus only available in development versions of Coq. The first version in which the new behaviour will be available is v8.14. I'm not sure, if the patch I made in this PR is still compatible with the new behaviour for simple cases. I didn't get around to checking it. Certainly, this PR does not mirror the old nor the new behaviour of coq_makefile. If I remember correctly, the parsing code of ProofGeneral processes some escape sequences (it's the call to To give a short overview of the parsing algorithm:
I made an exemplary _CoqProject file and went through the processing steps. I hope it's useful and that I didn't make a mistake.
Tokenization produces the following list of strings (where a newline indicates the end of a string)
Of course the next step wouldn't be able to interpret the arbitrary strings as filenames or arguments. But lets ignore this and consider what lists the
While the argument list concerning
Please ask further questions if something is unclear. |
Thanks a lot @Columbus240 for your detailed answer! (and sorry for late reply as well) As already said by @cpitclaudel, the inherent discrepancy between both _CoqProject parsers (either elisp or (ocaml+make)-based) has always been an issue; anyway your patch looks very sensible and as @Matafou I agree we should merge this soon, and as we have a planned PG team telco on this Wednesday evening, we'll be able to discuss whether it can be merged at once… or maybe after adding some unit tests 🙂 (to check that coq_makefile and PG's parsing behave the same on, at least, a few specific cases; relying on PG's CI that can test PG against several different Coq versions…) BTW (just to be sure, I just skimmed https://github.com/coq/coq/pull/14558/commits), is there another recent change in coq's _CoqProject parser algorithm that should be taken into account for PG? (beyond this support of single-quotes in Thanks again! |
From reading https://github.com/coq/coq/blob/master/doc/sphinx/practical-tools/utilities.rst I think that the only thing to change is the way double and simple quotes are interpreted. |
I think this PR should come with a test of the coq version. Am I wrong?
|
Hi all,
Indeed @Matafou I guess that adding unit or integrations tests in this PR would be very nice (all the more as we can test from now on _CoqProject + PG with Coq 8.14.* since there is an image These tests could for example, be inspired by the links I gave in this old comment of mine.
However I believe that these two other items can wait for another PR: all the more as if/when we have _CoqProject-dedicated tests, it will be easy to detect if the semantics is broken for a given version of Coq (Coq 8.14 or Coq 8.15), and add conditional elisp code in this case. @Matafou @Columbus240 if you agree with my remarks above, |
You're welcome! Regarding:
I now skimmed over https://github.com/coq/coq/commits/master/lib/coqProject_file.ml and don't think anything noteworthy happened to the parsing of _CoqProject in the last few years other than my change.
The only difference between spaces, horizontal tabs and newlines is, that only newlines end comments. Otherwise they are always treated the same. (A short look at coqProject_file.ml can confirm this) I think implementing version-dependent behaviour is a good intention. But the current behaviour of PG isn't even compliant with coq v8.14 and earlier, because there the semantics of coq_makefile and _CoqProject were also influenced by how Make (and the shell called by Make) would escape and interpret characters. I had to reduce how much I use Coq and with that PG as well. So I'm not particularly waiting for this feature. |
Thanks @Columbus240. I think we should merge this and see. I am quite sure almost nobody will notice the difference, and this goes in the right direction. |
This is bit-rotting. Should we merge this immediately? |
This was waiting for much too long. I don't see much risk. |
A haphazard sketch to issue #589. It is not an acceptable final solution, I think
coq_makefile parses _CoqProject files in a slightly weird way. If we write
-arg "a b"
in _CoqProject then it passes the argumentsa
andb
to coqc, but if we write-arg "'a b'"
it passesa b
to coqc, as a single argument.I tried to adapt PG to this behavior. It works for my use-case, but I haven’t tested where the differences in behaviour (between PG and coq_makefile) lie now. A weird fact is, that coq_makefile produces some string, which it stores in
Makefile.coq.conf
, which later gets processed by make and passed on to coqc. So a "good" solution would try to reproduce the complete processing chain, i.e. first the processing done by coq_makefile, then the processing done by make.Maybe we could call
lib/coqProject_file.mli
from elisp and hand over the parsing to the OCaml code of the coq repo.