GeezerVison is showing github.com — [BUG] BNF does not match the implementation · Issue #665 · npm/node-semver
[BUG] BNF does not match the implementation #665
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
semver.valid('1.2.3-00') // 'null'
semver.valid('1.2.3+00') // '1.2.3'
However, according to the BNF
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+
pre and build are just the same.
Expected Behavior
The behavior of program is correct, but BNF is not.
We need to update the BNF form.
Steps To Reproduce
No response
Environment
- npm: 9.9.1
- Node: v18.17.0
- OS: windows
Activity
changed the title
[-][BUG] <title> BNF does not match the implmentation[/-] [+][BUG] BNF does not match the implementation[/+] on Dec 6, 2023mbtools commented on Feb 1, 2024
Agree. Numeric parts of a pre-release must not have leading zero. Also the part definition isn't BNF but a regex.
How about this?
alphanum ::= ( ['0'-'9'] | ['A'-'Z'] | ['a'-'z'] | '-' ) +
pre ::= ( nr | alphanum ) ( '.' ( nr | alphanum ) ) *
build ::= alphanum ( '.' alphanum ) *
PS: This isn't perfect since alphanum could be a just numbers starting with a zero but the definition makes the difference between pre-release and build much clearer.
ShuiRuTian commented on Feb 22, 2024
Sorry for the late response. I was on Chinese Spring Festival.
It looks good to me!
And just out of curious, why we did not keep it same with(or close to) Semver?
mbtools commented on Feb 25, 2024
Because it was invented 10 years ago. I'm working on a update to a formal EBNF that will settle several issues (PR after my vacation)
Reacted by Song Gao and Gar
added a commit that references this issue
on Feb 24, 2026This issue will close once commit 3106a1d is merged into the 'main' branch.3106a1d added a commit that references this issue
on Feb 24, 2026This issue will close once commit 37776c3 is merged into the 'main' branch.37776c3
Metadata
Metadata
Development
No branches or pull requestsIssue actions