For those interested in parsing semver 2.0.0 strings: DCG

For those interested in parsing (or more accurately assembling and disassembling) semver 2.0.0 strings like

1.2.0
1.2.0-00x67
1.2.3-00x67+alpha.foo-bar.0099

etc.

There is a Semver 2.0.0 string parser/composer using Prolog’s DCG for your use.

Both source and unit test code are here.

(Note that github can’t syntax-highlight the unit test code. It mistakes a .plt file for gnuplot code, so the result is a bit of a mess.)

The unit tests also include tests for the PCRE (Perl Compatible Regular Expressions) based disassembly. These not essential and can be commented out if one does not want to bother with PCRE.

3 Likes