Skip to content

Add BNF Grammar for valid version strings - #116

Merged
haacked merged 4 commits into
semver:masterfrom
isaacs:bnf
Aug 6, 2013
Merged

haacked merged 4 commits into
semver:masterfrom
isaacs:bnf

Conversation

@isaacs

@isaacs isaacs commented Jun 14, 2013

Copy link
Copy Markdown
Contributor

Written in collaboration with @petermichaux

Closes #110

This was referenced Jun 14, 2013
@isaacs

isaacs commented Jun 14, 2013

Copy link
Copy Markdown
Contributor Author

@petermichaux Yes, that's absolutely right. Also, this doesn't allow build identifiers to have leading zeroes, so 1.2.3+0000.build wouldn't pass, but ought to.

Updated. The change is this:

diff --git a/semver.md b/semver.md
index 34b67df..e8b732d 100644
--- a/semver.md
+++ b/semver.md
@@ -144,19 +144,25 @@ Backus–Naur Form Grammar for Valid SemVer Versions

     <pre-release> ::= <dot-separated identifiers>

-    <build> ::= <dot-separated identifiers>
+    <build> ::= <dot-separated build identifiers>

     <dot-separated identifiers> ::= <identifier>
                                   | <identifier> "." <dot-separated identifiers>

+    <dot-separated build identifiers> ::= <build identifier>
+                                        | <build identifier> "." <dot-separated build identifiers>
+
+    <identifier> ::= <non-negative integer>
+                   | <non-numeric identifier>
+
+    <build identifier> ::= <identifier character>
+                         | <identifier character> <build identifier>
+
     <non-numeric identifier> ::= <non-digit character>
                                | <non-digit character> <identifier>
                                | <identifier> <non-digit character>
                                | <identifier> <non-digit character> <identifier>

-    <identifier> ::= <identifier character>
-                   | <identifier character> <identifier>
-
     <non-digit character> ::= <letter> | "-"

     <identifier character> ::= <non-digit character> | <digit>

@isaacs

isaacs commented Jun 14, 2013

Copy link
Copy Markdown
Contributor Author

Oh, also, the <non-numeric identifier> was overly strict. It only allowed a <non-digit character> mixed with an <identifier>, but an <identifier> cannot be a 0-prefixed number, so a009 for example would not be valid.

Fixed with this patch:

diff --git a/semver.md b/semver.md
index e8b732d..73f098c 100644
--- a/semver.md
+++ b/semver.md
@@ -159,9 +159,9 @@ Backus–Naur Form Grammar for Valid SemVer Versions
                          | <identifier character> <build identifier>

     <non-numeric identifier> ::= <non-digit character>
-                               | <non-digit character> <identifier>
-                               | <identifier> <non-digit character>
-                               | <identifier> <non-digit character> <identifier>
+                               | <non-digit character> <build identifier>
+                               | <build identifier> <non-digit character>
+                               | <build identifier> <non-digit character> <build identifier>

     <non-digit character> ::= <letter> | "-"

Perhaps a better name for <build identifier> would be good? Maybe something like <loose identifier> and <strict identifier>?

@petermichaux

Copy link
Copy Markdown

Where do I see the aggregate change set?

@isaacs

isaacs commented Jun 14, 2013

Copy link
Copy Markdown
Contributor Author

The aggregate from master is on the "files changed" tab. The aggregate from when you first started reviewing is https://gist.github.com/isaacs/5784077

I'm not sure how to get that sort of thing from the github website. If you'd prefer, I can push incremental changes as we discuss, and only squash once you +1 it.

@petermichaux

Copy link
Copy Markdown

Some of the choices for names of things in the BNF could be improved now that it has grown to this stage and perhaps the ordering could be improved but it might be better to have this committed as is and then clean up later. I think this should be intended to be in a version of the standard after 2.0.0 so it can be seen by more people and refined before being official.

The BNF now seems quite complex. That is unfortunate.

@haacked

haacked commented Jun 15, 2013

Copy link
Copy Markdown
Contributor

I think this should be intended to be in a version of the standard after 2.0.0 so it can be seen by more people and refined before being official.

How do others feel about this? I'm all for releasing 2.0 now and having the BNF target 2.1 as it's a clarification of the spec and should not (hopefully) change anything.

