Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55278 - in trunk/libs/spirit: doc doc/html doc/html/spirit doc/html/spirit/qi/reference/string doc/qi example/qi
From: frabar666_at_[hidden]
Date: 2009-07-30 14:45:08


Author: fbarel
Date: 2009-07-30 05:58:52 EDT (Thu, 30 Jul 2009)
New Revision: 55278
URL: http://svn.boost.org/trac/boost/changeset/55278

Log:
Spirit: doc: describe usage of symbols in no_case + add 2 FAQ entries
Text files modified:
   trunk/libs/spirit/doc/faq.qbk | 51 +++++++++++++++++++++++++++++-
   trunk/libs/spirit/doc/html/index.html | 2
   trunk/libs/spirit/doc/html/spirit/faq.html | 65 +++++++++++++++++++++++++++++++++++++++
   trunk/libs/spirit/doc/html/spirit/qi/reference/string/symbols.html | 30 ++++++++++++++++++
   trunk/libs/spirit/doc/qi/string.qbk | 8 ++++
   trunk/libs/spirit/doc/spirit2.qbk | 2 +
   trunk/libs/spirit/example/qi/reference.cpp | 24 ++++++++++++++
   7 files changed, 177 insertions(+), 5 deletions(-)

Modified: trunk/libs/spirit/doc/faq.qbk
==============================================================================
--- trunk/libs/spirit/doc/faq.qbk (original)
+++ trunk/libs/spirit/doc/faq.qbk 2009-07-30 05:58:52 EDT (Thu, 30 Jul 2009)
@@ -9,7 +9,7 @@
 [section:faq Spirit FAQ]
 
 [heading I'm getting multiple symbol definition errors while using Visual C++. Anything I could do about that?]
-
+
 Do you see strange multiple symbol definition linker errors mentioning
 `boost::mpl::failed` and `boost::spirit::qi::rule`? Then this FAQ entry might
 be for you.
@@ -37,7 +37,7 @@
 
 
 [heading I'm very confused about the header hell in my boost/spirit directory. What's all this about?]
-
+
 The boost/spirit directory currently holds two versions of the Spirit library:
 __classic__ (former V1.8.x) and SpiritV2. Both are completely independent
 and usually not used at the same time. Do not mix these two in the same grammar.
@@ -72,7 +72,7 @@
     boost/spirit/include
 
 which contains forwarding headers as well. But this time the headers won't go
-away. We encourage application writers t use only the includes contained in
+away. We encourage application writers to use only the includes contained in
 this directory. This allows us to restructure the directories underneath if
 needed without worrying application compatibility. Please use those files in
 your application only. If it turns out that some forwarding file is missing,
@@ -122,4 +122,49 @@
 will be safe in the future as well, as we will probably redirect to the
 Boost.Phoenix headers as soon as these are available.
 
+
+[heading Why doesn't my symbol table work in a `no_case` directive?]
+
+In order to perform
+[/link spirit.qi.reference.directive.no_case] case-insensitive parsing with a [/$$$ TODO: link me $$$]
+[link spirit.qi.reference.string.symbols symbol table] (i.e. use a `symbols`
+parser in a `no_case` directive), that symbol table needs to be filled with
+all-lowercase contents. Entries containing one or more uppercase characters
+will not match any input.
+
+
+[heading I'm getting a compilation error mentioning `boost::function` and/or
+ `boost::function4`. What does this mean?]
+
+If you are using Visual C++ and have an error like:
+
+[pre
+error C2664: \'bool boost::function4<R,T0,T1,T2,T3>::operator ()(T0,T1,T2,T3) const\' :
+ cannot convert parameter 4 from '...' to '...'
+]
+
+or you are using GCC and have an error like:
+
+[pre
+error: no match for call to '(const boost::function<bool ()(...)>) (...)'
+note: candidates are: ... boost::function4<R,T1,T2,T3,T4>::operator()(T0,T1,T2,T3) const [with ...\]
+]
+
+then this FAQ entry may help you.
+
+The definition of a __rule__ or __grammar__ may contain a skip parser type. If
+it does, it means that non-terminal can only be used with a skip parser of a
+compatible type. The error above arises when this is not the case, i.e.:
+
+* a non-terminal defined with a skip parser type is used without a skip parser
+ (for example, a rule with a skip parser type is used inside a `lexeme`
+ directive, or a grammar with a skip parser type is used in `parse` instead of
+ `phrase_parse`),
+* or a non-terminal is used with a skip parser of an incompatible type
+ (for example, a rule defined with one skip parser type calls a second rule
+ defined with another, incompatible skip parser type).
+
+[note The same applies to __karma__, replacing 'skip parser' and `lexeme`
+ by 'delimit generator' and `verbatim`.]
+
 [endsect]

Modified: trunk/libs/spirit/doc/html/index.html
==============================================================================
--- trunk/libs/spirit/doc/html/index.html (original)
+++ trunk/libs/spirit/doc/html/index.html 2009-07-30 05:58:52 EDT (Thu, 30 Jul 2009)
@@ -187,7 +187,7 @@
 </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: July 28, 2009 at 14:55:35 GMT</small></p></td>
+<td align="left"><p><small>Last revised: July 30, 2009 at 09:20:56 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: trunk/libs/spirit/doc/html/spirit/faq.html
==============================================================================
--- trunk/libs/spirit/doc/html/spirit/faq.html (original)
+++ trunk/libs/spirit/doc/html/spirit/faq.html 2009-07-30 05:58:52 EDT (Thu, 30 Jul 2009)
@@ -111,7 +111,7 @@
 </pre>
 <p>
       which contains forwarding headers as well. But this time the headers won't
- go away. We encourage application writers t use only the includes contained
+ go away. We encourage application writers to use only the includes contained
       in this directory. This allows us to restructure the directories underneath
       if needed without worrying application compatibility. Please use those files
       in your application only. If it turns out that some forwarding file is missing,
@@ -171,6 +171,69 @@
       as we will probably redirect to the Boost.Phoenix headers as soon as these
       are available.
     </p>
+<a name="spirit.faq.why_doesn_t_my_symbol_table_work_in_a__code__phrase_role__identifier__no_case__phrase___code__directive_"></a><h4>
+<a name="id3159214"></a>
+ <a class="link" href="faq.html#spirit.faq.why_doesn_t_my_symbol_table_work_in_a__code__phrase_role__identifier__no_case__phrase___code__directive_">Why
+ doesn't my symbol table work in a <code class="computeroutput"><span class="identifier">no_case</span></code>
+ directive?</a>
+ </h4>
+<p>
+ In order to perform case-insensitive parsing with a <a class="link" href="qi/reference/string/symbols.html" title="symbols">symbol
+ table</a> (i.e. use a <code class="computeroutput"><span class="identifier">symbols</span></code>
+ parser in a <code class="computeroutput"><span class="identifier">no_case</span></code> directive),
+ that symbol table needs to be filled with all-lowercase contents. Entries containing
+ one or more uppercase characters will not match any input.
+ </p>
+<a name="spirit.faq.i_m_getting_a_compilation_error_mentioning__code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__function__phrase___code__and_or___________code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__function4__phrase___code___what_does_this_mean_"></a><h4>
+<a name="id3159289"></a>
+ <a class="link" href="faq.html#spirit.faq.i_m_getting_a_compilation_error_mentioning__code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__function__phrase___code__and_or___________code__phrase_role__identifier__boost__phrase__phrase_role__special______phrase__phrase_role__identifier__function4__phrase___code___what_does_this_mean_">I'm
+ getting a compilation error mentioning <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span></code>
+ and/or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function4</span></code>. What does this mean?</a>
+ </h4>
+<p>
+ If you are using Visual C++ and have an error like:
+ </p>
+<pre class="programlisting">error C2664: 'bool boost::function4&lt;R,T0,T1,T2,T3&gt;::operator ()(T0,T1,T2,T3) const' :
+ cannot convert parameter 4 from '...' to '...'
+</pre>
+<p>
+ or you are using GCC and have an error like:
+ </p>
+<pre class="programlisting">error: no match for call to '(const boost::function&lt;bool ()(...)&gt;) (...)'
+note: candidates are: ... boost::function4&lt;R,T1,T2,T3,T4&gt;::operator()(T0,T1,T2,T3) const [with ...]
+</pre>
+<p>
+ then this FAQ entry may help you.
+ </p>
+<p>
+ The definition of a Rule or Grammar may contain a skip parser type. If it does,
+ it means that non-terminal can only be used with a skip parser of a compatible
+ type. The error above arises when this is not the case, i.e.:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ a non-terminal defined with a skip parser type is used without a skip parser
+ (for example, a rule with a skip parser type is used inside a <code class="computeroutput"><span class="identifier">lexeme</span></code> directive, or a grammar with a skip
+ parser type is used in <code class="computeroutput"><span class="identifier">parse</span></code>
+ instead of <code class="computeroutput"><span class="identifier">phrase_parse</span></code>),
+ </li>
+<li class="listitem">
+ or a non-terminal is used with a skip parser of an incompatible type (for
+ example, a rule defined with one skip parser type calls a second rule defined
+ with another, incompatible skip parser type).
+ </li>
+</ul></div>
+<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>
+ The same applies to <span class="emphasis"><em>Spirit.Karma</em></span>, replacing 'skip parser'
+ and <code class="computeroutput"><span class="identifier">lexeme</span></code> by 'delimit generator'
+ and <code class="computeroutput"><span class="identifier">verbatim</span></code>.
+ </p></td></tr>
+</table></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/doc/html/spirit/qi/reference/string/symbols.html
==============================================================================
--- trunk/libs/spirit/doc/html/spirit/qi/reference/string/symbols.html (original)
+++ trunk/libs/spirit/doc/html/spirit/qi/reference/string/symbols.html 2009-07-30 05:58:52 EDT (Thu, 30 Jul 2009)
@@ -486,6 +486,7 @@
 </p>
 <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">parse</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">qi</span><span class="special">::</span><span class="identifier">symbols</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">ascii</span><span class="special">::</span><span class="identifier">no_case</span><span class="special">;</span>
 </pre>
 <p>
             </p>
@@ -515,6 +516,35 @@
             </p>
 <p>
           </p>
+<p>
+ When symbols is used for case-insensitive parsing (in a <code class="computeroutput"><span class="identifier">no_case</span></code> directive), added symbol strings
+ should be in lowercase. Symbol strings containing one or more uppercase
+ characters will not match any input when symbols is used in a <code class="computeroutput"><span class="identifier">no_case</span></code> directive.
+ </p>
+<p>
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="identifier">symbols</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">,</span> <span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">sym</span><span class="special">;</span>
+
+<span class="identifier">sym</span><span class="special">.</span><span class="identifier">add</span>
+ <span class="special">(</span><span class="string">"apple"</span><span class="special">,</span> <span class="number">1</span><span class="special">)</span> <span class="comment">// symbol strings are added in lowercase...
+</span> <span class="special">(</span><span class="string">"banana"</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span>
+ <span class="special">(</span><span class="string">"orange"</span><span class="special">,</span> <span class="number">3</span><span class="special">)</span>
+<span class="special">;</span>
+
+<span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>
+<span class="comment">// ...because sym is used for case-insensitive parsing
+</span><span class="identifier">test_parser_attr</span><span class="special">(</span><span class="string">"Apple"</span><span class="special">,</span> <span class="identifier">no_case</span><span class="special">[</span> <span class="identifier">sym</span> <span class="special">],</span> <span class="identifier">i</span><span class="special">);</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="identifier">test_parser_attr</span><span class="special">(</span><span class="string">"ORANGE"</span><span class="special">,</span> <span class="identifier">no_case</span><span class="special">[</span> <span class="identifier">sym</span> <span class="special">],</span> <span class="identifier">i</span><span class="special">);</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+</pre>
+<p>
+ </p>
+<p>
+ </p>
 </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/doc/qi/string.qbk
==============================================================================
--- trunk/libs/spirit/doc/qi/string.qbk (original)
+++ trunk/libs/spirit/doc/qi/string.qbk 2009-07-30 05:58:52 EDT (Thu, 30 Jul 2009)
@@ -246,6 +246,14 @@
 
 [reference_symbols_with_data]
 
+When symbols is used for case-insensitive parsing (in a
+[/link spirit.qi.reference.directive.no_case] `no_case` directive), added [/$$$ TODO: link me $$$]
+symbol strings should be in lowercase. Symbol strings containing one or more
+uppercase characters will not match any input when symbols is used in a
+`no_case` directive.
+
+[reference_symbols_with_no_case]
+
 [endsect] [/ symbols]
 
 [endsect] [/ String]

Modified: trunk/libs/spirit/doc/spirit2.qbk
==============================================================================
--- trunk/libs/spirit/doc/spirit2.qbk (original)
+++ trunk/libs/spirit/doc/spirit2.qbk 2009-07-30 05:58:52 EDT (Thu, 30 Jul 2009)
@@ -148,6 +148,7 @@
 [def __attribute__ Attribute] [/$$$ TODO: link me $$$]
 [def __compatible_attribute__ Compatible Attribute] [/$$$ TODO: link me $$$]
 [def __rule__ Rule] [/$$$ TODO: link me $$$]
+[def __grammar__ Grammar] [/$$$ TODO: link me $$$]
 [def __parser_conversion__ Parser Conversion] [/$$$ TODO: link me $$$]
 [def __delegate_pattern__ Delegate Design Pattern] [/$$$ TODO: link me $$$]
 [def __composite_pattern__ Composite Design Pattern] [/$$$ TODO: link me $$$]
@@ -157,6 +158,7 @@
 [def __karma_attribute__ Attribute] [/$$$ TODO: link me $$$]
 [def __karma_compatible_attribute__ Compatible Attribute] [/$$$ TODO: link me $$$]
 [def __karma_rule__ Rule] [/$$$ TODO: link me $$$]
+[def __karma_grammar__ Grammar] [/$$$ TODO: link me $$$]
 
 [/ Some images ]
 

Modified: trunk/libs/spirit/example/qi/reference.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/reference.cpp (original)
+++ trunk/libs/spirit/example/qi/reference.cpp 2009-07-30 05:58:52 EDT (Thu, 30 Jul 2009)
@@ -86,6 +86,7 @@
         //[reference_using_declarations_symbols
         using boost::spirit::qi::parse;
         using boost::spirit::qi::symbols;
+ using boost::spirit::ascii::no_case;
         //]
 
         //[reference_symbols_with_data
@@ -102,6 +103,29 @@
         std::cout << i << std::endl;
         //]
     }
+
+ {
+ using boost::spirit::qi::parse;
+ using boost::spirit::qi::symbols;
+ using boost::spirit::ascii::no_case;
+
+ //[reference_symbols_with_no_case
+ symbols<char, int> sym;
+
+ sym.add
+ ("apple", 1) // symbol strings are added in lowercase...
+ ("banana", 2)
+ ("orange", 3)
+ ;
+
+ int i;
+ // ...because sym is used for case-insensitive parsing
+ test_parser_attr("Apple", no_case[ sym ], i);
+ std::cout << i << std::endl;
+ test_parser_attr("ORANGE", no_case[ sym ], i);
+ std::cout << i << std::endl;
+ //]
+ }
 
     return 0;
 }


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