> if (!line.accept('[').isEmpty() ) // [section] header.
Is this really ergonomic?
Is this really ergonomic?
> StringView has no operator bool, so a successful match reads as !scanner.accept('=').isEmpty(). Noisier than returning a bool, but the matched text comes back with the answer instead of requiring a second call to go get it.
Clearly there is a second call, it's the call to isEmpty. Plus, the actual text is lost in this particual example (though we know what it was).
An actual ergonomic way of using this would set things up so that the INI parser's inner code could be written something like this:
bool success =
(name = trim(acceptUntil('='))) &&
accept('=') &&
accept(Space) &&
(property = acceptAll());"if not accept this character, so this is skipping the match, oh wait, if the result of trying to match is empty, no wait again, it was not empty, i.,e we ARE matching...".