zafarkhaja / jsemver

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

Fixed expression language to match syntax from https://docs.npmjs.com… #34

Closed tdraier closed 1 year ago

tdraier commented 7 years ago

Hi, I had to change the expression parser to semver range as they are defined by :
https://docs.npmjs.com/misc/semver#range-grammar It's not really compatible with the one defined in https://github.com/zafarkhaja/jsemver/issues/1 - I replaced it, but maybe we could move the code in a separate implementation if you're interested to include it. Regards

nantunes commented 7 years ago

I'm having problems with expressions like ">2.5-alpha".

The version qualifier is ok with the version parser (Version.valueOf( "2.5-alpha" )), but not in version filter expressions (parsedVersion.satisfies( ">2.5-alpha" )).

Illegal character near 'alpha'
    at com.github.zafarkhaja.semver.expr.Lexer.tokenize(Lexer.java:218)
    at com.github.zafarkhaja.semver.expr.ExpressionParser.parse(ExpressionParser.java:86)
    at com.github.zafarkhaja.semver.expr.ExpressionParser.parse(ExpressionParser.java:43)
    at com.github.zafarkhaja.semver.Version.satisfies(Version.java:325)
cixel commented 7 years ago

Looking at the comment @zafarkhaja left here, it seems his intention is for the 2 grammars to be kept separate and used by 2 different parsers.

zafarkhaja commented 1 year ago

Hello Thomas, I hope you're doing well!

I'm sorry it took me this long to get back to you. And I appreciate you taking the time and effort to contribute.

While I'm still not a fan of mixing multiple grammars in a single parser, as @cixel kindly pointed out, these days I'm somewhat more open to the idea of extending the existing parser in a backward-compatible manner, like providing functionality that would fix @nantunes's problems. Also, I think that evolving the existing parser to parse a different grammar is harder and more confusing. Writing a separate parser from scratch would be more comfortable of a process, as I've always planned to. And maybe once SemVer has its official range grammar, we can stick to that.

Have a nice day,