Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73443 - sandbox/coerce/libs/coerce/example
From: vexocide_at_[hidden]
Date: 2011-07-30 10:45:37


Author: vexocide
Date: 2011-07-30 10:45:36 EDT (Sat, 30 Jul 2011)
New Revision: 73443
URL: http://svn.boost.org/trac/boost/changeset/73443

Log:
Made the examples compatible with older version of boost
Text files modified:
   sandbox/coerce/libs/coerce/example/grammar.cpp | 17 +++++++++++++----
   sandbox/coerce/libs/coerce/example/rule.cpp | 21 +++++++++++++++------
   2 files changed, 28 insertions(+), 10 deletions(-)

Modified: sandbox/coerce/libs/coerce/example/grammar.cpp
==============================================================================
--- sandbox/coerce/libs/coerce/example/grammar.cpp (original)
+++ sandbox/coerce/libs/coerce/example/grammar.cpp 2011-07-30 10:45:36 EDT (Sat, 30 Jul 2011)
@@ -4,8 +4,6 @@
 // (See accompanying file ../../../LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
-
 #include <boost/coerce.hpp>
 #include <boost/spirit/include/karma_grammar.hpp>
 #include <boost/spirit/include/karma_uint.hpp>
@@ -17,6 +15,7 @@
 #include <boost/spirit/include/qi_sequence.hpp>
 
 #include <iostream>
+#include <limits>
 #include <string>
 
 namespace tag {
@@ -28,9 +27,14 @@
             : spirit::qi::grammar<Iterator, Target()> {
             parser(tag::hexadecimal const &)
                 : parser::base_type(start) {
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+ start = spirit::qi::lit("0x")
+ >> spirit::qi::hex;
+#else
                 start = spirit::qi::lit_type()("0x")
>> spirit::qi::hex_type();
- }
+#endif
+ }
 
             spirit::qi::rule<Iterator, Target()> start;
         };
@@ -40,8 +44,13 @@
             : spirit::karma::grammar<Iterator, Source()> {
             generator(tag::hexadecimal const &)
                 : generator::base_type(start) {
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+ start = spirit::karma::lit("0x")
+ << spirit::karma::hex;
+#else
                 start = spirit::karma::lit_type()("0x")
                         << spirit::karma::hex_type();
+#endif
             }
 
             spirit::karma::rule<Iterator, Source()> start;
@@ -58,7 +67,7 @@
 
         static inline type
         call(T const &, ::tag::hexadecimal const &) {
- return 2 + 8;
+ return 2 + std::numeric_limits<unsigned int>::digits / 4;
         }
     };
 

Modified: sandbox/coerce/libs/coerce/example/rule.cpp
==============================================================================
--- sandbox/coerce/libs/coerce/example/rule.cpp (original)
+++ sandbox/coerce/libs/coerce/example/rule.cpp 2011-07-30 10:45:36 EDT (Sat, 30 Jul 2011)
@@ -4,19 +4,18 @@
 // (See accompanying file ../../../LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
-
 #include <boost/coerce.hpp>
-#include <boost/spirit/include/karma_uint.hpp>
 #include <boost/spirit/include/karma_sequence.hpp>
 #include <boost/spirit/include/karma_string.hpp>
 #include <boost/spirit/include/karma_rule.hpp>
+#include <boost/spirit/include/karma_uint.hpp>
 #include <boost/spirit/include/qi_lit.hpp>
-#include <boost/spirit/include/qi_uint.hpp>
-#include <boost/spirit/include/qi_sequence.hpp>
 #include <boost/spirit/include/qi_rule.hpp>
+#include <boost/spirit/include/qi_sequence.hpp>
+#include <boost/spirit/include/qi_uint.hpp>
 
 #include <iostream>
+#include <limits>
 #include <string>
 
 namespace tag {
@@ -28,8 +27,13 @@
             : spirit::qi::rule<Iterator, Target()> {
             parser(tag::hexadecimal const &)
                 : spirit::qi::rule<Iterator, Target()>(
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+ spirit::qi::lit("0x")
+ >> spirit::qi::hex
+#else
                         spirit::qi::lit_type()("0x")
>> spirit::qi::hex_type()
+#endif
                 ) { }
         };
 
@@ -38,8 +42,13 @@
             : spirit::karma::rule<Iterator, Source()> {
             generator(tag::hexadecimal const &)
                 : spirit::karma::rule<Iterator, Source()>(
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+ spirit::karma::lit("0x")
+ << spirit::karma::hex
+#else
                         spirit::karma::lit_type()("0x")
                     << spirit::karma::hex_type()
+#endif
                 ) { }
         };
     };
@@ -54,7 +63,7 @@
 
         static inline type
         call(T const &, ::tag::hexadecimal const &) {
- return 2 + 8;
+ return 2 + std::numeric_limits<unsigned int>::digits / 4;
         }
     };
 


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