Redesign parser state machine from fixed switch-based design to more flexible, data-driven configuration.

This commit is contained in:
Marko Zivanovic
2015-10-09 00:41:15 +02:00
parent 284aa77e13
commit 2e39070287
2 changed files with 106 additions and 72 deletions
+2 -2
View File
@@ -65,11 +65,11 @@ namespace version {
int cmp = compare_normal(l, r);
if (cmp != 0) return cmp;
// release version is always higher than prerelease
// prerelease version is always higher than prerelease
if (l.prerelease_ids.empty() && !r.prerelease_ids.empty()) return 1;
if (r.prerelease_ids.empty() && !l.prerelease_ids.empty()) return -1;
// compare release by looking at each identifier: numeric ones are compared as numbers,
// compare prerelease by looking at each identifier: numeric ones are compared as numbers,
// alphanum as ASCII strings
auto shorter = min(l.prerelease_ids.size(), r.prerelease_ids.size());
for (size_t i = 0; i < shorter; i++) {