|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54897 - in trunk/libs/spirit/repository: doc doc/html doc/html/spirit_repository doc/qi example/qi
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-11 14:24:46
Author: hkaiser
Date: 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
New Revision: 54897
URL: http://svn.boost.org/trac/boost/changeset/54897
Log:
Spirit: adding flush_multi_pass to the repository
Added:
trunk/libs/spirit/repository/doc/qi/compound_parsers.qbk (contents, props changed)
trunk/libs/spirit/repository/doc/qi/directives.qbk (contents, props changed)
trunk/libs/spirit/repository/doc/qi/flush_multi_pass.qbk (contents, props changed)
trunk/libs/spirit/repository/doc/qi/primitive_parsers.qbk (contents, props changed)
trunk/libs/spirit/repository/example/qi/Jamfile (contents, props changed)
trunk/libs/spirit/repository/example/qi/flush_multi_pass.cpp (contents, props changed)
trunk/libs/spirit/repository/example/qi/flush_multi_pass.txt (contents, props changed)
Text files modified:
trunk/libs/spirit/repository/doc/html/index.html | 10 -
trunk/libs/spirit/repository/doc/html/spirit_repository/karma_components.html | 18 +-
trunk/libs/spirit/repository/doc/html/spirit_repository/preface.html | 8
trunk/libs/spirit/repository/doc/html/spirit_repository/qi_components.html | 199 +++++++++++++++++++++++++++++++++++++--
trunk/libs/spirit/repository/doc/qi.qbk | 10 -
5 files changed, 205 insertions(+), 40 deletions(-)
Modified: trunk/libs/spirit/repository/doc/html/index.html
==============================================================================
--- trunk/libs/spirit/repository/doc/html/index.html (original)
+++ trunk/libs/spirit/repository/doc/html/index.html 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -34,7 +34,7 @@
<div><p class="copyright">Copyright © 2001-2009 Joel
de Guzman, Hartmut Kaiser</p></div>
<div><div class="legalnotice" title="Legal Notice">
-<a name="id1041938"></a><p>
+<a name="id1024159"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
</p>
@@ -57,16 +57,14 @@
<dd><dl>
<dt><span class="section"><a href="spirit_repository/qi_components.html#spirit_repository.qi_components.qi_parser_primitives">Qi
Parser Primitives</a></span></dt>
-<dt><span class="section"><a href="spirit_repository/qi_components.html#spirit_repository.qi_components.qi_parser_directives">Qi
- Parser Directives</a></span></dt>
-<dt><span class="section"><a href="spirit_repository/qi_components.html#spirit_repository.qi_components.qi_compound_parsers">Qi
- Compound Parsers</a></span></dt>
+<dd><dl><dt><span class="section"><a href="spirit_repository/qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser">Qi
+ flush_multi_pass parser</a></span></dt></dl></dd>
</dl></dd>
</dl>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: June 24, 2009 at 20:05:29 GMT</small></p></td>
+<td align="left"><p><small>Last revised: July 11, 2009 at 18:03:03 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: trunk/libs/spirit/repository/doc/html/spirit_repository/karma_components.html
==============================================================================
--- trunk/libs/spirit/repository/doc/html/spirit_repository/karma_components.html (original)
+++ trunk/libs/spirit/repository/doc/html/spirit_repository/karma_components.html 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -45,7 +45,7 @@
Confix Generator</a>
</h4></div></div></div>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.description"></a><h6>
-<a name="id1042334"></a>
+<a name="id1024555"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.description">Description</a>
</h6>
<p>
@@ -112,19 +112,19 @@
tag using a simple: <code class="computeroutput"><span class="identifier">ol</span><span class="special">[</span><span class="string">"Some text"</span><span class="special">]</span></code> (which results in <code class="computeroutput"><span class="special"><</span><span class="identifier">ol</span><span class="special">></span><span class="identifier">Some</span> <span class="identifier">text</span><span class="special"></</span><span class="identifier">ol</span><span class="special">></span></code>).
</p>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.header"></a><h6>
-<a name="id1043258"></a>
+<a name="id1025479"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.header">Header</a>
</h6>
<pre class="programlisting"><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">repository</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma_confix</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
</pre>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.synopsis"></a><h6>
-<a name="id1043328"></a>
+<a name="id1025549"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.synopsis">Synopsis</a>
</h6>
<pre class="programlisting"><span class="identifier">confix</span><span class="special">(</span><span class="identifier">prefix</span><span class="special">,</span> <span class="identifier">suffix</span><span class="special">)[</span><span class="identifier">subject</span><span class="special">]</span>
</pre>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.parameters"></a><h6>
-<a name="id1043376"></a>
+<a name="id1025597"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.parameters">Parameters</a>
</h6>
<div class="informaltable"><table class="table">
@@ -193,7 +193,7 @@
All three parameters can be arbitrary complex generators themselves.
</p>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.attribute"></a><h6>
-<a name="id1046270"></a>
+<a name="id1027951"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.attribute">Attribute</a>
</h6>
<p>
@@ -220,7 +220,7 @@
</p></td></tr>
</table></div>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.example"></a><h6>
-<a name="id1046445"></a>
+<a name="id1028126"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.example">Example</a>
</h6>
<p>
@@ -229,7 +229,7 @@
styles and a function prototype (for the full example code see here: confix.cpp)
</p>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.prerequisites"></a><h6>
-<a name="id1046475"></a>
+<a name="id1028156"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.prerequisites">Prerequisites</a>
</h6>
<p>
@@ -267,7 +267,7 @@
<p>
</p>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.generating_different_comment_styles"></a><h6>
-<a name="id1046719"></a>
+<a name="id1028399"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.generating_different_comment_styles">Generating
Different Comment Styles</a>
</h6>
@@ -319,7 +319,7 @@
*/</span> </code>.
</p>
<a name="spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.generating_a_function_prototype"></a><h6>
-<a name="id1047020"></a>
+<a name="id1028701"></a>
<a class="link" href="karma_components.html#spirit_repository.karma_components.karma_generator_primitives.karma_confix_generator.generating_a_function_prototype">Generating
a Function Prototype</a>
</h6>
Modified: trunk/libs/spirit/repository/doc/html/spirit_repository/preface.html
==============================================================================
--- trunk/libs/spirit/repository/doc/html/spirit_repository/preface.html (original)
+++ trunk/libs/spirit/repository/doc/html/spirit_repository/preface.html 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -27,7 +27,7 @@
<a name="spirit_repository.preface"></a><a class="link" href="preface.html" title="Preface">Preface</a>
</h2></div></div></div>
<a name="spirit_repository.preface.the_spirit_repository"></a><h4>
-<a name="id1041968"></a>
+<a name="id1024189"></a>
<a class="link" href="preface.html#spirit_repository.preface.the_spirit_repository">The Spirit
Repository</a>
</h4>
@@ -40,7 +40,7 @@
General List</a>.
</p>
<a name="spirit_repository.preface.how_to_use_this_manual"></a><h4>
-<a name="id1042003"></a>
+<a name="id1024224"></a>
<a class="link" href="preface.html#spirit_repository.preface.how_to_use_this_manual">How to use
this manual</a>
</h4>
@@ -49,7 +49,7 @@
icons precede some text to indicate:
</p>
<div class="table">
-<a name="id1042016"></a><p class="title"><b>Table 1. Icons</b></p>
+<a name="id1024237"></a><p class="title"><b>Table 1. Icons</b></p>
<div class="table-contents"><table class="table" summary="Icons">
<colgroup>
<col>
@@ -170,7 +170,7 @@
Tools</a>.
</p>
<a name="spirit_repository.preface.support"></a><h4>
-<a name="id1042258"></a>
+<a name="id1024478"></a>
<a class="link" href="preface.html#spirit_repository.preface.support">Support</a>
</h4>
<p>
Modified: trunk/libs/spirit/repository/doc/html/spirit_repository/qi_components.html
==============================================================================
--- trunk/libs/spirit/repository/doc/html/spirit_repository/qi_components.html (original)
+++ trunk/libs/spirit/repository/doc/html/spirit_repository/qi_components.html 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -28,23 +28,194 @@
<div class="toc"><dl>
<dt><span class="section"><a href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives">Qi
Parser Primitives</a></span></dt>
-<dt><span class="section"><a href="qi_components.html#spirit_repository.qi_components.qi_parser_directives">Qi
- Parser Directives</a></span></dt>
-<dt><span class="section"><a href="qi_components.html#spirit_repository.qi_components.qi_compound_parsers">Qi
- Compound Parsers</a></span></dt>
+<dd><dl><dt><span class="section"><a href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser">Qi
+ flush_multi_pass parser</a></span></dt></dl></dd>
</dl></div>
-<div class="section" title="Qi Parser Primitives"><div class="titlepage"><div><div><h3 class="title">
+<div class="section" title="Qi Parser Primitives">
+<div class="titlepage"><div><div><h3 class="title">
<a name="spirit_repository.qi_components.qi_parser_primitives"></a><a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives" title="Qi Parser Primitives">Qi
Parser Primitives</a>
-</h3></div></div></div></div>
-<div class="section" title="Qi Parser Directives"><div class="titlepage"><div><div><h3 class="title">
-<a name="spirit_repository.qi_components.qi_parser_directives"></a><a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_directives" title="Qi Parser Directives">Qi
- Parser Directives</a>
-</h3></div></div></div></div>
-<div class="section" title="Qi Compound Parsers"><div class="titlepage"><div><div><h3 class="title">
-<a name="spirit_repository.qi_components.qi_compound_parsers"></a><a class="link" href="qi_components.html#spirit_repository.qi_components.qi_compound_parsers" title="Qi Compound Parsers">Qi
- Compound Parsers</a>
-</h3></div></div></div></div>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section"><a href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser">Qi
+ flush_multi_pass parser</a></span></dt></dl></div>
+<div class="section" title="Qi flush_multi_pass parser">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser"></a><a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser" title="Qi flush_multi_pass parser">Qi
+ flush_multi_pass parser</a>
+</h4></div></div></div>
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.description"></a><h6>
+<a name="id1029044"></a>
+ <a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.description">Description</a>
+ </h6>
+<p>
+ The <span class="emphasis"><em>Spirit.Qi</em></span> <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code>
+ parser is a primitive (pseudo) parser component allowing to clear the internal
+ buffer of a <code class="computeroutput"><span class="identifier">multi_pass</span></code>
+ iterator. Clearing the buffer of a <code class="computeroutput"><span class="identifier">multi_pass</span></code>
+ might be beneficial for grammars where it is clear that no backtracking
+ can occur. The general syntax for using the <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code>
+ is:
+ </p>
+<pre class="programlisting"><span class="identifier">flush_multi_pass</span>
+</pre>
+<p>
+ which will class the <code class="computeroutput"><span class="identifier">clear_queue</span><span class="special">()</span></code> member function if the current iterators
+ are of the type <code class="computeroutput"><span class="identifier">multi_pass</span></code>.
+ For all other iterator types this is a no-op. The <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code>
+ generates a parser component which always succeeds and which does not consume
+ any input (very much like <code class="computeroutput"><span class="identifier">eps</span></code>).
+ </p>
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.header"></a><h6>
+<a name="id1029139"></a>
+ <a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.header">Header</a>
+ </h6>
+<pre class="programlisting"><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">repository</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">qi_flush_multi_pass</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+</pre>
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.synopsis"></a><h6>
+<a name="id1029208"></a>
+ <a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.synopsis">Synopsis</a>
+ </h6>
+<pre class="programlisting"><span class="identifier">flush_multi_pass</span>
+</pre>
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.parameters"></a><h6>
+<a name="id1029230"></a>
+ <a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.parameters">Parameters</a>
+ </h6>
+<p>
+ The <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code> does
+ not require any parameters.
+ </p>
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.attribute"></a><h6>
+<a name="id1029254"></a>
+ <a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.attribute">Attribute</a>
+ </h6>
+<p>
+ The <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code> component
+ exposes no attribute (the exposed attribute type is <code class="computeroutput"><span class="identifier">unused_type</span></code>):
+ </p>
+<pre class="programlisting"><span class="identifier">flush_multi_pass</span> <span class="special">--></span> <span class="identifier">unused</span>
+</pre>
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.example"></a><h6>
+<a name="id1029303"></a>
+ <a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.example">Example</a>
+ </h6>
+<p>
+ The following example shows a simple use case of the <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code>
+ parser.
+ </p>
+<p>
+ We will illustrate its usage by generating different comment styles and
+ a function prototype (for the full example code see here: flush_multi_pass.cpp)
+ </p>
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.prerequisites"></a><h6>
+<a name="id1029335"></a>
+ <a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.prerequisites">Prerequisites</a>
+ </h6>
+<p>
+ In addition to the main header file needed to include the core components
+ implemented in <span class="emphasis"><em>Spirit.Qi</em></span> we add the header file needed
+ for the new <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code>
+ parser.
+ </p>
+<p>
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><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</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<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">repository</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">qi_flush_multi_pass</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+</pre>
+<p>
+ </p>
+<p>
+ </p>
+<p>
+ To make all the code below more readable we introduce the following namespaces.
+ </p>
+<p>
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">;</span>
+<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">repository</span><span class="special">::</span><span class="identifier">flush_multi_pass</span><span class="special">;</span>
+</pre>
+<p>
+ </p>
+<p>
+ </p>
+<a name="spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.clearing_the_internal_buffer"></a><h6>
+<a name="id1029547"></a>
+ <a class="link" href="qi_components.html#spirit_repository.qi_components.qi_parser_primitives.qi_flush_multi_pass_parser.clearing_the_internal_buffer">Clearing
+ the internal buffer</a>
+ </h6>
+<p>
+ The example grammar recognizes the (simplified) preprocessor commands
+ <code class="computeroutput"><span class="preprocessor">#define</span></code> and <code class="computeroutput"><span class="preprocessor">#undef</span></code> both of which are constraint
+ to a single line. This makes it possible to delete all internal iterator
+ buffers on each detected line break. This is safe as no backtracking will
+ occur after any line end. The following code snippet shows the usage of
+ <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code> for this
+ purpose.
+ </p>
+<p>
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Iterator</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Skipper</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">preprocessor</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">grammar</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">Skipper</span><span class="special">></span>
+<span class="special">{</span>
+ <span class="comment">// This is a simplified preprocessor grammar recognizing
+</span> <span class="comment">//
+</span> <span class="comment">// #define MACRONAME something
+</span> <span class="comment">// #undef MACRONAME
+</span> <span class="comment">//
+</span> <span class="comment">// Its sole purpose is to show an example how to use the
+</span> <span class="comment">// flush_multi_pass parser. At the end of each line no backtracking can
+</span> <span class="comment">// occur anymore so that it's safe to clear all internal buffers in the
+</span> <span class="comment">// multi_pass.
+</span> <span class="identifier">preprocessor</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">preprocessor</span><span class="special">::</span><span class="identifier">base_type</span><span class="special">(</span><span class="identifier">file</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">using</span> <span class="identifier">spirit</span><span class="special">::</span><span class="identifier">ascii</span><span class="special">::</span><span class="identifier">char_</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qi</span><span class="special">::</span><span class="identifier">eol</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qi</span><span class="special">::</span><span class="identifier">lit</span><span class="special">;</span>
+
+ <span class="identifier">file</span> <span class="special">=</span>
+ <span class="special">*</span><span class="identifier">line</span>
+ <span class="special">;</span>
+
+ <span class="identifier">line</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">command</span> <span class="special">|</span> <span class="special">*(</span><span class="identifier">char_</span> <span class="special">-</span> <span class="identifier">eol</span><span class="special">)</span> <span class="special">)</span>
+ <span class="special">>></span> <span class="identifier">eol</span>
+ <span class="special">>></span> <span class="identifier">flush_multi_pass</span>
+ <span class="special">;</span>
+
+ <span class="identifier">command</span> <span class="special">=</span>
+ <span class="string">"#define"</span> <span class="special">>></span> <span class="special">*</span><span class="identifier">lit</span><span class="special">(</span><span class="char">' '</span><span class="special">)</span> <span class="special">>></span> <span class="special">*(</span><span class="identifier">char_</span> <span class="special">-</span> <span class="char">' '</span><span class="special">)</span> <span class="special">>></span> <span class="special">*</span><span class="identifier">lit</span><span class="special">(</span><span class="char">' '</span><span class="special">)</span> <span class="special">>></span> <span class="special">*(</span><span class="identifier">char_</span> <span class="special">-</span> <span class="identifier">eol</span><span class="special">)</span>
+ <span class="special">|</span> <span class="string">"#undef"</span> <span class="special">>></span> <span class="special">*</span><span class="identifier">lit</span><span class="special">(</span><span class="char">' '</span><span class="special">)</span> <span class="special">>></span> <span class="special">*(</span><span class="identifier">char_</span> <span class="special">-</span> <span class="identifier">eol</span><span class="special">)</span>
+ <span class="special">;</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">rule</span><span class="special"><</span><span class="identifier">Iterator</span><span class="special">,</span> <span class="identifier">Skipper</span><span class="special">></span> <span class="identifier">file</span><span class="special">,</span> <span class="identifier">line</span><span class="special">,</span> <span class="identifier">command</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<p>
+ </p>
+<div class="note" title="Note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Using the <code class="computeroutput"><span class="identifier">flush_multi_pass</span></code>
+ parser component with iterators other than <code class="computeroutput"><span class="identifier">multi_pass</span></code>
+ is safe to use as it has no effect on the parsing.
+ </p></td></tr>
+</table></div>
+</div>
+</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
Modified: trunk/libs/spirit/repository/doc/qi.qbk
==============================================================================
--- trunk/libs/spirit/repository/doc/qi.qbk (original)
+++ trunk/libs/spirit/repository/doc/qi.qbk 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -8,13 +8,9 @@
[section Qi Components]
-[section Qi Parser Primitives]
-[endsect]
-[section Qi Parser Directives]
-[endsect]
-[section Qi Compound Parsers]
-[endsect]
-
+[include qi/primitive_parsers.qbk]
+[/include qi/directives.qbk]
+[/include qi/compount_parsers.qbk]
[endsect] [/ Qi]
Added: trunk/libs/spirit/repository/doc/qi/compound_parsers.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/repository/doc/qi/compound_parsers.qbk 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -0,0 +1,10 @@
+[/==============================================================================
+ Copyright (C) 2001-2009 Joel de Guzman
+ Copyright (C) 2001-2009 Hartmut Kaiser
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+===============================================================================/]
+
+[section Qi Compound Parsers]
+[endsect]
Added: trunk/libs/spirit/repository/doc/qi/directives.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/repository/doc/qi/directives.qbk 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -0,0 +1,10 @@
+[/==============================================================================
+ Copyright (C) 2001-2009 Joel de Guzman
+ Copyright (C) 2001-2009 Hartmut Kaiser
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+===============================================================================/]
+
+[section Qi Parser Directives]
+[endsect]
Added: trunk/libs/spirit/repository/doc/qi/flush_multi_pass.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/repository/doc/qi/flush_multi_pass.qbk 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -0,0 +1,80 @@
+[/==============================================================================
+ Copyright (C) 2001-2009 Hartmut Kaiser
+ Copyright (C) 2001-2009 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+===============================================================================/]
+
+[section Qi flush_multi_pass parser]
+
+[heading Description]
+
+The __qi__ `flush_multi_pass` parser is a primitive (pseudo) parser component
+allowing to clear the internal buffer of a `multi_pass` iterator. Clearing the
+buffer of a `multi_pass` might be beneficial for grammars where it is clear
+that no backtracking can occur.
+The general syntax for using the `flush_multi_pass` is:
+
+ flush_multi_pass
+
+which will call the `clear_queue()` member function if the current iterators
+are of the type `multi_pass`. For all other iterator types this is a no-op.
+The `flush_multi_pass` generates a parser component which always succeeds and
+which does not consume any input (very much like `eps`).
+
+[heading Header]
+
+ #include <boost/spirit/repository/include/qi_flush_multi_pass.hpp>
+
+[heading Synopsis]
+
+ flush_multi_pass
+
+[heading Parameters]
+
+The `flush_multi_pass` does not require any parameters.
+
+[heading Attribute]
+
+The `flush_multi_pass` component exposes no attribute (the exposed attribute
+type is `unused_type`):
+
+ flush_multi_pass --> unused
+
+[heading Example]
+
+The following example shows a simple use case of the `flush_multi_pass` parser.
+
+We will illustrate its usage by generating different comment styles and a
+function prototype (for the full example code see here:
+[@../../example/qi/flush_multi_pass.cpp flush_multi_pass.cpp])
+
+[import ../example/qi/flush_multi_pass.cpp]
+
+[heading Prerequisites]
+
+In addition to the main header file needed to include the core components
+implemented in __qi__ we add the header file needed for the new
+`flush_multi_pass` parser.
+
+[qi_flush_multi_pass_includes]
+
+To make all the code below more readable we introduce the following namespaces.
+
+[qi_flush_multi_pass_namespace]
+
+[heading Clearing the internal buffer]
+
+The example grammar recognizes the (simplified) preprocessor commands `#define`
+and `#undef` both of which are constraint to a single line. This makes it
+possible to delete all internal iterator buffers on each detected line break.
+This is safe as no backtracking will occur after any line end. The following
+code snippet shows the usage of `flush_multi_pass` for this purpose.
+
+[qi_flush_multi_pass_clear_buffer]
+
+[note Using the `flush_multi_pass` parser component with iterators other than
+ `multi_pass` is safe to use as it has no effect on the parsing.]
+
+[endsect]
Added: trunk/libs/spirit/repository/doc/qi/primitive_parsers.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/repository/doc/qi/primitive_parsers.qbk 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -0,0 +1,11 @@
+[/==============================================================================
+ Copyright (C) 2001-2009 Joel de Guzman
+ Copyright (C) 2001-2009 Hartmut Kaiser
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+===============================================================================/]
+
+[section Qi Parser Primitives]
+[include flush_multi_pass.qbk]
+[endsect]
Added: trunk/libs/spirit/repository/example/qi/Jamfile
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/repository/example/qi/Jamfile 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -0,0 +1,12 @@
+#==============================================================================
+# Copyright (c) 2001-2009 Joel de Guzman
+# Copyright (c) 2001-2009 Hartmut Kaiser
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#==============================================================================
+
+project spirit_v2_repository/example_qi ;
+
+exe flush_multi_pass : flush_multi_pass.cpp ;
+
Added: trunk/libs/spirit/repository/example/qi/flush_multi_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/repository/example/qi/flush_multi_pass.cpp 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -0,0 +1,98 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// The purpose of this example is to demonstrate a simple use case for the
+// flush_multi_pass parser.
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+//[qi_flush_multi_pass_includes
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/repository/include/qi_flush_multi_pass.hpp>
+//]
+
+//[qi_flush_multi_pass_namespace
+using namespace boost::spirit;
+using boost::spirit::repository::flush_multi_pass;
+//]
+
+namespace client
+{
+ //[qi_flush_multi_pass_clear_buffer
+ template <typename Iterator, typename Skipper>
+ struct preprocessor : spirit::qi::grammar<Iterator, Skipper>
+ {
+ // This is a simplified preprocessor grammar recognizing
+ //
+ // #define MACRONAME something
+ // #undef MACRONAME
+ //
+ // Its sole purpose is to show an example how to use the
+ // flush_multi_pass parser. At the end of each line no backtracking can
+ // occur anymore so that it's safe to clear all internal buffers in the
+ // multi_pass.
+ preprocessor() : preprocessor::base_type(file)
+ {
+ using spirit::ascii::char_;
+ using spirit::qi::eol;
+ using spirit::qi::lit;
+
+ file =
+ *line
+ ;
+
+ line = ( command | *(char_ - eol) )
+ >> eol
+ >> flush_multi_pass
+ ;
+
+ command =
+ "#define" >> *lit(' ') >> *(char_ - ' ') >> *lit(' ') >> *(char_ - eol)
+ | "#undef" >> *lit(' ') >> *(char_ - eol)
+ ;
+ }
+
+ spirit::qi::rule<Iterator, Skipper> file, line, command;
+ };
+ //]
+}
+
+template <typename Iterator, typename Skipper>
+bool parse(Iterator& first, Iterator end, Skipper const& skipper)
+{
+ client::preprocessor<Iterator, Skipper> g;
+ return boost::spirit::qi::phrase_parse(first, end, g, skipper);
+}
+
+int main()
+{
+ namespace spirit = boost::spirit;
+ using spirit::ascii::char_;
+ using spirit::qi::eol;
+
+ std::ifstream in("flush_multi_pass.txt"); // we get our input from this file
+ if (!in.is_open()) {
+ std::cout << "Could not open input file: 'flush_multi_pass.txt'" << std::endl;
+ return -1;
+ }
+
+ typedef std::istreambuf_iterator<char> base_iterator_type;
+ spirit::multi_pass<base_iterator_type> first =
+ spirit::make_default_multi_pass(base_iterator_type(in));
+ spirit::multi_pass<base_iterator_type> end =
+ spirit::make_default_multi_pass(base_iterator_type());
+
+ bool result = parse(first, end, '#' >> *(char_ - eol) >> eol);
+ if (!result) {
+ std::cout << "Failed parsing input file!" << std::endl;
+ return -2;
+ }
+
+ std::cout << "Successfully parsed input file!" << std::endl;
+ return 0;
+}
+
Added: trunk/libs/spirit/repository/example/qi/flush_multi_pass.txt
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/repository/example/qi/flush_multi_pass.txt 2009-07-11 14:24:45 EDT (Sat, 11 Jul 2009)
@@ -0,0 +1,8 @@
+# Copyright (c) 2001-2009 Hartmut Kaiser
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define MACRO foo
+#undef MACRO
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk