• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Not-Predicate Generator (!a)</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="../operator.html" title="Generator Operators">
9<link rel="prev" href="and_predicate.html" title="And-Predicate Generator (&amp;a)">
10<link rel="next" href="../stream.html" title="Stream Generators">
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="and_predicate.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../operator.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="../stream.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.karma.reference.operator.not_predicate"></a><a class="link" href="not_predicate.html" title="Not-Predicate Generator (!a)">Not-Predicate
28          Generator (<code class="computeroutput"><span class="special">!</span><span class="identifier">a</span></code>)</a>
29</h5></div></div></div>
30<h6>
31<a name="spirit.karma.reference.operator.not_predicate.h0"></a>
32            <span class="phrase"><a name="spirit.karma.reference.operator.not_predicate.description"></a></span><a class="link" href="not_predicate.html#spirit.karma.reference.operator.not_predicate.description">Description</a>
33          </h6>
34<p>
35            The not-predicate generator is used to test, whether the embedded generator
36            fails, without generating any output. It succeeds if the embedded generator
37            fails.
38          </p>
39<h6>
40<a name="spirit.karma.reference.operator.not_predicate.h1"></a>
41            <span class="phrase"><a name="spirit.karma.reference.operator.not_predicate.header"></a></span><a class="link" href="not_predicate.html#spirit.karma.reference.operator.not_predicate.header">Header</a>
42          </h6>
43<pre class="programlisting"><span class="comment">// forwards to &lt;boost/spirit/home/karma/operator/not_predicate.hpp&gt;</span>
44<span class="preprocessor">#include</span> <span class="special">&lt;</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">karma_not_predicate</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
45</pre>
46<p>
47            Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>.
48          </p>
49<h6>
50<a name="spirit.karma.reference.operator.not_predicate.h2"></a>
51            <span class="phrase"><a name="spirit.karma.reference.operator.not_predicate.model_of"></a></span><a class="link" href="not_predicate.html#spirit.karma.reference.operator.not_predicate.model_of">Model
52            of</a>
53          </h6>
54<div class="blockquote"><blockquote class="blockquote"><p>
55              <a class="link" href="../generator_concepts/unarygenerator.html" title="UnaryGenerator"><code class="computeroutput"><span class="identifier">UnaryGenerator</span></code></a>
56            </p></blockquote></div>
57<h6>
58<a name="spirit.karma.reference.operator.not_predicate.h3"></a>
59            <span class="phrase"><a name="spirit.karma.reference.operator.not_predicate.expression_semantics"></a></span><a class="link" href="not_predicate.html#spirit.karma.reference.operator.not_predicate.expression_semantics">Expression
60            Semantics</a>
61          </h6>
62<p>
63            Semantics of an expression is defined only where it differs from, or
64            is not defined in <a class="link" href="../generator_concepts/unarygenerator.html" title="UnaryGenerator"><code class="computeroutput"><span class="identifier">UnaryGenerator</span></code></a>.
65          </p>
66<div class="informaltable"><table class="table">
67<colgroup>
68<col>
69<col>
70</colgroup>
71<thead><tr>
72<th>
73                    <p>
74                      Expression
75                    </p>
76                  </th>
77<th>
78                    <p>
79                      Semantics
80                    </p>
81                  </th>
82</tr></thead>
83<tbody><tr>
84<td>
85                    <p>
86                      <code class="computeroutput"><span class="special">!</span><span class="identifier">a</span></code>
87                    </p>
88                  </td>
89<td>
90                    <p>
91                      The generator <code class="computeroutput"><span class="identifier">a</span></code>
92                      is executed for the sole purpose of testing whether it succeeds.
93                      The not-predicate generator succeeds if its embedded generator
94                      fails (unless the underlying output stream reports an error).
95                      The not-predicate never produces any output.
96                    </p>
97                  </td>
98</tr></tbody>
99</table></div>
100<p>
101            The not generator is implemented by redirecting all output produced by
102            its embedded generator into a discarding device.
103          </p>
104<h6>
105<a name="spirit.karma.reference.operator.not_predicate.h4"></a>
106            <span class="phrase"><a name="spirit.karma.reference.operator.not_predicate.attributes"></a></span><a class="link" href="not_predicate.html#spirit.karma.reference.operator.not_predicate.attributes">Attributes</a>
107          </h6>
108<p>
109            See <a class="link" href="../../quick_reference/compound_attribute_rules.html#spirit.karma.quick_reference.compound_attribute_rules.notation">Compound
110            Attribute Notation</a>.
111          </p>
112<div class="informaltable"><table class="table">
113<colgroup>
114<col>
115<col>
116</colgroup>
117<thead><tr>
118<th>
119                    <p>
120                      Expression
121                    </p>
122                  </th>
123<th>
124                    <p>
125                      Attribute
126                    </p>
127                  </th>
128</tr></thead>
129<tbody><tr>
130<td>
131                    <p>
132                      <code class="computeroutput"><span class="special">!</span><span class="identifier">a</span></code>
133                      (not-predicate, unary <code class="computeroutput"><span class="special">!</span></code>)
134                    </p>
135                  </td>
136<td>
137                    <p>
138                      <code class="computeroutput"><span class="identifier">a</span><span class="special">:</span>
139                      <span class="identifier">A</span> <span class="special">--&gt;</span>
140                      <span class="special">!</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span></code>
141                    </p>
142                  </td>
143</tr></tbody>
144</table></div>
145<div class="note"><table border="0" summary="Note">
146<tr>
147<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
148<th align="left">Note</th>
149</tr>
150<tr><td align="left" valign="top"><p>
151              The attribute of the not-predicate is not always <code class="computeroutput"><span class="identifier">unused_type</span></code>,
152              which is different from Qi's not-predicate. This is necessary as the
153              generator the and-predicate is attached to most of the time needs an
154              attribute.
155            </p></td></tr>
156</table></div>
157<h6>
158<a name="spirit.karma.reference.operator.not_predicate.h5"></a>
159            <span class="phrase"><a name="spirit.karma.reference.operator.not_predicate.complexity"></a></span><a class="link" href="not_predicate.html#spirit.karma.reference.operator.not_predicate.complexity">Complexity</a>
160          </h6>
161<div class="blockquote"><blockquote class="blockquote"><p>
162              The overall complexity of the not-predicate generator is defined by
163              the complexity of its embedded generator. The complexity of the not-predicate
164              generator itself is O(1).
165            </p></blockquote></div>
166<h6>
167<a name="spirit.karma.reference.operator.not_predicate.h6"></a>
168            <span class="phrase"><a name="spirit.karma.reference.operator.not_predicate.example"></a></span><a class="link" href="not_predicate.html#spirit.karma.reference.operator.not_predicate.example">Example</a>
169          </h6>
170<div class="note"><table border="0" summary="Note">
171<tr>
172<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
173<th align="left">Note</th>
174</tr>
175<tr><td align="left" valign="top"><p>
176              The test harness for the example(s) below is presented in the <a class="link" href="../basics.html#spirit.karma.reference.basics.examples">Basics Examples</a>
177              section.
178            </p></td></tr>
179</table></div>
180<p>
181            Some includes:
182          </p>
183<p>
184</p>
185<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</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">karma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
186<span class="preprocessor">#include</span> <span class="special">&lt;</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">support_utree</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
187<span class="preprocessor">#include</span> <span class="special">&lt;</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">phoenix_core</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
188<span class="preprocessor">#include</span> <span class="special">&lt;</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">phoenix_operator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
189<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">std_pair</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
190<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
191<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span>
192</pre>
193<p>
194          </p>
195<p>
196            Some using declarations:
197          </p>
198<p>
199</p>
200<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">karma</span><span class="special">::</span><span class="identifier">double_</span><span class="special">;</span>
201<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">karma</span><span class="special">::</span><span class="identifier">ascii</span><span class="special">::</span><span class="identifier">char_</span><span class="special">;</span>
202<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">karma</span><span class="special">::</span><span class="identifier">ascii</span><span class="special">::</span><span class="identifier">string</span><span class="special">;</span>
203<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">ref</span><span class="special">;</span>
204</pre>
205<p>
206          </p>
207<p>
208            Basic usage of a not predicate generator:
209          </p>
210<p>
211</p>
212<pre class="programlisting"><span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"c"</span><span class="special">,</span> <span class="special">!</span><span class="identifier">char_</span><span class="special">(</span><span class="char">'a'</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="char">'b'</span> <span class="special">|</span> <span class="char">'c'</span><span class="special">,</span> <span class="char">'a'</span><span class="special">);</span>
213<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"b"</span><span class="special">,</span> <span class="special">!</span><span class="identifier">char_</span><span class="special">(</span><span class="char">'a'</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="char">'b'</span> <span class="special">|</span> <span class="char">'c'</span><span class="special">,</span> <span class="char">'x'</span><span class="special">);</span>
214
215<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"def"</span><span class="special">,</span> <span class="special">!</span><span class="identifier">string</span><span class="special">(</span><span class="string">"123"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"abc"</span> <span class="special">|</span> <span class="string">"def"</span><span class="special">,</span> <span class="string">"123"</span><span class="special">);</span>
216<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"abc"</span><span class="special">,</span> <span class="special">!</span><span class="identifier">string</span><span class="special">(</span><span class="string">"123"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"abc"</span> <span class="special">|</span> <span class="string">"def"</span><span class="special">,</span> <span class="string">"456"</span><span class="special">);</span>
217</pre>
218<p>
219          </p>
220</div>
221<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
222<td align="left"></td>
223<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
224        Distributed under the Boost Software License, Version 1.0. (See accompanying
225        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>)
226      </p>
227</div></td>
228</tr></table>
229<hr>
230<div class="spirit-nav">
231<a accesskey="p" href="and_predicate.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../operator.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="../stream.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
232</div>
233</body>
234</html>
235