[Issue 18336] Add std.algorithm.untilClosingParens

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 30 15:49:52 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18336

Jack Stouffer <jack at jackstouffer.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jack at jackstouffer.com

--- Comment #1 from Jack Stouffer <jack at jackstouffer.com> ---
I'm wondering how useful something like this would be in real world parsing
situations like math statements or languages. If you have nested parens you'd
have to do recursive calls to untilClosingParentheses to properly break up a
statement like "(5 + (10 - 2))".

Maybe it's be more useful to have some function that returns the following

------
assert("(5 + (10 - 2))".func().equals(
    [tuple(1UL, "5 + "), tuple(2UL, "10 - 2")]
));
assert("7 + (4 * (2^^(-1)))".func().equals(
    [tuple(0UL, "7 + "), tuple(1UL, "4 * "), tuple(2UL, "2^^"), tuple(3UL,
"-1")]
));
------

But at that point I don't know if it would be a good fit for Phobos.

--


More information about the Digitalmars-d-bugs mailing list