• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Kleene Parser (*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="expect.html" title="Expectation Operator (a &gt; b)">
10<link rel="next" href="list.html" title="List 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="expect.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="list.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.kleene"></a><a class="link" href="kleene.html" title="Kleene Parser (*a)">Kleene Parser
28          (<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.qi.reference.operator.kleene.h0"></a>
32            <span class="phrase"><a name="spirit.qi.reference.operator.kleene.description"></a></span><a class="link" href="kleene.html#spirit.qi.reference.operator.kleene.description">Description</a>
33          </h6>
34<p>
35            The kleene operator, <code class="computeroutput"><span class="special">*</span><span class="identifier">a</span></code>,
36            is a unary operator that matches its operand zero or more times.
37          </p>
38<h6>
39<a name="spirit.qi.reference.operator.kleene.h1"></a>
40            <span class="phrase"><a name="spirit.qi.reference.operator.kleene.header"></a></span><a class="link" href="kleene.html#spirit.qi.reference.operator.kleene.header">Header</a>
41          </h6>
42<pre class="programlisting"><span class="comment">// forwards to &lt;boost/spirit/home/qi/operator/kleene.hpp&gt;</span>
43<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_kleene</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
44</pre>
45<p>
46            Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>.
47          </p>
48<h6>
49<a name="spirit.qi.reference.operator.kleene.h2"></a>
50            <span class="phrase"><a name="spirit.qi.reference.operator.kleene.model_of"></a></span><a class="link" href="kleene.html#spirit.qi.reference.operator.kleene.model_of">Model
51            of</a>
52          </h6>
53<div class="blockquote"><blockquote class="blockquote"><p>
54              <a class="link" href="../parser_concepts/unaryparser.html" title="UnaryParser"><code class="computeroutput"><span class="identifier">UnaryParser</span></code></a>
55            </p></blockquote></div>
56<div class="variablelist">
57<p class="title"><b>Notation</b></p>
58<dl class="variablelist">
59<dt><span class="term"><code class="computeroutput"><span class="identifier">a</span></code></span></dt>
60<dd><p>
61                  A <a class="link" href="../parser_concepts/parser.html" title="Parser"><code class="computeroutput"><span class="identifier">Parser</span></code></a>
62                </p></dd>
63</dl>
64</div>
65<h6>
66<a name="spirit.qi.reference.operator.kleene.h3"></a>
67            <span class="phrase"><a name="spirit.qi.reference.operator.kleene.expression_semantics"></a></span><a class="link" href="kleene.html#spirit.qi.reference.operator.kleene.expression_semantics">Expression
68            Semantics</a>
69          </h6>
70<p>
71            Semantics of an expression is defined only where it differs from, or
72            is not defined in <a class="link" href="../parser_concepts/unaryparser.html" title="UnaryParser"><code class="computeroutput"><span class="identifier">UnaryParser</span></code></a>.
73          </p>
74<div class="informaltable"><table class="table">
75<colgroup>
76<col>
77<col>
78</colgroup>
79<thead><tr>
80<th>
81                    <p>
82                      Expression
83                    </p>
84                  </th>
85<th>
86                    <p>
87                      Semantics
88                    </p>
89                  </th>
90</tr></thead>
91<tbody><tr>
92<td>
93                    <p>
94                      <code class="computeroutput"><span class="special">*</span><span class="identifier">a</span></code>
95                    </p>
96                  </td>
97<td>
98                    <p>
99                      Match <code class="computeroutput"><span class="identifier">a</span></code> zero
100                      or more times.
101                    </p>
102                  </td>
103</tr></tbody>
104</table></div>
105<h6>
106<a name="spirit.qi.reference.operator.kleene.h4"></a>
107            <span class="phrase"><a name="spirit.qi.reference.operator.kleene.attributes"></a></span><a class="link" href="kleene.html#spirit.qi.reference.operator.kleene.attributes">Attributes</a>
108          </h6>
109<p>
110            See <a class="link" href="../../quick_reference/compound_attribute_rules.html#spirit.qi.quick_reference.compound_attribute_rules.notation">Compound
111            Attribute Notation</a>.
112          </p>
113<div class="informaltable"><table class="table">
114<colgroup>
115<col>
116<col>
117</colgroup>
118<thead><tr>
119<th>
120                    <p>
121                      Expression
122                    </p>
123                  </th>
124<th>
125                    <p>
126                      Attribute
127                    </p>
128                  </th>
129</tr></thead>
130<tbody><tr>
131<td>
132                    <p>
133                      <code class="computeroutput"><span class="special">*</span><span class="identifier">a</span></code>
134                    </p>
135                  </td>
136<td>
137                    <p>
138</p>
139<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">--&gt;</span> <span class="special">*</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;</span>
140<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--&gt;</span> <span class="special">*</span><span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span></pre>
141<p>
142                    </p>
143                  </td>
144</tr></tbody>
145</table></div>
146<h6>
147<a name="spirit.qi.reference.operator.kleene.h5"></a>
148            <span class="phrase"><a name="spirit.qi.reference.operator.kleene.complexity"></a></span><a class="link" href="kleene.html#spirit.qi.reference.operator.kleene.complexity">Complexity</a>
149          </h6>
150<div class="blockquote"><blockquote class="blockquote"><p>
151              The overall complexity of the Kleene star is defined by the complexity
152              of its subject, <code class="computeroutput"><span class="identifier">a</span></code>,
153              multiplied by the number of repetitions. The complexity of the Kleene
154              star itself is O(N), where N is the number successful repetitions.
155            </p></blockquote></div>
156<h6>
157<a name="spirit.qi.reference.operator.kleene.h6"></a>
158            <span class="phrase"><a name="spirit.qi.reference.operator.kleene.example"></a></span><a class="link" href="kleene.html#spirit.qi.reference.operator.kleene.example">Example</a>
159          </h6>
160<div class="note"><table border="0" summary="Note">
161<tr>
162<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
163<th align="left">Note</th>
164</tr>
165<tr><td align="left" valign="top"><p>
166              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>
167              section.
168            </p></td></tr>
169</table></div>
170<p>
171            Some using declarations:
172          </p>
173<p>
174</p>
175<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">int_</span><span class="special">;</span>
176</pre>
177<p>
178          </p>
179<p>
180            Parse a comma separated list of numbers and put them in a vector:
181          </p>
182<p>
183</p>
184<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">attr</span><span class="special">;</span>
185<span class="identifier">test_phrase_parser_attr</span><span class="special">(</span>
186    <span class="string">"111, 222, 333, 444, 555"</span><span class="special">,</span> <span class="identifier">int_</span> <span class="special">&gt;&gt;</span> <span class="special">*(</span><span class="char">','</span> <span class="special">&gt;&gt;</span> <span class="identifier">int_</span><span class="special">),</span> <span class="identifier">attr</span><span class="special">);</span>
187<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span>
188    <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">&lt;&lt;</span> <span class="char">','</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">&lt;&lt;</span> <span class="char">','</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">[</span><span class="number">2</span><span class="special">]</span> <span class="special">&lt;&lt;</span> <span class="char">','</span>
189    <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">[</span><span class="number">3</span><span class="special">]</span> <span class="special">&lt;&lt;</span> <span class="char">','</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">[</span><span class="number">4</span><span class="special">]</span>
190    <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
191</pre>
192<p>
193          </p>
194</div>
195<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
196<td align="left"></td>
197<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
198        Distributed under the Boost Software License, Version 1.0. (See accompanying
199        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>)
200      </p>
201</div></td>
202</tr></table>
203<hr>
204<div class="spirit-nav">
205<a accesskey="p" href="expect.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="list.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
206</div>
207</body>
208</html>
209