-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support for Whole Document Parsing #5
Comments
If the last sentence is not valid, at the very least, return the location of the start of the last sentence. I think returning the list of valid positions, together with an exception, would be best; this way I don't have to make an extra round-trip to parse the valid portion of the document if I want to do that. |
I've pushed a bit more smart parsing in 6bb9b53. However, this is going to be hard to do well: As you can see in the below example, Coq parsing is extremely stateful so we must execute the document as we proceed with parsing! (P (Parse "Lemma U n : n + n = n. Proof. intros n. "))
(Answer P Ack)
(Answer P
(ObjList
((CoqLoc
((fname "") (line_nb 1) (bol_pos 0) (line_nb_last 1) (bol_pos_last 0)
(bp 0) (ep 22)))
(CoqLoc
((fname "") (line_nb 1) (bol_pos 0) (line_nb_last 1) (bol_pos_last 0)
(bp 23) (ep 29))))))
(Answer P (CoqExn (Stream.Error "illegal begin of vernac"))) Here |
I think a simple enough interface (for IDEs) would be one that just returns the end of the current sentence. This way after guessing a good-ish location, IDEs would send the current sentence. They'd either get an OK, or an error; in the latter case, they'd simply send more, repeating until they've got at least one sentence. Even that roundtripping might not be the best, though; a version of Add that just processes the first sentence might be nicer. In any case, kudos on the great work! |
Hi Clément, thanks for the comments! The simple interface should be working now, then, just use Another possibility on parse would be to build the STM DAG using Thus, in this case |
An additional problem with the current |
|
Preliminary design commited in d100e0e, waiting to resolve this upstream to close the issue. |
A question we have been discussing with Enrico is what should we do on Doing an |
Hmm. I'm not sure I understand the question fully. Do you mean that an Add to a state in the middle document can move things around? I think that's true. Worse, the user might have some unprocessed text in the middle of a proof. So yes, I think the position information needs to be relative. But that won't be much of a problem on the IDE side, I expect. In most cases positions relative to the start of a sentence/state can be enough; for other cases where we want absolute positions (e.g. line and column numbers or absolute offsets in a file, say for the debugger), the IDE could send a list of pairs In fact, I don't think there's a way around this resyncing process: we want to allow users to add comments, spaces, and contents inside comments without canceling (PG already supports editing comments without cancelling, for example). We also want to make meaning-preserving changes without canceling (for example fully qualifying module names, which Company-coq can now do). An alternative would of course be to add a |
Indeed that is what I meant. Coq reports locations in several ways but it is not 100% clear when to report a relative vs absolute position, specially if we allow "whole document parsing". I have done some tests with whole-document back and forth (with SerAPI caching). It is interesting but with the current edit model is just doesn't seem too effective. |
I am close to solving this issue. Reliable full document parsing is implemented in the
|
We adapt to Coq changes motivate by SerAPI. We now have true and reliable full document "parsing" (in the Coq sense of stateful parsing). However to be able to close ejgallego#5 we still need to enrich our `Add` protocol with the notion of sub-document.
@cpitclaudel and @JasonGross have requested to have whole Coq document parsing. This issue is to design and discuss how such a mechanism would work.
Current status [edit: updated, see below]
SerAPI provides a parsing command that will indicate where the current sentence ends:
This was meant as a proof of concept but it is useful in itself.
Proposal 1: extend to lists of positions:
A first step towards improving this would be to support a
(Parse Sentence "doc")
.Such command would return a list of
CoqLoc
objects signalling the end of each sentence. It would be up to the ide to split the doc.If the last sentence is not a valid one, I wonder what to return. We could fail the whole parsing, just ignore it, or return the list of valid positions plus an exception.
[Edit]
Current Status
This feature is mostly implemented,
StmAdd
now takes a parameter indicating the number of sentences to parse, and will try to parse as many as indicated. I a parse error occurs, it will still add the number of well-parsed sentences.To close this issue, it remains to:
The text was updated successfully, but these errors were encountered: