<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Boost.Spirit &#187; Documentation Addendum</title>
	<atom:link href="http://boost-spirit.com/home/category/documentation-addendum/feed/" rel="self" type="application/rss+xml" />
	<link>http://boost-spirit.com/home</link>
	<description>Home of The Boost.Spirit Library</description>
	<lastBuildDate>Sun, 04 Dec 2011 22:11:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using _val in Top Level Semantic Actions</title>
		<link>http://boost-spirit.com/home/2011/02/26/using-_val-in-top-level-semantic-actions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-_val-in-top-level-semantic-actions</link>
		<comments>http://boost-spirit.com/home/2011/02/26/using-_val-in-top-level-semantic-actions/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 18:35:32 +0000</pubDate>
		<dc:creator>Hartmut Kaiser</dc:creator>
				<category><![CDATA[Documentation Addendum]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Karma]]></category>
		<category><![CDATA[Qi]]></category>

		<guid isPermaLink="false">http://boost-spirit.com/home/?p=1355</guid>
		<description><![CDATA[Frank Dellaert was asking a valid question on the Spirit mailing list where he pointed out some things he was not able to understand. His question clearly uncovered an inconsistency in Spirit’s API. This lead us to implement some minor additional feature, which in the end turned out to make more uniform the way semantic [...]<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (1 vote cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>Frank Dellaert was asking a valid question on the Spirit mailing list where he pointed out some things he was not able to understand. His question clearly uncovered an inconsistency in <em>Spirit’s</em> API. This lead us to implement some minor additional feature, which in the end turned out to make more uniform the way semantic actions are handled.</p>
<p><span id="more-1355"></span></p>
<p>Given the following definitions:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;boost/spirit/include/qi.hpp&gt;
#include &lt;boost/spirit/include/phoenix.hpp&gt;

namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;

class Point3
{
    double x_, y_, z_;
public:
    Point3() : x_(0), y_(0), z_(0) {}
    Point3(double x, double y, double z) : x_(x), y_(y), z_(z) {}
};

Point3 pt3;
std::string input(&quot;1.0,2.0,3.0&quot;);
</pre>
<p>He showed that this piece of code works fine:</p>
<pre class="brush: cpp; title: ; notranslate">
qi::rule&lt;std::string::iterator, Point3()&gt; r =
    (qi::double_ &gt;&gt; ',' &gt;&gt; qi::double_ &gt;&gt; ',' &gt;&gt; qi::double_)
    [
        qi::_val = phoenix::construct&lt;Point3&gt;(qi::_1, qi::_2, qi::_3)
    ];
qi::parse(input.begin(), input.end(), r, pt3);
</pre>
<p>At the same time, this code does not compile:</p>
<pre class="brush: cpp; title: ; notranslate">
qi::parse(
   input.begin(), input.end(),
   (qi::double_ &gt;&gt; ',' &gt;&gt; qi::double_ &gt;&gt; ',' &gt;&gt; qi::double_)
   [
       qi::_val = phoenix::construct&lt;Point3&gt;(qi::_1, qi::_2, qi::_3)
   ],
   pt3);
</pre>
<p>The only difference between the two is that in the first case the parser is wrapped into a rule, while in the second example the parser is directly placed inline into the <span style="font-family: Courier New;">parse()</span> API call. After some investigation I understood, that the placeholder <span style="font-family: Courier New;">qi::_val</span> was only usable in semantic actions attached to some right hand side of a rule. In this context, it referred to the rule’s attribute.</p>
<p>After some discussions on IRC we decided that this limitation in the behavior of <span style="font-family: Courier New;">qi::_val</span> is unneeded and confusing. It turned out that the fix is simple and does not break any existing code. The change, which will be available starting with the next release of Boost (V1.47), has been committed to SVN already. With this change in place it is possible to use the placeholder <span style="font-family: Courier New;">qi::_val</span> in top level semantic actions as well, where it will refer to the whole attribute passed in by the user. This now allows to compile the second code example from above.</p>
<p>Please feel free to try it in your code! Note that the fix has been applied not only to <em>Qi’s</em> set of <span style="font-family: Courier New;">parse()</span> API functions, but also to <em>Karma’s</em> set of <span style="font-family: Courier New;">generate()</span> functions.</p>
<p>Thanks again to Frank for bringing up this detail, which in the end stirred some interesting discussions and which made Spirit a bit easier to use.</p>
<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (1 vote cast)</div><br />]]></content:encoded>
			<wfw:commentRss>http://boost-spirit.com/home/2011/02/26/using-_val-in-top-level-semantic-actions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Attribute Propagation and Attribute Compatibility</title>
		<link>http://boost-spirit.com/home/2011/02/12/attribute-propagation-and-attribute-compatibility/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=attribute-propagation-and-attribute-compatibility</link>
		<comments>http://boost-spirit.com/home/2011/02/12/attribute-propagation-and-attribute-compatibility/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 22:15:46 +0000</pubDate>
		<dc:creator>Hartmut Kaiser</dc:creator>
				<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Documentation Addendum]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[Karma]]></category>
		<category><![CDATA[Qi]]></category>

		<guid isPermaLink="false">http://boost-spirit.com/home/?p=1321</guid>
		<description><![CDATA[Narinder Claire asked a seemingly innocent question on the Spirit mailing list the other day. After starting to write an answer I realized that this question is not innocent at all as it touches the very fabric of Spirit: the rules of attribute handling. Many people have a hard time to properly understand what is [...]<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (2 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>Narinder Claire asked a seemingly innocent question on the Spirit mailing list the other day. After starting to write an answer I realized that this question is not innocent at all as it touches the very fabric of Spirit: the rules of attribute handling. Many people have a hard time to properly understand what is going on in the nether regions of Spirit. More importantly, they have a hard time to understand why is Spirit implemented the way it is.</p>
<p>The new article <a href="http://boost-spirit.com/home/articles/attribute_handling/attribute-propagation-and-attribute-compatibility/">Attribute Propagation and Attribute Compatibility</a> not only answers Narinders questions but tries to explain those important concepts in more detail.</p>
<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (2 votes cast)</div><br />]]></content:encoded>
			<wfw:commentRss>http://boost-spirit.com/home/2011/02/12/attribute-propagation-and-attribute-compatibility/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stream-based Parsing Made Easy</title>
		<link>http://boost-spirit.com/home/2010/01/05/stream-based-parsing-made-easy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=stream-based-parsing-made-easy</link>
		<comments>http://boost-spirit.com/home/2010/01/05/stream-based-parsing-made-easy/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 20:14:22 +0000</pubDate>
		<dc:creator>Hartmut Kaiser</dc:creator>
				<category><![CDATA[Documentation Addendum]]></category>
		<category><![CDATA[Qi]]></category>

		<guid isPermaLink="false">http://boost-spirit.com/home/?p=836</guid>
		<description><![CDATA[We got many questions how to parse data which has to be accessed using a standard input stream (usually a std::istream) without having to read all of the data into memory first. The standard way of iterating over a stream would be to wrap it into a std::istream_iterator, but unfortunately this is not possible. Qi [...]<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (3 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>We got many questions how to parse data which has to be accessed using a standard input stream (usually a <span style="font-family: Courier New;">std::istream</span>) without having to read all of the data into memory first.</p>
<p>The standard way of iterating over a stream would be to wrap it into a <span style="font-family: Courier New;">std::istream_iterator</span>, but unfortunately this is not possible. <em>Qi</em> requires iterators to be at least <a href="http://www.sgi.com/tech/stl/ForwardIterator.html">forward iterators</a>, while the <span style="font-family: Courier New;">std::istream_iterator</span> is an <a href="http://www.sgi.com/tech/stl/InputIterator.html">input iterator</a> only. To overcome this limitation Spirit V2.2 (the next version of Spirit, to be released with Boost V1.42) will implement a new iterator.</p>
<p><span id="more-836"></span></p>
<pre class="brush: cpp; title: ; notranslate">
namespace boost { namespace spirit
{
    // this is functionally equivalent to std::istream_iterator
    template &lt;typename Char, typename Traits = std::char_traits&lt;Char&gt; &gt;
    struct basic_istream_iterator;

    // predefine specialization for 'char'
    typedef basic_istream_iterator&lt;char&gt; istream_iterator;
}}
</pre>
<p>This iterator is functionally equivalent to the <span style="font-family: Courier New;">std::istream_iterator</span> except that it is a <a href="http://www.sgi.com/tech/stl/ForwardIterator.html">forward iterator</a> you can utilize for your Qi parsing needs. Here is an example:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;boost/spirit/include/support_istream_iterator.hpp&gt;

namespace spirit = boost::spirit;

// open file, disable skipping of whitespace
std::ifstream in(&quot;some_data_file&quot;);
in.unsetf(std::ios::skipws);

// wrap istream into iterator
spirit::istream_iterator begin(in);
spirit::istream_iterator end;

// use iterator to parse file data
spirit::qi::parse(begin, end, &lt;...your grammar here...&gt;);
</pre>
<p>This iterator is implemented on top of the <span style="font-family: Courier New;">multi_pass</span> iterator framework, which is documented <a href="http://www.boost.org/doc/libs/1_41_0/libs/spirit/doc/html/spirit/support/multi_pass.html">here</a>. For those curious enough to have a peek: you can access the new iterator from <a href="www.boost.org">Boost</a> SVN <a href="http://svn.boost.org/svn/boost/trunk/boost/spirit/home/support/iterators/istream_iterator.hpp">here</a>. But in order to use it with Boost prior to V1.42 you will need to download the <a href="http://svn.boost.org/svn/boost/trunk/boost/spirit/home/support/iterators/">whole iterators directory</a> from SVN.</p>
<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=5.0" /></div><div>Rating: 5.0/<strong>5</strong> (3 votes cast)</div><br />]]></content:encoded>
			<wfw:commentRss>http://boost-spirit.com/home/2010/01/05/stream-based-parsing-made-easy/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>FAQ</title>
		<link>http://boost-spirit.com/home/2009/12/21/faq/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=faq</link>
		<comments>http://boost-spirit.com/home/2009/12/21/faq/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 07:17:06 +0000</pubDate>
		<dc:creator>Joel de Guzman</dc:creator>
				<category><![CDATA[Documentation Addendum]]></category>

		<guid isPermaLink="false">http://boost-spirit.com/home/?p=806</guid>
		<description><![CDATA[I added a page for FAQ entries. This page will contain FAQ entries which will eventually be incorporated into the FAQ section of the documentation. See the page here. Rating: 0.0/5 (0 votes cast)<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>I added a page for FAQ entries. This page will contain FAQ entries which will eventually be incorporated into the FAQ section of the documentation.</p>
<p><a href="http://boost-spirit.com/home/articles/doc-addendum/faq/">See the page here.</a></p>
<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=0.0" /></div><div>Rating: 0.0/<strong>5</strong> (0 votes cast)</div><br />]]></content:encoded>
			<wfw:commentRss>http://boost-spirit.com/home/2009/12/21/faq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Support (Doc Addendum)</title>
		<link>http://boost-spirit.com/home/2009/11/19/debugging-support-doc-addendum/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugging-support-doc-addendum</link>
		<comments>http://boost-spirit.com/home/2009/11/19/debugging-support-doc-addendum/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 05:44:12 +0000</pubDate>
		<dc:creator>Joel de Guzman</dc:creator>
				<category><![CDATA[Documentation Addendum]]></category>
		<category><![CDATA[Addendum]]></category>
		<category><![CDATA[Documentation]]></category>

		<guid isPermaLink="false">http://boost-spirit.com/home/?p=546</guid>
		<description><![CDATA[Somehow, this did not make it into the 2.1 documentation. This important piece of information shouldn&#8217;t languish too far into the abyss. So here it is&#8230; Rating: 2.0/5 (1 vote cast)<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=2.0" /></div><div>Rating: 2.0/<strong>5</strong> (1 vote cast)</div><br />]]></description>
			<content:encoded><![CDATA[<p>Somehow, this did not make it into the 2.1 documentation. This important piece of information shouldn&#8217;t languish too far into the abyss. <a href="http://boost-spirit.com/home/?page_id=540">So here it is&#8230;</a></p>
<br /><div><img src="http://boost-spirit.com/home/wp-content/plugins/gd-star-rating/gfx.php?value=2.0" /></div><div>Rating: 2.0/<strong>5</strong> (1 vote cast)</div><br />]]></content:encoded>
			<wfw:commentRss>http://boost-spirit.com/home/2009/11/19/debugging-support-doc-addendum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

