-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add syntax highlighting for PRQL #3313
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
Conversation
Adds a syntax highlighting mode for the PRQL query language. PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement. https://prql-lang.org/ https://github.com/PRQL/prql
|
Hey @zyedidia can you merge this? |
|
Hey @dmaluka can you merge this? |
|
@JoeKar @Andriamanitra could you take care of reviewing this? |
Andriamanitra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know PRQL beforehand so I went through some examples from the documentation and it seems to work alright for the most part, but I found a few minor issues.
According to the documentation "String literals can use any matching odd number of either single or double quotes", but this doesn't currently work for something like """ ab "" " cd """. Arbitrary length but matching start/end is impossible to do within the highlighting system in micro but we could hard-code a few of the first cases (eg. """"", """, ", ''''', ''', ').
| - constant.number: "\\b0b(_?[01])+\\b" # bin | ||
| - constant.number: "\\b0o(_?[0-7])+\\b" # oct | ||
| - constant.number: "\\b0x(_?[0-9a-fA-F])+\\b" # hex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The online playground for PRQL doesn't accept a literal like 0x55_55 but this syntax does, but I'm not sure if it's a bug in this syntax or the playground. Based on the other syntaxes in PRQL Github repo it seems PRQL is supposed to allow underscore separators like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. PRQL does support underscores in numbers but it appears not in hex notation though it arguably should. I would like to leave it in here for future compatibility.
Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
|
@Andriamanitra so it basically handles it the same way as Python and the syntax file for Python doesn't put too much effort into handling the various different types of strings and quotations. |
Python does handle triple quoted strings separately (and Python doesn't have syntax for arbitrary numbers of quotes) micro/runtime/syntax/python3.yaml Lines 34 to 40 in 41b912b
As another example in Rust which allows arbitrary but matching number of micro/runtime/syntax/rust.yaml Lines 31 to 45 in 41b912b
|
|
But do we need to handle triple quoted strings considering that first quote opens the string, followed by the second quote closes the the string, followed by the third quote which opens the quote? |
If we don't then having a single quote inside the triple quoted string will mess up highlighting for the rest of the file. I think it's worth it. |
|
@dmaluka Okay Andriamanitra has reviewed and approved this. |
Adds a syntax highlighting mode for the PRQL query language.
PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement.
https://prql-lang.org/
https://github.com/PRQL/prql