Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the SemVer Expressions API #1

Closed
zafarkhaja opened this issue Mar 31, 2013 · 4 comments
Closed

Implement the SemVer Expressions API #1

zafarkhaja opened this issue Mar 31, 2013 · 4 comments

Comments

@zafarkhaja
Copy link
Owner

The SemVer Expressions API shall consist of a single method boolean Version.satisfies(String expr) which will take a SemVer expression as its argument. Below are examples of what SemVer expressions might look like:

1.*
~1.5
>1.0.0 & <2.0.0
>1.5.0 & !=1.5.10
1.* | 2.*
<=1.9
!(>=1.0 & <2.0)
(0.* | 1.*) & <3

The grammar of the SemVer Expressions is subject to further revision.

As a part of this issue, a SemVer expression parser needs to be implemented as well.

@ghost ghost assigned zafarkhaja Mar 31, 2013
@zafarkhaja
Copy link
Owner Author

Came up with the following BNF grammar for the SemVer Expressions

          <semver-expr> ::= "(" <semver-expr> ")"
                          | "!" "(" <semver-expr> ")"
                          | <semver-expr> <boolean-expr>
                          | <expr>

         <boolean-expr> ::= <boolean-op> <semver-expr>
                          | <epsilon>

           <boolean-op> ::= "&" | "|"

                 <expr> ::= <comparison-expr>
                          | <version-expr>
                          | <tilde-expr>
                          | <range-expr>

      <comparison-expr> ::= <comparison-op> <version> 
                          | <version>

         <version-expr> ::= <major> "." "*"
                          | <major> "." <minor> "." "*"

           <tilde-expr> ::= "~" <version>

           <range-expr> ::= <version> "-" <version>

              <version> ::= <major>
                          | <major> "." <minor>
                          | <major> "." <minor> "." <patch>

        <comparison-op> ::= "=" | "!=" | ">" | ">=" | "<" | "<="

                <major> ::= <numeric-identifier>

                <minor> ::= <numeric-identifier>

                <patch> ::= <numeric-identifier>

   <numeric-identifier> ::= "0"
                          | <positive-digit>
                          | <positive-digit> <numeric-identifier>

       <positive-digit> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

@zafarkhaja
Copy link
Owner Author

Shipped as of version 0.7.0 [3c12426].

@zafarkhaja
Copy link
Owner Author

The BNF grammar update for the 0.9.0 release

          <semver-expr> ::= "(" <semver-expr> ")"
                          | "!" "(" <semver-expr> ")"
                          | <semver-expr> <more-expr>
                          | <range>

            <more-expr> ::= <boolean-op> <semver-expr>
                          | epsilon

           <boolean-op> ::= "&" | "|"

                <range> ::= <comparison-range>
                          | <wildcard-range>
                          | <tilde-range>
                          | <caret-range>
                          | <hyphen-range>
                          | <partial-version-range>

     <comparison-range> ::= <comparison-op> <version> 
                          | <version>

       <wildcard-range> ::= <wildcard>
                          | <major> "." <wildcard>
                          | <major> "." <minor> "." <wildcard>

          <tilde-range> ::= "~" <version>

          <caret-range> ::= "^" <version>

         <hyphen-range> ::= <version> "-" <version>

<partial-version-range> ::= <major>
                          | <major> "." <minor>

              <version> ::= <major>
                          | <major> "." <minor>
                          | <major> "." <minor> "." <patch>

        <comparison-op> ::= "=" | "!=" | ">" | ">=" | "<" | "<="

                <major> ::= <numeric-identifier>

                <minor> ::= <numeric-identifier>

                <patch> ::= <numeric-identifier>

   <numeric-identifier> ::= "0"
                          | <positive-digit>
                          | <positive-digit> <numeric-identifier>

       <positive-digit> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

             <wildcard> ::= "*" | "x" | "X"

@zafarkhaja
Copy link
Owner Author

zafarkhaja commented Jan 30, 2024

A tiny update from the 0.10.0 release

The diff

-<boolean-op> ::= "&" | "|"
+<boolean-op> ::= "&" | "&&" | "|" | "||"

The resulting BNF grammar

          <semver-expr> ::= "(" <semver-expr> ")"
                          | "!" "(" <semver-expr> ")"
                          | <semver-expr> <more-expr>
                          | <range>

            <more-expr> ::= <boolean-op> <semver-expr>
                          | epsilon

           <boolean-op> ::= "&" | "&&" | "|" | "||"

                <range> ::= <comparison-range>
                          | <wildcard-range>
                          | <tilde-range>
                          | <caret-range>
                          | <hyphen-range>
                          | <partial-version-range>

     <comparison-range> ::= <comparison-op> <version> 
                          | <version>

       <wildcard-range> ::= <wildcard>
                          | <major> "." <wildcard>
                          | <major> "." <minor> "." <wildcard>

          <tilde-range> ::= "~" <version>

          <caret-range> ::= "^" <version>

         <hyphen-range> ::= <version> "-" <version>

<partial-version-range> ::= <major>
                          | <major> "." <minor>

              <version> ::= <major>
                          | <major> "." <minor>
                          | <major> "." <minor> "." <patch>

        <comparison-op> ::= "=" | "!=" | ">" | ">=" | "<" | "<="

                <major> ::= <numeric-identifier>

                <minor> ::= <numeric-identifier>

                <patch> ::= <numeric-identifier>

   <numeric-identifier> ::= "0"
                          | <positive-digit>
                          | <positive-digit> <numeric-identifier>

       <positive-digit> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

             <wildcard> ::= "*" | "x" | "X"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant