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
Syntax diagram #1810
Comments
I think let's merge this into #12 given how intertwined it is, let me add a comment there. |
Actually #12 is closed. But this relies on defining a formal grammar which we don't have at the moment, and I probably wouldn't suggest we write yet, given we'd need to keep it up to date, and we're still making changes to the language — at least unless someone wants to write it and commit to maintain it... We already have 4 grammar definitions (https://prql-lang.org/book/internals/syntax-highlighting.html)! To the extent we could make something out of an existing grammar — Is that reasonable @vanillajonathan ? |
Sure it can be postponed until later, right now might not be the best time, but you can add it on to some "to do" list using some issue tag, milestone or a project. |
Good idea — added a label. We can do a search of closed issues with this label in future |
I wrote some EBNF grammar for PRQL. Statements ::= Statement Comment? | (('|' | NEWLINE) Statement)* Comment?
Statement ::= Assignment | FunctionCall
Array ::= '[' SPACE* Name? SPACE* (',' SPACE* Name SPACE* ','?)* ']'
Atom ::= 'true' | 'false' | 'null'
Comment ::= '#' '*'*
Name ::= '_'* ALPHA+ (ALPHANUM | '_')*
DateInner ::= (DIGIT+ '-' DIGIT+ '-' DIGIT+)
TimeInner ::= (DIGIT+ ':' DIGIT+ ':' DIGIT+) ('.' DIGIT+)? (('+' | '-') DIGIT+ ':' DIGIT+ | 'Z')?
Date ::= '@' DateInner
Time ::= '@' TimeInner
DateTime ::= '@' DateInner 'T' TimeInner
Expression ::= 'Table'
FunctionCall ::= '(' Name (Param | Name ':' 'something')* ')' | Name (Param | Name ':' 'something')*
FunctionDef ::= 'func' SPACE* Name SPACE* Param? SPACE* '->' SPACE* Expression
IntervalLiteral ::= DIGIT+ ('microseconds' | 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'years')
CmpOp ::= '==' | '!=' | '~=' | '<' | '>' | '<=' | '>='
MathOp ::= '+' | '-' | '/' | '*'
Param ::= Name | Name '<' ALPHA+ '>'
Range ::= Number '..' Number
String ::= ('"' '*'* '"' | "'" '*'* "'") /* Slicer? */
FString ::= 'f' String /* Slicer? */
RString ::= 'r' String /* Slicer? */
SString ::= 's' String
Number ::= ('+' | '-')? DIGIT ('_'? DIGIT+)* ('e' DIGIT+)?
Assignment ::= 'let' SPACE* '=' SPACE* Expression
/* Slicer ::= '[' Number (':' Number)? ']' */
Now you see some pretty diagrams which you can also download. Note: the diagram is very far from truthful! |
Cool @vanillajonathan ! If it's possible to make that accurate we could add it to the repo. It would need to be maintained. Otherwise we'll have your initial attempt for future travelers as a starting point, still useful. |
It would be possible to make it accurate, but I am not all too familiar with the PRQL grammar and no PRQL specification exists, furthermore this is the first time I try to write EBNF so I have no experience with that. Yes, it would need to be maintained as the language evolves. Maybe someone else have a better understanding of PRQL and EBNF than me. Some issues with the above EBNF grammar.
|
The website and/or documentation should include a syntax diagram.
The text was updated successfully, but these errors were encountered: