Document reserved keywords and built-in functions
Like this:
- https://docs.python.org/3/reference/lexical_analysis.html#keywords
- https://docs.python.org/3/library/functions.html
Reserved keywords are:
aggregatederivefalsefilterfromgroupjoinnullprqlselectsortswitchtaketrue
Maybe I am missing some?
One source for them is somewhere like https://github.com/PRQL/prql/blob/main/book/highlight-prql.js.
I'm not sure how to maintain that list though. Unless we can do that well — e.g. we make this list from the compiler itself — I probably wouldn't explicitly list it given it'll fall out of date.
If anyone has thoughts on whether that's possible, that'd be welcome...
I don't know how keep it up to date either, I just figured it would be good to have a reference other than to have to dig into some source file.
From higlight-prql.js
Transforms:
aggregateappendderivefilterfrom_textfromgroupjoinselectsorttakeunionwindow
Built-in functions:
switchinas
Keywords:
funcletprql
To be technically correct, most of the mentioned named are not reserved. Transforms and in and as reside in std module (namespace) which is in the lookup path of the root module, which means they are "always in scope".
So keywords are only:
- prql
- func
- let
- switch
But even they are parsed as keywords only when used correctly. Otherwise, they are regular idents:
from invoices
select [prql, switch, let, func]
... which is a thing that we should maybe change.
This looks covered by the book now, so it may be ready to close.
- Reserved keywords: the Keywords section of
keywords.md, added in #2995, listsprql,let,into,case,type,enum,func,module,import,internal,true,falseandnull, and says how to use one as an identifier (backticks). That matches the lexer'sKEYWORDSandRESERVED_LITERALSexactly. The same section explains that transforms are ordinarystdfunctions rather than keywords, which was @aljazerzen's point above. - Built-in functions: the standard library page includes the full
std.prqlsource, so the list can't fall out of date (the maintenance concern raised earlier).