Boost C++ Libraries: Ticket #10193: [Spirit.qi] real_parser is too strict with the exponent part https://svn.boost.org/trac10/ticket/10193 <p> E.g. parsing "4em" string fails with </p> <pre class="wiki">double_ &gt;&gt; lit("em") </pre><p> "e" is considered start of exponent part and integer is expected after it. </p> <p> Exponent handling as described in documentation as follows: </p> <pre class="wiki">exponent_part = (lit('e') | 'E') &gt;&gt; -sign &gt;&gt; +digit ; </pre><p> But as it is implemented now, grammar should be: </p> <pre class="wiki">exponent_part = (lit('e') | 'E') &gt; -sign &gt; +digit ; </pre><p> It will be better if "e" is treated as exponent part only if it is followed by integer (with optional sign). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10193 Trac 1.4.3 viboes Wed, 23 Jul 2014 21:08:19 GMT component changed; owner set https://svn.boost.org/trac10/ticket/10193#comment:1 https://svn.boost.org/trac10/ticket/10193#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Joel de Guzman</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">spirit</span> </li> </ul> Ticket Joel de Guzman Thu, 24 Jul 2014 01:03:37 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10193#comment:2 https://svn.boost.org/trac10/ticket/10193#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> No, that is incorrect. '4e' is a valid real number even without an integer following it. The grammar in the docs is correct. No exceptions are thrown. It parses '4e' just fine. If that's not you want, then you can customize the real number parser. </p> <p> See <a class="ext-link" href="http://en.cppreference.com/w/cpp/language/floating_literal"><span class="icon">​</span>http://en.cppreference.com/w/cpp/language/floating_literal</a> </p> <p> If you do not agree with this, please start a discussion in the Spirit mailing list. I'm closing this one as invalid. </p> Ticket olegmax@… Mon, 11 Aug 2014 07:05:47 GMT <link>https://svn.boost.org/trac10/ticket/10193#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10193#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10193#comment:2" title="Comment 2">djowel</a>: </p> <blockquote class="citation"> <p> The grammar in the docs is correct. It parses '4e' just fine. </p> </blockquote> <p> No, it is not. exponent_part grammar in docs <strong>requires</strong> at least one digit after 'e'. How can it match '4e'? </p> </description> <category>Ticket</category> </item> <item> <author>olegmax@…</author> <pubDate>Mon, 11 Aug 2014 07:07:08 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/10193#comment:4 https://svn.boost.org/trac10/ticket/10193#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> Ticket Joel de Guzman Mon, 11 Aug 2014 08:46:22 GMT <link>https://svn.boost.org/trac10/ticket/10193#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10193#comment:5</guid> <description> <p> Sorry, you are right. OK, let me try again... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Mon, 11 Aug 2014 09:10:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10193#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10193#comment:6</guid> <description> <p> OK, second try. Pardon the confusion. 42e is indeed not valid. What was I thinking! </p> <p> OK, here's what's happening. The parser parses 4e and attempts to find a number after that. So, 4em is not a double number and it fails. If I understand correctly, what you want is this: </p> <blockquote> <p> exponent_part = -((lit('e') | 'E') &gt;&gt; -sign &gt;&gt; +digit); </p> </blockquote> <p> Is that correct? In other words, the whole exponent part is optional. I think that makes sense. I reopened this as a bug. </p> </description> <category>Ticket</category> </item> <item> <author>olegmax@…</author> <pubDate>Mon, 11 Aug 2014 09:40:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10193#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10193#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10193#comment:6" title="Comment 6">djowel</a>: </p> <blockquote class="citation"> <p> If I understand correctly, what you want is this: </p> <blockquote> <p> exponent_part = -((lit('e') | 'E') &gt;&gt; -sign &gt;&gt; +digit); </p> </blockquote> </blockquote> <p> <a href="http://www.boost.org/doc/libs/1_56_0/libs/spirit/doc/html/spirit/qi/reference/numeric/real.html">Grammar</a> in documentation is already treats exponent_part as optional. So, preferred solution for me as a library user is to sync code with existing grammar description. Not sure whether you may break backward compatibility in this case. May be additional option should be added... </p> <p> Btw, grammar in documentation doesn't permit dot before exponent part (integer only mantissa), but I'm almost sure that actual code permits it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Mon, 11 Aug 2014 09:55:39 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10193#comment:8 https://svn.boost.org/trac10/ticket/10193#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket Joel de Guzman Mon, 11 Aug 2014 09:57:46 GMT <link>https://svn.boost.org/trac10/ticket/10193#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10193#comment:9</guid> <description> <p> It's fixed now in devel branch. Thanks for your diligence and sorry for my confusion. </p> </description> <category>Ticket</category> </item> </channel> </rss>