1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Parser Directive Re-Establishing Skipping (skip[])</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="matches.html" title="Directive Testing if Parser Succeeded (matches[])"> 10<link rel="next" href="hold.html" title="Parser Directive for Attribute Commit/Rollback (hold[])"> 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="matches.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="hold.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.skip"></a><a class="link" href="skip.html" title="Parser Directive Re-Establishing Skipping (skip[])">Parser Directive 28 Re-Establishing Skipping (<code class="computeroutput"><span class="identifier">skip</span><span class="special">[]</span></code>)</a> 29</h5></div></div></div> 30<h6> 31<a name="spirit.qi.reference.directive.skip.h0"></a> 32 <span class="phrase"><a name="spirit.qi.reference.directive.skip.description"></a></span><a class="link" href="skip.html#spirit.qi.reference.directive.skip.description">Description</a> 33 </h6> 34<p> 35 The <code class="computeroutput"><span class="identifier">skip</span></code> directive is 36 the inverse of <a class="link" href="lexeme.html" title="Parser Directive Inhibiting Skipping (lexeme[])"><code class="computeroutput"><span class="identifier">lexeme</span></code></a> or <a class="link" href="no_skip.html" title="Parser Directive Inhibiting Skipping Without Pre-skip (no_skip[])"><code class="computeroutput"><span class="identifier">no_skip</span></code></a>. While the <a class="link" href="lexeme.html" title="Parser Directive Inhibiting Skipping (lexeme[])"><code class="computeroutput"><span class="identifier">lexeme</span></code></a> directive turns off white 37 space skipping, the <code class="computeroutput"><span class="identifier">skip</span></code> 38 directive turns it on again. This is simply done by wrapping the parts 39 inside the <code class="computeroutput"><span class="identifier">skip</span></code> directive: 40 </p> 41<pre class="programlisting"><span class="identifier">skip</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span> 42</pre> 43<p> 44 It is also possible to supply a skip parser to the <code class="computeroutput"><span class="identifier">skip</span></code> 45 directive: 46 </p> 47<pre class="programlisting"><span class="identifier">skip</span><span class="special">(</span><span class="identifier">p</span><span class="special">)[</span><span class="identifier">a</span><span class="special">]</span> <span class="comment">// Use `p` as a skipper for parsing `a`</span> 48</pre> 49<p> 50 This makes it possible to: 51 </p> 52<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 53<li class="listitem"> 54 Perform localized phrase level parsing while doing character level 55 parsing. 56 </li> 57<li class="listitem"> 58 Replace the current skipper anywhere with an entirely different skipper 59 while doing phrase level parsing. 60 </li> 61</ul></div> 62<h6> 63<a name="spirit.qi.reference.directive.skip.h1"></a> 64 <span class="phrase"><a name="spirit.qi.reference.directive.skip.header"></a></span><a class="link" href="skip.html#spirit.qi.reference.directive.skip.header">Header</a> 65 </h6> 66<pre class="programlisting"><span class="comment">// forwards to <boost/spirit/home/qi/directive/skip.hpp></span> 67<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_skip</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 68</pre> 69<p> 70 Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>. 71 </p> 72<h6> 73<a name="spirit.qi.reference.directive.skip.h2"></a> 74 <span class="phrase"><a name="spirit.qi.reference.directive.skip.namespace"></a></span><a class="link" href="skip.html#spirit.qi.reference.directive.skip.namespace">Namespace</a> 75 </h6> 76<div class="informaltable"><table class="table"> 77<colgroup><col></colgroup> 78<thead><tr><th> 79 <p> 80 Name 81 </p> 82 </th></tr></thead> 83<tbody><tr><td> 84 <p> 85 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">skip</span> <span class="comment">// alias: 86 boost::spirit::qi::skip</span></code> 87 </p> 88 </td></tr></tbody> 89</table></div> 90<h6> 91<a name="spirit.qi.reference.directive.skip.h3"></a> 92 <span class="phrase"><a name="spirit.qi.reference.directive.skip.model_of"></a></span><a class="link" href="skip.html#spirit.qi.reference.directive.skip.model_of">Model 93 of</a> 94 </h6> 95<div class="blockquote"><blockquote class="blockquote"><p> 96 <a class="link" href="../parser_concepts/unaryparser.html" title="UnaryParser"><code class="computeroutput"><span class="identifier">UnaryParser</span></code></a> 97 </p></blockquote></div> 98<div class="variablelist"> 99<p class="title"><b>Notation</b></p> 100<dl class="variablelist"> 101<dt><span class="term"><code class="computeroutput"><span class="identifier">a</span></code></span></dt> 102<dd><p> 103 A <a class="link" href="../parser_concepts/parser.html" title="Parser"><code class="computeroutput"><span class="identifier">Parser</span></code></a>. 104 </p></dd> 105</dl> 106</div> 107<h6> 108<a name="spirit.qi.reference.directive.skip.h4"></a> 109 <span class="phrase"><a name="spirit.qi.reference.directive.skip.expression_semantics"></a></span><a class="link" href="skip.html#spirit.qi.reference.directive.skip.expression_semantics">Expression 110 Semantics</a> 111 </h6> 112<p> 113 Semantics of an expression is defined only where it differs from, or 114 is not defined in <a class="link" href="../parser_concepts/unaryparser.html" title="UnaryParser"><code class="computeroutput"><span class="identifier">UnaryParser</span></code></a>. 115 </p> 116<div class="informaltable"><table class="table"> 117<colgroup> 118<col> 119<col> 120</colgroup> 121<thead><tr> 122<th> 123 <p> 124 Expression 125 </p> 126 </th> 127<th> 128 <p> 129 Semantics 130 </p> 131 </th> 132</tr></thead> 133<tbody> 134<tr> 135<td> 136 <p> 137 <code class="computeroutput"><span class="identifier">skip</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span></code> 138 </p> 139 </td> 140<td> 141 <p> 142 Re-establish the skipper that got inhibited by lexeme or no_skip 143 </p> 144 </td> 145</tr> 146<tr> 147<td> 148 <p> 149 <code class="computeroutput"><span class="identifier">skip</span><span class="special">(</span><span class="identifier">p</span><span class="special">)[</span><span class="identifier">a</span><span class="special">]</span></code> 150 </p> 151 </td> 152<td> 153 <p> 154 Use <code class="computeroutput"><span class="identifier">p</span></code> as a 155 skipper for parsing <code class="computeroutput"><span class="identifier">a</span></code> 156 </p> 157 </td> 158</tr> 159</tbody> 160</table></div> 161<h6> 162<a name="spirit.qi.reference.directive.skip.h5"></a> 163 <span class="phrase"><a name="spirit.qi.reference.directive.skip.attributes"></a></span><a class="link" href="skip.html#spirit.qi.reference.directive.skip.attributes">Attributes</a> 164 </h6> 165<p> 166 See <a class="link" href="../../quick_reference/compound_attribute_rules.html#spirit.qi.quick_reference.compound_attribute_rules.notation">Compound 167 Attribute Notation</a>. 168 </p> 169<div class="informaltable"><table class="table"> 170<colgroup> 171<col> 172<col> 173</colgroup> 174<thead><tr> 175<th> 176 <p> 177 Expression 178 </p> 179 </th> 180<th> 181 <p> 182 Attribute 183 </p> 184 </th> 185</tr></thead> 186<tbody> 187<tr> 188<td> 189 <p> 190 <code class="computeroutput"><span class="identifier">skip</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span></code> 191 </p> 192 </td> 193<td> 194 <p> 195</p> 196<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">skip</span><span class="special">[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">A</span> 197<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--></span> <span class="identifier">skip</span><span class="special">[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">Unused</span></pre> 198<p> 199 </p> 200 </td> 201</tr> 202<tr> 203<td> 204 <p> 205 <code class="computeroutput"><span class="identifier">skip</span><span class="special">(</span><span class="identifier">p</span><span class="special">)[</span><span class="identifier">a</span><span class="special">]</span></code> 206 </p> 207 </td> 208<td> 209 <p> 210</p> 211<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">skip</span><span class="special">(</span><span class="identifier">p</span><span class="special">)[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">A</span> 212<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--></span> <span class="identifier">skip</span><span class="special">(</span><span class="identifier">p</span><span class="special">)[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">Unused</span></pre> 213<p> 214 </p> 215 </td> 216</tr> 217</tbody> 218</table></div> 219<h6> 220<a name="spirit.qi.reference.directive.skip.h6"></a> 221 <span class="phrase"><a name="spirit.qi.reference.directive.skip.complexity"></a></span><a class="link" href="skip.html#spirit.qi.reference.directive.skip.complexity">Complexity</a> 222 </h6> 223<div class="blockquote"><blockquote class="blockquote"><p> 224 The complexity is defined by the complexity of the subject parser, 225 <code class="computeroutput"><span class="identifier">a</span></code> 226 </p></blockquote></div> 227<h6> 228<a name="spirit.qi.reference.directive.skip.h7"></a> 229 <span class="phrase"><a name="spirit.qi.reference.directive.skip.example"></a></span><a class="link" href="skip.html#spirit.qi.reference.directive.skip.example">Example</a> 230 </h6> 231<div class="note"><table border="0" summary="Note"> 232<tr> 233<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td> 234<th align="left">Note</th> 235</tr> 236<tr><td align="left" valign="top"><p> 237 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> 238 section. 239 </p></td></tr> 240</table></div> 241<p> 242 Some using declarations: 243 </p> 244<p> 245</p> 246<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">skip</span><span class="special">;</span> 247<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">int_</span><span class="special">;</span> 248<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">space</span><span class="special">;</span> 249</pre> 250<p> 251 </p> 252<p> 253 Simple usage of <code class="computeroutput"><span class="identifier">skip</span><span class="special">[]</span></code>: 254 </p> 255<p> 256 Explicitly specify a skip parser. This parser parses comma delimited 257 numbers, ignoring spaces. 258 </p> 259<p> 260</p> 261<pre class="programlisting"><span class="identifier">test_parser</span><span class="special">(</span><span class="string">"1, 2, 3, 4, 5"</span><span class="special">,</span> <span class="identifier">skip</span><span class="special">(</span><span class="identifier">space</span><span class="special">)[</span><span class="identifier">int_</span> <span class="special">>></span> <span class="special">*(</span><span class="char">','</span> <span class="special">>></span> <span class="identifier">int_</span><span class="special">)]);</span> 262</pre> 263<p> 264 </p> 265</div> 266<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 267<td align="left"></td> 268<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p> 269 Distributed under the Boost Software License, Version 1.0. (See accompanying 270 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>) 271 </p> 272</div></td> 273</tr></table> 274<hr> 275<div class="spirit-nav"> 276<a accesskey="p" href="matches.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="hold.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 277</div> 278</body> 279</html> 280