@haacked

haacked commented Jun 15, 2013

Copy link
Copy Markdown
Contributor

Also, I need to make time to review it myself. :)

@Tieske

Tieske commented Jun 16, 2013

Copy link
Copy Markdown
Contributor

I'm all for releasing 2.0 now and having the BNF target 2.1 as it's a clarification of the spec

Sounds like a plan... 👍

@EddieGarmon

Copy link
Copy Markdown
Contributor

A proposed simplified and descriptive update to the BNF.
https://github.com/isaacs/semver/pull/1

@haacked

haacked commented Jun 19, 2013

Copy link
Copy Markdown
Contributor

How do we feel about this PR? Ready for my review? Anyone else have any last edits or comments?

@isaacs

isaacs commented Jun 19, 2013

Copy link
Copy Markdown
Contributor Author

@haacked I want to merge in @EddieGarmon's changes into this as well.

@EddieGarmon I like the changes in the PR you sent to my repo. Do you mind if I change the commit messages to be a bit more meaningful?

@haacked

haacked commented Jun 19, 2013

Copy link
Copy Markdown
Contributor

@isaacs sounds good. Just let me know when it's ready.

isaacs and others added 3 commits June 19, 2013 14:04
@isaacs

isaacs commented Jun 19, 2013

Copy link
Copy Markdown
Contributor Author

Landed with @EddieGarmon's changes. Please review, it looks good to me.

@petermichaux It'd be good if you could look over it again as well, if you've got time. Thanks :)

@EddieGarmon

Copy link
Copy Markdown
Contributor

<digits> and <letters> nonterminals are now unused and can be removed. good simplification of <alphanumeric identifier>

@EddieGarmon

Copy link
Copy Markdown
Contributor

Make that 'non-digits'. I'm a doof.

@petermichaux

Copy link
Copy Markdown

<digits> is still used.

@isaacs

isaacs commented Jun 20, 2013

Copy link
Copy Markdown
Contributor Author

@EddieGarmon True that! Updated on 5f00f57

@petermichaux Can you put <> things in back-ticks so that github doesn't think you're trying to haxxor their htmls?

@EddieGarmon

Copy link
Copy Markdown
Contributor

Ship it.

Closes #122

@petermichaux

Copy link
Copy Markdown

<alphanumeric identifier> has grown a lot in complexity. Is that really necessary?

@petermichaux

Copy link
Copy Markdown

<valid semver> does not need to contain "valid". Anything that satisfies a grammar is valid.

@EddieGarmon

Copy link
Copy Markdown
Contributor

<alphanumeric identifier> ensures that there is at least one <non-digit>. if it were only <identifier characters> then then leading zero digit only strings would match, and we do not want that.

@petermichaux

Copy link
Copy Markdown

@EddieGarmon If having at least one non-digit is the only requirement then the following works which is what I had previously.

<alphanumeric identifier> ::= <non-digit>
                            | <non-digit> <identifier characters>
                            | <identifier characters> <non-digit>
                            | <identifier characters> <non-digit> <identifier characters>

@EddieGarmon

Copy link
Copy Markdown
Contributor

And that is what the current pr looks like

@petermichaux

Copy link
Copy Markdown

Whatever it was that I was looking at had several more options for <alphanumeric identifier>. Glad the current pull request is simple.

@isaacs

isaacs commented Jul 6, 2013

Copy link
Copy Markdown
Contributor Author

@haacked @mojombo What's the status of this? I'm getting complains that node-semver "doesn't comply" because versions like "1.0.2alpha2" raise errors now. When I point people at semver.org, they get confused by the wall of english text. A clear grammar needs to be published somewhere.

@haacked

haacked commented Jul 9, 2013

Copy link
Copy Markdown
Contributor

@isaacs I've been pretty busy lately. I'll try to look at it soon.

@EddieGarmon EddieGarmon mentioned this pull request Jul 18, 2013
@haacked

haacked commented Aug 6, 2013

Copy link
Copy Markdown
Contributor

Sorry for the long delay in reviewing this. Great job on this!

picard-clapping

haacked added a commit that referenced this pull request Aug 6, 2013
Add BNF Grammar for valid version strings
@haacked
haacked merged commit f1ab1fa into semver:master Aug 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants