On Jan 27, 2017, at 7:54 PM, Dave Abrahams <[email protected]> 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! -Chris _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
