Skip to content

Conversation

@vanillajonathan
Copy link
Contributor

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

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
@vanillajonathan
Copy link
Contributor Author

Hey @zyedidia can you merge this?

@vanillajonathan
Copy link
Contributor Author

Hey @dmaluka can you merge this?

@dmaluka
Copy link
Collaborator

dmaluka commented Jun 30, 2025

@JoeKar @Andriamanitra could you take care of reviewing this?

Copy link
Contributor

@Andriamanitra Andriamanitra left a 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. """"", """, ", ''''', ''', ').

Comment on lines +43 to +45
- constant.number: "\\b0b(_?[01])+\\b" # bin
- constant.number: "\\b0o(_?[0-7])+\\b" # oct
- constant.number: "\\b0x(_?[0-9a-fA-F])+\\b" # hex
Copy link
Contributor

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.

Copy link
Contributor Author

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.

vanillajonathan and others added 5 commits July 1, 2025 16:47
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>
@vanillajonathan
Copy link
Contributor Author

@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.

@Andriamanitra
Copy link
Contributor

@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)

- constant.string:
start: "\"\"\""
end: "\"\"\""
- constant.string:
start: "'''"
end: "'''"

As another example in Rust which allows arbitrary but matching number of # characters on either side of raw strings we hard-coded cases up to 4:

- constant.string:
start: "[bc]?r#\""
end: "\"#"
- constant.string:
start: "[bc]?r##\""
end: "\"##"
- constant.string:
start: "[bc]?r###\""
end: "\"###"
- constant.string:
start: "[bc]?r####+\""
end: "\"####+"

@vanillajonathan
Copy link
Contributor Author

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?

@Andriamanitra
Copy link
Contributor

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.

@vanillajonathan
Copy link
Contributor Author

@dmaluka Okay Andriamanitra has reviewed and approved this.

@dmaluka dmaluka merged commit cf92f77 into zyedidia:master Jul 8, 2025
@vanillajonathan vanillajonathan deleted the patch-1 branch July 8, 2025 13:15
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.

3 participants