News for hackers. Stuff that matters.
Re:Parsers don't have to be complicated by alexjurkiewicz on Friday August 07, 2026 @05:56AM (#49208092)
> if (!line.accept('[').isEmpty() ) // [section] header.

Is this really ergonomic?

Re:Parsers don't have to be complicated by derdi on Friday August 07, 2026 @08:04AM (#49209129)
It's not, and the article's attempt at putting lipstick on this pig is nonsensical:

> 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());
Re:Parsers don't have to be complicated by roaringrocky on Friday August 07, 2026 @07:19AM (#49208683)
Yeah those all read a bit brain teasy to me.

"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...".