zafarkhaja / jsemver

Java implementation of the SemVer Specification
MIT License
429 stars 82 forks source link

Implement the SemVer Expressions API #1

Closed zafarkhaja closed 10 years ago

zafarkhaja commented 11 years ago

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.

zafarkhaja commented 10 years ago

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 commented 10 years ago

Shipped as of version 0.7.0 [3c12426].

zafarkhaja commented 9 years ago

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 commented 5 months ago

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"