GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docs: fix BNF grammar to distinguish prerelease from build identifiers by abhu85 · Pull Request #846 · npm/node-semver

Conversation

@abhu85

@abhu85 abhu85 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Summary

The BNF grammar in README.md and range.bnf incorrectly defined pre and build as identical rules (parts), but they have different requirements per the SemVer 2.0.0 specification:

  • Prerelease identifiers: Numeric parts must not have leading zeros
  • Build metadata: Allows any alphanumeric string including leading zeros

Current behavior (correctly implemented, but BNF was wrong)

semver.valid('1.2.3-00')  // null (invalid - prerelease numeric with leading zero)
semver.valid('1.2.3+00')  // '1.2.3' (valid - build metadata allows any alphanumeric)
semver.valid('1.2.3-0')   // '1.2.3-0' (valid - single zero is fine)

Changes

Updates the BNF grammar to distinguish between:

  • prepart - uses nr (no leading zeros) or alphanumid (alphanumeric identifier)
  • buildid - any alphanumeric string including leading zeros

Also adds an explanatory note after the BNF block to clarify the distinction.

Fixes #665

Test plan

  • Verified the implementation behavior matches the updated BNF
  • Confirmed alignment with SemVer 2.0.0 spec item 9

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@abhu85 @claude
docs: fix BNF grammar to distinguish prerelease from build identifiers
3106a1d
The BNF grammar incorrectly showed `pre` and `build` as identical rules,
but they have different requirements per SemVer 2.0.0 specification:

- Prerelease identifiers: numeric parts must not have leading zeros
  (e.g., `1.2.3-00` is invalid, `1.2.3-0` is valid)
- Build metadata: allows any alphanumeric string including leading zeros
  (e.g., `1.2.3+00` is valid)

This updates the BNF in both README.md and range.bnf to correctly reflect
the implementation behavior and SemVer spec.

Fixes npm#665

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@abhu85
abhu85 requested a review from a team as a code owner February 24, 2026 11:40
@wraithgar

wraithgar commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Had to go back and double check a few things there, just to be sure..

> semver.parse('1.2.0--pre').prerelease
[ '-pre' ]
> semver.parse('1.2.0+-build').build
[ '-build' ]

Yep, leading - is ok on those.

abhu85 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

wraithgar
wraithgar approved these changes Feb 24, 2026
View reviewed changes
@wraithgar
wraithgar merged commit 37776c3 into npm:main Feb 24, 2026
29 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Feb 24, 2026
chore: release 7.8.0 #847
Merged
@abhu85
abhu85 deleted the fix/bnf-prerelease-build-distinction branch February 24, 2026 17:06
owlstronaut pushed a commit that referenced this pull request May 8, 2026
@github-actions
chore: release 7.8.0 (#847)
efa4be6
🤖 I have created a release *beep* *boop*
---


## [7.8.0](v7.7.4...v7.8.0)
(2026-05-08)
### Features
*
[`0d0a0a2`](0d0a0a2)
[#855](#855) Add `truncate`
function (#855) (@pjohnmeyer, @owlstronaut)
### Bug Fixes
*
[`3905343`](3905343)
[#859](#859) Warn when defaulting
to --inc=patch in CLI (@pjohnmeyer)
### Documentation
*
[`c368af6`](c368af6)
[#853](#853) fix typos in
documentation (#853) (@ankitkumar572005)
*
[`37776c3`](37776c3)
[#846](#846) fix BNF grammar to
distinguish prerelease from build identifiers (#846) (@abhu85, @claude)
### Chores
*
[`9542e09`](9542e09)
[#860](#860) template-oss-apply
(@owlstronaut)
*
[`937bc2c`](937bc2c)
[#860](#860)
`[email protected]` (@owlstronaut)
*
[`6946fef`](6946fef)
[#852](#852) bump
@npmcli/template-oss from 4.29.0 to 4.30.0 (#852) (@dependabot[bot],
@npm-cli-bot)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This was referenced May 9, 2026
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#75
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#79
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#83
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#87
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#91
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#95
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#100
Closed
This was referenced May 16, 2026
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#106
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#112
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#118
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#124
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#131
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#137
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#143
Closed
This was referenced May 23, 2026
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#149
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#155
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#161
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#167
Open
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#174
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#180
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#186
Closed
@github-actions github-actions Bot mentioned this pull request May 30, 2026
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#193
Closed
5 tasks
This was referenced May 31, 2026
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#200
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#208
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#216
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#224
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#232
Closed
deps: semver 7.7.4 → 7.8.2 suj1e/larkcc#240
Closed
deps: semver 7.7.4 → 7.8.2 suj1e/larkcc#248
Closed
This was referenced Jun 7, 2026
deps: semver 7.7.4 → 7.8.2 suj1e/larkcc#256
Closed
deps: semver 7.7.4 → 7.8.2 suj1e/larkcc#264
Closed
deps: semver 7.7.4 → 7.8.3 suj1e/larkcc#273
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#282
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#291
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#300
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#309
Closed
This was referenced Jun 14, 2026
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#318
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#327
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#336
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#345
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#354
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#363
Closed
This was referenced Jul 24, 2026
chore: automate npm release versioning DonArtkins/warp-wizard#1
Merged
docs(proposals): add CalVer versioning and tag-based deploy proposal eten-tech-foundation/fluent-api#245
Closed
docs: add CalVer versioning and tag-based deployment proposal eten-tech-foundation/fluent-web#379
Closed
This was referenced Aug 4, 2026
fix(release): require explicit approved release cuts nearai/ironclaw#7122
Merged
Fix OpenClaw upgrade dependency drift joshuaswarren/remnic#2343
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
BUMP - VID PlanetaryOrbit/orbit#198
Merged
6 of 17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@wraithgar wraithgar wraithgar approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] BNF does not match the implementation

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@abhu85 @wraithgar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.