1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>The utree data structure</title> 5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../index.html" title="Spirit 2.5.8"> 8<link rel="up" href="../support.html" title="Supporting Libraries"> 9<link rel="prev" href="line_pos_iterator.html" title="The line position iterator"> 10<link rel="next" href="../faq.html" title="Spirit FAQ"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="line_pos_iterator.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../support.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../faq.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="spirit.support.utree"></a><a class="link" href="utree.html" title="The utree data structure">The utree data structure</a> 28</h3></div></div></div> 29<p> 30 <code class="computeroutput"><span class="identifier">utree</span></code> is a dynamically-typed 31 hierarchical data structure that can represent abstract syntax trees. It's 32 well integrated with <span class="emphasis"><em>Spirit.Qi</em></span> and <span class="emphasis"><em>Spirit.Karma</em></span>. 33 <code class="computeroutput"><span class="identifier">utree</span></code> can be passed as an 34 attribute to almost any grammar. <code class="computeroutput"><span class="identifier">utree</span></code>'s 35 type system is implemented through the use of a discriminated union and type 36 punning. 37 </p> 38<p> 39 <code class="computeroutput"><span class="identifier">utree</span></code> has a minimal memory 40 footprint. The data structure size is 16 bytes on a 32-bit platform, and 41 32 bytes on 64-bit a platform (<code class="computeroutput"><span class="number">4</span><span class="special">*</span><span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">void</span><span class="special">*)</span></code>). Being 42 a container of itself, it can represent tree structures. 43 </p> 44<p> 45 Each instance of an <code class="computeroutput"><span class="identifier">utree</span></code> 46 data structure can store exactly one of the following data types at a time: 47 </p> 48<p> 49</p> 50<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">utree_type</span> 51<span class="special">{</span> 52 <span class="keyword">enum</span> <span class="identifier">info</span> 53 <span class="special">{</span> 54 <span class="identifier">invalid_type</span><span class="special">,</span> <span class="comment">// the utree has not been initialized (it's </span> 55 <span class="comment">// default constructed)</span> 56 <span class="identifier">nil_type</span><span class="special">,</span> <span class="comment">// nil is the sentinel (empty) utree type.</span> 57 <span class="identifier">list_type</span><span class="special">,</span> <span class="comment">// A doubly linked list of utrees.</span> 58 <span class="identifier">range_type</span><span class="special">,</span> <span class="comment">// A range of list::iterators. </span> 59 <span class="identifier">reference_type</span><span class="special">,</span> <span class="comment">// A reference to another utree.</span> 60 <span class="identifier">any_type</span><span class="special">,</span> <span class="comment">// A pointer or reference to any C++ type. </span> 61 <span class="identifier">function_type</span><span class="special">,</span> <span class="comment">// A utree holding a stored_function<F> object,</span> 62 <span class="comment">// where F is an unary function object taking a </span> 63 <span class="comment">// utree as it's parameter and returning a</span> 64 <span class="comment">// utree.</span> 65 66 <span class="comment">// numeric atoms</span> 67 <span class="identifier">bool_type</span><span class="special">,</span> <span class="comment">// An utree holding a boolean value</span> 68 <span class="identifier">int_type</span><span class="special">,</span> <span class="comment">// An utree holding a integer (int) value</span> 69 <span class="identifier">double_type</span><span class="special">,</span> <span class="comment">// An utree holding a floating point (double) value</span> 70 71 <span class="comment">// text atoms (utf8)</span> 72 <span class="identifier">string_type</span><span class="special">,</span> <span class="comment">// An UTF-8 string </span> 73 <span class="identifier">string_range_type</span><span class="special">,</span> <span class="comment">// A pair of iterators into an UTF-8 string</span> 74 <span class="identifier">symbol_type</span><span class="special">,</span> <span class="comment">// An UTF-8 symbol name</span> 75 76 <span class="identifier">binary_type</span> <span class="comment">// Arbitrary binary data</span> 77 <span class="special">};</span> 78 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_t</span><span class="special"><</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">info</span><span class="special">)*</span><span class="number">8</span><span class="special">>::</span><span class="identifier">exact</span> <span class="identifier">exact_integral_type</span><span class="special">;</span> 79 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_t</span><span class="special"><</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">info</span><span class="special">)*</span><span class="number">8</span><span class="special">>::</span><span class="identifier">fast</span> <span class="identifier">fast_integral_type</span><span class="special">;</span> 80<span class="special">};</span> 81</pre> 82<p> 83 </p> 84<p> 85 The UTF-8 string, UTF-8 symbol, and binary data types are internally stored 86 either directly as the node data (small string optimization applied), or 87 they are allocated from the heap, storing the pointer to the allocated data 88 in the <code class="computeroutput"><span class="identifier">utree</span></code>. The maximum 89 possible length of the data to be stored in the node data depends on the 90 platform the <code class="computeroutput"><span class="identifier">utree</span></code> is compiled 91 for. It is 14 bytes for a 32-bit platform and 30 bytes for a 64-bit platform. 92 </p> 93<h5> 94<a name="spirit.support.utree.h0"></a> 95 <span class="phrase"><a name="spirit.support.utree.class_reference"></a></span><a class="link" href="utree.html#spirit.support.utree.class_reference">Class 96 Reference</a> 97 </h5> 98<p> 99 The <code class="computeroutput"><span class="identifier">utree</span></code> data structure 100 is very versatile and can be used as an attribute for all possible <span class="emphasis"><em>Spirit.Qi</em></span> 101 parsers and <span class="emphasis"><em>Spirit.Karma</em></span> generators. For this reason, 102 it exposes a set of typedef's making it compatible with STL containers: 103 </p> 104<p> 105</p> 106<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">utree</span> <span class="identifier">value_type</span><span class="special">;</span> 107<span class="keyword">typedef</span> <span class="identifier">utree</span><span class="special">&</span> <span class="identifier">reference</span><span class="special">;</span> 108<span class="keyword">typedef</span> <span class="identifier">utree</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">const_reference</span><span class="special">;</span> 109<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ptrdiff_t</span> <span class="identifier">difference_type</span><span class="special">;</span> 110<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size_type</span><span class="special">;</span> 111 112<span class="keyword">typedef</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">list</span><span class="special">::</span><span class="identifier">node_iterator</span><span class="special"><</span><span class="identifier">utree</span><span class="special">></span> <span class="identifier">iterator</span><span class="special">;</span> 113<span class="keyword">typedef</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">list</span><span class="special">::</span><span class="identifier">node_iterator</span><span class="special"><</span><span class="identifier">utree</span> <span class="keyword">const</span><span class="special">></span> <span class="identifier">const_iterator</span><span class="special">;</span> 114</pre> 115<p> 116 </p> 117<p> 118 The <code class="computeroutput"><span class="identifier">utree</span></code> data type exposes 119 the functional interface of a bidirectional STL container. The iterators 120 returned from <code class="computeroutput"><span class="identifier">begin</span><span class="special">()</span></code> 121 et.al. conform to the Standard requirements of a bidirectional iterator. 122 </p> 123<p> 124</p> 125<pre class="programlisting"><span class="comment">// STL Container interface</span> 126 127<span class="comment">// insertion </span> 128<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 129<span class="keyword">void</span> <span class="identifier">push_back</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&);</span> 130<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 131<span class="keyword">void</span> <span class="identifier">push_front</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&);</span> 132<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 133<span class="identifier">iterator</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&);</span> 134<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 135<span class="keyword">void</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&);</span> 136<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Iterator</span><span class="special">></span> 137<span class="keyword">void</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">iterator</span><span class="special">,</span> <span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">Iterator</span><span class="special">);</span> 138 139<span class="comment">// erasure</span> 140<span class="keyword">void</span> <span class="identifier">pop_front</span><span class="special">();</span> 141<span class="keyword">void</span> <span class="identifier">pop_back</span><span class="special">();</span> 142<span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span><span class="special">);</span> 143<span class="identifier">iterator</span> <span class="identifier">erase</span><span class="special">(</span><span class="identifier">iterator</span><span class="special">,</span> <span class="identifier">iterator</span><span class="special">);</span> 144 145<span class="comment">// front access</span> 146<span class="identifier">reference</span> <span class="identifier">front</span><span class="special">();</span> 147<span class="identifier">const_reference</span> <span class="identifier">front</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> 148<span class="identifier">iterator</span> <span class="identifier">begin</span><span class="special">();</span> 149<span class="identifier">const_iterator</span> <span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> 150<span class="identifier">ref_iterator</span> <span class="identifier">ref_begin</span><span class="special">();</span> 151 152<span class="comment">// back access</span> 153<span class="identifier">reference</span> <span class="identifier">back</span><span class="special">();</span> 154<span class="identifier">const_reference</span> <span class="identifier">back</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> 155<span class="identifier">iterator</span> <span class="identifier">end</span><span class="special">();</span> 156<span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> 157<span class="identifier">ref_iterator</span> <span class="identifier">ref_end</span><span class="special">();</span> 158</pre> 159<p> 160 </p> 161<p> 162 The exposed container interface makes the <code class="computeroutput"><span class="identifier">utree</span></code> 163 usable with all <span class="emphasis"><em>Spirit.Qi</em></span> parser and <span class="emphasis"><em>Spirit.Karma</em></span> 164 generator components, which are compatible with an STL container attribute 165 type. 166 </p> 167<p> 168 A <code class="computeroutput"><span class="identifier">utree</span></code> can be constructed 169 or initialized from a wide range of data types, allowing to create <code class="computeroutput"><span class="identifier">utree</span></code> instances for every possible node 170 type (see the description of <code class="computeroutput"><span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">info</span></code> 171 above). For this reason it exposes a constructor and an assignment operator 172 for each of the allowed node types as shown below. All constructors are non-explicit 173 on purpose, allowing to use an utree instance as the attribute to almost 174 any Qi parser. 175 </p> 176<p> 177</p> 178<pre class="programlisting"><span class="comment">// This constructs an `invalid_type` node. When used in places</span> 179<span class="comment">// where a boost::optional is expected (i.e. as an attribute for the </span> 180<span class="comment">// optional component), this represents the 'empty' state.</span> 181<span class="identifier">utree</span><span class="special">(</span><span class="identifier">invalid_type</span> <span class="special">=</span> <span class="identifier">invalid_type</span><span class="special">());</span> 182 183<span class="comment">// This initializes a `nil_type` node, which represents a valid,</span> 184<span class="comment">// 'initialized empty' utree (different from invalid_type!).</span> 185<span class="identifier">utree</span><span class="special">(</span><span class="identifier">nil_type</span><span class="special">);</span> 186<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">nil_type</span><span class="special">);</span> 187 188<span class="comment">// This initializes a `boolean_type` node, which can hold 'true' or</span> 189<span class="comment">// 'false' only.</span> 190<span class="keyword">explicit</span> <span class="identifier">utree</span><span class="special">(</span><span class="keyword">bool</span><span class="special">);</span> 191<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">bool</span><span class="special">);</span> 192 193<span class="comment">// This initializes an `integer_type` node, which can hold arbitrary </span> 194<span class="comment">// integers. For convenience these functions are overloaded for signed</span> 195<span class="comment">// and unsigned integer types.</span> 196<span class="identifier">utree</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">);</span> 197<span class="identifier">utree</span><span class="special">(</span><span class="keyword">int</span><span class="special">);</span> 198<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">);</span> 199<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">int</span><span class="special">);</span> 200 201<span class="comment">// This initializes a `double_type` node, which can hold arbitrary </span> 202<span class="comment">// floating point (double) values.</span> 203<span class="identifier">utree</span><span class="special">(</span><span class="keyword">double</span><span class="special">);</span> 204<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">double</span><span class="special">);</span> 205 206<span class="comment">// This initializes a `string_type` node, which can hold a narrow </span> 207<span class="comment">// character sequence (usually an UTF-8 string).</span> 208<span class="identifier">utree</span><span class="special">(</span><span class="keyword">char</span><span class="special">);</span> 209<span class="identifier">utree</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*);</span> 210<span class="identifier">utree</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">);</span> 211<span class="identifier">utree</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&);</span> 212<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">char</span><span class="special">);</span> 213<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*);</span> 214<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&);</span> 215 216<span class="comment">// This constructs a `string_range_type` node, which does not copy the </span> 217<span class="comment">// data but stores the iterator range to the character sequence the </span> 218<span class="comment">// range has been initialized from.</span> 219<span class="identifier">utree</span><span class="special">(</span><span class="identifier">utf8_string_range_type</span> <span class="keyword">const</span><span class="special">&,</span> <span class="identifier">shallow_tag</span><span class="special">);</span> 220 221<span class="comment">// This initializes a `reference_type` node, which holds a reference to </span> 222<span class="comment">// another utree node. All operations on such a node are automatically</span> 223<span class="comment">// forwarded to the referenced utree instance.</span> 224<span class="identifier">utree</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special"><</span><span class="identifier">utree</span><span class="special">>);</span> 225<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special"><</span><span class="identifier">utree</span><span class="special">>);</span> 226 227<span class="comment">// This initializes an `any_type` node, which can hold a pointer to an</span> 228<span class="comment">// instance of any type together with the typeid of that type. When </span> 229<span class="comment">// accessing that pointer the typeid will be checked, causing a </span> 230<span class="comment">// std::bad_cast to be thrown if the typeids do not match.</span> 231<span class="identifier">utree</span><span class="special">(</span><span class="identifier">any_ptr</span> <span class="keyword">const</span><span class="special">&);</span> 232<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">any_ptr</span> <span class="keyword">const</span><span class="special">&);</span> 233 234<span class="comment">// This initializes a `range_type` node, which holds an utree list node</span> 235<span class="comment">// the elements of which are copy constructed (assigned) from the </span> 236<span class="comment">// elements referenced by the given range of iterators.</span> 237<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Iterator</span><span class="special">></span> 238<span class="identifier">utree</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">>);</span> 239<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Iterator</span><span class="special">></span> 240<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">>);</span> 241 242<span class="comment">// This initializes a `function_type` node from a polymorphic function</span> 243<span class="comment">// object pointer (takes ownership) or reference. </span> 244<span class="identifier">utree</span><span class="special">(</span><span class="identifier">function_base</span> <span class="keyword">const</span><span class="special">&);</span> 245<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">function_base</span> <span class="keyword">const</span><span class="special">&);</span> 246<span class="identifier">utree</span><span class="special">(</span><span class="identifier">function_base</span><span class="special">*);</span> 247<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">function_base</span><span class="special">*);</span> 248 249<span class="comment">// This initializes either a `string_type`, a `symbol_type`, or a </span> 250<span class="comment">// `binary_type` node (depending on the template parameter `type_`), </span> 251<span class="comment">// which will hold the corresponding narrow character sequence (usually </span> 252<span class="comment">// an UTF-8 string).</span> 253<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Base</span><span class="special">,</span> <span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">info</span> <span class="identifier">type_</span><span class="special">></span> 254<span class="identifier">utree</span><span class="special">(</span><span class="identifier">basic_string</span><span class="special"><</span><span class="identifier">Base</span><span class="special">,</span> <span class="identifier">type_</span><span class="special">></span> <span class="keyword">const</span><span class="special">&);</span> 255<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Base</span><span class="special">,</span> <span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">info</span> <span class="identifier">type_</span><span class="special">></span> 256<span class="identifier">reference</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">basic_string</span><span class="special"><</span><span class="identifier">Base</span><span class="special">,</span> <span class="identifier">type_</span><span class="special">></span> <span class="keyword">const</span><span class="special">&);</span> 257</pre> 258<p> 259 </p> 260<p> 261 The <code class="computeroutput"><span class="identifier">utree</span></code> data type exposes 262 the functional interface compatible to <a href="http://www.boost.org/doc/html/variant.html" target="_top">Boost.Variant</a> 263 as well. Its very nature is to hold different data types, one at each point 264 in time, making it functionally very similar to <a href="http://www.boost.org/doc/html/variant.html" target="_top">Boost.Variant</a>. 265 </p> 266<p> 267</p> 268<pre class="programlisting"><span class="comment">// return the data type (`utree_type::info`) of the currently stored </span> 269<span class="comment">// data item</span> 270<span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">info</span> <span class="identifier">which</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> 271 272<span class="comment">// access the currently stored data in a type safe manner, this will </span> 273<span class="comment">// throw a `std::bad_cast()` if the currently stored data item is not </span> 274<span class="comment">// default convertible to `T`.</span> 275<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 276<span class="identifier">T</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> 277</pre> 278<p> 279 </p> 280<p> 281 The exposed variant-like interface makes the <code class="computeroutput"><span class="identifier">utree</span></code> 282 usable with all <span class="emphasis"><em>Spirit.Qi</em></span> parser and <span class="emphasis"><em>Spirit.Karma</em></span> 283 generator components, which are compatible with an <a href="http://www.boost.org/doc/html/variant.html" target="_top">Boost.Variant</a> 284 attribute type. 285 </p> 286<h5> 287<a name="spirit.support.utree.h1"></a> 288 <span class="phrase"><a name="spirit.support.utree.string_types"></a></span><a class="link" href="utree.html#spirit.support.utree.string_types">String 289 Types</a> 290 </h5> 291<p> 292 The <code class="computeroutput"><span class="identifier">utree</span></code> string types described 293 below are used by the <code class="computeroutput"><span class="identifier">utree</span></code> 294 API only. These are not used to store information in the <code class="computeroutput"><span class="identifier">utree</span></code> 295 itself. Their purpose is to refer to different internal <code class="computeroutput"><span class="identifier">utree</span></code> 296 node types only. For instance, creating a <code class="computeroutput"><span class="identifier">utree</span></code> 297 from a binary data type will create a <code class="computeroutput"><span class="identifier">binary_type</span></code> 298 utree node (see above). 299 </p> 300<p> 301 The binary data type can be represented either verbatim as a sequence of 302 bytes or as a pair of iterators into some other stored binary data sequence. 303 Use this string type to access/create a <code class="computeroutput"><span class="identifier">binary_type</span></code> 304 <code class="computeroutput"><span class="identifier">utree</span></code>. 305 </p> 306<p> 307</p> 308<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">basic_string</span><span class="special"><</span> 309 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special"><</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*>,</span> <span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">binary_type</span> 310<span class="special">></span> <span class="identifier">binary_range_type</span><span class="special">;</span> 311<span class="keyword">typedef</span> <span class="identifier">basic_string</span><span class="special"><</span> 312 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">binary_type</span> 313<span class="special">></span> <span class="identifier">binary_string_type</span><span class="special">;</span> 314</pre> 315<p> 316 </p> 317<p> 318 The UTF-8 string can be represented either verbatim as a sequence of characters 319 or as a pair of iterators into some other stored binary data sequence. Use 320 this string type to access/create a <code class="computeroutput"><span class="identifier">string_type</span></code> 321 <code class="computeroutput"><span class="identifier">utree</span></code>. 322 </p> 323<p> 324</p> 325<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">basic_string</span><span class="special"><</span> 326 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special"><</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*>,</span> <span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">string_type</span> 327<span class="special">></span> <span class="identifier">utf8_string_range_type</span><span class="special">;</span> 328<span class="keyword">typedef</span> <span class="identifier">basic_string</span><span class="special"><</span> 329 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">string_type</span> 330<span class="special">></span> <span class="identifier">utf8_string_type</span><span class="special">;</span> 331</pre> 332<p> 333 </p> 334<p> 335 The UTF-8 symbol can be represented either verbatim as a sequence of characters 336 or as a pair of iterators into some other stored binary data sequence. Use 337 this string type to access/create a <code class="computeroutput"><span class="identifier">symbol_type</span></code> 338 <code class="computeroutput"><span class="identifier">utree</span></code>. 339 </p> 340<p> 341</p> 342<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">basic_string</span><span class="special"><</span> 343 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special"><</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*>,</span> <span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">symbol_type</span> 344<span class="special">></span> <span class="identifier">utf8_symbol_range_type</span><span class="special">;</span> 345<span class="keyword">typedef</span> <span class="identifier">basic_string</span><span class="special"><</span> 346 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">utree_type</span><span class="special">::</span><span class="identifier">symbol_type</span> 347<span class="special">></span> <span class="identifier">utf8_symbol_type</span><span class="special">;</span> 348</pre> 349<p> 350 </p> 351<h5> 352<a name="spirit.support.utree.h2"></a> 353 <span class="phrase"><a name="spirit.support.utree.function_object_interface"></a></span><a class="link" href="utree.html#spirit.support.utree.function_object_interface">Function 354 Object Interface</a> 355 </h5> 356<p> 357 The stored_function template class can to store a unary function objects 358 with a signature of utree(scope const&) as a utree node. 359 </p> 360<p> 361</p> 362<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">function_base</span> 363<span class="special">{</span> 364 <span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">function_base</span><span class="special">()</span> <span class="special">{}</span> 365 <span class="keyword">virtual</span> <span class="identifier">utree</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">utree</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">env</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> 366 <span class="keyword">virtual</span> <span class="identifier">utree</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">utree</span><span class="special">&</span> <span class="identifier">env</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> 367 368 <span class="comment">// Calling f.clone() must return a newly allocated function_base </span> 369 <span class="comment">// instance that is equal to f.</span> 370 <span class="keyword">virtual</span> <span class="identifier">function_base</span><span class="special">*</span> <span class="identifier">clone</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> 371<span class="special">};</span> 372 373<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">F</span><span class="special">></span> 374<span class="keyword">struct</span> <span class="identifier">stored_function</span> <span class="special">:</span> <span class="identifier">function_base</span> 375<span class="special">{</span> 376 <span class="identifier">F</span> <span class="identifier">f</span><span class="special">;</span> 377 <span class="identifier">stored_function</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">F</span><span class="special">());</span> 378 <span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">stored_function</span><span class="special">();</span> 379 <span class="keyword">virtual</span> <span class="identifier">utree</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">utree</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">env</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 380 <span class="keyword">virtual</span> <span class="identifier">utree</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">utree</span><span class="special">&</span> <span class="identifier">env</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 381 <span class="keyword">virtual</span> <span class="identifier">function_base</span><span class="special">*</span> <span class="identifier">clone</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> 382<span class="special">};</span> 383 384<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">F</span><span class="special">></span> 385<span class="keyword">struct</span> <span class="identifier">referenced_function</span> <span class="special">:</span> <span class="identifier">function_base</span> 386<span class="special">{</span> 387 <span class="identifier">F</span><span class="special">&</span> <span class="identifier">f</span><span class="special">;</span> 388 <span class="identifier">referenced_function</span><span class="special">(</span><span class="identifier">F</span><span class="special">&</span> <span class="identifier">f</span><span class="special">);</span> 389 <span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">referenced_function</span><span class="special">();</span> 390 <span class="keyword">virtual</span> <span class="identifier">utree</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">utree</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">env</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 391 <span class="keyword">virtual</span> <span class="identifier">utree</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">utree</span><span class="special">&</span> <span class="identifier">env</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 392 <span class="keyword">virtual</span> <span class="identifier">function_base</span><span class="special">*</span> <span class="identifier">clone</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> 393<span class="special">};</span> 394</pre> 395<p> 396 </p> 397<h5> 398<a name="spirit.support.utree.h3"></a> 399 <span class="phrase"><a name="spirit.support.utree.exceptions"></a></span><a class="link" href="utree.html#spirit.support.utree.exceptions">Exceptions</a> 400 </h5> 401<p> 402 All exceptions thrown by utree are derived from utree_exception. 403 </p> 404<p> 405</p> 406<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">BOOST_SYMBOL_VISIBLE</span> <span class="identifier">utree_exception</span> <span class="special">:</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span> <span class="special">{};</span> 407</pre> 408<p> 409 </p> 410<p> 411 The <code class="computeroutput"><span class="identifier">bad_type_exception</span></code> is 412 thrown whenever somebody calls a member function, which applies to certain 413 stored utree_type's only, but this precondition is violated as the <code class="computeroutput"><span class="identifier">utree</span></code> instance holds some other type. 414 </p> 415<p> 416</p> 417<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">bad_type_exception</span> <span class="comment">/*: utree_exception*/</span><span class="special">;</span> 418</pre> 419<p> 420 </p> 421<p> 422 The <code class="computeroutput"><span class="identifier">empty_exception</span></code> is thrown 423 whenever a precondition of a list or range utree method is violated due to 424 the list or range being empty. 425 </p> 426<p> 427</p> 428<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">empty_exception</span> <span class="comment">/*: utree_exception*/</span><span class="special">;</span> 429</pre> 430<p> 431 </p> 432<h5> 433<a name="spirit.support.utree.h4"></a> 434 <span class="phrase"><a name="spirit.support.utree.example__sexpr_parser"></a></span><a class="link" href="utree.html#spirit.support.utree.example__sexpr_parser">Example: 435 Sexpr Parser</a> 436 </h5> 437<p> 438 Our first example demonstrates how to use <code class="computeroutput"><span class="identifier">utree</span></code> 439 to write a parser for <a href="http://en.wikipedia.org/wiki/S-expression" target="_top">symbolic 440 expressions</a>. While <code class="computeroutput"><span class="identifier">utree</span></code> 441 is capable of representing just about any AST, <code class="computeroutput"><span class="identifier">utree</span></code>'s 442 design is based on the simple yet powerful nature of symbolic expressions. 443 This example introduces a number of basic and intermediate <code class="computeroutput"><span class="identifier">utree</span></code> development techniques: using <span class="emphasis"><em>Spirit.Qi</em></span> 444 and <span class="emphasis"><em>Spirit.Karma</em></span> integration, tracking source code locations 445 and taking advantage of UTF8 support. 446 </p> 447<p> 448 The source for this example can be found here: <a href="../../../../example/support/utree" target="_top">../../example/support/utree</a>. 449 </p> 450<p> 451</p> 452<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">sexpr</span> 453<span class="special">{</span> 454 455<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Iterator</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">ErrorHandler</span> <span class="special">=</span> <span class="identifier">error_handler</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">></span> <span class="special">></span> 456<span class="keyword">struct</span> <span class="identifier">parser</span> <span class="special">:</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">grammar</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">utree</span><span class="special">(),</span> <span class="identifier">whitespace</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">></span> <span class="special">></span> 457<span class="special">{</span> 458 <span class="identifier">qi</span><span class="special">::</span><span class="identifier">rule</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">utree</span><span class="special">(),</span> <span class="identifier">whitespace</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">></span> <span class="special">></span> 459 <span class="identifier">start</span><span class="special">,</span> <span class="identifier">element</span><span class="special">,</span> <span class="identifier">list</span><span class="special">;</span> 460 461 <span class="identifier">qi</span><span class="special">::</span><span class="identifier">rule</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">utree</span><span class="special">()></span> 462 <span class="identifier">atom</span><span class="special">;</span> 463 464 <span class="identifier">qi</span><span class="special">::</span><span class="identifier">rule</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="keyword">int</span><span class="special">()></span> 465 <span class="identifier">integer</span><span class="special">;</span> 466 467 <span class="identifier">qi</span><span class="special">::</span><span class="identifier">rule</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">utf8_symbol_type</span><span class="special">()></span> 468 <span class="identifier">symbol</span><span class="special">;</span> 469 470 <span class="identifier">qi</span><span class="special">::</span><span class="identifier">rule</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">utree</span><span class="special">::</span><span class="identifier">nil_type</span><span class="special">()></span> 471 <span class="identifier">nil_</span><span class="special">;</span> 472 473 <span class="identifier">qi</span><span class="special">::</span><span class="identifier">rule</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">binary_string_type</span><span class="special">()></span> 474 <span class="identifier">binary</span><span class="special">;</span> 475 476 <span class="identifier">utf8</span><span class="special">::</span><span class="identifier">parser</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">></span> 477 <span class="identifier">string</span><span class="special">;</span> 478 479 <span class="identifier">px</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</span><span class="identifier">ErrorHandler</span><span class="special">></span> <span class="keyword">const</span> 480 <span class="identifier">error</span><span class="special">;</span> 481 482 <span class="identifier">tagger</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">save_line_pos</span><span class="special">></span> 483 <span class="identifier">pos</span><span class="special">;</span> 484 485 <span class="identifier">parser</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">source_file</span> <span class="special">=</span> <span class="string">"<string>"</span><span class="special">):</span> 486 <span class="identifier">parser</span><span class="special">::</span><span class="identifier">base_type</span><span class="special">(</span><span class="identifier">start</span><span class="special">),</span> <span class="identifier">error</span><span class="special">(</span><span class="identifier">ErrorHandler</span><span class="special">(</span><span class="identifier">source_file</span><span class="special">))</span> 487 <span class="special">{</span> 488 <span class="keyword">using</span> <span class="identifier">standard</span><span class="special">::</span><span class="identifier">char_</span><span class="special">;</span> 489 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">unused_type</span><span class="special">;</span> 490 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">lexeme</span><span class="special">;</span> 491 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">hex</span><span class="special">;</span> 492 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">oct</span><span class="special">;</span> 493 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">no_case</span><span class="special">;</span> 494 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">real_parser</span><span class="special">;</span> 495 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">strict_real_policies</span><span class="special">;</span> 496 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">uint_parser</span><span class="special">;</span> 497 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">bool_parser</span><span class="special">;</span> 498 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">on_error</span><span class="special">;</span> 499 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">fail</span><span class="special">;</span> 500 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">int_</span><span class="special">;</span> 501 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">lit</span><span class="special">;</span> 502 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">_val</span><span class="special">;</span> 503 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">_1</span><span class="special">;</span> 504 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">_2</span><span class="special">;</span> 505 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">_3</span><span class="special">;</span> 506 <span class="keyword">using</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">_4</span><span class="special">;</span> 507 508 <span class="identifier">real_parser</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">strict_real_policies</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">></span> <span class="identifier">strict_double</span><span class="special">;</span> 509 <span class="identifier">uint_parser</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">,</span> <span class="number">16</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">2</span><span class="special">></span> <span class="identifier">hex2</span><span class="special">;</span> 510 <span class="identifier">bool_parser</span><span class="special"><</span><span class="keyword">bool</span><span class="special">,</span> <span class="identifier">sexpr</span><span class="special">::</span><span class="identifier">bool_input_policies</span><span class="special">></span> <span class="identifier">boolean</span><span class="special">;</span> 511 512 <span class="identifier">start</span> <span class="special">=</span> <span class="identifier">element</span><span class="special">.</span><span class="identifier">alias</span><span class="special">();</span> 513 514 <span class="identifier">element</span> <span class="special">=</span> <span class="identifier">atom</span> <span class="special">|</span> <span class="identifier">list</span><span class="special">;</span> 515 516 <span class="identifier">list</span> <span class="special">=</span> <span class="identifier">pos</span><span class="special">(</span><span class="identifier">_val</span><span class="special">,</span> <span class="char">'('</span><span class="special">)</span> <span class="special">></span> <span class="special">*</span><span class="identifier">element</span> <span class="special">></span> <span class="char">')'</span><span class="special">;</span> 517 518 <span class="identifier">atom</span> <span class="special">=</span> <span class="identifier">nil_</span> 519 <span class="special">|</span> <span class="identifier">strict_double</span> 520 <span class="special">|</span> <span class="identifier">integer</span> 521 <span class="special">|</span> <span class="identifier">boolean</span> 522 <span class="special">|</span> <span class="identifier">string</span> 523 <span class="special">|</span> <span class="identifier">symbol</span> 524 <span class="special">|</span> <span class="identifier">binary</span><span class="special">;</span> 525 526 <span class="identifier">nil_</span> <span class="special">=</span> <span class="identifier">qi</span><span class="special">::</span><span class="identifier">attr_cast</span><span class="special">(</span><span class="identifier">lit</span><span class="special">(</span><span class="string">"nil"</span><span class="special">));</span> 527 528 <span class="identifier">integer</span> <span class="special">=</span> <span class="identifier">lexeme</span><span class="special">[</span> <span class="identifier">no_case</span><span class="special">[</span><span class="string">"#x"</span><span class="special">]</span> <span class="special">></span> <span class="identifier">hex</span><span class="special">]</span> 529 <span class="special">|</span> <span class="identifier">lexeme</span><span class="special">[</span> <span class="identifier">no_case</span><span class="special">[</span><span class="string">"#o"</span><span class="special">]</span> <span class="special">>></span> <span class="identifier">oct</span><span class="special">]</span> 530 <span class="special">|</span> <span class="identifier">lexeme</span><span class="special">[-</span><span class="identifier">no_case</span><span class="special">[</span><span class="string">"#d"</span><span class="special">]</span> <span class="special">>></span> <span class="identifier">int_</span><span class="special">];</span> 531 532 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">exclude</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="string">" ();\"\x01-\x1f\x7f"</span><span class="special">)</span> <span class="special">+</span> <span class="char">'\0'</span><span class="special">;</span> 533 <span class="identifier">symbol</span> <span class="special">=</span> <span class="identifier">lexeme</span><span class="special">[+(~</span><span class="identifier">char_</span><span class="special">(</span><span class="identifier">exclude</span><span class="special">))];</span> 534 535 <span class="identifier">binary</span> <span class="special">=</span> <span class="identifier">lexeme</span><span class="special">[</span><span class="char">'#'</span> <span class="special">></span> <span class="special">*</span><span class="identifier">hex2</span> <span class="special">></span> <span class="char">'#'</span><span class="special">];</span> 536 537 <span class="identifier">start</span><span class="special">.</span><span class="identifier">name</span><span class="special">(</span><span class="string">"sexpr"</span><span class="special">);</span> 538 <span class="identifier">element</span><span class="special">.</span><span class="identifier">name</span><span class="special">(</span><span class="string">"element"</span><span class="special">);</span> 539 <span class="identifier">list</span><span class="special">.</span><span class="identifier">name</span><span class="special">(</span><span class="string">"list"</span><span class="special">);</span> 540 <span class="identifier">atom</span><span class="special">.</span><span class="identifier">name</span><span class="special">(</span><span class="string">"atom"</span><span class="special">);</span> 541 <span class="identifier">nil_</span><span class="special">.</span><span class="identifier">name</span><span class="special">(</span><span class="string">"nil"</span><span class="special">);</span> 542 <span class="identifier">integer</span><span class="special">.</span><span class="identifier">name</span><span class="special">(</span><span class="string">"integer"</span><span class="special">);</span> 543 <span class="identifier">symbol</span><span class="special">.</span><span class="identifier">name</span><span class="special">(</span><span class="string">"symbol"</span><span class="special">);</span> 544 <span class="identifier">binary</span><span class="special">.</span><span class="identifier">name</span><span class="special">(</span><span class="string">"binary"</span><span class="special">);</span> 545 546 <span class="identifier">on_error</span><span class="special"><</span><span class="identifier">fail</span><span class="special">>(</span><span class="identifier">start</span><span class="special">,</span> <span class="identifier">error</span><span class="special">(</span><span class="identifier">_1</span><span class="special">,</span> <span class="identifier">_2</span><span class="special">,</span> <span class="identifier">_3</span><span class="special">,</span> <span class="identifier">_4</span><span class="special">));</span> 547 <span class="special">}</span> 548<span class="special">};</span> 549 550<span class="special">}</span> <span class="comment">// sexpr</span> 551</pre> 552<p> 553 </p> 554</div> 555<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 556<td align="left"></td> 557<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p> 558 Distributed under the Boost Software License, Version 1.0. (See accompanying 559 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 560 </p> 561</div></td> 562</tr></table> 563<hr> 564<div class="spirit-nav"> 565<a accesskey="p" href="line_pos_iterator.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../support.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../faq.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 566</div> 567</body> 568</html> 569