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.

The README, as well as 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.

Update:

After a few months, I have made available a corresponding SWI-Prolog pack.

  • The README describes how to install it.
  • The pack comes in the form of a .tgz file in this directory on github. Currently: onepointfour_semver-0.9.tgz. It is of course very small: 8 KiB. Check out the directory for the latest version.
4 Likes