TurboMagic 92 Posted February 12, 2022 Hello, this is to let you know that there was a open source collaboration project started to create a formal specification of the Delphi language in Backus-Naur format (https://en.wikipedia.org/wiki/Backus–Naur_form). It is hosted on GitHub here: https://github.com/MHumm/DelphiGrammar David Hoyle contributed his Delphi 10.3 version as a starting point. If you want to participate in this endeavor, which might help developers of language tools, just drop me a message with your GitHub account name and I'll give you commit permission. Either via this forum or as an issue on that GitHub project. Currently I picked Apache 2.0 as license, but if necessary we can discuss to use something else. Cheers TurboMagic 1 Share this post Link to post
Uwe Raabe 2057 Posted February 12, 2022 10 minutes ago, TurboMagic said: If you want to participate in this endeavor, which might help developers of language tools, just drop me a message with your GitHub account name and I'll give you commit permission. Have you considered keeping the number of direct committers small and let the majority of interested participants provide their contributions via pull requests? Share this post Link to post
TurboMagic 92 Posted February 12, 2022 This would be another approach. At least for the start we should attract many developers to get it started. I know that you're after, but if we make entry barrier as low as possible at the start we might attract more contributors. We can still switch afterwards if we find that some don't do the right things. But: we need people working on it. Otherwise it's useless... 😉 Share this post Link to post
dummzeuch 1505 Posted February 12, 2022 Are you aware of the (outdated) grammar at https://delphi.fandom.com/wiki/Object_Pascal_Grammar ? Share this post Link to post
TurboMagic 92 Posted February 12, 2022 Now I am. Thanks! But for which version is this? The one our new project already has as starting point is compatible with 10.3 and I guess mostly compatible with that release so I guess it's newer than the one you linked. But you can compare both versions I guess...? Share this post Link to post
Uwe Raabe 2057 Posted February 12, 2022 1 hour ago, TurboMagic said: I know that you're after, but if we make entry barrier as low as possible at the start we might attract more contributors. Perhaps it is just my take of it, but being a contributor bears some responsibility - for the whole repository and not only for the part you contribute. I wouldn't call that lowering the barrier. On the other hand, forking the repo, doing your thing and creating a pull request seems much less hassle to me. Anyway, everyone can just do so whatever you decide. 1 Share this post Link to post
dummzeuch 1505 Posted February 12, 2022 9 minutes ago, TurboMagic said: Now I am. Thanks! But for which version is this? The one our new project already has as starting point is compatible with 10.3 and I guess mostly compatible with that release so I guess it's newer than the one you linked. But you can compare both versions I guess...? My guess would be that the on in the Delphi Wiki is older than Delphi 10.3. Share this post Link to post
Tommi Prami 130 Posted February 14, 2022 This BNF was new thing for me. Is there some easily usable "things" we could benefit from that Grammar. Any cool tools that could use that etc. Please educate me and others BNF-challenged persons :) -Tee- Share this post Link to post
Alexander Elagin 143 Posted February 14, 2022 Syntax diagrams are easier to read and understand than BNF or ABNF and they look good in any documentation , but BNF is better suited for automated parsing and validation. Share this post Link to post
Anders Melander 1783 Posted February 14, 2022 2 hours ago, Tommi Prami said: Please educate me and others BNF-challenged persons 🙂 Didn't you read the wikipedia link on Backus-Naur format? 2 hours ago, Alexander Elagin said: Syntax diagrams are easier to read and understand than BNF or ABNF and they look good in any documentation There are a few online tools that generates railroad diagrams from EBNF (https://www.bottlecaps.de/rr/ui is probably the best known) but I know of none that operate on BNF. I actually don't think the original BNF is much used outside old textbooks. 1 Share this post Link to post
darnocian 85 Posted February 14, 2022 Re BNF vs diagrams… as the format should be formal, it would allow for diagrams to be created easily using tools like graphgviz/dot and sexier/modern versions thereof. Re benefits of a grammar it can be used as a basis for all kinds of things… once a model is created using a parser generator or manually crafted, you can create things that might be out of scope of the actual compiler. E.g. static code analysis, documentation generation, dependency analysis (between units), search tools, creating diagrams, etc. Writing parsers can take a bit of effort, and to do it correctly, the grammar needs to be right. There is a lot of boiler plate (repeated patterns) when it comes to parsing, so over time people have written parser generation tools to assist with this process more optimally (and avoid bugs). Their input would normally be a bnf type config file. Examples of such tools is yacc (yet another compiler compiler), etc. I personally like the ANTLR framework. Unfortunately, the latest version 4 doesn’t have a Delphi runtime, but version 3 had one. it would be convenient to update this to fit in with one of those tools as it also makes it easier to instantly validate and create test cases on the grammar. 1 Share this post Link to post
Tommi Prami 130 Posted February 14, 2022 7 hours ago, Anders Melander said: Didn't you read the wikipedia link on Backus-Naur format? Read parts of it, but did not shed much light on how we could use it. I'll try to read it later with some though. -Tee- Share this post Link to post
Lars Fosdal 1792 Posted February 15, 2022 BTW - Is this file in EBNF format? Share this post Link to post
David Hoyle 68 Posted February 15, 2022 It's my file using extended backus-naur format. It's easier for me to maintain these files along side my parsers than using diagrams. The Object Pascal files started from the grammar that was included in the Delphi 7's Object Pascal Guide. 1 Share this post Link to post
Anders Melander 1783 Posted February 15, 2022 30 minutes ago, Lars Fosdal said: BTW - Is this file in EBNF format? No. It's regular BNF. You can tell by the use of <> brackets and :== Here's a comparison: https://en.wikipedia.org/wiki/Syntax_diagram#Example Share this post Link to post
Lars Fosdal 1792 Posted February 15, 2022 I can't find a validator that will accept the Object Pascal Grammar. Share this post Link to post
David Hoyle 68 Posted February 15, 2022 There is one in by Browse and Doc It IDE plug-in. Its extended because BNF is single line and I needed multi-line and introduced the semi-colon to me line termination detection easier. 1 Share this post Link to post
Lars Fosdal 1792 Posted February 15, 2022 There is a diagram renderer here: https://www.bottlecaps.de/rr/ui - but it barfs on the first definition. 1 Share this post Link to post
Bill Meyer 337 Posted February 15, 2022 (edited) In the Wikipedia page on EBNF, it does not appear to support ::= as a symbol for definition -- it specifies =. I would think that for the project to have value, it needs to adhere fully to EBNF. That said, I claim no expertise in language specification. UPDATE: I note that there is a link on the Wikipedia page for EBNF which offers a zipped PDF of the ISO variant of EBNF: http://standards.iso.org/ittf/PubliclyAvailableStandards/s026153_ISO_IEC_14977_1996(E).zip Unfortunately, the file I received in two separate attempts can't be opened as a zip, but provokes an error saying the file is corrupt. Edited February 15, 2022 by Bill Meyer Share this post Link to post
Uwe Raabe 2057 Posted February 15, 2022 I guess the problem is the use of semicolons in the grammar to separate the rules, which seems not to be standard BNF. Share this post Link to post
Stefan Glienke 2002 Posted February 15, 2022 (edited) 58 minutes ago, Lars Fosdal said: There is a diagram renderer here: https://www.bottlecaps.de/rr/ui - but it barfs on the first definition. If you look at https://www.w3.org/TR/2010/REC-xquery-20101214/#EBNFNotation and https://www.w3.org/TR/xml/#sec-notation you will see that it uses some in between format of BNF and EBNF - using the ::= from BNF but not the angle brackets. Edited February 15, 2022 by Stefan Glienke Share this post Link to post
Uwe Raabe 2057 Posted February 15, 2022 Yeah, it doesn't look like clean BNF at all. Any BNF parser I tried has had its problems with it. Share this post Link to post
Anders Melander 1783 Posted February 15, 2022 1 hour ago, Bill Meyer said: I would think that for the project to have value, it needs to adhere fully to EBNF. That said, I claim no expertise in language specification. Exactly - and you don't need to be an expert to come to that conclusion. 1 Share this post Link to post
Bill Meyer 337 Posted February 15, 2022 16 minutes ago, Anders Melander said: Exactly - and you don't need to be an expert to come to that conclusion. No, of course not, but it would not be that difficult for this to become contentious. 😉 Share this post Link to post
Bill Meyer 337 Posted February 15, 2022 3 hours ago, Uwe Raabe said: Yeah, it doesn't look like clean BNF at all. Any BNF parser I tried has had its problems with it. My own casual survey leads me to offer this summary: BNF seems to be considered too limiting, and generally not for new work EBNF, though better, suffers from the extensions being numerous and undisciplined, so there seems to be no "standard" EBNF ABNF appears to be more useful than BNF, and better managed than EBNF -- see IETF RFC 5234 Don't shoot me, I didn't mention "right" and "wrong"! 3 Share this post Link to post