mirror of
https://github.com/semver/semver.git
synced 2026-07-11 05:12:48 -05:00
[GH-ISSUE #192] EBNF grammar #2845
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @christianhujer on GitHub (Apr 14, 2014).
Original GitHub issue: https://github.com/semver/semver/issues/192
The Semantic Versioning Spec could have an EBNF grammar.
Here it is, according to http://www.w3.org/TR/xml/#sec-notation.
version ::= MAJOR '.' MINOR '.' PATCH ('-' PRE)? ('+' BUILD)?
MAJOR ::= decimalnumber
MINOR ::= decimalnumber
PATCH ::= decimalnumber
PRE ::= string
BUILD ::= string
string ::= [0-9A-Za-z-]+
decimalnumber ::= [0-9]+
@rlidwka commented on GitHub (Apr 14, 2014):
it's much more complex than that...
@bessarabov commented on GitHub (Apr 14, 2014):
Just in case one hasn't seen it. There is BNF grammar for SemVer: https://github.com/mojombo/semver/blob/master/semver.md#backusnaur-form-grammar-for-valid-semver-versions
@christianhujer commented on GitHub (Apr 17, 2014):
Just found a flaw.
decimalnumber should actually be, to disallow leading zeros:
decimalnumber ::= '0' | [1-9] [0-9]+
I've taken a look at the BNF grammar for SemVer. It is quite verbose because it is plain old BNF, which doesn't have quantifiers and character groups, unlike simple EBNF from the W3C.
But I do not care which BNF language as long as there is a BNF, any BNF is fine with me :)
@FichteFoll commented on GitHub (Apr 21, 2014):
FWIW, here is a regular expression I used for my Python implementation. It's not 2.0.0-comform because I allow empty build and pre-release fields to make version selectors more simple but otherwise it should be correct. Furthermore, I added a "whitespace detection" to the regex to allow extracting it from a string, but that doesn't matter when enclosing with
^$anyway (like I did 2 lines later).@gvlx commented on GitHub (Jun 27, 2018):
Here it is.
Please comment and correct.
@glebec commented on GitHub (Oct 2, 2018):
@gvlx my corrections:
PreReleaseIdentifierhad a spurious+onNumericIdentifierAlphaNumericIdentifiercannot parse asIdentifierCharacter* NonNumericCharacter ...b/cIdentifierCharacter*includesNonNumericCharacter. So a typical parser would consume all of the input usingIdentifierCharacter*and then fail because there is noNonNumericCharacterto consume. The correct version isNumericCharacter* NonNumericCharacter ....@gvlx commented on GitHub (Oct 2, 2018):
The EBNF has been corrected by @glebec on https://github.com/semver/semver/issues/192#issuecomment-426123552 .
This issue should now be closed.
@jwdonahue commented on GitHub (Oct 8, 2018):
@christianhujer , unless you have further questions, can you please close this issue at your earliest possible convenience?
@ebkalderon commented on GitHub (Sep 4, 2019):
@christianhujer Looks like the EBNF grammar has already been merged into
master. Can this issue be closed?