Skip to content
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

A tighter parse of the metaclass operator #17

Merged

Conversation

apozharski
Copy link
Contributor

@apozharski apozharski commented Aug 15, 2024

According to the metaclass documentation the metaclass operator ? must be followed by a class name literal (a dot delimited sequence of identifiers) and not an arbitrary expression. This patch makes the parse of this operator more accurate.

@acristoffers
Copy link
Owner

Don't add another node just for the class identifier, do it in a single line:

    metaclass_operator: ($) => prec.left(seq('?', seq($.identifier, repeat(seq('.', $.identifier))))),

This avoids creating an unnecessary node.

For all PRs: they should all be based on the main branch, and not on each other. I cannot merge this one, for example, because it contains commits from the others. Rebase them all.

If you can rename the commits to be semantic (https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716) it would be nice. I accepted a pull request without paying attention to that and I regret it, I prefer to follow it.

@apozharski apozharski force-pushed the metaclass-operator-tighter-parse branch from f39f91b to ef2fc93 Compare August 19, 2024 07:35
@apozharski
Copy link
Contributor Author

For all PRs: they should all be based on the main branch, and not on each other. I cannot merge this one, for example, because it contains commits from the others. Rebase them all.

I have done this but now on second thought wouldn't this lead to the auto-generated src/parser.c and co. to be inaccurate unless after each merge tree-sitter generate is run again and the branch is rebased. Obviously this is only a minor inconvenience but that was the reason I saw for stacking the PRs.

@acristoffers
Copy link
Owner

I was thinking about the rebase approach, since it's what I usually do on my day job. But I think that for this specific case simply not committing them is probably the best approach, I can generate them after accepting the PRs. I'm going to create a CONTRIBUTING.md like you suggested stating this. I'll accept one of your PRs now and when you rebase you can drop the autogenerated files and I'll probably not have any trouble accepting the other two right after that (without you having to rebase again, hopefully).

@apozharski apozharski force-pushed the metaclass-operator-tighter-parse branch from ef2fc93 to 7e00e71 Compare August 20, 2024 06:35
@acristoffers acristoffers merged commit 4e2fefa into acristoffers:main Aug 20, 2024
6 checks passed
@acristoffers
Copy link
Owner

There, when the auto-generated files are out of the way merging is easy. Thank you for your contributions :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants