Boost C++ Libraries: Ticket #4704: Support for multicapture and balancing groups https://svn.boost.org/trac10/ticket/4704 <p> Feature request ticked to jog Eric Nieblers memory to take a look at some code. </p> <p> I've added support for multicapture and balancing groups to Boost::Xpressive. </p> <p> Syntax for pop capture: </p> <blockquote> <p> dynamic: (?P&lt;-name&gt;stuff)<br /> static: (name -= stuff) </p> </blockquote> <p> Syntax for capture conditional: </p> <blockquote> <p> dynamic: (?P(name)stuff)<br /> static: (name &amp;= stuff) </p> </blockquote> <p> The changes are in the vault and can be found here: <a class="ext-link" href="http://tinyurl.com/3aak7mp"><span class="icon">​</span>http://tinyurl.com/3aak7mp</a> </p> <p> It can be unpacked against trunk from 2010-10-02 or the 1.44.0 release. I've run the dynamic regression tests without errors and I have added some tests for the new functionality. The code it only tested on Visual Studio 2010 since I don't have access to any other compiler. </p> <p> Erik Rydgren </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4704 Trac 1.4.3 Eric Niebler Wed, 06 Oct 2010 18:16:23 GMT status changed https://svn.boost.org/trac10/ticket/4704#comment:1 https://svn.boost.org/trac10/ticket/4704#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Eric Niebler Thu, 07 Oct 2010 00:37:46 GMT <link>https://svn.boost.org/trac10/ticket/4704#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4704#comment:2</guid> <description> <p> The capture conditional: </p> <blockquote class="citation"> <p> dynamic: (?P(name)stuff) </p> </blockquote> <p> Looking at the implementation of this in parse_group, "stuff" is parsed by calling parse_sequence. Is it really the case that stuff can not have alternates? Can I not say "(?P(name)this|that)"? If so, this would be the only grouping construct that does not permit alternates. I have a bad feeling about that. Note that your implementation of that feature ends up returning early---the only one to do so---and doesn't reset the traits flags. In short, this feels like a great big ugly hack to me. Can you clean this up? </p> <p> Also, would be very nice if you followed my coding convention. Eg: </p> <pre class="wiki"> if(this) { // 4 space indent } </pre><p> not this: </p> <pre class="wiki"> if (this) { // 2 space indent } </pre><p> Finally, all these new features need documentation. </p> <p> Still reviewing your code, more comments to come I'm sure. Don't be discouraged, I still am very happy to have your contribution and have every intention of accepting it, once the kinks are worked out. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Thu, 07 Oct 2010 00:46:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4704#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4704#comment:3</guid> <description> <p> In parser_traits.hpp: </p> <pre class="wiki"> case BOOST_XPR_CHAR_(char_type, 'P'): this-&gt;eat_ws_(++begin, end); BOOST_XPR_ENSURE_(begin != end, error_paren, "incomplete extension"); switch(*begin) { case BOOST_XPR_CHAR_(char_type, '&lt;'): this-&gt;eat_ws_(++begin, end); switch (*begin) ^^^^^^^^^^^^^^^ Whoops! Doesn't check that begin != end before dereferencing begin! </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Thu, 07 Oct 2010 00:56:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4704#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4704#comment:4</guid> <description> <p> There's probably a simple answer, but why did you change the handling of <code>token_named_mark</code> to allow the same capture name to be reused? Previously it was an error. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Thu, 07 Oct 2010 01:16:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4704#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4704#comment:5</guid> <description> <p> Oh wait! I just realized from looking at your change to <code>mark_end_matcher</code> that you are <em>always</em> populating the <code>captures</code> member of the <code>sub_match</code> struct (for non-hidden captures). This will have disastrous performance implications. There cannot potentially be an allocation every time you match a marked sub-expression. I can't accept this change. </p> <p> I suggest you find a way to make this behavior opt-in. </p> </description> <category>Ticket</category> </item> <item> <author>Erik Rydgren <erik@…></author> <pubDate>Fri, 08 Oct 2010 00:37:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4704#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4704#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4704#comment:4" title="Comment 4">eric_niebler</a>: </p> <blockquote class="citation"> <p> There's probably a simple answer, but why did you change the handling of <code>token_named_mark</code> to allow the same capture name to be reused? Previously it was an error. </p> </blockquote> <p> I thought it to be nice to have the same capabilities in a dynamic expression as in static one. A static expression (s1 = whatever) &lt;&lt; (s1 = whatever) is perfectly legal but the dynamic compiler frowned upon (?P&lt;name&gt; whatever) (?P&lt;name&gt; whatever). Now they behave the same. It makes it hard to figure out the resulting group numbers though, so these constructs are really only useful when using named multi captures. You can capture on several places in the expression to the same named stack of captures. Can be useful at times. </p> </description> <category>Ticket</category> </item> <item> <author>Erik Rydgren <erik@…></author> <pubDate>Sun, 10 Oct 2010 15:14:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4704#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4704#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4704#comment:5" title="Comment 5">eric_niebler</a>: </p> <blockquote class="citation"> <p> Oh wait! I just realized from looking at your change to <code>mark_end_matcher</code> that you are <em>always</em> populating the <code>captures</code> member of the <code>sub_match</code> struct (for non-hidden captures). This will have disastrous performance implications. There cannot potentially be an allocation every time you match a marked sub-expression. I can't accept this change. </p> <p> I suggest you find a way to make this behavior opt-in. </p> </blockquote> <p> I have now uploaded an updated version of the multicapture functionality. Multicapture is now opt-in with very little impact on performance if not used. </p> <p> Some documentation about multicapture and the new syntax constructs is added and I've also gone over the changes to make sure it follows the same coding standard as the rest of the code. </p> <p> I also changed the mark conditional construct to accept alternates, (?P(name)this|that|andwhatnot). </p> <p> The new syntax for static pop capture required some extra code in the grammar, is_pure and width_of. I would be grateful for some extra reviewing in those areas since I am uncertain that I fully grasp all the details about what's going on there. </p> <p> The new code can be reached through the same URL as the old version. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>matt.c</dc:creator> <pubDate>Thu, 29 Jun 2017 18:58:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4704#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4704#comment:8</guid> <description> <p> Did this ever get integrated? </p> </description> <category>Ticket</category> </item> </channel> </rss>