Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72434 - in branches/release: . libs libs/spirit libs/spirit/example libs/spirit/example/qi/compiler_tutorial/calc7 libs/spirit/example/qi/compiler_tutorial/calc8 libs/spirit/example/qi/compiler_tutorial/conjure libs/spirit/example/qi/compiler_tutorial/conjure_lexer libs/spirit/example/qi/compiler_tutorial/mini_c
From: hartmut.kaiser_at_[hidden]
Date: 2011-06-06 08:42:20


Author: hkaiser
Date: 2011-06-06 08:42:19 EDT (Mon, 06 Jun 2011)
New Revision: 72434
URL: http://svn.boost.org/trac/boost/changeset/72434

Log:
Spirit: merging minor fixes for examples from trunk
Properties modified:
   branches/release/ (props changed)
   branches/release/libs/ (props changed)
   branches/release/libs/spirit/ (props changed)
   branches/release/libs/spirit/example/ (props changed)
Text files modified:
   branches/release/libs/spirit/example/qi/compiler_tutorial/calc7/annotation.hpp | 18 ++++++++++++++----
   branches/release/libs/spirit/example/qi/compiler_tutorial/calc8/annotation.hpp | 18 ++++++++++++++----
   branches/release/libs/spirit/example/qi/compiler_tutorial/conjure/annotation.hpp | 18 ++++++++++++++----
   branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/annotation.hpp | 18 ++++++++++++++----
   branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/conjure_static_lexer_generate.cpp | 3 ---
   branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/lexer.hpp | 11 +++++++----
   branches/release/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp | 18 ++++++++++++++----
   7 files changed, 77 insertions(+), 27 deletions(-)

Modified: branches/release/libs/spirit/example/qi/compiler_tutorial/calc7/annotation.hpp
==============================================================================
--- branches/release/libs/spirit/example/qi/compiler_tutorial/calc7/annotation.hpp (original)
+++ branches/release/libs/spirit/example/qi/compiler_tutorial/calc7/annotation.hpp 2011-06-06 08:42:19 EDT (Mon, 06 Jun 2011)
@@ -9,6 +9,8 @@
 
 #include <map>
 #include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
 #include "ast.hpp"
 
 namespace client
@@ -35,17 +37,25 @@
             int id;
             set_id(int id) : id(id) {}
 
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
             {
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
             }
 
             // This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
             {
                 // (no-op) no need for tags
             }
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
         };
 
         void operator()(ast::operand& ast, Iterator pos) const

Modified: branches/release/libs/spirit/example/qi/compiler_tutorial/calc8/annotation.hpp
==============================================================================
--- branches/release/libs/spirit/example/qi/compiler_tutorial/calc8/annotation.hpp (original)
+++ branches/release/libs/spirit/example/qi/compiler_tutorial/calc8/annotation.hpp 2011-06-06 08:42:19 EDT (Mon, 06 Jun 2011)
@@ -9,6 +9,8 @@
 
 #include <map>
 #include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
 #include "ast.hpp"
 
 namespace client
@@ -35,17 +37,25 @@
             int id;
             set_id(int id) : id(id) {}
 
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
             {
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
             }
 
             // This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
             {
                 // (no-op) no need for tags
             }
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
         };
 
         void operator()(ast::operand& ast, Iterator pos) const

Modified: branches/release/libs/spirit/example/qi/compiler_tutorial/conjure/annotation.hpp
==============================================================================
--- branches/release/libs/spirit/example/qi/compiler_tutorial/conjure/annotation.hpp (original)
+++ branches/release/libs/spirit/example/qi/compiler_tutorial/conjure/annotation.hpp 2011-06-06 08:42:19 EDT (Mon, 06 Jun 2011)
@@ -9,6 +9,8 @@
 
 #include <map>
 #include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
 #include "ast.hpp"
 
 namespace client
@@ -35,17 +37,25 @@
             int id;
             set_id(int id) : id(id) {}
 
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
             {
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
             }
 
             // This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
             {
                 // (no-op) no need for tags
             }
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
         };
 
         void operator()(ast::operand& ast, Iterator pos) const

Modified: branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/annotation.hpp
==============================================================================
--- branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/annotation.hpp (original)
+++ branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/annotation.hpp 2011-06-06 08:42:19 EDT (Mon, 06 Jun 2011)
@@ -9,6 +9,8 @@
 
 #include <map>
 #include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
 #include "ast.hpp"
 
 namespace client
@@ -35,17 +37,25 @@
             int id;
             set_id(int id) : id(id) {}
 
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
             {
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
             }
 
             // This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
             {
                 // (no-op) no need for tags
             }
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
         };
 
         void operator()(ast::operand& ast, Iterator pos) const

Modified: branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/conjure_static_lexer_generate.cpp
==============================================================================
--- branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/conjure_static_lexer_generate.cpp (original)
+++ branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/conjure_static_lexer_generate.cpp 2011-06-06 08:42:19 EDT (Mon, 06 Jun 2011)
@@ -9,9 +9,6 @@
 #include <fstream>
 #include <iostream>
 
-// Generating the static lexers is done based on the dynamic table based lexer
-#define CONJURE_LEXER_DYNAMIC_TABLES 1
-
 #include "lexer_def.hpp"
 #include <boost/spirit/include/lex_generate_static_lexertl.hpp>
 

Modified: branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/lexer.hpp
==============================================================================
--- branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/lexer.hpp (original)
+++ branches/release/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/lexer.hpp 2011-06-06 08:42:19 EDT (Mon, 06 Jun 2011)
@@ -7,6 +7,9 @@
 #if !defined(BOOST_SPIRIT_CONJURE_LEXER_HPP)
 #define BOOST_SPIRIT_CONJURE_LEXER_HPP
 
+#include "config.hpp"
+#include "token_ids.hpp"
+
 #if CONJURE_LEXER_STATIC_TABLES != 0
 #include <boost/spirit/include/lex_static_lexertl.hpp>
 #include "conjure_static_lexer.hpp"
@@ -15,8 +18,6 @@
 #include "conjure_static_switch_lexer.hpp"
 #endif
 
-#include "token_ids.hpp"
-
 namespace client { namespace lexer
 {
     ///////////////////////////////////////////////////////////////////////////
@@ -42,12 +43,14 @@
                 token_type
               , boost::spirit::lex::lexertl::static_::lexer_conjure_static
> type;
-#else // CONJURE_LEXER_STATIC_SWITCH != 0
- // use the lexer based on runtime generated DFA tables
+#elif CONJURE_LEXER_STATIC_SWITCH != 0
+ // use the lexer based on pre-generated static DFA tables
             typedef lex::lexertl::static_actor_lexer<
                 token_type
               , boost::spirit::lex::lexertl::static_::lexer_conjure_static_switch
> type;
+#else
+#error "Configuration problem: please select exactly one type of lexer to build"
 #endif
         };
     }

Modified: branches/release/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp
==============================================================================
--- branches/release/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp (original)
+++ branches/release/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp 2011-06-06 08:42:19 EDT (Mon, 06 Jun 2011)
@@ -9,6 +9,8 @@
 
 #include <map>
 #include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
 #include "ast.hpp"
 
 namespace client
@@ -35,17 +37,25 @@
             int id;
             set_id(int id) : id(id) {}
 
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
             {
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
             }
 
             // This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
             {
                 // (no-op) no need for tags
             }
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
         };
 
         void operator()(ast::operand& ast, Iterator pos) const


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