Closed susliko closed 2 years ago
I'll take a look at this after the 25th hopefully - on holiday at the moment!
This approach looks good! Considering how complicated the _expr
rule is it makes sense to include the pluscal grammar in this grammar.
@ahelwer I've stumbled upon 2 failing tests with conj(disj)unction lists, which are implemented via external parser. Do you have any ideas on what should be changed to make this work?
I'll take a look at that failing test. This also brings to mind an edge case, which is that:
So I'll have to figure out a way of ensuring that the jlist in (3) doesn't interact weirdly with the jlist in (1).
I left a comment on the scanner.cc
changes about how the lexing code for block comment tokens (not the full scan_block_comment_text
code, but the other stuff) needs to be left in so the non-block-comment external tokens know to bail out when they see a block comment; perhaps that will fix the failing test?
Hm, can't see your comment on scanner.cc
changes for some reason
Are you sure you've posted it?
Doesn't seem like you can link to a review but try scrolling up in this PR. Here's a screenshot, I left a few other comments as well:
Maybe the force pushes are causing an issue.
There is a 'Pending' comment status on the screenshot. This usually means that the review is not yet submitted (button in the upper right corner) 🤔
Well that's confusing. I think it's now in a weird state where it can't be submitted because of the force pushes overwriting commits or something.
Edit: ah no, I was simply confused by github's UI.
Fun update - I'm working to get this grammar enabled for highlighting the TLA+ code on github! Plus fuzzy code navigation and such. Your changes will certainly be important for that.
Fun update - I'm working to get this grammar enabled for highlighting the TLA+ code on github! Plus fuzzy code navigation and such. Your changes will certainly be important for that.
I'd love to have a look at your work on enabling this grammar on github 🔥
With the latest UT runs it made it all the way to the corpus tests. This is where I run the parser against every file in the https://github.com/tlaplus/examples repo to see whether it passes. Pretty easy to do locally - looks like the pluscal parsing fails on a number of them.
The latest update seems to parse all the specs in the corpus, except for two cases:
await \/ num[nxt] = 0
\/ <<num[self], self>> \prec <<num[nxt], nxt>> ; \* should not be consumed
(* \* *)
btw, I am not allowed to run github workflows in this repo, since I'm a first-time contributor
(1) can probably be fixed by a simple change to the external scanner (just have it recognize a ;
character then categorize it as an OTHER
token). (2) sounds like a puzzle!
Actually for the semicolon issue, what are the desired semantics? Should the semicolon terminate the entire jlist?
Actually for the semicolon issue, what are the desired semantics? Should the semicolon terminate the entire jlist?
Semicolon terminates a PlusCal statement, which contains the jlist. Therefore, it should terminate the jlist. As far as I understand, the lexer should emit the DEDENT token for jlist termination
Ah, okay. In that case you want to tokenize the semicolon as Token_TERMINATOR in the external scanner, which will trigger the appropriate jlist handling logic. You can probably figure out how to do this on your own but if you need help I can make the change.
Managed to fix both cases. All the specs in the corpus should be parsed now
Brilliant! Would you say this is ready for full review and such, or would you like to make more stylistic changes, write more tests etc.?
Edit: I see a few corpus tests are failing in the CI
I see a few corpus tests are failing in the CI
Indeed. I'll have a look
make more stylistic changes, write more tests etc.
Yeah, there are some tests to be written. I'd also like to explore the idea of getting builtin library operators (like Head
and Len
from the Sequences
) highlighted only when the module EXTENDS
this library (there is a draft in nvim's locals.scm 🤯)
That highlighting is certainly a possibility, although we can separate it from these changes.
Although the test suite is not yet fully completed, I think the MR is ready to be reviewed 🎉
Looks great! Can't wait to see reference-based highlighting working. @hwayne should be interested to hear of this progress.
The test suite is completed now, all comments fixed
Great! Feel free to announce this release on the google group thread.
You can also issue a PR against the nvim-treesitter repo and tag me.
@ahelwer Thank you for assisting throughout this work!
@susliko thanks for all the hard work! I'm sure many people will appreciate support for pluscal.
@susliko could you please backport the changes to the neovim query files to this repo? Thanks!
Yeah, sure
https://github.com/tlaplus-community/tree-sitter-tlaplus/issues/31
Block comment detection is altered from the external parser to the solution proposed in this comment. This allows for straightforward implementation of pluscal support.
@ahelwer, would be happy to hear from you
If we agree on this approach I'll proceed with docs, tests and syntax highlighting
Example:
Tree-sitter-output: