• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>And-Predicate Parser (&amp;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="Parser Operators">
9<link rel="prev" href="alternative.html" title="Alternative Parser (a | b)">
10<link rel="next" href="difference.html" title="Difference Parser (a - b)">
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="alternative.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="difference.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.operator.and_predicate"></a><a class="link" href="and_predicate.html" title="And-Predicate Parser (&amp;a)">And-Predicate
28          Parser (<code class="computeroutput"><span class="special">&amp;</span><span class="identifier">a</span></code>)</a>
29</h5></div></div></div>
30<h6>
31<a name="spirit.qi.reference.operator.and_predicate.h0"></a>
32            <span class="phrase"><a name="spirit.qi.reference.operator.and_predicate.description"></a></span><a class="link" href="and_predicate.html#spirit.qi.reference.operator.and_predicate.description">Description</a>
33          </h6>
34<p>
35            Syntactic predicates assert a certain conditional syntax to be satisfied
36            before evaluating another production. Similar to semantic predicates,
37            <a class="link" href="../auxiliary/eps.html" title="Epsilon Parser (eps)"><code class="computeroutput"><span class="identifier">eps</span></code></a>,
38            syntactic predicates do not consume any input. The <span class="emphasis"><em>and-predicate</em></span>,
39            <code class="computeroutput"><span class="special">&amp;</span><span class="identifier">a</span></code>,
40            is a positive syntactic predicate that returns a zero length match only
41            if its predicate matches.
42          </p>
43<h6>
44<a name="spirit.qi.reference.operator.and_predicate.h1"></a>
45            <span class="phrase"><a name="spirit.qi.reference.operator.and_predicate.header"></a></span><a class="link" href="and_predicate.html#spirit.qi.reference.operator.and_predicate.header">Header</a>
46          </h6>
47<pre class="programlisting"><span class="comment">// forwards to &lt;boost/spirit/home/qi/operator/and_predicate.hpp&gt;</span>
48<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">qi_and_predicate</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
49</pre>
50<p>
51            Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>.
52          </p>
53<h6>
54<a name="spirit.qi.reference.operator.and_predicate.h2"></a>
55            <span class="phrase"><a name="spirit.qi.reference.operator.and_predicate.model_of"></a></span><a class="link" href="and_predicate.html#spirit.qi.reference.operator.and_predicate.model_of">Model of</a>
56          </h6>
57<div class="blockquote"><blockquote class="blockquote"><p>
58              <a class="link" href="../parser_concepts/unaryparser.html" title="UnaryParser"><code class="computeroutput"><span class="identifier">UnaryParser</span></code></a>
59            </p></blockquote></div>
60<div class="variablelist">
61<p class="title"><b>Notation</b></p>
62<dl class="variablelist">
63<dt><span class="term"><code class="computeroutput"><span class="identifier">a</span></code></span></dt>
64<dd><p>
65                  A <a class="link" href="../parser_concepts/parser.html" title="Parser"><code class="computeroutput"><span class="identifier">Parser</span></code></a>
66                </p></dd>
67</dl>
68</div>
69<h6>
70<a name="spirit.qi.reference.operator.and_predicate.h3"></a>
71            <span class="phrase"><a name="spirit.qi.reference.operator.and_predicate.expression_semantics"></a></span><a class="link" href="and_predicate.html#spirit.qi.reference.operator.and_predicate.expression_semantics">Expression
72            Semantics</a>
73          </h6>
74<p>
75            Semantics of an expression is defined only where it differs from, or
76            is not defined in <a class="link" href="../parser_concepts/unaryparser.html" title="UnaryParser"><code class="computeroutput"><span class="identifier">UnaryParser</span></code></a>.
77          </p>
78<div class="informaltable"><table class="table">
79<colgroup>
80<col>
81<col>
82</colgroup>
83<thead><tr>
84<th>
85                    <p>
86                      Expression
87                    </p>
88                  </th>
89<th>
90                    <p>
91                      Semantics
92                    </p>
93                  </th>
94</tr></thead>
95<tbody><tr>
96<td>
97                    <p>
98                      <code class="computeroutput"><span class="special">&amp;</span><span class="identifier">a</span></code>
99                    </p>
100                  </td>
101<td>
102                    <p>
103                      If the predicate <code class="computeroutput"><span class="identifier">a</span></code>
104                      matches, return a zero length match. Otherwise, fail.
105                    </p>
106                  </td>
107</tr></tbody>
108</table></div>
109<h6>
110<a name="spirit.qi.reference.operator.and_predicate.h4"></a>
111            <span class="phrase"><a name="spirit.qi.reference.operator.and_predicate.attributes"></a></span><a class="link" href="and_predicate.html#spirit.qi.reference.operator.and_predicate.attributes">Attributes</a>
112          </h6>
113<p>
114            See <a class="link" href="../../quick_reference/compound_attribute_rules.html#spirit.qi.quick_reference.compound_attribute_rules.notation">Compound
115            Attribute Notation</a>.
116          </p>
117<div class="informaltable"><table class="table">
118<colgroup>
119<col>
120<col>
121</colgroup>
122<thead><tr>
123<th>
124                    <p>
125                      Expression
126                    </p>
127                  </th>
128<th>
129                    <p>
130                      Attribute
131                    </p>
132                  </th>
133</tr></thead>
134<tbody><tr>
135<td>
136                    <p>
137                      <code class="computeroutput"><span class="special">&amp;</span><span class="identifier">a</span></code>
138                    </p>
139                  </td>
140<td>
141                    <p>
142                      <code class="computeroutput"><span class="identifier">unused_type</span></code>
143                    </p>
144                  </td>
145</tr></tbody>
146</table></div>
147<h6>
148<a name="spirit.qi.reference.operator.and_predicate.h5"></a>
149            <span class="phrase"><a name="spirit.qi.reference.operator.and_predicate.complexity"></a></span><a class="link" href="and_predicate.html#spirit.qi.reference.operator.and_predicate.complexity">Complexity</a>
150          </h6>
151<div class="blockquote"><blockquote class="blockquote"><p>
152              The complexity is defined by the complexity of the predicate, <code class="computeroutput"><span class="identifier">a</span></code>
153            </p></blockquote></div>
154<h6>
155<a name="spirit.qi.reference.operator.and_predicate.h6"></a>
156            <span class="phrase"><a name="spirit.qi.reference.operator.and_predicate.example"></a></span><a class="link" href="and_predicate.html#spirit.qi.reference.operator.and_predicate.example">Example</a>
157          </h6>
158<div class="note"><table border="0" summary="Note">
159<tr>
160<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
161<th align="left">Note</th>
162</tr>
163<tr><td align="left" valign="top"><p>
164              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>
165              section.
166            </p></td></tr>
167</table></div>
168<p>
169            Some using declarations:
170          </p>
171<p>
172</p>
173<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">lit</span><span class="special">;</span>
174</pre>
175<p>
176          </p>
177<p>
178            Basic look-ahead example: make sure that the last character is a semicolon,
179            but don't consume it, just peek at the next character:
180          </p>
181<p>
182</p>
183<pre class="programlisting"><span class="identifier">test_phrase_parser</span><span class="special">(</span><span class="string">"Hello ;"</span><span class="special">,</span> <span class="identifier">lit</span><span class="special">(</span><span class="string">"Hello"</span><span class="special">)</span> <span class="special">&gt;&gt;</span> <span class="special">&amp;</span><span class="identifier">lit</span><span class="special">(</span><span class="char">';'</span><span class="special">),</span> <span class="keyword">false</span><span class="special">);</span>
184</pre>
185<p>
186          </p>
187</div>
188<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
189<td align="left"></td>
190<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
191        Distributed under the Boost Software License, Version 1.0. (See accompanying
192        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>)
193      </p>
194</div></td>
195</tr></table>
196<hr>
197<div class="spirit-nav">
198<a accesskey="p" href="alternative.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="difference.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
199</div>
200</body>
201</html>
202