digitalmars.D - Dlang grammar
- Alexandru Ermicioi (14/14) May 06 2022 Hello,
- Sergey (3/17) May 06 2022 Maybe this example could be useful
- Alexandru Ermicioi (2/4) May 06 2022 Thx, I'll try adapt it to antlr format (EBNF).
- Bastiaan Veelo (4/9) May 08 2022 That grammar is very old, and contains some experiments. It is
- Alexandru Ermicioi (6/16) May 09 2022 Thx for the tip. I gave one more try to the official grammar, and
- max haughton (5/19) May 06 2022 Vladimir and a few others have an effort to do a tree-sitter
- Alexandru Ermicioi (7/11) May 06 2022 Well, I was trying to learn Truffle Language Implementation
Hello, Is there somewhere a proper grammar file for D language, that you can easily feed into a parser generator, and get out of it nicely baked parser (preferably parser in Java)? Tried to search for such grammars, and no luck. Found of course: 1. https://dlang.org/spec/grammar.html 2. https://libdparse.dlang.io/grammar.html I've tried both of them to adapt to antlr4 but eventually failed (requires a lot more effort than I have willpower for it). First for some reason got out of memory exception, while for the latter it is plainly incomplete, and also with couple of mistyped words, even if it is generated from libdparse. Thanks for the tips, Alexandru.
May 06 2022
On Friday, 6 May 2022 at 21:03:02 UTC, Alexandru Ermicioi wrote:Hello, Is there somewhere a proper grammar file for D language, that you can easily feed into a parser generator, and get out of it nicely baked parser (preferably parser in Java)? Tried to search for such grammars, and no luck. Found of course: 1. https://dlang.org/spec/grammar.html 2. https://libdparse.dlang.io/grammar.html I've tried both of them to adapt to antlr4 but eventually failed (requires a lot more effort than I have willpower for it). First for some reason got out of memory exception, while for the latter it is plainly incomplete, and also with couple of mistyped words, even if it is generated from libdparse. Thanks for the tips, Alexandru.Maybe this example could be useful https://github.com/PhilippeSigaud/Pegged/blob/master/examples/dgrammar/src/pegged/examples/dgrammar.d
May 06 2022
On Friday, 6 May 2022 at 21:16:30 UTC, Sergey wrote:Maybe this example could be useful https://github.com/PhilippeSigaud/Pegged/blob/master/examples/dgrammar/src/pegged/examples/dgrammar.dThx, I'll try adapt it to antlr format (EBNF).
May 06 2022
On Friday, 6 May 2022 at 22:46:28 UTC, Alexandru Ermicioi wrote:On Friday, 6 May 2022 at 21:16:30 UTC, Sergey wrote:That grammar is very old, and contains some experiments. It is probably not what you want. — Bastiaan.Maybe this example could be useful https://github.com/PhilippeSigaud/Pegged/blob/master/examples/dgrammar/src/pegged/examples/dgrammar.dThx, I'll try adapt it to antlr format (EBNF).
May 08 2022
On Sunday, 8 May 2022 at 14:40:36 UTC, Bastiaan Veelo wrote:On Friday, 6 May 2022 at 22:46:28 UTC, Alexandru Ermicioi wrote:Thx for the tip. I gave one more try to the official grammar, and managed to generate a parser (ofc after some bugfix in antlr4 itself). Dunno if it is an working one yet, will have to test it. Best regards, Alexandru.On Friday, 6 May 2022 at 21:16:30 UTC, Sergey wrote:That grammar is very old, and contains some experiments. It is probably not what you want. — Bastiaan.Maybe this example could be useful https://github.com/PhilippeSigaud/Pegged/blob/master/examples/dgrammar/src/pegged/examples/dgrammar.dThx, I'll try adapt it to antlr format (EBNF).
May 09 2022
On Friday, 6 May 2022 at 21:03:02 UTC, Alexandru Ermicioi wrote:Hello, Is there somewhere a proper grammar file for D language, that you can easily feed into a parser generator, and get out of it nicely baked parser (preferably parser in Java)? Tried to search for such grammars, and no luck. Found of course: 1. https://dlang.org/spec/grammar.html 2. https://libdparse.dlang.io/grammar.html I've tried both of them to adapt to antlr4 but eventually failed (requires a lot more effort than I have willpower for it). First for some reason got out of memory exception, while for the latter it is plainly incomplete, and also with couple of mistyped words, even if it is generated from libdparse. Thanks for the tips, Alexandru.Vladimir and a few others have an effort to do a tree-sitter grammar for D. That's the closest anyone has come in recent years at least. What do you want the grammar for?
May 06 2022
On Friday, 6 May 2022 at 22:24:33 UTC, max haughton wrote:Vladimir and a few others have an effort to do a tree-sitter grammar for D. That's the closest anyone has come in recent years at least. What do you want the grammar for?Well, I was trying to learn Truffle Language Implementation Framework (https://www.graalvm.org/22.0/graalvm-as-a-platform/language-imple entation-framework) for starters, and then play a bit with it, and find out the features it provides, using D grammar as basis. In long term (low probability) even to do some kind of D language interpreter for java. Just wondering how well is truffle api built for debugging, as well as for LSP integration.
May 06 2022