I've read on the forum that this is a custom grammar that was introduced to replace a previous EBNF grammar.
Since Nim uses this grammar, I'd like to learn more about it for it could be used to create custom languages in Nim too. The presentation of this grammar in the Nim Manual is very brief, so I was wondering if there are other resources dedicated to it, which I could study to learn more about it.
Thanks
Is this the complete grammar of Nim?
Yes. The grammar is extracted from comments in parser.nim so it occasionally it can be out-of-sync, but it should be complete.
Has this grammar definition got a name?
Not officially. I call it ABNF for "actions within EBNF". (And also for "Araq's version of BNF" ;-) )
Can anyone describe me its properties (e.g. context-free grammar, typology, etc.)?
It tries to be as close to LL(1) as possible with some PEG-like extensions. It offers the "ordered choice" / as well as the unordered choice |.
Was it created specifically for Nim, or is it used in other contexts too?
Specifically for Nim but it's generally useful.
Thanks @Araq, this was really useful info.
Specifically for Nim but it's generally useful, I hope.
If I were to write a grammar-based parser generator, I'd definitely go for Nim's native grammar — Araq-BNF (I like the name!).