digitalmars.D - [spec] Looking for a write-up on the grammar notation
- Dibyendu Majumdar (8/8) May 15 2019 Hi,
- Dibyendu Majumdar (4/7) May 15 2019 Something like this:
- Dibyendu Majumdar (16/19) May 16 2019 From lack of response I take it there isn't anything. So would
- Max Haughton (9/16) May 16 2019 I'm very rusty with the theory behind grammars:
- Dibyendu Majumdar (7/11) May 17 2019 Thank you for the link. I meant where one could use the D Grammar
- Dibyendu Majumdar (7/10) May 17 2019 Interestingly I could probably just use the words by Dennis
Hi, I want to add a section that describes the notations used in the document. As part of this I would like to add something about the grammar notation. Is there any write up available that describes how to read the notation? Thanks and Regards Dibyendu
May 15 2019
On Wednesday, 15 May 2019 at 23:57:55 UTC, Dibyendu Majumdar wrote:As part of this I would like to add something about the grammar notation. Is there any write up available that describes how to read the notation?Something like this: https://golang.org/ref/spec#Notation
May 15 2019
On Wednesday, 15 May 2019 at 23:57:55 UTC, Dibyendu Majumdar wrote:As part of this I would like to add something about the grammar notation. Is there any write up available that describes how to read the notation?From lack of response I take it there isn't anything. So would this be correct for the grammar describing D syntax: 1. The grammar is context-free. 2. Non-terminals are in italics. 3. The right hand side of each production gives available alternatives, i.e. there is an implicit OR. 4. Terminals are shown in bold, non-italic text. 5. Optional non-terminals are suffixed by an 'opt'. Some questions: 1. Is the grammar complete? 2. Is it unambiguous? 3. Can it be directly converted to a parser? Sorry I am not an expert in this so apologies if above is stupid. Regards
May 16 2019
On Thursday, 16 May 2019 at 18:48:15 UTC, Dibyendu Majumdar wrote:Some questions: 1. Is the grammar complete? 2. Is it unambiguous? 3. Can it be directly converted to a parser? Sorry I am not an expert in this so apologies if above is stupid. RegardsI'm very rusty with the theory behind grammars: the grammar is complete for the core language (There are some DIPs that change things, but AFAIK they're either within the existing grammar or require no modification). The D's *grammar* is almost context free generators (https://github.com/PhilippeSigaud/Pegged/blob/master/pegged examples/dgrammar.d is close(?) to a D grammar for pegged). The Source for the actual parser in dmd is recursive descent and therefore basically follows the grammar rules (In the source)
May 16 2019
On Thursday, 16 May 2019 at 20:23:39 UTC, Max Haughton wrote:The D's *grammar* is almost context freeHi, Could you explain this further?parser generators (https://github.com/PhilippeSigaud/Pegged/blob/master/pegged examples/dgrammar.d is close(?) to a D grammar for pegged). The Source for the actual parser in dmd is recursive descent and therefore basically follows the grammar rules (In the source)Thank you for the link. I meant where one could use the D Grammar and literally translate it to a system like yacc or ANTLR and get a working parser. For instance in C, you can't do that I believe because you need a symbol table to resolve typedefs. Regards
May 17 2019
On Wednesday, 15 May 2019 at 23:57:55 UTC, Dibyendu Majumdar wrote:As part of this I would like to add something about the grammar notation. Is there any write up available that describes how to read the notation?Interestingly I could probably just use the words by Dennis Ritchie back in 1975: https://www.bell-labs.com/usr/dmr/www/cman.pdf Looks like even the latest C and C++ standards essentially follow that.
May 17 2019