[swift-evolution] Strings in Swift 4
sabre at nondot.org
Fri Jan 27 21:55:10 CST 2017
On Jan 27, 2017, at 7:54 PM, Dave Abrahams <dabrahams at apple.com> wrote:
>> Sure, depending on how the grammar is defined, the compiler will know
>> when multiple matches are possible. If multiple matches are possible,
>> it is straight-forward to bind them into an array of results instead
>> of a single scalar result.
> Even an array of subranges is inadequate for the general case; you
> actually need to capture the structure of the parse tree somehow. A
> really simple example would be
> case /((let id: \d+): (let name: \w+)?)+/
> If you're just accumulating arrays, you lose the association of id to
> name as soon as someone decides to omit a name. Designing a system that
> is both super clean for the simple cases and powerful enough to handle
> more complex ones is going to be a fun project.
Yep, that’s what makes it worth doing!
More information about the swift-evolution