Navigation Menu

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

Official Tree-sitter Grammar for Cython #3662

Open
ghost opened this issue Jun 2, 2020 · 4 comments
Open

Official Tree-sitter Grammar for Cython #3662

ghost opened this issue Jun 2, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Jun 2, 2020

Proposal

Cython should have an official Tree-sitter grammar separate from the main repo, with Cython-only syntax rules programmatically appended to Python's Tree-sitter grammar (and thus having Python's Tree-sitter grammar as a dependency). Note that I don't think Cython's compiler should use Tree-sitter for parsing.

Pros

  • Since Cython-only syntax rules would be programmatically appended to Python's, Cython's Tree-sitter grammar would have a clean architecture, containing syntax changes to Python's Tree-sitter grammar whenever they occur. (This makes sense as Cython's grammar is a superset of Python's)
  • The Tree-sitter grammar itself would in a way document Cython's syntax very clearly.
  • Improved syntax highlighting and editor support!

Cons

  • Having to maintain another grammar.
@scoder
Copy link
Contributor

scoder commented Jun 4, 2020

I wouldn't mind, if someone implements it.

@ghost
Copy link
Author

ghost commented Jul 3, 2020

@scoder I am willing to implement it once Cython's grammar is fully formally documented. I am really interested in improving editor support for Cython (e.g. in Atom).

@ghost
Copy link
Author

ghost commented Jul 16, 2020

I am willing to implement it once Cython's grammar is fully formally documented.

Never mind, I will try my best to implement Cython's Tree-sitter grammar right now, though as a fork of (rather than a dependent of) Python's Tree-sitter grammar, since I am not sure about how to programmatically append rules to existing Tree-sitter grammars. It will be difficult though due to the absence of an accurate description of Cython's grammar other than the parser code.

@Mrestof
Copy link

Mrestof commented Feb 24, 2023

Hi, came across this thread while searching for cython support in treesitter. As I understand, the separate grammar file is needed. What's the status on this, is it planned to be made?

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

No branches or pull requests

2 participants