1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Directive for Transduction Parsing (raw[])</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="../directive.html" title="Parser Directives"> 9<link rel="prev" href="omit.html" title="Parser Directive Ignoring Attribute (omit[])"> 10<link rel="next" href="repeat.html" title="Repetition Parser Directive (repeat[])"> 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="omit.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../directive.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="repeat.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h5 class="title"> 27<a name="spirit.qi.reference.directive.raw"></a><a class="link" href="raw.html" title="Directive for Transduction Parsing (raw[])">Directive for 28 Transduction Parsing (<code class="computeroutput"><span class="identifier">raw</span><span class="special">[]</span></code>)</a> 29</h5></div></div></div> 30<h6> 31<a name="spirit.qi.reference.directive.raw.h0"></a> 32 <span class="phrase"><a name="spirit.qi.reference.directive.raw.description"></a></span><a class="link" href="raw.html#spirit.qi.reference.directive.raw.description">Description</a> 33 </h6> 34<p> 35 The <code class="computeroutput"><span class="identifier">raw</span><span class="special">[]</span></code> 36 disregards the attribute of its subject parser, instead exposing the 37 half-open range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">last</span><span class="special">)</span></code> pointing to the matched characters from 38 the input stream. The <code class="computeroutput"><span class="identifier">raw</span><span class="special">[]</span></code> directive brings back the classic Spirit 39 transduction (un-attributed) behavior for a subject parser. 40 </p> 41<h6> 42<a name="spirit.qi.reference.directive.raw.h1"></a> 43 <span class="phrase"><a name="spirit.qi.reference.directive.raw.header"></a></span><a class="link" href="raw.html#spirit.qi.reference.directive.raw.header">Header</a> 44 </h6> 45<pre class="programlisting"><span class="comment">// forwards to <boost/spirit/home/qi/directive/raw.hpp></span> 46<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">qi_raw</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 47</pre> 48<p> 49 Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>. 50 </p> 51<h6> 52<a name="spirit.qi.reference.directive.raw.h2"></a> 53 <span class="phrase"><a name="spirit.qi.reference.directive.raw.namespace"></a></span><a class="link" href="raw.html#spirit.qi.reference.directive.raw.namespace">Namespace</a> 54 </h6> 55<div class="informaltable"><table class="table"> 56<colgroup><col></colgroup> 57<thead><tr><th> 58 <p> 59 Name 60 </p> 61 </th></tr></thead> 62<tbody><tr><td> 63 <p> 64 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">raw</span> <span class="comment">// alias: 65 boost::spirit::qi::raw</span></code> 66 </p> 67 </td></tr></tbody> 68</table></div> 69<h6> 70<a name="spirit.qi.reference.directive.raw.h3"></a> 71 <span class="phrase"><a name="spirit.qi.reference.directive.raw.model_of"></a></span><a class="link" href="raw.html#spirit.qi.reference.directive.raw.model_of">Model 72 of</a> 73 </h6> 74<div class="blockquote"><blockquote class="blockquote"><p> 75 <a class="link" href="../parser_concepts/unaryparser.html" title="UnaryParser"><code class="computeroutput"><span class="identifier">UnaryParser</span></code></a> 76 </p></blockquote></div> 77<div class="variablelist"> 78<p class="title"><b>Notation</b></p> 79<dl class="variablelist"> 80<dt><span class="term"><code class="computeroutput"><span class="identifier">a</span></code></span></dt> 81<dd><p> 82 A <a class="link" href="../parser_concepts/parser.html" title="Parser"><code class="computeroutput"><span class="identifier">Parser</span></code></a>. 83 </p></dd> 84<dt><span class="term"><code class="computeroutput"><span class="identifier">Iter</span></code></span></dt> 85<dd><p> 86 A <a href="http://en.cppreference.com/w/cpp/named_req/ForwardIterator" target="_top"><code class="computeroutput"><span class="identifier">ForwardIterator</span></code></a> type. 87 </p></dd> 88</dl> 89</div> 90<h6> 91<a name="spirit.qi.reference.directive.raw.h4"></a> 92 <span class="phrase"><a name="spirit.qi.reference.directive.raw.expression_semantics"></a></span><a class="link" href="raw.html#spirit.qi.reference.directive.raw.expression_semantics">Expression 93 Semantics</a> 94 </h6> 95<p> 96 Semantics of an expression is defined only where it differs from, or 97 is not defined in <a class="link" href="../parser_concepts/unaryparser.html" title="UnaryParser"><code class="computeroutput"><span class="identifier">UnaryParser</span></code></a>. 98 </p> 99<div class="informaltable"><table class="table"> 100<colgroup> 101<col> 102<col> 103</colgroup> 104<thead><tr> 105<th> 106 <p> 107 Expression 108 </p> 109 </th> 110<th> 111 <p> 112 Semantics 113 </p> 114 </th> 115</tr></thead> 116<tbody><tr> 117<td> 118 <p> 119 <code class="computeroutput"><span class="identifier">raw</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span></code> 120 </p> 121 </td> 122<td> 123 <p> 124 Disregard the attribute of the subject parser, <code class="computeroutput"><span class="identifier">a</span></code>. Expose instead the half-open 125 range <code class="computeroutput"><span class="special">[</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">last</span><span class="special">)</span></code> pointing to the matched characters 126 from the input stream. 127 </p> 128 </td> 129</tr></tbody> 130</table></div> 131<h6> 132<a name="spirit.qi.reference.directive.raw.h5"></a> 133 <span class="phrase"><a name="spirit.qi.reference.directive.raw.attributes"></a></span><a class="link" href="raw.html#spirit.qi.reference.directive.raw.attributes">Attributes</a> 134 </h6> 135<p> 136 See <a class="link" href="../../quick_reference/compound_attribute_rules.html#spirit.qi.quick_reference.compound_attribute_rules.notation">Compound 137 Attribute Notation</a>. 138 </p> 139<div class="informaltable"><table class="table"> 140<colgroup> 141<col> 142<col> 143</colgroup> 144<thead><tr> 145<th> 146 <p> 147 Expression 148 </p> 149 </th> 150<th> 151 <p> 152 Attribute 153 </p> 154 </th> 155</tr></thead> 156<tbody><tr> 157<td> 158 <p> 159 <code class="computeroutput"><span class="identifier">raw</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span></code> 160 </p> 161 </td> 162<td> 163 <p> 164</p> 165<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--></span> <span class="identifier">raw</span><span class="special">[</span><span class="identifier">a</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">Iter</span><span class="special">></span> 166<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--></span> <span class="identifier">raw</span><span class="special">[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">Unused</span></pre> 167<p> 168 </p> 169 </td> 170</tr></tbody> 171</table></div> 172<div class="note"><table border="0" summary="Note"> 173<tr> 174<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td> 175<th align="left">Note</th> 176</tr> 177<tr><td align="left" valign="top"><p> 178 See <a href="../../../../../../../../libs/range/doc/html/range/reference/utilities/iterator_range.html" target="_top"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span></code></a>. 179 </p></td></tr> 180</table></div> 181<h6> 182<a name="spirit.qi.reference.directive.raw.h6"></a> 183 <span class="phrase"><a name="spirit.qi.reference.directive.raw.complexity"></a></span><a class="link" href="raw.html#spirit.qi.reference.directive.raw.complexity">Complexity</a> 184 </h6> 185<div class="blockquote"><blockquote class="blockquote"><p> 186 The complexity is defined by the complexity of the subject parser, 187 <code class="computeroutput"><span class="identifier">a</span></code> 188 </p></blockquote></div> 189<h6> 190<a name="spirit.qi.reference.directive.raw.h7"></a> 191 <span class="phrase"><a name="spirit.qi.reference.directive.raw.example"></a></span><a class="link" href="raw.html#spirit.qi.reference.directive.raw.example">Example</a> 192 </h6> 193<div class="note"><table border="0" summary="Note"> 194<tr> 195<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td> 196<th align="left">Note</th> 197</tr> 198<tr><td align="left" valign="top"><p> 199 The test harness for the example(s) below is presented in the <a class="link" href="../basics.html#spirit.qi.reference.basics.examples">Basics Examples</a> 200 section. 201 </p></td></tr> 202</table></div> 203<p> 204 Some using declarations: 205 </p> 206<p> 207</p> 208<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qi</span><span class="special">::</span><span class="identifier">raw</span><span class="special">;</span> 209<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">ascii</span><span class="special">::</span><span class="identifier">alpha</span><span class="special">;</span> 210<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">ascii</span><span class="special">::</span><span class="identifier">alnum</span><span class="special">;</span> 211</pre> 212<p> 213 </p> 214<p> 215 This parser matches and extracts C++ identifiers: 216 </p> 217<p> 218</p> 219<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">id</span><span class="special">;</span> 220<span class="identifier">test_parser_attr</span><span class="special">(</span><span class="string">"James007"</span><span class="special">,</span> <span class="identifier">raw</span><span class="special">[(</span><span class="identifier">alpha</span> <span class="special">|</span> <span class="char">'_'</span><span class="special">)</span> <span class="special">>></span> <span class="special">*(</span><span class="identifier">alnum</span> <span class="special">|</span> <span class="char">'_'</span><span class="special">)],</span> <span class="identifier">id</span><span class="special">);</span> 221<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">id</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// should print James007</span> 222</pre> 223<p> 224 </p> 225</div> 226<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 227<td align="left"></td> 228<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p> 229 Distributed under the Boost Software License, Version 1.0. (See accompanying 230 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>) 231 </p> 232</div></td> 233</tr></table> 234<hr> 235<div class="spirit-nav"> 236<a accesskey="p" href="omit.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../directive.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="repeat.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 237</div> 238</body> 239</html> 240