Update of /cvsroot/boost/boost/boost/spirit/tree
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17149

Modified Files:
      Tag: SPIRIT_1_6
        common.hpp 
Log Message:
Applied Tobias Schwinger's patches

Index: common.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/spirit/tree/common.hpp,v
retrieving revision 1.13.2.8
retrieving revision 1.13.2.9
diff -u -d -r1.13.2.8 -r1.13.2.9
--- common.hpp  29 Mar 2006 07:42:29 -0000      1.13.2.8
+++ common.hpp  26 Feb 2007 23:06:24 -0000      1.13.2.9
@@ -824,7 +824,6 @@
     typedef no_tree_gen_node_parser<T> self_t;
     typedef no_tree_gen_node_parser_gen parser_generator_t;
     typedef unary_parser_category parser_category_t;
-//    typedef no_tree_gen_node_parser<T> const &embed_t;
 
     no_tree_gen_node_parser(T const& a)
     : unary<T, parser<no_tree_gen_node_parser<T> > >(a) {}
@@ -842,7 +841,8 @@
             action_policy_t
         > policies_t;
 
-        return this->subject().parse(scanner.change_policies(policies_t()));
+        return this->subject().parse(scanner.change_policies(policies_t(
+            scanner,match_policy(),scanner)));
     }
 };
 
@@ -873,6 +873,70 @@
 //////////////////////////////////
 const no_tree_gen_node_parser_gen no_node_d = no_tree_gen_node_parser_gen();
 
+//////////////////////////////////
+
+struct leaf_node_parser_gen;
+
+template<typename T>
+struct leaf_node_parser
+:   public unary<T, parser<leaf_node_parser<T> > >
+{
+    typedef leaf_node_parser<T> self_t;
+    typedef leaf_node_parser_gen parser_generator_t;
+    typedef unary_parser_category parser_category_t;
+
+    leaf_node_parser(T const& a)
+    : unary<T, parser<leaf_node_parser<T> > >(a) {}
+
+    template <typename ScannerT>
+    typename parser_result<self_t, ScannerT>::type
+    parse(ScannerT const& scanner) const
+    {
+        typedef scanner_policies< typename ScannerT::iteration_policy_t,
+            match_policy, typename ScannerT::action_policy_t > policies_t;
+
+        typedef typename ScannerT::iterator_t iterator_t;
+        typedef typename parser_result<self_t, ScannerT>::type result_t;
+        typedef typename result_t::node_factory_t factory_t;
+
+        iterator_t from = scanner.first;
+        result_t hit = impl::contiguous_parser_parse<result_t>(this->subject(),
+            
scanner.change_policies(policies_t(scanner,match_policy(),scanner)),
+            scanner);
+
+        if (hit)
+            return result_t(hit.length(),
+                factory_t::create_node(from, scanner.first, true));
+        else
+            return result_t(hit.length());
+    }
+};
+
+struct leaf_node_parser_gen
+{
+    template <typename T>
+    struct result {
+
+        typedef leaf_node_parser<T> type;
+    };
+
+    template <typename T>
+    static leaf_node_parser<T>
+    generate(parser<T> const& s)
+    {
+        return leaf_node_parser<T>(s.derived());
+    }
+
+    template <typename T>
+    leaf_node_parser<T>
+    operator[](parser<T> const& s) const
+    {
+        return leaf_node_parser<T>(s.derived());
+    }
+};
+
+const leaf_node_parser_gen leaf_node_d = leaf_node_parser_gen();
+const leaf_node_parser_gen token_node_d = leaf_node_parser_gen();
 
 //////////////////////////////////
 namespace impl {
@@ -950,7 +1014,7 @@
 const node_parser_gen<discard_node_op> discard_node_d =
     node_parser_gen<discard_node_op>();
 
-struct leaf_node_op
+struct reduced_node_op
 {
     template <typename MatchT>
     void operator()(MatchT& m) const
@@ -967,10 +1031,8 @@
     }
 };
 
-const node_parser_gen<leaf_node_op> leaf_node_d =
-    node_parser_gen<leaf_node_op>();
-const node_parser_gen<leaf_node_op> token_node_d =
-    node_parser_gen<leaf_node_op>();
+const node_parser_gen<reduced_node_op> reduced_node_d =
+    node_parser_gen<reduced_node_op>();
 
 struct infix_node_op
 {
@@ -1385,3 +1447,4 @@
 
 #endif
 #endif
+


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to