I'd like to suggest using EBNF according to ISO 14977 instead of a non-standard modified BNF like currently, it is much more readable and makes the result much more concise, e. g. by eliminating the need for recursion and introducing optionals.
Originally created by @Vampire on GitHub (Jun 12, 2020).
Original GitHub issue: https://github.com/semver/semver/issues/575
I'd like to suggest using EBNF according to ISO 14977 instead of a non-standard modified BNF like currently, it is much more readable and makes the result much more concise, e. g. by eliminating the need for recursion and introducing optionals.
E. g.
```
<pre-release> ::= <dot-separated pre-release identifiers>
<dot-separated pre-release identifiers> ::= <pre-release identifier> | <pre-release identifier> "." <dot-separated pre-release identifiers>
```
could be written as
```
pre_release = pre_release_identifier, { ".", pre_release_identifier };
```
## Reuse nonterminals where possible
```
<numeric identifier> ::= "0"
| <positive digit>
| <positive digit> <digits>
```
should be
```
<numeric identifier> ::= <digit>
| <positive digit> <digits>
```
## Simplify the BNF form, even if not using EBNF
e. g. if
```
<identifier characters> ::= <identifier character>
| <identifier character> <identifier characters>
```
is changed to
```
<identifier characters> ::= | <identifier character> <identifier characters>
```
you can simplify
```
<alphanumeric identifier> ::= <non-digit>
| <non-digit> <identifier characters>
| <identifier characters> <non-digit>
| <identifier characters> <non-digit> <identifier characters>
```
to
```
<alphanumeric identifier> ::= <identifier characters> <non-digit> <identifier characters>
```
as now `<identifier characters>` can be empty
I generally am in favor of using standard things over non-standard things, but haven't had the opportunity to review this in detail at all.
<!-- gh-comment-id:880992923 -->
@steveklabnik commented on GitHub (Jul 15, 2021):
I generally am in favor of using standard things over non-standard things, but haven't had the opportunity to review this in detail at all.
May I suggest BNF for Java? https://sourceforge.net/projects/bnf-for-java/
In 2007, I wrote this parser-generator in Java, and conforms to ISO-14977.
In 2022, I am re-writing the compiler in Antlr. Wish me luck!
<!-- gh-comment-id:1220815694 -->
@ghost commented on GitHub (Aug 19, 2022):
May I suggest BNF for Java?
https://sourceforge.net/projects/bnf-for-java/
In 2007, I wrote this parser-generator in Java, and conforms to ISO-14977.
In 2022, I am re-writing the compiler in Antlr. Wish me luck!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @Vampire on GitHub (Jun 12, 2020).
Original GitHub issue: https://github.com/semver/semver/issues/575
I'd like to suggest using EBNF according to ISO 14977 instead of a non-standard modified BNF like currently, it is much more readable and makes the result much more concise, e. g. by eliminating the need for recursion and introducing optionals.
E. g.
could be written as
Reuse nonterminals where possible
should be
Simplify the BNF form, even if not using EBNF
e. g. if
is changed to
you can simplify
to
as now
<identifier characters>can be empty@Vampire commented on GitHub (Jun 20, 2020):
This would for example be a possible EBNF form I could PR:
Or maybe even better than ISO 14977 EBNF would be RFC 5234 ABNF:
@davbrito commented on GitHub (Nov 10, 2020):
I like the idea of use ABNF from RFC 5234
@greggirwin commented on GitHub (Feb 22, 2021):
Here's a visible comparison of the 3 formats, as syntax diagrams.
ABNF
#EBNF

#BNF

@greggirwin commented on GitHub (Feb 22, 2021):
Oy, sorry about that. They show large in the comments.
@greggirwin commented on GitHub (Jul 7, 2021):
Any follow-up on this from maintainers?
@steveklabnik commented on GitHub (Jul 15, 2021):
I generally am in favor of using standard things over non-standard things, but haven't had the opportunity to review this in detail at all.
@greggirwin commented on GitHub (Jul 15, 2021):
Here's an ABNF version, minus the ABNF standard values.
@greggirwin commented on GitHub (Sep 10, 2021):
Ping. Any thoughts?
@ghost commented on GitHub (Aug 19, 2022):
May I suggest BNF for Java?
https://sourceforge.net/projects/bnf-for-java/
In 2007, I wrote this parser-generator in Java, and conforms to ISO-14977.
In 2022, I am re-writing the compiler in Antlr. Wish me luck!