$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r60190 - in trunk/libs/spirit: doc/qi test/qi
From: joel_at_[hidden]
Date: 2010-03-05 10:40:13
Author: djowel
Date: 2010-03-05 10:40:12 EST (Fri, 05 Mar 2010)
New Revision: 60190
URL: http://svn.boost.org/trac/boost/changeset/60190
Log:
rules with parameters for char encoding
Text files modified: 
   trunk/libs/spirit/doc/qi/directive.qbk |     8 +++-----                                
   trunk/libs/spirit/test/qi/rule.cpp     |    37 +++++++++++++++++++++++++++++++++----   
   2 files changed, 36 insertions(+), 9 deletions(-)
Modified: trunk/libs/spirit/doc/qi/directive.qbk
==============================================================================
--- trunk/libs/spirit/doc/qi/directive.qbk	(original)
+++ trunk/libs/spirit/doc/qi/directive.qbk	2010-03-05 10:40:12 EST (Fri, 05 Mar 2010)
@@ -29,11 +29,9 @@
 of view, lexemes (and primitives) are minimal atomic units (e.g. words,
 numbers, identifiers, etc). These are the things that you'd normally put
 in the lexer (hinting at the term "lexeme"), but in a lexer-less world,
-you put in a lexeme.
-
-Seeing its subject as a primitive, the `lexeme` directive does an
-initial pre-skip (as all primitives do) and turns off white space
-skipping.
+you put these in a lexeme. Seeing its subject as a primitive, the
+`lexeme` directive does an initial pre-skip (as all primitives do) and
+turns off white space skipping.
 
 At the phrase level, the parser ignores white spaces, possibly including
 comments. Use `lexeme` in situations where you want to work at the
Modified: trunk/libs/spirit/test/qi/rule.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/rule.cpp	(original)
+++ trunk/libs/spirit/test/qi/rule.cpp	2010-03-05 10:40:12 EST (Fri, 05 Mar 2010)
@@ -10,6 +10,7 @@
 #include <boost/spirit/include/qi_string.hpp>
 #include <boost/spirit/include/qi_numeric.hpp>
 #include <boost/spirit/include/qi_auxiliary.hpp>
+#include <boost/spirit/include/qi_directive.hpp>
 #include <boost/spirit/include/qi_nonterminal.hpp>
 #include <boost/spirit/include/qi_action.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
@@ -37,6 +38,7 @@
     using boost::spirit::qi::fail;
     using boost::spirit::qi::on_error;
     using boost::spirit::qi::debug;
+    using boost::spirit::qi::lit;
 
     namespace phx = boost::phoenix;
 
@@ -134,7 +136,7 @@
         {
             char const *s1 = " a b a a b b a c ... "
               , *const e1 = s1 + std::strlen(s1);
-            BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::dont_postskip) 
+            BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::dont_postskip)
               && s1 == e1 - 5);
         }
 
@@ -142,17 +144,17 @@
         {
             char const *s1 = " a a a a b a b a b a a a b b b c "
               , *const e1 = s1 + std::strlen(s1);
-            BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::postskip) 
+            BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::postskip)
               && s1 == e1);
         }
         {
             char const *s1 = " a a a a b a b a b a a a b b b c "
               , *const e1 = s1 + std::strlen(s1);
-            BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::dont_postskip) 
+            BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::dont_postskip)
               && s1 == e1 - 1);
         }
     }
-    
+
     { // test unassigned rule
 
         rule<char const*> a;
@@ -418,6 +420,33 @@
         BOOST_TEST(!test("[123,456]", r));
     }
 
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("french")
+#endif
+    { // specifying the encoding
+
+        typedef boost::spirit::char_encoding::iso8859_1 iso8859_1;
+        rule<char const*, iso8859_1> r;
+
+        r = no_case['á'];
+        BOOST_TEST(test("Á", r));
+        r = no_case[char_('á')];
+        BOOST_TEST(test("Á", r));
+
+        r = no_case[no_case[char_("å-ï")]];
+        BOOST_TEST(test("É", r));
+        BOOST_TEST(!test("ÿ", r));
+
+        r = no_case["áÁ"];
+        BOOST_TEST(test("Áá", r));
+        r = no_case[lit("áÁ")];
+        BOOST_TEST(test("Áá", r));
+    }
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("")
+#endif
+
     return boost::report_errors();
 }