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

feat: Initial Lezer grammar #1289

Merged
merged 14 commits into from
Dec 26, 2022
Merged

feat: Initial Lezer grammar #1289

merged 14 commits into from
Dec 26, 2022

Conversation

max-sixty
Copy link
Member

Based on #1102

I've been using https://lezer-playground.vercel.app/, which is great! And I struggled to set up a JS project that was good for iterating; though we'll need to do that at some point.

This parses our standard query (in examples.md) though it gives a couple of warnings around linebreaks — I still haven't really got my head around the way @precedence works.

It doesn't yet parse things like func & table though those aren't difficult. It heavily relied upon our pest file, though requires some different approaches in some areas.


Where should this go? In this repo? How should we package it? https://github.com/Snowflake-Labs/lezer-snowsql is an example of a full repo & package for a Lezer grammar

max-sixty and others added 5 commits December 18, 2022 00:18
Based on #1102

I've been using https://lezer-playground.vercel.app/, which is great!  And I struggled to set up a JS project that was good for iterating; though we'll need to do that at some point.

This parses our standard query (in examples.md) though it gives a couple of warnings around linebreaks — I still haven't really got my head around the way `@precedence` works.

It doesn't yet parse things like `func` & `table` though those aren't difficult. It heavily relied upon our pest file, though requires some different approaches in some areas.

---

Where should this go? In this repo? How should we package it? https://github.com/Snowflake-Labs/lezer-snowsql is an example of a full repo & package for a Lezer grammar
@aljazerzen
Copy link
Member

I like the syntax of Lezer grammars, because it's quite similar to EBNF #285.

But I don't see the point of having another grammar definition, along with 4 others, each of which is not totally correct... We need a way to unify them somehow.

@max-sixty
Copy link
Member Author

But I don't see the point of having another grammar definition, along with 4 others, each of which is not totally correct... We need a way to unify them somehow.

In a way I couldn't agree more — I've been quite surprised at how fragmented the space is.

But what's the alternative? They're too different to automatically translate — at least no one has built a tool to do that. And we need CodeMirror / Lezer for PRQL to a) be included in DuckDB's new tool (though we have no guarantee it would be included even if we do make this), and b) have syntax highlighting in Jupyter (though again, it's still non-trivial to get that to work).

But totally mood-affiliated and very open to ideas!

(And maybe someone will come and ask for a treesitter grammar — that would be a 5th!)

@aljazerzen
Copy link
Member

Ok, that all I needed to hear: there is a need for them.

The grammar should not change much so there is not a lot of maintenance anyway. And even it they are broken, the worst effect is bad syntax highlighting.

@max-sixty
Copy link
Member Author

This is in a pretty good state now!

I now need to work out how to get it to work with Jupyter etc; it may go in its own repo. I may use https://github.com/Snowflake-Labs/lezer-snowsql as a template

@max-sixty
Copy link
Member Author

Done!

This contributes towards (but doesn't close) PRQL/pyprql#45

@max-sixty max-sixty enabled auto-merge (squash) December 26, 2022 19:38
@max-sixty max-sixty merged commit 801f041 into main Dec 26, 2022
@max-sixty max-sixty deleted the lezer branch December 26, 2022 19:49
max-sixty added a commit to max-sixty/prql that referenced this pull request Dec 27, 2022
* feat: Initial Lezer grammar

Based on PRQL#1102

I've been using https://lezer-playground.vercel.app/, which is great!  And I struggled to set up a JS project that was good for iterating; though we'll need to do that at some point.

This parses our standard query (in examples.md) though it gives a couple of warnings around linebreaks — I still haven't really got my head around the way `@precedence` works.

It doesn't yet parse things like `func` & `table` though those aren't difficult. It heavily relied upon our pest file, though requires some different approaches in some areas.

---

Where should this go? In this repo? How should we package it? https://github.com/Snowflake-Labs/lezer-snowsql is an example of a full repo & package for a Lezer grammar

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* .

* .

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* .

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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