Add syntax highlighting for PRQL#3313
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.
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.
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.
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) https://github.com/zyedidia/micro/blob/41b912b5392ff80c1cce7d0ef7668f406977cc00/runtime/syntax/python3.yaml#L34-L40 As another example in Rust which allows arbitrary but matching number of |
|
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